• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • services
  • fileindexer
fileindexerconfig.h
Go to the documentation of this file.
1 /* This file is part of the KDE Project
2  Copyright (c) 2008-2009 Sebastian Trueg <trueg@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef _NEPOMUK_FILEINDEXER_SERVICE_CONFIG_H_
20 #define _NEPOMUK_FILEINDEXER_SERVICE_CONFIG_H_
21 
22 #include <QtCore/QObject>
23 #include <QtCore/QList>
24 #include <QtCore/QSet>
25 #include <QtCore/QRegExp>
26 #include <QtCore/QReadWriteLock>
27 
28 #include <kconfig.h>
29 #include <kio/global.h>
30 
31 #include "regexpcache.h"
32 
33 namespace Nepomuk2 {
38  class FileIndexerConfig : public QObject
39  {
40  Q_OBJECT
41 
42  public:
47  FileIndexerConfig(QObject* parent = 0);
48  ~FileIndexerConfig();
49 
53  static FileIndexerConfig* self();
54 
60  QList<QPair<QString, bool> > folders() const;
61 
65  QStringList includeFolders() const;
66 
71  QStringList excludeFolders() const;
72 
73  QStringList excludeFilters() const;
74 
75  bool indexHiddenFilesAndFolders() const;
76 
81  KIO::filesize_t minDiskSpace() const;
82 
87  bool isInitialRun() const;
88 
96  bool initialUpdateDisabled() const;
97 
106  bool suspendOnPowerSaveDisabled() const;
107 
120  bool shouldBeIndexed( const QString& path ) const;
121 
132  bool shouldFolderBeIndexed( const QString& path ) const;
133 
141  bool shouldFileBeIndexed( const QString& fileName ) const;
142 
149  bool shouldMimeTypeBeIndexed( const QString& mimeType ) const;
150 
156  bool isDebugModeEnabled() const;
157 
158 
163  bool folderInFolderList( const QString& path );
164 
165  Q_SIGNALS:
166  void configChanged();
167 
168  void includeFolderListChanged( const QStringList& added, const QStringList& removed );
169  void excludeFolderListChanged( const QStringList& added, const QStringList& removed );
170  void fileExcludeFiltersChanged();
171  void mimeTypeFiltersChanged();
172 
173  public Q_SLOTS:
181  bool forceConfigUpdate();
182 
187  void setInitialRun(bool isInitialRun);
188 
189  private Q_SLOTS:
190  void slotConfigDirty();
191 
192  private:
198  bool folderInFolderList( const QString& path, QString& folder ) const;
199 
200  // These functions return true if the the new cache is different from the old one
201  // They also emit signals to indicate how they are different
202  bool buildFolderCache();
203  bool buildExcludeFilterRegExpCache();
204  bool buildMimeTypeCache();
205 
206  mutable KConfig m_config;
207 
209  QList<QPair<QString, bool> > m_folderCache;
210 
213  RegExpCache m_excludeFilterRegExpCache;
214  QSet<QString> m_prevFileFilters;
215 
217  QSet<QString> m_excludeMimetypes;
218 
219  bool m_indexHidden;
220 
221  mutable QReadWriteLock m_folderCacheMutex;
222  mutable QReadWriteLock m_mimetypeMutex;
223 
224  static FileIndexerConfig* s_self;
225 
226  //
227  // Use to save the previous data in order to inform clients of the changes
228  //
229  struct Entry {
230  QSet<QString> includes;
231  QSet<QString> excludes;
232  };
233  QHash<QString, Entry> m_entries;
234 
239  void fillIncludeFolderChanges( const Entry& entry, const QSet<QString>& include,
240  QStringList* includeAdded, QStringList* includeRemoved );
241  void fillExcludeFolderChanges( const Entry& entry, const QSet<QString>& exclude,
242  QStringList* excludeAdded, QStringList* excludeRemoved );
243  };
244 }
245 
246 #endif
Nepomuk2::FileIndexerConfig::excludeFolderListChanged
void excludeFolderListChanged(const QStringList &added, const QStringList &removed)
Nepomuk2::FileIndexerConfig::shouldFolderBeIndexed
bool shouldFolderBeIndexed(const QString &path) const
Check if the folder at path should be indexed.
Definition: fileindexerconfig.cpp:179
Nepomuk2::FileIndexerConfig::shouldMimeTypeBeIndexed
bool shouldMimeTypeBeIndexed(const QString &mimeType) const
Checks if mimeType should be indexed.
Definition: fileindexerconfig.cpp:219
Nepomuk2::FileIndexerConfig::configChanged
void configChanged()
Nepomuk2::FileIndexerConfig::excludeFilters
QStringList excludeFilters() const
Definition: fileindexerconfig.cpp:116
Nepomuk2::FileIndexerConfig::FileIndexerConfig
FileIndexerConfig(QObject *parent=0)
Create a new file indexr config.
Definition: fileindexerconfig.cpp:57
Nepomuk2::FileIndexerConfig::isDebugModeEnabled
bool isDebugModeEnabled() const
Check if the debug mode is enabled.
Definition: fileindexerconfig.cpp:481
QHash
Nepomuk2::FileIndexerConfig::includeFolders
QStringList includeFolders() const
The folders to search for files to analyze.
Definition: fileindexerconfig.cpp:94
Nepomuk2::FileIndexerConfig
Active config class which emits signals if the config was changed, for example if the KCM saved the c...
Definition: fileindexerconfig.h:38
QObject
Nepomuk2::FileIndexerConfig::includeFolderListChanged
void includeFolderListChanged(const QStringList &added, const QStringList &removed)
Nepomuk2::FileIndexerConfig::folderInFolderList
bool folderInFolderList(const QString &path)
Returns true if the folder is in the list indexed directories and not in the list of exclude director...
Definition: fileindexerconfig.cpp:226
Nepomuk2::FileIndexerConfig::shouldFileBeIndexed
bool shouldFileBeIndexed(const QString &fileName) const
Check fileName for all exclude filters.
Definition: fileindexerconfig.cpp:212
Nepomuk2::FileIndexerConfig::excludeFolders
QStringList excludeFolders() const
The folders that should be excluded.
Definition: fileindexerconfig.cpp:105
Nepomuk2::FileIndexerConfig::shouldBeIndexed
bool shouldBeIndexed(const QString &path) const
Check if path should be indexed taking into account the includeFolders(), the excludeFolders(), and the excludeFilters().
Definition: fileindexerconfig.cpp:165
Nepomuk2::FileIndexerConfig::folders
QList< QPair< QString, bool > > folders() const
A cleaned up list of all include and exclude folders with their respective include/exclude flag sorte...
Definition: fileindexerconfig.cpp:88
Nepomuk2::FileIndexerConfig::indexHiddenFilesAndFolders
bool indexHiddenFilesAndFolders() const
Definition: fileindexerconfig.cpp:139
Nepomuk2::FileIndexerConfig::minDiskSpace
KIO::filesize_t minDiskSpace() const
The minimal available disk space.
Definition: fileindexerconfig.cpp:145
Nepomuk2::FileIndexerConfig::initialUpdateDisabled
bool initialUpdateDisabled() const
A "hidden" config option which allows to disable the initial update of all indexed folders...
Definition: fileindexerconfig.cpp:471
Nepomuk2::FileIndexerConfig::mimeTypeFiltersChanged
void mimeTypeFiltersChanged()
Nepomuk2::FileIndexerConfig::~FileIndexerConfig
~FileIndexerConfig()
Definition: fileindexerconfig.cpp:77
RegExpCache
Definition: regexpcache.h:30
Nepomuk2::FileIndexerConfig::isInitialRun
bool isInitialRun() const
true the first time the service is run (or after manually tampering with the config.
Definition: fileindexerconfig.cpp:159
Nepomuk2::FileIndexerConfig::setInitialRun
void setInitialRun(bool isInitialRun)
Should be called once the initial indexing is done, ie.
Definition: fileindexerconfig.cpp:466
Nepomuk2::FileIndexerConfig::suspendOnPowerSaveDisabled
bool suspendOnPowerSaveDisabled() const
A "hidden" config option which allows to disable the feature where the file indexing is suspended whe...
Definition: fileindexerconfig.cpp:476
Nepomuk2::FileIndexerConfig::forceConfigUpdate
bool forceConfigUpdate()
Reread the config from disk and update the configuration cache.
Definition: fileindexerconfig.cpp:448
Nepomuk2::FileIndexerConfig::fileExcludeFiltersChanged
void fileExcludeFiltersChanged()
regexpcache.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal