Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

kateconfig.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef KATECONFIG_H
00022 #define KATECONFIG_H
00023 
00024 // ##### could use QSettings with Qt 3.0
00025 
00026 #include <qmap.h>
00027 #include <qstringlist.h>
00028 #include <qfont.h>
00029 #include <qcolor.h>
00030 
00031 class KateConfigPrivate;
00032 class KateConfig
00033 {
00034 public:
00035     typedef QMap< QString, QString > KateConfigGroup;
00036     
00037     enum Domain { File, User };
00038     KateConfig( const QString &name, Domain domain=User );
00039     ~KateConfig();
00040     
00041     bool operator == ( const KateConfig & other ) const { return (filename == other.filename); }
00042     bool operator != ( const KateConfig & other ) const { return (filename != other.filename); }
00043     
00044     bool isValid() const;
00045     bool hasKey( const QString &key ) const;
00046 
00047         // inline for better SharpROM BC
00048         inline bool hasGroup ( const QString &gname ) const  { return ( groups. find ( gname ) != groups. end ( )); };
00049         inline QStringList groupList ( ) const { QStringList sl; for ( QMap< QString, KateConfigGroup >::ConstIterator it = groups. begin ( ); it != groups. end ( ); ++it ) { sl << it.key(); } return sl; };
00050     
00051     void setGroup( const QString &gname );
00052     void writeEntry( const QString &key, const char* value );
00053     void writeEntry( const QString &key, const QString &value );
00054     void writeEntryCrypt( const QString &key, const QString &value );
00055     void writeEntry( const QString &key, int num );
00056     void writeEntry( const QString &key, unsigned int num );
00057 #ifdef Q_HAS_BOOL_TYPE
00058     void writeEntry( const QString &key, bool b );
00059 #endif
00060     void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
00061     void writeEntry( const QString &key, const QColor & );
00062     void writeEntry( const QString &key, const QFont & );
00063     void removeEntry( const QString &key );
00064     
00065     QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
00066     QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
00067     QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
00068     int readNumEntry( const QString &key, int deflt = -1 ) const;
00069     bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
00070     QStringList readListEntry( const QString &key, const QChar &sep ) const;
00071     QColor readColorEntry( const QString &, const QColor & ) const;
00072     QFont readFontEntry( const QString &, const QFont & ) const;
00073     QValueList<int> readIntListEntry( const QString &key ) const;
00074 
00075     // For compatibility, non-const versions.
00076     QString readEntry( const QString &key, const QString &deflt );
00077     QString readEntryCrypt( const QString &key, const QString &deflt );
00078     QString readEntryDirect( const QString &key, const QString &deflt );
00079     int readNumEntry( const QString &key, int deflt );
00080     bool readBoolEntry( const QString &key, bool deflt );
00081     QStringList readListEntry( const QString &key, const QChar &sep );
00082     
00083     void clearGroup();
00084     
00085     void write( const QString &fn = QString::null );
00086     
00087 protected:
00088     void read();
00089     bool parse( const QString &line );
00090     
00091     QMap< QString, KateConfigGroup > groups;
00092     QMap< QString, KateConfigGroup >::Iterator git;
00093     QString filename;
00094     QString lang;
00095     QString glang;
00096     bool changed;
00097     KateConfigPrivate *d;
00098     static QString configFilename(const QString& name, Domain);
00099 
00100 private: // Sharp ROM compatibility
00101     KateConfig( const QString &name, bool what );
00102 };
00103 
00104 inline QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
00105 { return ((KateConfig*)this)->readEntry(key,deflt); }
00106 inline QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
00107 { return ((KateConfig*)this)->readEntryCrypt(key,deflt); }
00108 inline QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
00109 { return ((KateConfig*)this)->readEntryDirect(key,deflt); }
00110 inline int KateConfig::readNumEntry( const QString &key, int deflt ) const
00111 { return ((KateConfig*)this)->readNumEntry(key,deflt); }
00112 inline bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
00113 { return ((KateConfig*)this)->readBoolEntry(key,deflt); }
00114 inline QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
00115 { return ((KateConfig*)this)->readListEntry(key,sep); }
00116 
00117 #endif

Generated on Sat Nov 5 16:17:11 2005 for OPIE by  doxygen 1.4.2