-rw-r--r-- | microkde/kconfig.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index e0b6e99..821e386 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -44,49 +44,49 @@ void KConfig::setGroup( const QString &group ) | |||
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 | { |
@@ -114,49 +114,52 @@ QSize KConfig::readSizeEntry( const QString &key, QSize* def ) | |||
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 | return QStringList::split(":", QString::fromUtf8((*it).latin1())); | 138 | QStringList temp = QStringList::split(":@:", QString::fromUtf8((*it).latin1())); |
139 | if ( temp.count() == 1 ) | ||
140 | return QStringList::split(":", QString::fromUtf8((*it).latin1())); | ||
141 | return temp; | ||
139 | 142 | ||
140 | } | 143 | } |
141 | 144 | ||
142 | bool KConfig::readBoolEntry( const QString &key, bool def ) | 145 | bool KConfig::readBoolEntry( const QString &key, bool def ) |
143 | { | 146 | { |
144 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); | 147 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); |
145 | 148 | ||
146 | if ( it == mBoolMap.end() ) { | 149 | if ( it == mBoolMap.end() ) { |
147 | return def; | 150 | return def; |
148 | } | 151 | } |
149 | 152 | ||
150 | return *it; | 153 | return *it; |
151 | } | 154 | } |
152 | 155 | ||
153 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) | 156 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) |
154 | { | 157 | { |
155 | 158 | ||
156 | QStringList l; | 159 | QStringList l; |
157 | l = readListEntry( e.utf8() ); | 160 | l = readListEntry( e.utf8() ); |
158 | if (l.count() != 3 ) { | 161 | if (l.count() != 3 ) { |
159 | if ( def ) | 162 | if ( def ) |
160 | return *def; | 163 | return *def; |
161 | else | 164 | else |
162 | return QColor(); | 165 | return QColor(); |
@@ -199,49 +202,49 @@ void KConfig::writeEntry( const QString &key, const QValueList<int> &value) | |||
199 | 202 | ||
200 | for( it = value.begin(); it != value.end(); ++it ) | 203 | for( it = value.begin(); it != value.end(); ++it ) |
201 | { | 204 | { |
202 | valuesAsStrings << QString::number(*it); | 205 | valuesAsStrings << QString::number(*it); |
203 | } | 206 | } |
204 | 207 | ||
205 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); | 208 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); |
206 | mDirty = true; | 209 | mDirty = true; |
207 | } | 210 | } |
208 | 211 | ||
209 | void KConfig::writeEntry( const QString & key , int num ) | 212 | void KConfig::writeEntry( const QString & key , int num ) |
210 | { | 213 | { |
211 | writeEntry( key, QString::number ( num ) ); | 214 | writeEntry( key, QString::number ( num ) ); |
212 | } | 215 | } |
213 | 216 | ||
214 | void KConfig::writeEntry( const QString &key, const QString &value ) | 217 | void KConfig::writeEntry( const QString &key, const QString &value ) |
215 | { | 218 | { |
216 | mStringMap.insert( mGroup + key, value.utf8() ); | 219 | mStringMap.insert( mGroup + key, value.utf8() ); |
217 | 220 | ||
218 | mDirty = true; | 221 | mDirty = true; |
219 | } | 222 | } |
220 | 223 | ||
221 | void KConfig::writeEntry( const QString &key, const QStringList &value ) | 224 | void KConfig::writeEntry( const QString &key, const QStringList &value ) |
222 | { | 225 | { |
223 | mStringMap.insert( mGroup + key, value.join(":").utf8() ); | 226 | mStringMap.insert( mGroup + key, value.join(":@:").utf8() ); |
224 | 227 | ||
225 | mDirty = true; | 228 | mDirty = true; |
226 | } | 229 | } |
227 | 230 | ||
228 | void KConfig::writeEntry( const QString &key, bool value) | 231 | void KConfig::writeEntry( const QString &key, bool value) |
229 | { | 232 | { |
230 | mBoolMap.insert( mGroup + key, value ); | 233 | mBoolMap.insert( mGroup + key, value ); |
231 | 234 | ||
232 | mDirty = true; | 235 | mDirty = true; |
233 | } | 236 | } |
234 | 237 | ||
235 | void KConfig::writeEntry( const QString & e, const QColor & c ) | 238 | void KConfig::writeEntry( const QString & e, const QColor & c ) |
236 | { | 239 | { |
237 | QStringList l; | 240 | QStringList l; |
238 | l.append( QString::number ( c.red() ) ); | 241 | l.append( QString::number ( c.red() ) ); |
239 | l.append( QString::number ( c.green() ) ); | 242 | l.append( QString::number ( c.green() ) ); |
240 | l.append( QString::number ( c.blue() ) ); | 243 | l.append( QString::number ( c.blue() ) ); |
241 | writeEntry( e.utf8(), l ); | 244 | writeEntry( e.utf8(), l ); |
242 | } | 245 | } |
243 | 246 | ||
244 | void KConfig::writeEntry( const QString & e, const QSize & s ) | 247 | void KConfig::writeEntry( const QString & e, const QSize & s ) |
245 | { | 248 | { |
246 | QValueList<int> intlist; | 249 | QValueList<int> intlist; |
247 | intlist << s.width() << s.height(); | 250 | intlist << s.width() << s.height(); |