File indexing completed on 2024-04-28 15:17:40

0001 /*
0002     This file is part of the KDE Baloo Project
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef BALOO_INDEXERCONFIG_H
0009 #define BALOO_INDEXERCONFIG_H
0010 
0011 #include <QObject>
0012 #include "core_export.h"
0013 
0014 namespace Baloo {
0015 
0016 /**
0017  * @class IndexerConfig indexerconfig.h <Baloo/IndexerConfig>
0018  *
0019  * This class allows it to access the current config, to
0020  * read and modify it.
0021  *
0022  * It is not meant as a means to infer the current state of
0023  * the Indexer or the DB. The DB is updated asynchronously,
0024  * and changes of the config will not be reflected immediately.
0025  */
0026 class BALOO_CORE_EXPORT IndexerConfig
0027 {
0028 public:
0029     IndexerConfig();
0030     ~IndexerConfig();
0031 
0032     IndexerConfig(const IndexerConfig &) = delete;
0033     IndexerConfig &operator=(const IndexerConfig &) = delete;
0034 
0035     bool fileIndexingEnabled() const;
0036     void setFileIndexingEnabled(bool enabled) const;
0037 
0038     /**
0039     * Check if the file or folder \p path should be indexed.
0040     *
0041     * If itself or its nearest explicitly included or excluded ancestor is
0042     * excluded it is not indexed.
0043     * Otherwise it is indexed according to the
0044     * includeFolders and excludeFilters config.
0045     *
0046     * \return \c true if the file or folder at \p path should
0047     * be indexed according to the configuration.
0048     *
0049     * TODO KF6: deprecate, not of any concern for ouside
0050     * users. Use \c Baloo::File to know if a file has
0051     * been indexed.
0052     * \sa Baloo::File
0053     */
0054     bool shouldBeIndexed(const QString& path) const;
0055 
0056     /**
0057     * Check if \p folder can be searched.
0058     * \p folder can be searched if itself or one of its descendants is indexed.
0059     *
0060     * Example:
0061     * if ~/foo is not indexed and ~/foo/bar is indexed
0062     * then ~/foo can be searched.
0063     *
0064     * \return \c true if the \p folder can be searched.
0065     */
0066     bool canBeSearched(const QString& folder) const;
0067 
0068     /**
0069      * Folders to search for files to index and analyze.
0070      * \return list of paths.
0071      */
0072     QStringList includeFolders() const;
0073 
0074     /**
0075      * Folders that are excluded from indexing.
0076      * (Descendant folders of an excluded folder can be added
0077      * and they will be indexed.)
0078      * \return list of paths.
0079      */
0080     QStringList excludeFolders() const;
0081     QStringList excludeFilters() const;
0082     QStringList excludeMimetypes() const;
0083 
0084     void setIncludeFolders(const QStringList& includeFolders);
0085     void setExcludeFolders(const QStringList& excludeFolders);
0086     void setExcludeFilters(const QStringList& excludeFilters);
0087     void setExcludeMimetypes(const QStringList& excludeMimetypes);
0088 
0089 #if BALOO_CORE_BUILD_DEPRECATED_SINCE(5, 69)
0090     /**
0091      * @deprecated Since 5.69. Do not use this function, firstRun is no longer
0092      * exposed in the config, as it is an internal baloo state.
0093      * \return \c false
0094      */
0095     BALOO_CORE_DEPRECATED_VERSION(5, 69, "Do not use. firstRun is a baloo internal state")
0096     bool firstRun() const;
0097     /**
0098      * @deprecated Since 5.69. Do not use this function. Since 5.69, calling
0099      * it no longer has any effect.
0100      */
0101     BALOO_CORE_DEPRECATED_VERSION(5, 69, "Do not use. firstRun is a baloo internal state")
0102     void setFirstRun(bool firstRun) const;
0103 #endif
0104 
0105     bool indexHidden() const;
0106     void setIndexHidden(bool value) const;
0107 
0108     bool onlyBasicIndexing() const;
0109     void setOnlyBasicIndexing(bool value);
0110 
0111     void refresh() const;
0112 
0113 private:
0114     class Private;
0115     Private* d;
0116 };
0117 }
0118 
0119 #endif // BALOO_INDEXERCONFIG_H