NepomukDaemons
strigiconfigfile.h
Go to the documentation of this file.00001 /* 00002 * This file is part of the Nepomuk KDE project. 00003 * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef _NEPOMUK_STRIGI_CONFIG_H_ 00022 #define _NEPOMUK_STRIGI_CONFIG_H_ 00023 00024 #include <QtCore/QObject> 00025 #include <QtCore/QStringList> 00026 00027 class QDomElement; 00028 class QTextStream; 00029 00030 namespace Nepomuk { 00038 class StrigiConfigFile : public QObject 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 StrigiConfigFile(); 00044 StrigiConfigFile( const QString& filename ); 00045 ~StrigiConfigFile(); 00046 00047 void setFilename( const QString& filename ); 00048 00049 bool load(); 00050 bool save(); 00051 00055 class Repository { 00056 public: 00057 QString name() const { return m_name; } 00058 QString type() const { return m_type; } 00059 QString indexDir() const { return m_indexDir; } 00060 bool writeable() const { return m_writeable; } 00061 QString urlBase() const { return m_urlBase; } 00062 QStringList indexedDirectories() const { return m_indexedDirectories; } 00063 int pollingInterval() const { return m_pollingInterval; } 00064 00065 bool isValid() const { return !m_type.isEmpty(); } 00066 00067 void setType( const QString& type ) { m_type = type; } 00068 void setName( const QString& name ) { m_name = name; } 00069 void setIndexDir( const QString& dir ) { m_indexDir = dir; } 00070 void setWriteable( bool writeable ) { m_writeable = writeable; } 00071 void setUrlBase( const QString& urlBase ) { m_urlBase = urlBase; } 00072 void addIndexedDirectory( const QString& dir ) { m_indexedDirectories << dir; } 00073 void setIndexedDirectories( const QStringList& dirs ) { m_indexedDirectories = dirs; } 00074 void setPollingInterval( int pollingInterval ) { m_pollingInterval = pollingInterval; } 00075 00076 private: 00077 QString m_name; 00078 QString m_type; 00079 QString m_indexDir; 00080 bool m_writeable; 00081 QString m_urlBase; 00082 QStringList m_indexedDirectories; 00083 int m_pollingInterval; 00084 }; 00085 00086 bool useDBus() const; 00087 QStringList excludeFilters() const; 00088 QStringList includeFilters() const; 00089 QList<Repository> repositories() const; 00090 00100 Repository& defaultRepository(); 00101 const Repository& defaultRepository() const; 00102 00106 static QString defaultStrigiConfigFilePath(); 00107 00108 public Q_SLOTS: 00109 void reset(); 00110 00111 void setUseDBus( bool b ); 00112 void setExcludeFilters( const QStringList& filters ); 00113 void addExcludeFilter( const QString& filter ); 00114 void setIncludeFilters( const QStringList& filters ); 00115 void addInludeFilter( const QString& filter ); 00116 void setRepositories( const QList<Repository>& repos ); 00117 void addRepository( const Repository& repo ); 00118 00119 private: 00120 bool readConfig( const QDomElement& ); 00121 Repository readRepositoryConfig( const QDomElement& ); 00122 bool readFilterConfig( const QDomElement& filterElement ); 00123 00124 QString m_filename; 00125 00126 bool m_useDBus; 00127 QStringList m_excludeFilters; 00128 QStringList m_includeFilters; 00129 QList<Repository> m_repositories; 00130 }; 00131 } 00132 00133 QTextStream& operator<<( QTextStream& s, const Nepomuk::StrigiConfigFile& scf ); 00134 00135 #endif