File indexing completed on 2024-04-14 03:49:48

0001 /*
0002     This file is part of the KDE Baloo Project
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <vhanda@kde.org>
0004     SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #include "indexerconfig.h"
0010 #include "../file/fileindexerconfig.h"
0011 #include "../file/fileexcludefilters.h"
0012 #include "../file/regexpcache.h"
0013 
0014 #include <QDBusConnection>
0015 #include "maininterface.h"
0016 #include "baloosettings.h"
0017 
0018 using namespace Baloo;
0019 
0020 class BALOO_CORE_NO_EXPORT IndexerConfig::Private {
0021 public:
0022     FileIndexerConfig m_config;
0023     BalooSettings m_settings;
0024 };
0025 
0026 IndexerConfig::IndexerConfig()
0027     : d(new Private)
0028 {
0029 }
0030 
0031 IndexerConfig::~IndexerConfig()
0032 {
0033     d->m_settings.save();
0034 }
0035 
0036 bool IndexerConfig::fileIndexingEnabled() const
0037 {
0038     return d->m_settings.indexingEnabled();
0039 }
0040 
0041 void IndexerConfig::setFileIndexingEnabled(bool enabled) const
0042 {
0043     d->m_settings.setIndexingEnabled(enabled);
0044 }
0045 
0046 bool IndexerConfig::shouldBeIndexed(const QString& path) const
0047 {
0048     return d->m_config.shouldBeIndexed(path);
0049 }
0050 
0051 bool IndexerConfig::canBeSearched(const QString& folder) const
0052 {
0053     return d->m_config.canBeSearched(folder);
0054 }
0055 
0056 QStringList IndexerConfig::excludeFolders() const
0057 {
0058     return d->m_config.excludeFolders();
0059 }
0060 
0061 QStringList IndexerConfig::includeFolders() const
0062 {
0063     return d->m_config.includeFolders();
0064 }
0065 
0066 QStringList IndexerConfig::excludeFilters() const
0067 {
0068     return d->m_config.excludeFilters();
0069 }
0070 
0071 QStringList IndexerConfig::excludeMimetypes() const
0072 {
0073     return d->m_config.excludeMimetypes();
0074 }
0075 
0076 void IndexerConfig::setExcludeFolders(const QStringList& excludeFolders)
0077 {
0078     d->m_settings.setExcludedFolders(excludeFolders);
0079 }
0080 
0081 void IndexerConfig::setIncludeFolders(const QStringList& includeFolders)
0082 {
0083     d->m_settings.setFolders(includeFolders);
0084 }
0085 
0086 void IndexerConfig::setExcludeFilters(const QStringList& excludeFilters)
0087 {
0088     d->m_settings.setExcludedFilters(excludeFilters);
0089 }
0090 
0091 void IndexerConfig::setExcludeMimetypes(const QStringList& excludeMimetypes)
0092 {
0093     d->m_settings.setExcludedMimetypes(excludeMimetypes);
0094 }
0095 
0096 bool IndexerConfig::indexHidden() const
0097 {
0098     return d->m_settings.indexHiddenFolders();
0099 }
0100 
0101 void IndexerConfig::setIndexHidden(bool value) const
0102 {
0103     d->m_settings.setIndexHiddenFolders(value);
0104 }
0105 
0106 bool IndexerConfig::onlyBasicIndexing() const
0107 {
0108     return d->m_settings.onlyBasicIndexing();
0109 }
0110 
0111 void IndexerConfig::setOnlyBasicIndexing(bool value)
0112 {
0113     d->m_settings.setOnlyBasicIndexing(value);
0114 }
0115 
0116 void IndexerConfig::refresh() const
0117 {
0118     org::kde::baloo::main mainInterface(QStringLiteral("org.kde.baloo"),
0119                                                 QStringLiteral("/"),
0120                                                 QDBusConnection::sessionBus());
0121     mainInterface.updateConfig();
0122 }