-rw-r--r-- | microkde/kconfig.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 821e386..940196e 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -1,164 +1,164 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <qwidget.h> | 3 | #include <qwidget.h> |
4 | 4 | ||
5 | #include "kdebug.h" | 5 | #include "kdebug.h" |
6 | 6 | ||
7 | #include "kurl.h" | 7 | #include "kurl.h" |
8 | #include "kstandarddirs.h" | 8 | #include "kstandarddirs.h" |
9 | #include "kconfig.h" | 9 | #include "kconfig.h" |
10 | 10 | ||
11 | QString KConfig::mGroup = ""; | 11 | QString KConfig::mGroup = ""; |
12 | //QString KConfig::mGroup = "General"; | 12 | //QString KConfig::mGroup = "General"; |
13 | 13 | ||
14 | KConfig::KConfig( const QString &fileName ) | 14 | KConfig::KConfig( const QString &fileName ) |
15 | : mFileName( fileName ), mDirty( false ) | 15 | : mFileName( fileName ), mDirty( false ) |
16 | { | 16 | { |
17 | 17 | ||
18 | mTempGroup = ""; | 18 | mTempGroup = ""; |
19 | load(); | 19 | load(); |
20 | 20 | ||
21 | } | 21 | } |
22 | 22 | ||
23 | 23 | ||
24 | KConfig::~KConfig() | 24 | KConfig::~KConfig() |
25 | { | 25 | { |
26 | sync(); | 26 | sync(); |
27 | } | 27 | } |
28 | // we need the temp group for plugins on windows | 28 | // we need the temp group for plugins on windows |
29 | void KConfig::setTempGroup( const QString &group ) | 29 | void KConfig::setTempGroup( const QString &group ) |
30 | { | 30 | { |
31 | mTempGroup = group; | 31 | mTempGroup = group; |
32 | 32 | ||
33 | if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; | 33 | if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | QString KConfig::tempGroup() const { | 37 | QString KConfig::tempGroup() const { |
38 | return mTempGroup; | 38 | return mTempGroup; |
39 | } | 39 | } |
40 | 40 | ||
41 | void KConfig::setGroup( const QString &group ) | 41 | void KConfig::setGroup( const QString &group ) |
42 | { | 42 | { |
43 | 43 | ||
44 | 44 | ||
45 | mGroup = group; | 45 | mGroup = group; |
46 | 46 | ||
47 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; | 47 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; |
48 | } | 48 | } |
49 | 49 | ||
50 | //US | 50 | //US |
51 | QString KConfig::group() const { | 51 | QString KConfig::group() const { |
52 | return mGroup; | 52 | return mGroup; |
53 | } | 53 | } |
54 | 54 | ||
55 | //US added method | 55 | //US added method |
56 | QValueList<int> KConfig::readIntListEntry( const QString & key) | 56 | QValueList<int> KConfig::readIntListEntry( const QString & key) |
57 | { | 57 | { |
58 | // qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); | 58 | // qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); |
59 | 59 | ||
60 | QValueList<int> result; | 60 | QValueList<int> result; |
61 | 61 | ||
62 | QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); | 62 | QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); |
63 | 63 | ||
64 | if ( mit == mStringMap.end() ) { | 64 | if ( mit == mStringMap.end() ) { |
65 | return result; | 65 | return result; |
66 | } | 66 | } |
67 | 67 | ||
68 | QStringList valuesAsStrings = QStringList::split(":@:", *mit ); | 68 | QStringList valuesAsStrings = QStringList::split(":", *mit ); |
69 | bool ok = false; | 69 | bool ok = false; |
70 | bool ok2 = true; | 70 | bool ok2 = true; |
71 | int val; | 71 | int val; |
72 | 72 | ||
73 | for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { | 73 | for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { |
74 | val = (*sit).toInt(&ok); | 74 | val = (*sit).toInt(&ok); |
75 | result << val; | 75 | result << val; |
76 | if (ok == false) { | 76 | if (ok == false) { |
77 | //qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); | 77 | //qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); |
78 | ok2 = false; | 78 | ok2 = false; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | if (ok2 == false) | 82 | if (ok2 == false) |
83 | { | 83 | { |
84 | 84 | ||
85 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); | 85 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); |
86 | } | 86 | } |
87 | 87 | ||
88 | return result; | 88 | return result; |
89 | } | 89 | } |
90 | 90 | ||
91 | int KConfig::readNumEntry( const QString & key, int def ) | 91 | int KConfig::readNumEntry( const QString & key, int def ) |
92 | { | 92 | { |
93 | QString res = readEntry(key, QString::number(def ) ); | 93 | QString res = readEntry(key, QString::number(def ) ); |
94 | bool ok = false; | 94 | bool ok = false; |
95 | int result = res.toInt(&ok); | 95 | int result = res.toInt(&ok); |
96 | if ( ok ) | 96 | if ( ok ) |
97 | return result; | 97 | return result; |
98 | return def; | 98 | return def; |
99 | } | 99 | } |
100 | 100 | ||
101 | QString KConfig::readEntry( const QString &key, const QString &def ) | 101 | QString KConfig::readEntry( const QString &key, const QString &def ) |
102 | { | 102 | { |
103 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | 103 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); |
104 | 104 | ||
105 | if ( it == mStringMap.end() ) { | 105 | if ( it == mStringMap.end() ) { |
106 | return def; | 106 | return def; |
107 | } | 107 | } |
108 | 108 | ||
109 | return QString::fromUtf8((*it).latin1()); | 109 | return QString::fromUtf8((*it).latin1()); |
110 | } | 110 | } |
111 | 111 | ||
112 | QSize KConfig::readSizeEntry( const QString &key, QSize* def ) | 112 | QSize KConfig::readSizeEntry( const QString &key, QSize* def ) |
113 | { | 113 | { |
114 | QValueList<int> intlist = readIntListEntry(key); | 114 | QValueList<int> intlist = readIntListEntry(key); |
115 | 115 | ||
116 | if (intlist.count() < 2) | 116 | if (intlist.count() < 2) |
117 | { | 117 | { |
118 | if (def) | 118 | if (def) |
119 | return *def; | 119 | return *def; |
120 | else | 120 | else |
121 | return QSize(); | 121 | return QSize(); |
122 | } | 122 | } |
123 | 123 | ||
124 | QSize ret; | 124 | QSize ret; |
125 | ret.setWidth(intlist[0]); | 125 | ret.setWidth(intlist[0]); |
126 | ret.setHeight(intlist[1]); | 126 | ret.setHeight(intlist[1]); |
127 | 127 | ||
128 | return ret; | 128 | return ret; |
129 | } | 129 | } |
130 | 130 | ||
131 | QStringList KConfig::readListEntry( const QString &key ) | 131 | QStringList KConfig::readListEntry( const QString &key ) |
132 | { | 132 | { |
133 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | 133 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); |
134 | 134 | ||
135 | if ( it == mStringMap.end() ) { | 135 | if ( it == mStringMap.end() ) { |
136 | return QStringList(); | 136 | return QStringList(); |
137 | } | 137 | } |
138 | QStringList temp = QStringList::split(":@:", QString::fromUtf8((*it).latin1())); | 138 | QStringList temp = QStringList::split(":@:", QString::fromUtf8((*it).latin1())); |
139 | if ( temp.count() == 1 ) | 139 | if ( temp.count() == 1 ) |
140 | return QStringList::split(":", QString::fromUtf8((*it).latin1())); | 140 | return QStringList::split(":", QString::fromUtf8((*it).latin1())); |
141 | return temp; | 141 | return temp; |
142 | 142 | ||
143 | } | 143 | } |
144 | 144 | ||
145 | bool KConfig::readBoolEntry( const QString &key, bool def ) | 145 | bool KConfig::readBoolEntry( const QString &key, bool def ) |
146 | { | 146 | { |
147 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); | 147 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); |
148 | 148 | ||
149 | if ( it == mBoolMap.end() ) { | 149 | if ( it == mBoolMap.end() ) { |
150 | return def; | 150 | return def; |
151 | } | 151 | } |
152 | 152 | ||
153 | return *it; | 153 | return *it; |
154 | } | 154 | } |
155 | 155 | ||
156 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) | 156 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) |
157 | { | 157 | { |
158 | 158 | ||
159 | QStringList l; | 159 | QStringList l; |
160 | l = readListEntry( e.utf8() ); | 160 | l = readListEntry( e.utf8() ); |
161 | if (l.count() != 3 ) { | 161 | if (l.count() != 3 ) { |
162 | if ( def ) | 162 | if ( def ) |
163 | return *def; | 163 | return *def; |
164 | else | 164 | else |