Diffstat (limited to 'noncore/apps/checkbook/config.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/config.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/noncore/apps/checkbook/config.h b/noncore/apps/checkbook/config.h new file mode 100644 index 0000000..b3a8561 --- a/dev/null +++ b/noncore/apps/checkbook/config.h | |||
@@ -0,0 +1,99 @@ | |||
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 CONFIG_H | ||
22 | #define CONFIG_H | ||
23 | |||
24 | // ##### could use QSettings with Qt 3.0 | ||
25 | |||
26 | #include <qmap.h> | ||
27 | #include <qstringlist.h> | ||
28 | |||
29 | class ConfigPrivate; | ||
30 | class Config | ||
31 | { | ||
32 | public: | ||
33 | typedef QMap< QString, QString > ConfigGroup; | ||
34 | |||
35 | enum Domain { File, User }; | ||
36 | Config( const QString &name, Domain domain=User ); | ||
37 | ~Config(); | ||
38 | |||
39 | bool operator == ( const Config & other ) const { return (filename == other.filename); } | ||
40 | bool operator != ( const Config & other ) const { return (filename != other.filename); } | ||
41 | |||
42 | bool isValid() const; | ||
43 | bool hasKey( const QString &key ) const; | ||
44 | |||
45 | void setGroup( const QString &gname ); | ||
46 | void writeEntry( const QString &key, const char* value ); | ||
47 | void writeEntry( const QString &key, const QString &value ); | ||
48 | void writeEntryCrypt( const QString &key, const QString &value ); | ||
49 | void writeEntry( const QString &key, int num ); | ||
50 | #ifdef Q_HAS_BOOL_TYPE | ||
51 | void writeEntry( const QString &key, bool b ); | ||
52 | #endif | ||
53 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); | ||
54 | void removeEntry( const QString &key ); | ||
55 | |||
56 | QString readEntry( const QString &key, const QString &deflt = QString::null ) const; | ||
57 | QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; | ||
58 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; | ||
59 | int readNumEntry( const QString &key, int deflt = -1 ) const; | ||
60 | bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; | ||
61 | |||
62 | // For compatibility, non-const versions. | ||
63 | QString readEntry( const QString &key, const QString &deflt ); | ||
64 | QString readEntryCrypt( const QString &key, const QString &deflt ); | ||
65 | QString readEntryDirect( const QString &key, const QString &deflt ); | ||
66 | int readNumEntry( const QString &key, int deflt ); | ||
67 | bool readBoolEntry( const QString &key, bool deflt ); | ||
68 | |||
69 | void clearGroup(); | ||
70 | void removeGroup(); | ||
71 | |||
72 | void write( const QString &fn = QString::null ); | ||
73 | |||
74 | protected: | ||
75 | void read(); | ||
76 | bool parse( const QString &line ); | ||
77 | |||
78 | QMap< QString, ConfigGroup > groups; | ||
79 | QMap< QString, ConfigGroup >::Iterator git; | ||
80 | QString filename; | ||
81 | QString lang; | ||
82 | QString glang; | ||
83 | bool changed; | ||
84 | ConfigPrivate *d; | ||
85 | static QString configFilename(const QString& name, Domain); | ||
86 | }; | ||
87 | |||
88 | inline QString Config::readEntry( const QString &key, const QString &deflt ) const | ||
89 | { return ((Config*)this)->readEntry(key,deflt); } | ||
90 | inline QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const | ||
91 | { return ((Config*)this)->readEntryCrypt(key,deflt); } | ||
92 | inline QString Config::readEntryDirect( const QString &key, const QString &deflt ) const | ||
93 | { return ((Config*)this)->readEntryDirect(key,deflt); } | ||
94 | inline int Config::readNumEntry( const QString &key, int deflt ) const | ||
95 | { return ((Config*)this)->readNumEntry(key,deflt); } | ||
96 | inline bool Config::readBoolEntry( const QString &key, bool deflt ) const | ||
97 | { return ((Config*)this)->readBoolEntry(key,deflt); } | ||
98 | |||
99 | #endif | ||