1 | /* |
2 | This file is part of the KDE Project |
3 | SPDX-FileCopyrightText: 2008-2010 Sebastian Trueg <trueg@kde.org> |
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 | "*.tfstate*" , // Terraform state files |
80 | |
81 | // Bytecode files |
82 | "*.class" , // Java |
83 | "*.pyc" , // Python |
84 | "*.pyo" , // More Python |
85 | "*.elc" , // Emacs Lisp |
86 | "*.qmlc" , // QML |
87 | "*.jsc" , // Javascript |
88 | |
89 | // files known in bioinformatics containing huge amount of unindexable data |
90 | "*.fastq" , |
91 | "*.fq" , |
92 | "*.gb" , |
93 | "*.fasta" , |
94 | "*.fna" , |
95 | "*.gbff" , |
96 | "*.faa" , |
97 | "*.fna" , |
98 | // end of list |
99 | nullptr |
100 | }; |
101 | |
102 | const int s_defaultFileExcludeFiltersVersion = 9; |
103 | |
104 | const char* const s_defaultFolderExcludeFilters[] = { |
105 | "po" , |
106 | |
107 | // VCS |
108 | "CVS" , |
109 | ".svn" , |
110 | ".git" , |
111 | "_darcs" , |
112 | ".bzr" , |
113 | ".hg" , |
114 | |
115 | // development |
116 | "CMakeFiles" , |
117 | "CMakeTmp" , |
118 | "CMakeTmpQmake" , |
119 | ".moc" , |
120 | ".obj" , |
121 | ".pch" , |
122 | ".uic" , |
123 | ".npm" , |
124 | ".yarn" , |
125 | ".yarn-cache" , |
126 | "__pycache__" , |
127 | "node_modules" , |
128 | "node_packages" , |
129 | "nbproject" , |
130 | ".terraform" , |
131 | ".venv" , |
132 | "venv" , |
133 | |
134 | //misc |
135 | "core-dumps" , |
136 | "lost+found" , |
137 | |
138 | // end of list |
139 | nullptr |
140 | }; |
141 | |
142 | const int s_defaultFolderExcludeFiltersVersion = 4; |
143 | |
144 | const char* const s_sourceCodeMimeTypes[] = { |
145 | "text/css" , |
146 | "text/x-c++src" , |
147 | "text/x-c++hdr" , |
148 | "text/x-csrc" , |
149 | "text/x-chdr" , // c header files |
150 | "text/x-python" , |
151 | "text/x-assembly" , |
152 | "text/x-java" , |
153 | "text/x-objsrc" , |
154 | "text/x-ruby" , |
155 | "text/x-scheme" , |
156 | "text/x-pascal" , |
157 | "text/x-fortran" , |
158 | "text/x-erlang" , |
159 | "text/x-cmake" , |
160 | "text/x-lua" , |
161 | "text/x-yacc" , |
162 | "text/x-sed" , |
163 | "text/x-haskell" , |
164 | "text/x-copying" , // COPYING files |
165 | "text/x-readme" , // README files |
166 | "text/x-qml" , |
167 | "text/asp" , |
168 | "text/jsx" , |
169 | "text/csx" , |
170 | "text/vnd.trolltech.linguist" , |
171 | "application/x-awk" , |
172 | "application/x-cgi" , |
173 | "application/x-csh" , |
174 | "application/x-ipynb+json" , |
175 | "application/x-java" , |
176 | "application/x-javascript" , |
177 | "application/x-perl" , |
178 | "application/x-php" , |
179 | "application/x-python" , |
180 | "application/x-sh" , |
181 | "application/xml" , |
182 | "application/javascript" , |
183 | "application/json" , |
184 | "application/geo+json" , |
185 | "application/json-patch+json" , |
186 | "application/ld+json" , |
187 | "application/x-ipynb+json" , // Jupyter notebooks |
188 | |
189 | // Not really source code, but inherited from text/plain |
190 | "application/pgp-encrypted" , // pgp encrypted, with or without ASCII Armor |
191 | |
192 | // end of list |
193 | nullptr |
194 | }; |
195 | const int s_sourceCodeMimeTypesVersion = 3; |
196 | } |
197 | |
198 | QStringList Baloo::defaultExcludeFilterList() |
199 | { |
200 | QStringList l; |
201 | for (int i = 0; s_defaultFileExcludeFilters[i]; ++i) { |
202 | l << QLatin1String(s_defaultFileExcludeFilters[i]); |
203 | } |
204 | for (int i = 0; s_defaultFolderExcludeFilters[i]; ++i) { |
205 | l << QLatin1String(s_defaultFolderExcludeFilters[i]); |
206 | } |
207 | return l; |
208 | } |
209 | |
210 | int Baloo::defaultExcludeFilterListVersion() |
211 | { |
212 | return qMax(a: s_defaultFileExcludeFiltersVersion, b: s_defaultFolderExcludeFiltersVersion); |
213 | } |
214 | |
215 | QStringList Baloo::sourceCodeMimeTypes() |
216 | { |
217 | QStringList l; |
218 | for (int i = 0; s_sourceCodeMimeTypes[i]; ++i) { |
219 | l << QLatin1String(s_sourceCodeMimeTypes[i]); |
220 | } |
221 | |
222 | return l; |
223 | } |
224 | |
225 | QStringList Baloo::defaultExcludeMimetypes() |
226 | { |
227 | return sourceCodeMimeTypes(); |
228 | } |
229 | |
230 | int Baloo::defaultExcludeMimetypesVersion() |
231 | { |
232 | // The +1 is the image, video and audio mimetypes |
233 | return s_sourceCodeMimeTypesVersion + 1; |
234 | } |
235 | |