• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

config.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE Project
00002    Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "config.h"
00020 
00021 #include <QtCore/QStringList>
00022 #include <QtCore/QDir>
00023 
00024 #include <kdirwatch.h>
00025 #include <kstandarddirs.h>
00026 #include <kconfiggroup.h>
00027 
00028 
00029 Nepomuk::Config::Config()
00030     : QObject(),
00031       m_config( "nepomukstrigirc" )
00032 {
00033     KDirWatch* dirWatch = KDirWatch::self();
00034     connect( dirWatch, SIGNAL( dirty( const QString& ) ),
00035              this, SLOT( slotConfigDirty() ) );
00036     connect( dirWatch, SIGNAL( created( const QString& ) ),
00037              this, SLOT( slotConfigDirty() ) );
00038     dirWatch->addFile( KStandardDirs::locateLocal( "config", m_config.name() ) );
00039 }
00040 
00041 
00042 Nepomuk::Config::~Config()
00043 {
00044     m_config.group( "General" ).writeEntry( "first run", false );
00045 }
00046 
00047 
00048 Nepomuk::Config* Nepomuk::Config::self()
00049 {
00050     K_GLOBAL_STATIC( Config, _self );
00051     return _self;
00052 }
00053 
00054 
00055 QStringList Nepomuk::Config::folders() const
00056 {
00057     return m_config.group( "General" ).readPathEntry( "folders", QStringList() << QDir::homePath() );
00058 }
00059 
00060 
00061 QStringList Nepomuk::Config::excludeFolders() const
00062 {
00063     return m_config.group( "General" ).readPathEntry( "exclude folders", QStringList() );
00064 }
00065 
00066 
00067 QStringList Nepomuk::Config::excludeFilters() const
00068 {
00069     return m_config.group( "General" ).readEntry( "exclude filters", QStringList() << ".*/" << ".*" << "*~" << "*.part" );
00070 }
00071 
00072 
00073 QStringList Nepomuk::Config::includeFilters() const
00074 {
00075     return m_config.group( "General" ).readEntry( "include filters", QStringList() );
00076 }
00077 
00078 
00079 KIO::filesize_t Nepomuk::Config::minDiskSpace() const
00080 {
00081     // default: 200 MB
00082     return m_config.group( "General" ).readEntry( "min disk space", KIO::filesize_t( 200*1024*1024 ) );
00083 }
00084 
00085 
00086 void Nepomuk::Config::slotConfigDirty()
00087 {
00088     m_config.reparseConfiguration();
00089     emit configChanged();
00090 }
00091 
00092 
00093 bool Nepomuk::Config::showGui() const
00094 {
00095     return m_config.group( "General" ).readEntry( "show gui", true );
00096 }
00097 
00098 
00099 void Nepomuk::Config::setShowGui( bool showGui )
00100 {
00101     m_config.group( "General" ).writeEntry( "show gui", showGui );
00102 }
00103 
00104 
00105 bool Nepomuk::Config::isInitialRun() const
00106 {
00107     return m_config.group( "General" ).readEntry( "first run", true );
00108 }
00109 
00110 
00111 bool Nepomuk::Config::shouldFolderBeIndexed( const QString& path )
00112 {
00113     QStringList inDirs = folders();
00114     QStringList exDirs = excludeFolders();
00115 
00116     if( inDirs.contains( path ) ) {
00117         return true;
00118     }
00119     else if( exDirs.contains( path ) ) {
00120         return false;
00121     }
00122     else {
00123         QString parent = path.section( QDir::separator(), 0, -2, QString::SectionSkipEmpty|QString::SectionIncludeLeadingSep );
00124         if( parent.isEmpty() ) {
00125             return false;
00126         }
00127         else {
00128             return shouldFolderBeIndexed( parent );
00129         }
00130     }
00131 }
00132 
00133 #include "config.moc"

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal