File indexing completed on 2024-04-28 07:40:11

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 #include <memory>
0015 
0016 namespace Baloo {
0017 
0018 /**
0019  * @class IndexerConfig indexerconfig.h <Baloo/IndexerConfig>
0020  *
0021  * This class allows it to access the current config, to
0022  * read and modify it.
0023  *
0024  * It is not meant as a means to infer the current state of
0025  * the Indexer or the DB. The DB is updated asynchronously,
0026  * and changes of the config will not be reflected immediately.
0027  */
0028 class BALOO_CORE_EXPORT IndexerConfig
0029 {
0030 public:
0031     IndexerConfig();
0032     ~IndexerConfig();
0033 
0034     IndexerConfig(const IndexerConfig &) = delete;
0035     IndexerConfig &operator=(const IndexerConfig &) = delete;
0036 
0037     bool fileIndexingEnabled() const;
0038     void setFileIndexingEnabled(bool enabled) const;
0039 
0040     /**
0041     * Check if the file or folder \p path should be indexed.
0042     *
0043     * If itself or its nearest explicitly included or excluded ancestor is
0044     * excluded it is not indexed.
0045     * Otherwise it is indexed according to the
0046     * includeFolders and excludeFilters config.
0047     *
0048     * \return \c true if the file or folder at \p path should
0049     * be indexed according to the configuration.
0050     *
0051     * TODO KF6: deprecate, not of any concern for ouside
0052     * users. Use \c Baloo::File to know if a file has
0053     * been indexed.
0054     * \sa Baloo::File
0055     */
0056     bool shouldBeIndexed(const QString& path) const;
0057 
0058     /**
0059     * Check if \p folder can be searched.
0060     * \p folder can be searched if itself or one of its descendants is indexed.
0061     *
0062     * Example:
0063     * if ~/foo is not indexed and ~/foo/bar is indexed
0064     * then ~/foo can be searched.
0065     *
0066     * \return \c true if the \p folder can be searched.
0067     */
0068     bool canBeSearched(const QString& folder) const;
0069 
0070     /**
0071      * Folders to search for files to index and analyze.
0072      * \return list of paths.
0073      */
0074     QStringList includeFolders() const;
0075 
0076     /**
0077      * Folders that are excluded from indexing.
0078      * (Descendant folders of an excluded folder can be added
0079      * and they will be indexed.)
0080      * \return list of paths.
0081      */
0082     QStringList excludeFolders() const;
0083     QStringList excludeFilters() const;
0084     QStringList excludeMimetypes() const;
0085 
0086     void setIncludeFolders(const QStringList& includeFolders);
0087     void setExcludeFolders(const QStringList& excludeFolders);
0088     void setExcludeFilters(const QStringList& excludeFilters);
0089     void setExcludeMimetypes(const QStringList& excludeMimetypes);
0090 
0091     bool indexHidden() const;
0092     void setIndexHidden(bool value) const;
0093 
0094     bool onlyBasicIndexing() const;
0095     void setOnlyBasicIndexing(bool value);
0096 
0097     void refresh() const;
0098 
0099 private:
0100     class Private;
0101     std::unique_ptr<Private> const d;
0102 };
0103 }
0104 
0105 #endif // BALOO_INDEXERCONFIG_H