| 1 | /* |
|---|---|
| 2 | This file is part of the KDE Baloo Project |
| 3 | SPDX-FileCopyrightText: 2014 Vishesh Handa <vhanda@kde.org> |
| 4 | SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 7 | */ |
| 8 | |
| 9 | #include "indexerconfig.h" |
| 10 | #include "../file/fileindexerconfig.h" |
| 11 | #include "../file/fileexcludefilters.h" |
| 12 | #include "../file/regexpcache.h" |
| 13 | |
| 14 | #include <QDBusConnection> |
| 15 | #include "maininterface.h" |
| 16 | #include "baloosettings.h" |
| 17 | |
| 18 | using namespace Baloo; |
| 19 | |
| 20 | class BALOO_CORE_NO_EXPORT IndexerConfig::Private { |
| 21 | public: |
| 22 | FileIndexerConfig m_config; |
| 23 | BalooSettings m_settings; |
| 24 | }; |
| 25 | |
| 26 | IndexerConfig::IndexerConfig() |
| 27 | : d(new Private) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | IndexerConfig::~IndexerConfig() |
| 32 | { |
| 33 | d->m_settings.save(); |
| 34 | } |
| 35 | |
| 36 | bool IndexerConfig::fileIndexingEnabled() const |
| 37 | { |
| 38 | return d->m_settings.indexingEnabled(); |
| 39 | } |
| 40 | |
| 41 | void IndexerConfig::setFileIndexingEnabled(bool enabled) const |
| 42 | { |
| 43 | d->m_settings.setIndexingEnabled(enabled); |
| 44 | } |
| 45 | |
| 46 | bool IndexerConfig::shouldBeIndexed(const QString& path) const |
| 47 | { |
| 48 | return d->m_config.shouldBeIndexed(path); |
| 49 | } |
| 50 | |
| 51 | bool IndexerConfig::canBeSearched(const QString& folder) const |
| 52 | { |
| 53 | return d->m_config.canBeSearched(folder); |
| 54 | } |
| 55 | |
| 56 | QStringList IndexerConfig::excludeFolders() const |
| 57 | { |
| 58 | return d->m_config.excludeFolders(); |
| 59 | } |
| 60 | |
| 61 | QStringList IndexerConfig::includeFolders() const |
| 62 | { |
| 63 | return d->m_config.includeFolders(); |
| 64 | } |
| 65 | |
| 66 | QStringList IndexerConfig::excludeFilters() const |
| 67 | { |
| 68 | return d->m_config.excludeFilters(); |
| 69 | } |
| 70 | |
| 71 | QStringList IndexerConfig::excludeMimetypes() const |
| 72 | { |
| 73 | return d->m_config.excludeMimetypes(); |
| 74 | } |
| 75 | |
| 76 | void IndexerConfig::setExcludeFolders(const QStringList& excludeFolders) |
| 77 | { |
| 78 | d->m_settings.setExcludedFolders(excludeFolders); |
| 79 | } |
| 80 | |
| 81 | void IndexerConfig::setIncludeFolders(const QStringList& includeFolders) |
| 82 | { |
| 83 | d->m_settings.setFolders(includeFolders); |
| 84 | } |
| 85 | |
| 86 | void IndexerConfig::setExcludeFilters(const QStringList& excludeFilters) |
| 87 | { |
| 88 | d->m_settings.setExcludedFilters(excludeFilters); |
| 89 | } |
| 90 | |
| 91 | void IndexerConfig::setExcludeMimetypes(const QStringList& excludeMimetypes) |
| 92 | { |
| 93 | d->m_settings.setExcludedMimetypes(excludeMimetypes); |
| 94 | } |
| 95 | |
| 96 | bool IndexerConfig::indexHidden() const |
| 97 | { |
| 98 | return d->m_settings.indexHiddenFolders(); |
| 99 | } |
| 100 | |
| 101 | void IndexerConfig::setIndexHidden(bool value) const |
| 102 | { |
| 103 | d->m_settings.setIndexHiddenFolders(value); |
| 104 | } |
| 105 | |
| 106 | bool IndexerConfig::onlyBasicIndexing() const |
| 107 | { |
| 108 | return d->m_settings.onlyBasicIndexing(); |
| 109 | } |
| 110 | |
| 111 | void IndexerConfig::setOnlyBasicIndexing(bool value) |
| 112 | { |
| 113 | d->m_settings.setOnlyBasicIndexing(value); |
| 114 | } |
| 115 | |
| 116 | void IndexerConfig::refresh() const |
| 117 | { |
| 118 | org::kde::baloo::main mainInterface(QStringLiteral("org.kde.baloo"), |
| 119 | QStringLiteral("/"), |
| 120 | QDBusConnection::sessionBus()); |
| 121 | mainInterface.updateConfig(); |
| 122 | } |
| 123 |
