1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "dolphinsearchinformation.h"
22 #include <config-nepomuk.h>
25 #include <KConfigGroup>
26 #include <Nepomuk/ResourceManager>
32 struct DolphinSearchInformationSingleton
34 DolphinSearchInformation instance
;
36 K_GLOBAL_STATIC(DolphinSearchInformationSingleton
, s_dolphinSearchInformation
)
39 DolphinSearchInformation
& DolphinSearchInformation::instance()
41 return s_dolphinSearchInformation
->instance
;
44 DolphinSearchInformation::~DolphinSearchInformation()
48 bool DolphinSearchInformation::isIndexingEnabled() const
50 return m_indexingEnabled
;
53 bool DolphinSearchInformation::isPathIndexed(const KUrl
& url
) const
56 const KConfig
strigiConfig("nepomukstrigirc");
57 const QStringList indexedFolders
= strigiConfig
.group("General").readPathEntry("folders", QStringList());
59 // Check whether the path is part of an indexed folder
60 bool isIndexed
= false;
61 foreach (const QString
& indexedFolder
, indexedFolders
) {
62 const KUrl
indexedPath(indexedFolder
);
63 if (indexedPath
.isParentOf(url
)) {
70 // The path is part of an indexed folder. Check whether no
71 // excluded folder is part of the path.
72 const QStringList excludedFolders
= strigiConfig
.group("General").readPathEntry("exclude folders", QStringList());
73 foreach (const QString
& excludedFolder
, excludedFolders
) {
74 const KUrl
excludedPath(excludedFolder
);
75 if (excludedPath
.isParentOf(url
)) {
89 DolphinSearchInformation::DolphinSearchInformation() :
90 m_indexingEnabled(false)
93 if (Nepomuk::ResourceManager::instance()->initialized()) {
94 KConfig
config("nepomukserverrc");
95 m_indexingEnabled
= config
.group("Service-nepomukfileindexer").readEntry("autostart", false);