Diffstat (limited to 'noncore/apps/tinykate/libkate/kateconfig.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/kateconfig.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/kateconfig.h b/noncore/apps/tinykate/libkate/kateconfig.h new file mode 100644 index 0000000..80a4e67 --- a/dev/null +++ b/noncore/apps/tinykate/libkate/kateconfig.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef KATECONFIG_H | ||
22 | #define KATECONFIG_H | ||
23 | |||
24 | // ##### could use QSettings with Qt 3.0 | ||
25 | |||
26 | #include <qmap.h> | ||
27 | #include <qstringlist.h> | ||
28 | #include <qfont.h> | ||
29 | #include <qcolor.h> | ||
30 | |||
31 | class KateConfigPrivate; | ||
32 | class KateConfig | ||
33 | { | ||
34 | public: | ||
35 | typedef QMap< QString, QString > KateConfigGroup; | ||
36 | |||
37 | enum Domain { File, User }; | ||
38 | KateConfig( const QString &name, Domain domain=User ); | ||
39 | ~KateConfig(); | ||
40 | |||
41 | bool operator == ( const KateConfig & other ) const { return (filename == other.filename); } | ||
42 | bool operator != ( const KateConfig & other ) const { return (filename != other.filename); } | ||
43 | |||
44 | bool isValid() const; | ||
45 | bool hasKey( const QString &key ) const; | ||
46 | |||
47 | // inline for better SharpROM BC | ||
48 | inline bool hasGroup ( const QString &gname ) const { return ( groups. find ( gname ) != groups. end ( )); }; | ||
49 | inline QStringList groupList ( ) const { QStringList sl; for ( QMap< QString, KateConfigGroup >::ConstIterator it = groups. begin ( ); it != groups. end ( ); ++it ) { sl << it.key(); } return sl; }; | ||
50 | |||
51 | void setGroup( const QString &gname ); | ||
52 | void writeEntry( const QString &key, const char* value ); | ||
53 | void writeEntry( const QString &key, const QString &value ); | ||
54 | void writeEntryCrypt( const QString &key, const QString &value ); | ||
55 | void writeEntry( const QString &key, int num ); | ||
56 | void writeEntry( const QString &key, unsigned int num ); | ||
57 | #ifdef Q_HAS_BOOL_TYPE | ||
58 | void writeEntry( const QString &key, bool b ); | ||
59 | #endif | ||
60 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); | ||
61 | void writeEntry( const QString &key, const QColor & ); | ||
62 | void writeEntry( const QString &key, const QFont & ); | ||
63 | void removeEntry( const QString &key ); | ||
64 | |||
65 | QString readEntry( const QString &key, const QString &deflt = QString::null ) const; | ||
66 | QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; | ||
67 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; | ||
68 | int readNumEntry( const QString &key, int deflt = -1 ) const; | ||
69 | bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; | ||
70 | QStringList readListEntry( const QString &key, const QChar &sep ) const; | ||
71 | QColor readColorEntry( const QString &, const QColor & ) const; | ||
72 | QFont readFontEntry( const QString &, const QFont & ) const; | ||
73 | QValueList<int> readIntListEntry( const QString &key ) const; | ||
74 | |||
75 | // For compatibility, non-const versions. | ||
76 | QString readEntry( const QString &key, const QString &deflt ); | ||
77 | QString readEntryCrypt( const QString &key, const QString &deflt ); | ||
78 | QString readEntryDirect( const QString &key, const QString &deflt ); | ||
79 | int readNumEntry( const QString &key, int deflt ); | ||
80 | bool readBoolEntry( const QString &key, bool deflt ); | ||
81 | QStringList readListEntry( const QString &key, const QChar &sep ); | ||
82 | |||
83 | void clearGroup(); | ||
84 | |||
85 | void write( const QString &fn = QString::null ); | ||
86 | |||
87 | protected: | ||
88 | void read(); | ||
89 | bool parse( const QString &line ); | ||
90 | |||
91 | QMap< QString, KateConfigGroup > groups; | ||
92 | QMap< QString, KateConfigGroup >::Iterator git; | ||
93 | QString filename; | ||
94 | QString lang; | ||
95 | QString glang; | ||
96 | bool changed; | ||
97 | KateConfigPrivate *d; | ||
98 | static QString configFilename(const QString& name, Domain); | ||
99 | |||
100 | private: // Sharp ROM compatibility | ||
101 | KateConfig( const QString &name, bool what ); | ||
102 | }; | ||
103 | |||
104 | inline QString KateConfig::readEntry( const QString &key, const QString &deflt ) const | ||
105 | { return ((KateConfig*)this)->readEntry(key,deflt); } | ||
106 | inline QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const | ||
107 | { return ((KateConfig*)this)->readEntryCrypt(key,deflt); } | ||
108 | inline QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const | ||
109 | { return ((KateConfig*)this)->readEntryDirect(key,deflt); } | ||
110 | inline int KateConfig::readNumEntry( const QString &key, int deflt ) const | ||
111 | { return ((KateConfig*)this)->readNumEntry(key,deflt); } | ||
112 | inline bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const | ||
113 | { return ((KateConfig*)this)->readBoolEntry(key,deflt); } | ||
114 | inline QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const | ||
115 | { return ((KateConfig*)this)->readListEntry(key,sep); } | ||
116 | |||
117 | #endif | ||