File indexing completed on 2024-05-12 05:35:37

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2008-2010 Sebastian Trueg <trueg@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "fileexcludefilters.h"
0009 
0010 namespace
0011 {
0012 const char *const s_defaultFileExcludeFilters[] = {
0013     // tmp files
0014     "*~",
0015     "*.part",
0016 
0017     // temporary build files
0018     "*.o",
0019     "*.la",
0020     "*.lo",
0021     "*.loT",
0022     "*.moc",
0023     "moc_*.cpp",
0024     "qrc_*.cpp",
0025     "ui_*.h",
0026     "cmake_install.cmake",
0027     "CMakeCache.txt",
0028     "CTestTestfile.cmake",
0029     "libtool",
0030     "config.status",
0031     "confdefs.h",
0032     "autom4te",
0033     "conftest",
0034     "confstat",
0035     "Makefile.am",
0036 
0037     // misc
0038     "*.csproj",
0039     "*.m4",
0040     "*.rej",
0041     "*.gmo",
0042     "*.pc",
0043     "*.omf",
0044     "*.aux",
0045     "*.tmp",
0046     "*.po",
0047     "*.vm*",
0048     "*.nvram",
0049     "*.rcore",
0050     "*.swap",
0051     "lzo",
0052     "litmain.sh",
0053     "*.orig",
0054     ".histfile.*",
0055     ".xsession-errors*",
0056 
0057     // Compiled files
0058     "*.class", // Java
0059     "*.pyc", // Python
0060     "*.elc", // Emacs Lisp
0061 
0062     // end of list
0063     nullptr,
0064 };
0065 
0066 const int s_defaultFileExcludeFiltersVersion = 2;
0067 
0068 const char *const s_defaultFolderExcludeFilters[] = {
0069     "po",
0070 
0071     // VCS
0072     "CVS",
0073     ".svn",
0074     ".git",
0075     "_darcs",
0076     ".bzr",
0077     ".hg",
0078 
0079     // development
0080     "CMakeFiles",
0081     "CMakeTmp",
0082     "CMakeTmpQmake",
0083     ".moc",
0084     ".obj",
0085     ".pch",
0086     ".uic",
0087 
0088     // misc
0089     "core-dumps",
0090     "lost+found",
0091 
0092     // end of list
0093     nullptr,
0094 };
0095 
0096 const int s_defaultFolderExcludeFiltersVersion = 1;
0097 
0098 const char *const s_sourceCodeMimeTypes[] = {
0099     "text/css",
0100     "text/x-c++src",
0101     "text/x-c++hdr",
0102     "text/x-csrc",
0103     "text/x-chdr", // c header files
0104     "text/x-python",
0105     "text/x-assembly",
0106     "text/x-java",
0107     "text/x-objsrc",
0108     "text/x-ruby",
0109     "text/x-scheme",
0110     "text/x-pascal",
0111     "text/x-yacc",
0112     "text/x-sed",
0113     "text/x-haskell",
0114     "text/asp",
0115     "application/x-awk",
0116     "application/x-cgi",
0117     "application/x-csh",
0118     "application/x-java",
0119     "application/x-javascript",
0120     "application/x-perl",
0121     "application/x-php",
0122     "application/x-python",
0123     "application/x-sh",
0124     "application/x-tex",
0125 
0126     // end of list
0127     nullptr,
0128 };
0129 const int s_sourceCodeMimeTypesVersion = 1;
0130 }
0131 
0132 QStringList Baloo::defaultExcludeFilterList()
0133 {
0134     QStringList l;
0135     for (int i = 0; s_defaultFileExcludeFilters[i]; ++i)
0136         l << QLatin1String(s_defaultFileExcludeFilters[i]);
0137     for (int i = 0; s_defaultFolderExcludeFilters[i]; ++i)
0138         l << QLatin1String(s_defaultFolderExcludeFilters[i]);
0139     return l;
0140 }
0141 
0142 int Baloo::defaultExcludeFilterListVersion()
0143 {
0144     return qMax(s_defaultFileExcludeFiltersVersion, s_defaultFolderExcludeFiltersVersion);
0145 }
0146 
0147 QStringList Baloo::sourceCodeMimeTypes()
0148 {
0149     QStringList l;
0150     for (int i = 0; s_sourceCodeMimeTypes[i]; ++i)
0151         l << QLatin1String(s_sourceCodeMimeTypes[i]);
0152 
0153     return l;
0154 }
0155 
0156 QStringList Baloo::defaultExcludeMimetypes()
0157 {
0158     return sourceCodeMimeTypes();
0159 }
0160 
0161 int Baloo::defaultExcludeMimetypesVersion()
0162 {
0163     // The +1 is the image, video and audio mimetypes
0164     return s_sourceCodeMimeTypesVersion + 1;
0165 }