-rw-r--r-- | library/config.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/config.h b/library/config.h index 29ba0d6..f8d3bf7 100644 --- a/library/config.h +++ b/library/config.h | |||
@@ -1,108 +1,110 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000, 2004 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000, 2004 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef CONFIG_H | 21 | #ifndef CONFIG_H |
22 | #define CONFIG_H | 22 | #define CONFIG_H |
23 | 23 | ||
24 | // ##### could use QSettings with Qt 3.0 | 24 | // ##### could use QSettings with Qt 3.0 |
25 | 25 | ||
26 | #include <qpe/qpeglobal.h> | 26 | #include <qpe/qpeglobal.h> |
27 | 27 | ||
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | 30 | ||
31 | typedef QMap< QString, QString > ConfigGroup; | 31 | typedef QMap< QString, QString > ConfigGroup; |
32 | typedef QMap< QString, ConfigGroup> ConfigGroupMap; | 32 | typedef QMap< QString, ConfigGroup> ConfigGroupMap; |
33 | 33 | ||
34 | class QTextStream; | ||
34 | class ConfigPrivate; | 35 | class ConfigPrivate; |
35 | class Config | 36 | class Config |
36 | { | 37 | { |
37 | public: | 38 | public: |
38 | 39 | ||
39 | enum Domain { File, User }; | 40 | enum Domain { File, User }; |
40 | Config( const QString &name, Domain domain=User ); | 41 | Config( const QString &name, Domain domain=User ); |
41 | ~Config(); | 42 | ~Config(); |
42 | 43 | ||
43 | QTOPIA_MERGED_METHOD(static long timeStamp( const QString &name, Domain domain=User ), "2.1"); | 44 | QTOPIA_MERGED_METHOD(static long timeStamp( const QString &name, Domain domain=User ), "2.1"); |
44 | 45 | ||
45 | bool operator == ( const Config & other ) const { return (filename == other.filename); } | 46 | bool operator == ( const Config & other ) const { return (filename == other.filename); } |
46 | bool operator != ( const Config & other ) const { return (filename != other.filename); } | 47 | bool operator != ( const Config & other ) const { return (filename != other.filename); } |
47 | 48 | ||
48 | bool isValid() const; | 49 | bool isValid() const; |
49 | bool hasKey( const QString &key ) const; | 50 | bool hasKey( const QString &key ) const; |
50 | 51 | ||
51 | // inline for better SharpROM BC | 52 | // inline for better SharpROM BC |
52 | NOT_IN_QPE(bool hasGroup ( const QString &gname ) const); | 53 | NOT_IN_QPE(bool hasGroup ( const QString &gname ) const); |
53 | NOT_IN_QPE(QStringList groupList ( ) const); | 54 | NOT_IN_QPE(QStringList groupList ( ) const); |
54 | 55 | ||
55 | void setGroup( const QString &gname ); | 56 | void setGroup( const QString &gname ); |
56 | void writeEntry( const QString &key, const char* value ); | 57 | void writeEntry( const QString &key, const char* value ); |
57 | void writeEntry( const QString &key, const QString &value ); | 58 | void writeEntry( const QString &key, const QString &value ); |
58 | void writeEntryCrypt( const QString &key, const QString &value ); | 59 | void writeEntryCrypt( const QString &key, const QString &value ); |
59 | void writeEntry( const QString &key, int num ); | 60 | void writeEntry( const QString &key, int num ); |
60 | #ifdef Q_HAS_BOOL_TYPE | 61 | #ifdef Q_HAS_BOOL_TYPE |
61 | void writeEntry( const QString &key, bool b ); | 62 | void writeEntry( const QString &key, bool b ); |
62 | #endif | 63 | #endif |
63 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); | 64 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); |
64 | QTOPIA_MERGED_METHOD(void writeEntry( const QString &key, const QStringList &lst ), "2.1.0"); | 65 | QTOPIA_MERGED_METHOD(void writeEntry( const QString &key, const QStringList &lst ), "2.1.0"); |
65 | 66 | ||
66 | void removeEntry( const QString &key ); | 67 | void removeEntry( const QString &key ); |
67 | 68 | ||
68 | QString readEntry( const QString &key, const QString &deflt = QString::null ) const; | 69 | QString readEntry( const QString &key, const QString &deflt = QString::null ) const; |
69 | QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; | 70 | QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; |
70 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; | 71 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; |
71 | int readNumEntry( const QString &key, int deflt = -1 ) const; | 72 | int readNumEntry( const QString &key, int deflt = -1 ) const; |
72 | bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; | 73 | bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; |
73 | QStringList readListEntry( const QString &key, const QChar &sep ) const; | 74 | QStringList readListEntry( const QString &key, const QChar &sep ) const; |
74 | QTOPIA_MERGED_METHOD(QStringList readListEntry( const QString &key ) const, "2.1.0"); | 75 | QTOPIA_MERGED_METHOD(QStringList readListEntry( const QString &key ) const, "2.1.0"); |
75 | 76 | ||
76 | // For compatibility, non-const versions. | 77 | // For compatibility, non-const versions. |
77 | QString readEntry( const QString &key, const QString &deflt ); | 78 | QString readEntry( const QString &key, const QString &deflt ); |
78 | QString readEntryCrypt( const QString &key, const QString &deflt ); | 79 | QString readEntryCrypt( const QString &key, const QString &deflt ); |
79 | QString readEntryDirect( const QString &key, const QString &deflt ); | 80 | QString readEntryDirect( const QString &key, const QString &deflt ); |
80 | int readNumEntry( const QString &key, int deflt ); | 81 | int readNumEntry( const QString &key, int deflt ); |
81 | bool readBoolEntry( const QString &key, bool deflt ); | 82 | bool readBoolEntry( const QString &key, bool deflt ); |
82 | QStringList readListEntry( const QString &key, const QChar &sep ); | 83 | QStringList readListEntry( const QString &key, const QChar &sep ); |
83 | 84 | ||
84 | void clearGroup(); | 85 | void clearGroup(); |
85 | QTOPIA_MERGED_METHOD(void removeGroup(), "2.1.0"); | 86 | QTOPIA_MERGED_METHOD(void removeGroup(), "2.1.0"); |
86 | QTOPIA_MERGED_METHOD(void removeGroup(const QString&), "2.1.0"); | 87 | QTOPIA_MERGED_METHOD(void removeGroup(const QString&), "2.1.0"); |
87 | QTOPIA_MERGED_METHOD(QStringList allGroups() const, "2.1.0"); | 88 | QTOPIA_MERGED_METHOD(QStringList allGroups() const, "2.1.0"); |
88 | 89 | ||
89 | void write( const QString &fn = QString::null ); | 90 | void write( const QString &fn = QString::null ); |
90 | 91 | ||
91 | protected: | 92 | protected: |
92 | void read(); | 93 | void read(); |
93 | bool parse( const QString &line ); | 94 | bool parse( const QString &line ); |
94 | 95 | ||
95 | QMap< QString, ConfigGroup > groups; | 96 | ConfigGroupMap groups; |
96 | QMap< QString, ConfigGroup >::Iterator git; | 97 | ConfigGroupMap::Iterator git; |
97 | QString filename; | 98 | QString filename; |
98 | QString lang; | 99 | QString lang; |
99 | QString glang; | 100 | QString glang; |
100 | bool changed; | 101 | bool changed; |
101 | ConfigPrivate *d; | 102 | ConfigPrivate *d; |
102 | static QString configFilename(const QString& name, Domain); | 103 | static QString configFilename(const QString& name, Domain); |
103 | 104 | ||
104 | private: // Sharp ROM compatibility | 105 | private: // Sharp ROM compatibility |
105 | Config( const QString &name, bool what ); | 106 | Config( const QString &name, bool what ); |
107 | void read( QTextStream &s); | ||
106 | }; | 108 | }; |
107 | 109 | ||
108 | #endif | 110 | #endif |