diff --git a/src/file/fileindexerconfig.h b/src/file/fileindexerconfig.h index f6129ea5..29a324e8 100644 --- a/src/file/fileindexerconfig.h +++ b/src/file/fileindexerconfig.h @@ -1,210 +1,211 @@ /* Copyright (c) 2008-2009 Sebastian Trueg Copyright (c) 2012-2014 Vishesh Handa This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef BALOO_FILEINDEXER_SERVICE_CONFIG_H_ #define BALOO_FILEINDEXER_SERVICE_CONFIG_H_ #include #include #include #include #include "regexpcache.h" namespace Baloo { class StorageDevices; /** * Active config class which emits signals if the config * was changed, for example if the KCM saved the config file. */ class FileIndexerConfig : public QObject { Q_OBJECT public: - /** - * Create a new file indexr config. - */ + explicit FileIndexerConfig(QObject* parent = nullptr); ~FileIndexerConfig(); /** - * The folders to search for files to analyze. Cached and cleaned up. - */ + * Folders to search for files to index and analyze. + * \return list of paths. + */ QStringList includeFolders() const; /** - * The folders that should be excluded. Cached and cleaned up. - * It is perfectly possible to include subfolders again. + * Folders that are excluded from indexing. + * (Descendant folders of an excluded folder can be added + * and they will be indexed.) + * \return list of paths. */ QStringList excludeFolders() const; QStringList excludeFilters() const; QStringList excludeMimetypes() const; bool indexHiddenFilesAndFolders() const; bool onlyBasicIndexing() const; /** - * true the first time the service is run (or after manually - * tampering with the config. + * \return \c true if the service is run for the first time + * (or after manually setting "first run=true" in the config). */ bool isInitialRun() const; /** * A "hidden" config option which allows to disable the initial * update of all indexed folders. * * This should be used in combination with isInitialRun() to make * sure all folders are at least indexed once. */ bool initialUpdateDisabled() const; /** - * Check if \p folder can be searched taking only - * the includeFolders() into account. - * - * A path can be searched if itself or one of - * its descendants should be indexed. - * - * \return \p true if the \p folder should - * be searched. - */ + * Check if \p folder can be searched. + * \p folder can be searched if itself or one of its descendants is indexed. + * + * Example: + * if ~/foo is not indexed and ~/foo/bar is indexed + * then ~/foo can be searched. + * + * \return \c true if the \p folder can be searched. + */ bool canBeSearched(const QString& folder) const; /** - * Check if \p path should be indexed taking into account - * the includeFolders(), the excludeFolders(), and the - * excludeFilters(). + * Check if file or folder \p path should be indexed taking into account + * the includeFolders(), the excludeFolders(), and the excludeFilters(). + * Inclusion takes precedence. * * Be aware that this method does not check if parent dirs - * match any of the exclude filters. Only the name of the + * match any of the exclude filters. Only the path of the * dir itself it checked. * - * \return \p true if the file or folder at \p path should + * \return \c true if the file or folder at \p path should * be indexed according to the configuration. */ bool shouldBeIndexed(const QString& path) const; /** * Check if the folder at \p path should be indexed. * * Be aware that this method does not check if parent dirs * match any of the exclude filters. Only the name of the * dir itself it checked. * - * \return \p true if the folder at \p path should + * \return \c true if the folder at \p path should * be indexed according to the configuration. */ bool shouldFolderBeIndexed(const QString& path) const; /** * Check \p fileName for all exclude filters. This does * not take file paths into account. * - * \return \p true if a file with name \p filename should + * \return \c true if a file with name \p filename should * be indexed according to the configuration. */ bool shouldFileBeIndexed(const QString& fileName) const; /** * Checks if \p mimeType should be indexed * - * \return \p true if the mimetype should be indexed according + * \return \c true if the mimetype should be indexed according * to the configuration */ bool shouldMimeTypeBeIndexed(const QString& mimeType) const; /** * Returns true if the folder is in the list indexed directories * and not in the list of exclude directories */ bool folderInFolderList(const QString& path); /** * Check if \p path is in the list of folders to be indexed taking * include and exclude folders into account. * \p folder is set to the folder which was the reason for the descision. */ bool folderInFolderList(const QString& path, QString& folder) const; /** * Returns the internal version number of the Baloo database */ int databaseVersion() const; void setDatabaseVersion(int version); bool indexingEnabled() const; /** * Returns batch size */ uint maxUncomittedFiles(); public Q_SLOTS: /** * Reread the config from disk and update the configuration cache. * This is only required for testing as normally the config updates * itself whenever the config file on disk changes. * * \return \c true if the config has actually changed */ void forceConfigUpdate(); /** * Should be called once the initial indexing is done, ie. all folders * have been indexed. */ void setInitialRun(bool isInitialRun); private: void buildFolderCache(); void buildExcludeFilterRegExpCache(); void buildMimeTypeCache(); KConfig m_config; /// Caching cleaned up list (no duplicates, no useless entries, etc.) QList > m_folderCache; /// cache of regexp objects for all exclude filters /// to prevent regexp parsing over and over RegExpCache m_excludeFilterRegExpCache; /// A set of mimetypes which should never be indexed QSet m_excludeMimetypes; bool m_indexHidden; bool m_onlyBasicIndexing; StorageDevices* m_devices; const uint m_maxUncomittedFiles; }; } #endif diff --git a/src/lib/indexerconfig.h b/src/lib/indexerconfig.h index c4bfd940..abdb5886 100644 --- a/src/lib/indexerconfig.h +++ b/src/lib/indexerconfig.h @@ -1,82 +1,105 @@ /* * This file is part of the KDE Baloo Project * Copyright (C) 2014 Vishesh Handa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef BALOO_INDEXERCONFIG_H #define BALOO_INDEXERCONFIG_H #include #include "core_export.h" namespace Baloo { class BALOO_CORE_EXPORT IndexerConfig { public: IndexerConfig(); ~IndexerConfig(); bool fileIndexingEnabled() const; void setFileIndexingEnabled(bool enabled) const; + /** + * Check if the file or folder \p path should be indexed. + * + * If itself or its nearest explicitly included or excluded ancestor is + * excluded it is not indexed. + * Otherwise it is indexed according to the + * includeFolders and excludeFilters config. + * + * \return \c true if the file or folder at \p path should + * be indexed according to the configuration. + */ bool shouldBeIndexed(const QString& path) const; /** * Check if \p folder can be searched. * \p folder can be searched if itself or one of its descendants is indexed. * * Example: * if ~/foo is not indexed and ~/foo/bar is indexed * then ~/foo can be searched. * * \return \c true if the \p folder can be searched. */ bool canBeSearched(const QString& folder) const; + + /** + * Folders to search for files to index and analyze. + * \return list of paths. + */ QStringList includeFolders() const; + + /** + * Folders that are excluded from indexing. + * (Descendant folders of an excluded folder can be added + * and they will be indexed.) + * \return list of paths. + */ QStringList excludeFolders() const; QStringList excludeFilters() const; QStringList excludeMimetypes() const; void setIncludeFolders(const QStringList& includeFolders); void setExcludeFolders(const QStringList& excludeFolders); void setExcludeFilters(const QStringList& excludeFilters); void setExcludeMimetypes(const QStringList& excludeMimetypes); /** - * The first run indicates if the File Indexer has ever been run before - * and made a successful pass over all the files. + * \return \c true if the service is run for the first time + * (or after manually setting "first run=true" in the config). */ bool firstRun() const; void setFirstRun(bool firstRun) const; bool indexHidden() const; void setIndexHidden(bool value) const; bool onlyBasicIndexing() const; void setOnlyBasicIndexing(bool value); void refresh() const; private: class Private; Private* d; }; } #endif // BALOO_INDEXERCONFIG_H