Changeset View
Changeset View
Standalone View
Standalone View
src/lib/indexerconfig.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * This file is part of the KDE Baloo Project | 2 | * This file is part of the KDE Baloo Project | ||
3 | * Copyright (C) 2014 Vishesh Handa <vhanda@kde.org> | 3 | * Copyright (C) 2014 Vishesh Handa <vhanda@kde.org> | ||
4 | * Copyright (C) 2020 Benjamin Port <benjamin.port@enioka.com> | ||||
4 | * | 5 | * | ||
5 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
8 | * version 2.1 of the License, or (at your option) any later version. | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
9 | * | 10 | * | ||
10 | * This library is distributed in the hope that it will be useful, | 11 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * Lesser General Public License for more details. | 14 | * Lesser General Public License for more details. | ||
14 | * | 15 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 16 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | 17 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | * | 19 | * | ||
19 | */ | 20 | */ | ||
20 | 21 | | |||
21 | #include "indexerconfig.h" | 22 | #include "indexerconfig.h" | ||
22 | #include "../file/fileindexerconfig.h" | 23 | #include "../file/fileindexerconfig.h" | ||
23 | #include "../file/fileexcludefilters.h" | 24 | #include "../file/fileexcludefilters.h" | ||
24 | #include "../file/regexpcache.h" | 25 | #include "../file/regexpcache.h" | ||
25 | 26 | | |||
26 | #include <KConfig> | | |||
27 | #include <KConfigGroup> | | |||
28 | | ||||
29 | #include <QDBusConnection> | 27 | #include <QDBusConnection> | ||
30 | #include "maininterface.h" | 28 | #include "maininterface.h" | ||
29 | #include "baloosettings.h" | ||||
31 | 30 | | |||
32 | using namespace Baloo; | 31 | using namespace Baloo; | ||
33 | 32 | | |||
34 | class IndexerConfig::Private { | 33 | class IndexerConfig::Private { | ||
35 | public: | 34 | public: | ||
36 | FileIndexerConfig m_config; | 35 | FileIndexerConfig m_config; | ||
36 | BalooSettings m_settings; | ||||
37 | }; | 37 | }; | ||
38 | 38 | | |||
39 | IndexerConfig::IndexerConfig() | 39 | IndexerConfig::IndexerConfig() | ||
40 | : d(new Private) | 40 | : d(new Private) | ||
41 | { | 41 | { | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | IndexerConfig::~IndexerConfig() | 44 | IndexerConfig::~IndexerConfig() | ||
45 | { | 45 | { | ||
46 | delete d; | 46 | delete d; | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | bool IndexerConfig::fileIndexingEnabled() const | 49 | bool IndexerConfig::fileIndexingEnabled() const | ||
50 | { | 50 | { | ||
51 | return d->m_config.indexingEnabled(); | 51 | return d->m_settings.indexingEnabled(); | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | 54 | | |||
55 | void IndexerConfig::setFileIndexingEnabled(bool enabled) const | 55 | void IndexerConfig::setFileIndexingEnabled(bool enabled) const | ||
56 | { | 56 | { | ||
57 | KConfig config(QStringLiteral("baloofilerc")); | 57 | d->m_settings.setIndexingEnabled(enabled); | ||
58 | KConfigGroup basicSettings = config.group("Basic Settings"); | | |||
59 | basicSettings.writeEntry("Indexing-Enabled", enabled); | | |||
60 | } | 58 | } | ||
61 | 59 | | |||
62 | bool IndexerConfig::shouldBeIndexed(const QString& path) const | 60 | bool IndexerConfig::shouldBeIndexed(const QString& path) const | ||
63 | { | 61 | { | ||
64 | return d->m_config.shouldBeIndexed(path); | 62 | return d->m_config.shouldBeIndexed(path); | ||
65 | } | 63 | } | ||
66 | 64 | | |||
67 | 65 | | |||
Show All 19 Lines | |||||
87 | 85 | | |||
88 | QStringList IndexerConfig::excludeMimetypes() const | 86 | QStringList IndexerConfig::excludeMimetypes() const | ||
89 | { | 87 | { | ||
90 | return d->m_config.excludeMimetypes(); | 88 | return d->m_config.excludeMimetypes(); | ||
91 | } | 89 | } | ||
92 | 90 | | |||
93 | void IndexerConfig::setExcludeFolders(const QStringList& excludeFolders) | 91 | void IndexerConfig::setExcludeFolders(const QStringList& excludeFolders) | ||
94 | { | 92 | { | ||
95 | KConfig config(QStringLiteral("baloofilerc")); | 93 | d->m_settings.setExcludedFolders(excludeFolders); | ||
96 | config.group("General").writePathEntry("exclude folders", excludeFolders); | | |||
97 | } | 94 | } | ||
98 | 95 | | |||
99 | void IndexerConfig::setIncludeFolders(const QStringList& includeFolders) | 96 | void IndexerConfig::setIncludeFolders(const QStringList& includeFolders) | ||
100 | { | 97 | { | ||
101 | KConfig config(QStringLiteral("baloofilerc")); | 98 | d->m_settings.setFolders(includeFolders); | ||
102 | config.group("General").writePathEntry("folders", includeFolders); | | |||
103 | } | 99 | } | ||
104 | 100 | | |||
105 | void IndexerConfig::setExcludeFilters(const QStringList& excludeFilters) | 101 | void IndexerConfig::setExcludeFilters(const QStringList& excludeFilters) | ||
106 | { | 102 | { | ||
107 | KConfig config(QStringLiteral("baloofilerc")); | 103 | d->m_settings.setExcludedFilters(excludeFilters); | ||
108 | config.group("General").writeEntry("exclude filters", excludeFilters); | | |||
109 | } | 104 | } | ||
110 | 105 | | |||
111 | void IndexerConfig::setExcludeMimetypes(const QStringList& excludeMimetypes) | 106 | void IndexerConfig::setExcludeMimetypes(const QStringList& excludeMimetypes) | ||
112 | { | 107 | { | ||
113 | KConfig config(QStringLiteral("baloofilerc")); | 108 | d->m_settings.setExcludedMimetypes(excludeMimetypes); | ||
114 | config.group("General").writeEntry("exclude mimetypes", excludeMimetypes); | | |||
115 | } | 109 | } | ||
116 | 110 | | |||
117 | bool IndexerConfig::firstRun() const | 111 | bool IndexerConfig::firstRun() const | ||
118 | { | 112 | { | ||
119 | return d->m_config.isInitialRun(); | 113 | return d->m_config.isInitialRun(); | ||
120 | } | 114 | } | ||
121 | 115 | | |||
122 | void IndexerConfig::setFirstRun(bool firstRun) const | 116 | void IndexerConfig::setFirstRun(bool firstRun) const | ||
123 | { | 117 | { | ||
124 | d->m_config.setInitialRun(firstRun); | 118 | d->m_config.setInitialRun(firstRun); | ||
125 | } | 119 | } | ||
126 | 120 | | |||
127 | bool IndexerConfig::indexHidden() const | 121 | bool IndexerConfig::indexHidden() const | ||
128 | { | 122 | { | ||
129 | KConfig config(QStringLiteral("baloofilerc")); | 123 | return d->m_settings.indexHiddenFolders(); | ||
130 | return config.group("General").readEntry("index hidden folders", false); | | |||
131 | } | 124 | } | ||
132 | 125 | | |||
133 | void IndexerConfig::setIndexHidden(bool value) const | 126 | void IndexerConfig::setIndexHidden(bool value) const | ||
134 | { | 127 | { | ||
135 | KConfig config(QStringLiteral("baloofilerc")); | 128 | d->m_settings.setIndexHiddenFolders(value); | ||
136 | config.group("General").writeEntry("index hidden folders", value); | | |||
137 | } | 129 | } | ||
138 | 130 | | |||
139 | bool IndexerConfig::onlyBasicIndexing() const | 131 | bool IndexerConfig::onlyBasicIndexing() const | ||
140 | { | 132 | { | ||
141 | KConfig config(QStringLiteral("baloofilerc")); | 133 | return d->m_settings.onlyBasicIndexing(); | ||
142 | return config.group("General").readEntry("only basic indexing", false); | | |||
143 | } | 134 | } | ||
144 | 135 | | |||
145 | void IndexerConfig::setOnlyBasicIndexing(bool value) | 136 | void IndexerConfig::setOnlyBasicIndexing(bool value) | ||
146 | { | 137 | { | ||
147 | KConfig config(QStringLiteral("baloofilerc")); | 138 | d->m_settings.setOnlyBasicIndexing(value); | ||
148 | config.group("General").writeEntry("only basic indexing", value); | | |||
149 | } | 139 | } | ||
150 | 140 | | |||
151 | void IndexerConfig::refresh() const | 141 | void IndexerConfig::refresh() const | ||
152 | { | 142 | { | ||
153 | org::kde::baloo::main mainInterface(QStringLiteral("org.kde.baloo"), | 143 | org::kde::baloo::main mainInterface(QStringLiteral("org.kde.baloo"), | ||
154 | QStringLiteral("/"), | 144 | QStringLiteral("/"), | ||
155 | QDBusConnection::sessionBus()); | 145 | QDBusConnection::sessionBus()); | ||
156 | mainInterface.updateConfig(); | 146 | mainInterface.updateConfig(); | ||
157 | } | 147 | } |