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-only
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 
37     // misc
38     "*.csproj",
39     "*.m4",
40     "*.rej",
41     "*.gmo",
42     "*.pc",
43     "*.omf",
44     "*.aux",
45     "*.tmp",
46     "*.po",
47     "*.vm*",
48     "*.nvram",
49     "*.rcore",
50     "*.swap",
51     "lzo",
52     "litmain.sh",
53     "*.orig",
54     ".histfile.*",
55     ".xsession-errors*",
56 
57     // Compiled files
58     "*.class", // Java
59     "*.pyc", // Python
60     "*.elc", // Emacs Lisp
61 
62     // end of list
63     nullptr,
64 };
65 
66 const int s_defaultFileExcludeFiltersVersion = 2;
67 
68 const char *const s_defaultFolderExcludeFilters[] = {
69     "po",
70 
71     // VCS
72     "CVS",
73     ".svn",
74     ".git",
75     "_darcs",
76     ".bzr",
77     ".hg",
78 
79     // development
80     "CMakeFiles",
81     "CMakeTmp",
82     "CMakeTmpQmake",
83     ".moc",
84     ".obj",
85     ".pch",
86     ".uic",
87 
88     // misc
89     "core-dumps",
90     "lost+found",
91 
92     // end of list
93     nullptr,
94 };
95 
96 const int s_defaultFolderExcludeFiltersVersion = 1;
97 
98 const char *const s_sourceCodeMimeTypes[] = {
99     "text/css",
100     "text/x-c++src",
101     "text/x-c++hdr",
102     "text/x-csrc",
103     "text/x-chdr", // c header files
104     "text/x-python",
105     "text/x-assembly",
106     "text/x-java",
107     "text/x-objsrc",
108     "text/x-ruby",
109     "text/x-scheme",
110     "text/x-pascal",
111     "text/x-yacc",
112     "text/x-sed",
113     "text/x-haskell",
114     "text/asp",
115     "application/x-awk",
116     "application/x-cgi",
117     "application/x-csh",
118     "application/x-java",
119     "application/x-javascript",
120     "application/x-perl",
121     "application/x-php",
122     "application/x-python",
123     "application/x-sh",
124     "application/x-tex",
125 
126     // end of list
127     nullptr,
128 };
129 const int s_sourceCodeMimeTypesVersion = 1;
130 }
131 
defaultExcludeFilterList()132 QStringList Baloo::defaultExcludeFilterList()
133 {
134     QStringList l;
135     for (int i = 0; s_defaultFileExcludeFilters[i]; ++i)
136         l << QLatin1String(s_defaultFileExcludeFilters[i]);
137     for (int i = 0; s_defaultFolderExcludeFilters[i]; ++i)
138         l << QLatin1String(s_defaultFolderExcludeFilters[i]);
139     return l;
140 }
141 
defaultExcludeFilterListVersion()142 int Baloo::defaultExcludeFilterListVersion()
143 {
144     return qMax(s_defaultFileExcludeFiltersVersion, s_defaultFolderExcludeFiltersVersion);
145 }
146 
sourceCodeMimeTypes()147 QStringList Baloo::sourceCodeMimeTypes()
148 {
149     QStringList l;
150     for (int i = 0; s_sourceCodeMimeTypes[i]; ++i)
151         l << QLatin1String(s_sourceCodeMimeTypes[i]);
152 
153     return l;
154 }
155 
defaultExcludeMimetypes()156 QStringList Baloo::defaultExcludeMimetypes()
157 {
158     return sourceCodeMimeTypes();
159 }
160 
defaultExcludeMimetypesVersion()161 int Baloo::defaultExcludeMimetypesVersion()
162 {
163     // The +1 is the image, video and audio mimetypes
164     return s_sourceCodeMimeTypesVersion + 1;
165 }
166