add more spacing
[personal-kdebase.git] / runtime / nepomuk / services / strigi / config.cpp
blob146e19bfe673c4cadd6cbf91fe42e551c8383bbb
1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
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.
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.
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.
19 #include "config.h"
21 #include <QtCore/QStringList>
22 #include <QtCore/QDir>
24 #include <kdirwatch.h>
25 #include <kstandarddirs.h>
26 #include <kconfiggroup.h>
29 Nepomuk::Config::Config()
30 : QObject(),
31 m_config( "nepomukstrigirc" )
33 KDirWatch* dirWatch = KDirWatch::self();
34 connect( dirWatch, SIGNAL( dirty( const QString& ) ),
35 this, SLOT( slotConfigDirty() ) );
36 connect( dirWatch, SIGNAL( created( const QString& ) ),
37 this, SLOT( slotConfigDirty() ) );
38 dirWatch->addFile( KStandardDirs::locateLocal( "config", m_config.name() ) );
42 Nepomuk::Config::~Config()
44 m_config.group( "General" ).writeEntry( "first run", false );
48 Nepomuk::Config* Nepomuk::Config::self()
50 K_GLOBAL_STATIC( Config, _self );
51 return _self;
55 QStringList Nepomuk::Config::folders() const
57 return m_config.group( "General" ).readPathEntry( "folders", QStringList() << QDir::homePath() );
61 QStringList Nepomuk::Config::excludeFolders() const
63 return m_config.group( "General" ).readPathEntry( "exclude folders", QStringList() );
67 QStringList Nepomuk::Config::excludeFilters() const
69 return m_config.group( "General" ).readEntry( "exclude filters", QStringList() << ".*/" << ".*" << "*~" << "*.part" );
73 QStringList Nepomuk::Config::includeFilters() const
75 return m_config.group( "General" ).readEntry( "include filters", QStringList() );
79 KIO::filesize_t Nepomuk::Config::minDiskSpace() const
81 // default: 200 MB
82 return m_config.group( "General" ).readEntry( "min disk space", KIO::filesize_t( 200*1024*1024 ) );
86 void Nepomuk::Config::slotConfigDirty()
88 m_config.reparseConfiguration();
89 emit configChanged();
93 bool Nepomuk::Config::showGui() const
95 return m_config.group( "General" ).readEntry( "show gui", true );
99 void Nepomuk::Config::setShowGui( bool showGui )
101 m_config.group( "General" ).writeEntry( "show gui", showGui );
105 bool Nepomuk::Config::isInitialRun() const
107 return m_config.group( "General" ).readEntry( "first run", true );
111 bool Nepomuk::Config::shouldFolderBeIndexed( const QString& path )
113 QStringList inDirs = folders();
114 QStringList exDirs = excludeFolders();
116 if( inDirs.contains( path ) ) {
117 return true;
119 else if( exDirs.contains( path ) ) {
120 return false;
122 else {
123 QString parent = path.section( QDir::separator(), 0, -2, QString::SectionSkipEmpty|QString::SectionIncludeLeadingSep );
124 if( parent.isEmpty() ) {
125 return false;
127 else {
128 return shouldFolderBeIndexed( parent );
133 #include "config.moc"