| 1 | /* |
| 2 | This file is part of the KDE Baloo Project |
| 3 | SPDX-FileCopyrightText: 2014 Vishesh Handa <vhanda@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef BALOO_INDEXERCONFIG_H |
| 9 | #define BALOO_INDEXERCONFIG_H |
| 10 | |
| 11 | #include <QObject> |
| 12 | #include "core_export.h" |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | namespace Baloo { |
| 17 | |
| 18 | /*! |
| 19 | * \class Baloo::IndexerConfig |
| 20 | * \inheaderfile Baloo/IndexerConfig |
| 21 | * \inmodule Baloo |
| 22 | * |
| 23 | * \brief This class allows it to access the current config, to |
| 24 | * read and modify it. |
| 25 | * |
| 26 | * It is not meant as a means to infer the current state of |
| 27 | * the Indexer or the DB. The DB is updated asynchronously, |
| 28 | * and changes of the config will not be reflected immediately. |
| 29 | */ |
| 30 | class BALOO_CORE_EXPORT IndexerConfig |
| 31 | { |
| 32 | public: |
| 33 | /*! |
| 34 | * |
| 35 | */ |
| 36 | IndexerConfig(); |
| 37 | ~IndexerConfig(); |
| 38 | |
| 39 | IndexerConfig(const IndexerConfig &) = delete; |
| 40 | IndexerConfig &operator=(const IndexerConfig &) = delete; |
| 41 | |
| 42 | /*! |
| 43 | * |
| 44 | */ |
| 45 | bool fileIndexingEnabled() const; |
| 46 | |
| 47 | /*! |
| 48 | * |
| 49 | */ |
| 50 | void setFileIndexingEnabled(bool enabled) const; |
| 51 | |
| 52 | /*! |
| 53 | * Check if the file or folder \a path should be indexed. |
| 54 | * |
| 55 | * If itself or its nearest explicitly included or excluded ancestor is |
| 56 | * excluded it is not indexed. |
| 57 | * Otherwise it is indexed according to the |
| 58 | * includeFolders and excludeFilters config. |
| 59 | * |
| 60 | * Returns \c true if the file or folder at \a path should |
| 61 | * be indexed according to the configuration. |
| 62 | * |
| 63 | * TODO KF6: deprecate, not of any concern for ouside |
| 64 | * users. Use \c Baloo::File to know if a file has |
| 65 | * been indexed. |
| 66 | * \sa Baloo::File |
| 67 | */ |
| 68 | bool shouldBeIndexed(const QString& path) const; |
| 69 | |
| 70 | /*! |
| 71 | * Check if \a folder can be searched. |
| 72 | * |
| 73 | * \a folder can be searched if itself or one of its descendants is indexed. |
| 74 | * |
| 75 | * Example: |
| 76 | * if ~/foo is not indexed and ~/foo/bar is indexed |
| 77 | * then ~/foo can be searched. |
| 78 | * |
| 79 | * Returns \c true if the \a folder can be searched. |
| 80 | */ |
| 81 | bool canBeSearched(const QString& folder) const; |
| 82 | |
| 83 | /*! |
| 84 | * Folders to search for files to index and analyze. |
| 85 | */ |
| 86 | QStringList includeFolders() const; |
| 87 | |
| 88 | /*! |
| 89 | * Folders that are excluded from indexing. |
| 90 | * |
| 91 | * (Descendant folders of an excluded folder can be added |
| 92 | * and they will be indexed.) |
| 93 | */ |
| 94 | QStringList excludeFolders() const; |
| 95 | |
| 96 | /*! |
| 97 | * |
| 98 | */ |
| 99 | QStringList excludeFilters() const; |
| 100 | |
| 101 | /*! |
| 102 | * |
| 103 | */ |
| 104 | QStringList excludeMimetypes() const; |
| 105 | |
| 106 | /*! |
| 107 | * |
| 108 | */ |
| 109 | void setIncludeFolders(const QStringList& includeFolders); |
| 110 | |
| 111 | /*! |
| 112 | * |
| 113 | */ |
| 114 | void setExcludeFolders(const QStringList& excludeFolders); |
| 115 | |
| 116 | /*! |
| 117 | * |
| 118 | */ |
| 119 | void setExcludeFilters(const QStringList& excludeFilters); |
| 120 | |
| 121 | /*! |
| 122 | * |
| 123 | */ |
| 124 | void setExcludeMimetypes(const QStringList& excludeMimetypes); |
| 125 | |
| 126 | /*! |
| 127 | * |
| 128 | */ |
| 129 | bool indexHidden() const; |
| 130 | |
| 131 | /*! |
| 132 | * |
| 133 | */ |
| 134 | void setIndexHidden(bool value) const; |
| 135 | |
| 136 | /*! |
| 137 | * |
| 138 | */ |
| 139 | bool onlyBasicIndexing() const; |
| 140 | |
| 141 | /*! |
| 142 | * |
| 143 | */ |
| 144 | void setOnlyBasicIndexing(bool value); |
| 145 | |
| 146 | /*! |
| 147 | * |
| 148 | */ |
| 149 | void refresh() const; |
| 150 | |
| 151 | private: |
| 152 | class Private; |
| 153 | std::unique_ptr<Private> const d; |
| 154 | }; |
| 155 | } |
| 156 | |
| 157 | #endif // BALOO_INDEXERCONFIG_H |
| 158 | |