Baloo

fileexcludefilters.cpp
1 /*
2  This file is part of the KDE Project
3  SPDX-FileCopyrightText: 2008-2010 Sebastian Trueg <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "fileexcludefilters.h"
9 
10 namespace
11 {
12 const char* const s_defaultFileExcludeFilters[] = {
13  // tmp files
14  "*~",
15  "*.part",
16 
17  // temporary build files
18  "*.o",
19  "*.la",
20  "*.lo",
21  "*.loT",
22  "*.moc",
23  "moc_*.cpp",
24  "qrc_*.cpp",
25  "ui_*.h",
26  "cmake_install.cmake",
27  "CMakeCache.txt",
28  "CTestTestfile.cmake",
29  "libtool",
30  "config.status",
31  "confdefs.h",
32  "autom4te",
33  "conftest",
34  "confstat",
35  "Makefile.am",
36  "*.gcode", // CNC machine/3D printer toolpath files
37  ".ninja_deps",
38  ".ninja_log",
39  "build.ninja",
40 
41  // misc
42  "*.csproj",
43  "*.m4",
44  "*.rej",
45  "*.gmo",
46  "*.pc",
47  "*.omf",
48  "*.aux",
49  "*.tmp",
50  "*.po",
51  "*.vm*",
52  "*.nvram",
53  "*.rcore",
54  "*.swp",
55  "*.swap",
56  "lzo",
57  "litmain.sh",
58  "*.orig",
59  ".histfile.*",
60  ".xsession-errors*",
61  "*.map",
62  "*.so",
63  "*.a",
64  "*.db",
65  "*.qrc",
66  "*.ini",
67  "*.init",
68  "*.img", // typical extension for raw disk images
69  "*.vdi", // Virtualbox disk images
70  "*.vbox*", // Virtualbox VM files
71  "vbox.log", // Virtualbox log files
72  "*.qcow2", // QEMU QCOW2 disk images
73  "*.vmdk", // VMware disk images
74  "*.vhd", // Hyper-V disk images
75  "*.vhdx", // Hyper-V disk images
76  "*.sql", // SQL database dumps
77  "*.sql.gz", // Compressed SQL database dumps
78  "*.ytdl", // youtube-dl temp files
79 
80  // Bytecode files
81  "*.class", // Java
82  "*.pyc", // Python
83  "*.pyo", // More Python
84  "*.elc", // Emacs Lisp
85  "*.qmlc", // QML
86  "*.jsc", // Javascript
87 
88  // files known in bioinformatics containing huge amount of unindexable data
89  "*.fastq",
90  "*.fq",
91  "*.gb",
92  "*.fasta",
93  "*.fna",
94  "*.gbff",
95  "*.faa",
96  "*.fna",
97  // end of list
98  nullptr
99 };
100 
101 const int s_defaultFileExcludeFiltersVersion = 8;
102 
103 const char* const s_defaultFolderExcludeFilters[] = {
104  "po",
105 
106  // VCS
107  "CVS",
108  ".svn",
109  ".git",
110  "_darcs",
111  ".bzr",
112  ".hg",
113 
114  // development
115  "CMakeFiles",
116  "CMakeTmp",
117  "CMakeTmpQmake",
118  ".moc",
119  ".obj",
120  ".pch",
121  ".uic",
122  ".npm",
123  ".yarn",
124  ".yarn-cache",
125  "__pycache__",
126  "node_modules",
127  "node_packages",
128  "nbproject",
129  ".venv",
130  "venv",
131 
132  //misc
133  "core-dumps",
134  "lost+found",
135 
136  // end of list
137  nullptr
138 };
139 
140 const int s_defaultFolderExcludeFiltersVersion = 3;
141 
142 const char* const s_sourceCodeMimeTypes[] = {
143  "text/css",
144  "text/x-c++src",
145  "text/x-c++hdr",
146  "text/x-csrc",
147  "text/x-chdr", // c header files
148  "text/x-python",
149  "text/x-assembly",
150  "text/x-java",
151  "text/x-objsrc",
152  "text/x-ruby",
153  "text/x-scheme",
154  "text/x-pascal",
155  "text/x-fortran",
156  "text/x-erlang",
157  "text/x-cmake",
158  "text/x-lua",
159  "text/x-yacc",
160  "text/x-sed",
161  "text/x-haskell",
162  "text/x-copying", // COPYING files
163  "text/x-readme", // README files
164  "text/x-qml",
165  "text/asp",
166  "text/jsx",
167  "text/csx",
168  "text/vnd.trolltech.linguist",
169  "application/x-awk",
170  "application/x-cgi",
171  "application/x-csh",
172  "application/x-ipynb+json",
173  "application/x-java",
174  "application/x-javascript",
175  "application/x-perl",
176  "application/x-php",
177  "application/x-python",
178  "application/x-sh",
179  "application/xml",
180  "application/javascript",
181  "application/json",
182  "application/geo+json",
183  "application/json-patch+json",
184  "application/ld+json",
185  "application/x-ipynb+json", // Jupyter notebooks
186 
187  // Not really source code, but inherited from text/plain
188  "application/pgp-encrypted", // pgp encrypted, with or without ASCII Armor
189 
190  // end of list
191  nullptr
192 };
193 const int s_sourceCodeMimeTypesVersion = 3;
194 }
195 
197 {
198  QStringList l;
199  for (int i = 0; s_defaultFileExcludeFilters[i]; ++i) {
200  l << QLatin1String(s_defaultFileExcludeFilters[i]);
201  }
202  for (int i = 0; s_defaultFolderExcludeFilters[i]; ++i) {
203  l << QLatin1String(s_defaultFolderExcludeFilters[i]);
204  }
205  return l;
206 }
207 
209 {
210  return qMax(s_defaultFileExcludeFiltersVersion, s_defaultFolderExcludeFiltersVersion);
211 }
212 
213 QStringList Baloo::sourceCodeMimeTypes()
214 {
215  QStringList l;
216  for (int i = 0; s_sourceCodeMimeTypes[i]; ++i) {
217  l << QLatin1String(s_sourceCodeMimeTypes[i]);
218  }
219 
220  return l;
221 }
222 
223 QStringList Baloo::defaultExcludeMimetypes()
224 {
225  return sourceCodeMimeTypes();
226 }
227 
228 int Baloo::defaultExcludeMimetypesVersion()
229 {
230  // The +1 is the image, video and audio mimetypes
231  return s_sourceCodeMimeTypesVersion + 1;
232 }
233 
QStringList defaultExcludeFilterList()
int defaultExcludeFilterListVersion()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.