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
16namespace Baloo {
17
18/**
19 * @class IndexerConfig indexerconfig.h <Baloo/IndexerConfig>
20 *
21 * This class allows it to access the current config, to
22 * read and modify it.
23 *
24 * It is not meant as a means to infer the current state of
25 * the Indexer or the DB. The DB is updated asynchronously,
26 * and changes of the config will not be reflected immediately.
27 */
28class BALOO_CORE_EXPORT IndexerConfig
29{
30public:
31 IndexerConfig();
32 ~IndexerConfig();
33
34 IndexerConfig(const IndexerConfig &) = delete;
35 IndexerConfig &operator=(const IndexerConfig &) = delete;
36
37 bool fileIndexingEnabled() const;
38 void setFileIndexingEnabled(bool enabled) const;
39
40 /**
41 * Check if the file or folder \p path should be indexed.
42 *
43 * If itself or its nearest explicitly included or excluded ancestor is
44 * excluded it is not indexed.
45 * Otherwise it is indexed according to the
46 * includeFolders and excludeFilters config.
47 *
48 * \return \c true if the file or folder at \p path should
49 * be indexed according to the configuration.
50 *
51 * TODO KF6: deprecate, not of any concern for ouside
52 * users. Use \c Baloo::File to know if a file has
53 * been indexed.
54 * \sa Baloo::File
55 */
56 bool shouldBeIndexed(const QString& path) const;
57
58 /**
59 * Check if \p folder can be searched.
60 * \p folder can be searched if itself or one of its descendants is indexed.
61 *
62 * Example:
63 * if ~/foo is not indexed and ~/foo/bar is indexed
64 * then ~/foo can be searched.
65 *
66 * \return \c true if the \p folder can be searched.
67 */
68 bool canBeSearched(const QString& folder) const;
69
70 /**
71 * Folders to search for files to index and analyze.
72 * \return list of paths.
73 */
74 QStringList includeFolders() const;
75
76 /**
77 * Folders that are excluded from indexing.
78 * (Descendant folders of an excluded folder can be added
79 * and they will be indexed.)
80 * \return list of paths.
81 */
82 QStringList excludeFolders() const;
83 QStringList excludeFilters() const;
84 QStringList excludeMimetypes() const;
85
86 void setIncludeFolders(const QStringList& includeFolders);
87 void setExcludeFolders(const QStringList& excludeFolders);
88 void setExcludeFilters(const QStringList& excludeFilters);
89 void setExcludeMimetypes(const QStringList& excludeMimetypes);
90
91 bool indexHidden() const;
92 void setIndexHidden(bool value) const;
93
94 bool onlyBasicIndexing() const;
95 void setOnlyBasicIndexing(bool value);
96
97 void refresh() const;
98
99private:
100 class Private;
101 std::unique_ptr<Private> const d;
102};
103}
104
105#endif // BALOO_INDEXERCONFIG_H
106

source code of baloo/src/lib/indexerconfig.h