summaryrefslogtreecommitdiffabout
path: root/microkde/kconfig.cpp
authorzautrix <zautrix>2004-07-08 11:20:17 (UTC)
committer zautrix <zautrix>2004-07-08 11:20:17 (UTC)
commit3f84322a2da502f95be386372da9f75ed17df574 (patch) (unidiff)
tree9a4ccd4568c38d60bb1efa7a6713f4d0914aae86 /microkde/kconfig.cpp
parent40cf8102d2f38b5e952b889ffbd19cb1d428fc9b (diff)
downloadkdepimpi-3f84322a2da502f95be386372da9f75ed17df574.zip
kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.gz
kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.bz2
Fixes for resource plugin handling on wintendo
Diffstat (limited to 'microkde/kconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kconfig.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index 737b3f2..4cbec94 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -1,509 +1,521 @@
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
11QString KConfig::mGroup = ""; 11QString KConfig::mGroup = "";
12//QString KConfig::mGroup = "General"; 12//QString KConfig::mGroup = "General";
13 13
14KConfig::KConfig( const QString &fileName ) 14KConfig::KConfig( const QString &fileName )
15 : mFileName( fileName ), mDirty( false ) 15 : mFileName( fileName ), mDirty( false )
16{ 16{
17 kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; 17
18 18 mTempGroup = "";
19 load(); 19 load();
20 20
21} 21}
22 22
23 23
24KConfig::~KConfig() 24KConfig::~KConfig()
25{ 25{
26 sync(); 26 sync();
27} 27}
28// we need the temp group for plugins on windows
29void KConfig::setTempGroup( const QString &group )
30{
31 mTempGroup = group;
32
33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/";
34}
35
36
37QString KConfig::tempGroup() const {
38 return mTempGroup;
39}
28 40
29void KConfig::setGroup( const QString &group ) 41void KConfig::setGroup( const QString &group )
30{ 42{
31 kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; 43
32 44
33 mGroup = group; 45 mGroup = group;
34 46
35 if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; 47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
36} 48}
37 49
38//US 50//US
39QString KConfig::group() const { 51QString KConfig::group() const {
40 return mGroup; 52 return mGroup;
41} 53}
42 54
43//US added method 55//US added method
44QValueList<int> KConfig::readIntListEntry( const QString & key) 56QValueList<int> KConfig::readIntListEntry( const QString & key)
45{ 57{
46// qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); 58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1());
47 59
48 QValueList<int> result; 60 QValueList<int> result;
49 61
50 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); 62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key );
51 63
52 if ( mit == mStringMap.end() ) { 64 if ( mit == mStringMap.end() ) {
53 return result; 65 return result;
54 } 66 }
55 67
56 QStringList valuesAsStrings = QStringList::split(":", *mit ); 68 QStringList valuesAsStrings = QStringList::split(":", *mit );
57 bool ok = false; 69 bool ok = false;
58 bool ok2 = true; 70 bool ok2 = true;
59 int val; 71 int val;
60 72
61 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { 73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) {
62 val = (*sit).toInt(&ok); 74 val = (*sit).toInt(&ok);
63 result << val; 75 result << val;
64 if (ok == false) { 76 if (ok == false) {
65 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); 77 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val);
66 ok2 = false; 78 ok2 = false;
67 } 79 }
68 } 80 }
69 81
70 if (ok2 == false) 82 if (ok2 == false)
71 { 83 {
72 kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; 84
73 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); 85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues.");
74 } 86 }
75 87
76 return result; 88 return result;
77} 89}
78 90
79int KConfig::readNumEntry( const QString & key, int def ) 91int KConfig::readNumEntry( const QString & key, int def )
80{ 92{
81 QString res = readEntry(key, QString::number(def ) ); 93 QString res = readEntry(key, QString::number(def ) );
82 bool ok = false; 94 bool ok = false;
83 int result = res.toInt(&ok); 95 int result = res.toInt(&ok);
84 if ( ok ) 96 if ( ok )
85 return result; 97 return result;
86 return def; 98 return def;
87} 99}
88 100
89QString KConfig::readEntry( const QString &key, const QString &def ) 101QString KConfig::readEntry( const QString &key, const QString &def )
90{ 102{
91 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
92 104
93 if ( it == mStringMap.end() ) { 105 if ( it == mStringMap.end() ) {
94 return def; 106 return def;
95 } 107 }
96 108
97 return *it; 109 return *it;
98} 110}
99 111
100QStringList KConfig::readListEntry( const QString &key ) 112QStringList KConfig::readListEntry( const QString &key )
101{ 113{
102 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 114 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
103 115
104 if ( it == mStringMap.end() ) { 116 if ( it == mStringMap.end() ) {
105 return QStringList(); 117 return QStringList();
106 } 118 }
107 return QStringList::split(":", *it ); 119 return QStringList::split(":", *it );
108 120
109} 121}
110 122
111bool KConfig::readBoolEntry( const QString &key, bool def ) 123bool KConfig::readBoolEntry( const QString &key, bool def )
112{ 124{
113 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 125 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
114 126
115 if ( it == mBoolMap.end() ) { 127 if ( it == mBoolMap.end() ) {
116 return def; 128 return def;
117 } 129 }
118 130
119 return *it; 131 return *it;
120} 132}
121 133
122QColor KConfig::readColorEntry( const QString & e, QColor *def ) 134QColor KConfig::readColorEntry( const QString & e, QColor *def )
123{ 135{
124 136
125 QStringList l; 137 QStringList l;
126 l = readListEntry( e ); 138 l = readListEntry( e );
127 if (l.count() != 3 ) { 139 if (l.count() != 3 ) {
128 if ( def ) 140 if ( def )
129 return *def; 141 return *def;
130 else 142 else
131 return QColor(); 143 return QColor();
132 } 144 }
133 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); 145 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() );
134 return c; 146 return c;
135} 147}
136 148
137QFont KConfig::readFontEntry( const QString & e, QFont *def ) 149QFont KConfig::readFontEntry( const QString & e, QFont *def )
138{ 150{
139 QStringList font = readListEntry( e ); 151 QStringList font = readListEntry( e );
140 if ( font.isEmpty() ) 152 if ( font.isEmpty() )
141 return *def; 153 return *def;
142 QFont f; 154 QFont f;
143 f.setFamily( font[0]); 155 f.setFamily( font[0]);
144 f.setBold ( font[1] == "bold"); 156 f.setBold ( font[1] == "bold");
145 f.setPointSize ( font[2].toInt()); 157 f.setPointSize ( font[2].toInt());
146 f.setItalic( font[3] == "italic" ); 158 f.setItalic( font[3] == "italic" );
147 return f; 159 return f;
148} 160}
149 161
150QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 162QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
151{ 163{
152 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 164 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
153 165
154 if ( it == mDateTimeMap.end() ) { 166 if ( it == mDateTimeMap.end() ) {
155 if ( def ) return *def; 167 if ( def ) return *def;
156 else return QDateTime(); 168 else return QDateTime();
157 } 169 }
158 170
159 return *it; 171 return *it;
160} 172}
161 173
162//US added method 174//US added method
163void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 175void KConfig::writeEntry( const QString &key, const QValueList<int> &value)
164{ 176{
165 QStringList valuesAsStrings; 177 QStringList valuesAsStrings;
166 178
167 QValueList<int>::ConstIterator it; 179 QValueList<int>::ConstIterator it;
168 180
169 for( it = value.begin(); it != value.end(); ++it ) 181 for( it = value.begin(); it != value.end(); ++it )
170 { 182 {
171 valuesAsStrings << QString::number(*it); 183 valuesAsStrings << QString::number(*it);
172 } 184 }
173 185
174 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); 186 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") );
175 mDirty = true; 187 mDirty = true;
176} 188}
177 189
178void KConfig::writeEntry( const QString & key , int num ) 190void KConfig::writeEntry( const QString & key , int num )
179{ 191{
180 writeEntry( key, QString::number ( num ) ); 192 writeEntry( key, QString::number ( num ) );
181} 193}
182 194
183void KConfig::writeEntry( const QString &key, const QString &value ) 195void KConfig::writeEntry( const QString &key, const QString &value )
184{ 196{
185 mStringMap.insert( mGroup + key, value ); 197 mStringMap.insert( mGroup + key, value );
186 198
187 mDirty = true; 199 mDirty = true;
188} 200}
189 201
190void KConfig::writeEntry( const QString &key, const QStringList &value ) 202void KConfig::writeEntry( const QString &key, const QStringList &value )
191{ 203{
192 mStringMap.insert( mGroup + key, value.join(":") ); 204 mStringMap.insert( mGroup + key, value.join(":") );
193 205
194 mDirty = true; 206 mDirty = true;
195} 207}
196 208
197void KConfig::writeEntry( const QString &key, bool value) 209void KConfig::writeEntry( const QString &key, bool value)
198{ 210{
199 mBoolMap.insert( mGroup + key, value ); 211 mBoolMap.insert( mGroup + key, value );
200 212
201 mDirty = true; 213 mDirty = true;
202} 214}
203 215
204void KConfig::writeEntry( const QString & e, const QColor & c ) 216void KConfig::writeEntry( const QString & e, const QColor & c )
205{ 217{
206 QStringList l; 218 QStringList l;
207 l.append( QString::number ( c.red() ) ); 219 l.append( QString::number ( c.red() ) );
208 l.append( QString::number ( c.green() ) ); 220 l.append( QString::number ( c.green() ) );
209 l.append( QString::number ( c.blue() ) ); 221 l.append( QString::number ( c.blue() ) );
210 writeEntry( e, l ); 222 writeEntry( e, l );
211} 223}
212 224
213void KConfig::writeEntry( const QString & e , const QFont & f ) 225void KConfig::writeEntry( const QString & e , const QFont & f )
214{ 226{
215 QStringList font; 227 QStringList font;
216 font.append( f.family()); 228 font.append( f.family());
217 font.append( (!f.bold ()?"nonbold":"bold") ); 229 font.append( (!f.bold ()?"nonbold":"bold") );
218 font.append( QString::number ( f.pointSize () ) ); 230 font.append( QString::number ( f.pointSize () ) );
219 font.append( !f.italic ()?"nonitalic":"italic" ); 231 font.append( !f.italic ()?"nonitalic":"italic" );
220 writeEntry( e, font ); 232 writeEntry( e, font );
221} 233}
222 234
223void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 235void KConfig::writeEntry( const QString &key, const QDateTime &dt )
224{ 236{
225 mDateTimeMap.insert( mGroup + key, dt ); 237 mDateTimeMap.insert( mGroup + key, dt );
226} 238}
227 239
228void KConfig::load() 240void KConfig::load()
229{ 241{
230 kdDebug() << "KConfig::load(): " << mFileName << endl; 242
231 243
232 QFile f( mFileName ); 244 QFile f( mFileName );
233 if ( !f.open( IO_ReadOnly ) ) { 245 if ( !f.open( IO_ReadOnly ) ) {
234 qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 246 qDebug("KConfig: could not open file %s ",mFileName.latin1() );
235 return; 247 return;
236 } 248 }
237 249
238 mBoolMap.clear(); 250 mBoolMap.clear();
239 mStringMap.clear(); 251 mStringMap.clear();
240 252
241 QTextStream t( &f ); 253 QTextStream t( &f );
242 254
243 QString line = t.readLine(); 255 QString line = t.readLine();
244 256
245 while ( !line.isNull() ) { 257 while ( !line.isNull() ) {
246 QStringList tokens = QStringList::split( ",", line ); 258 QStringList tokens = QStringList::split( ",", line );
247 if ( tokens[0] == "bool" ) { 259 if ( tokens[0] == "bool" ) {
248 bool value = false; 260 bool value = false;
249 if ( tokens[2] == "1" ) value = true; 261 if ( tokens[2] == "1" ) value = true;
250 mBoolMap.insert( tokens[1], value ); 262 mBoolMap.insert( tokens[1], value );
251 } else if ( tokens[0] == "QString" ) { 263 } else if ( tokens[0] == "QString" ) {
252 QString value = tokens[2]; 264 QString value = tokens[2];
253 mStringMap.insert( tokens[1], value ); 265 mStringMap.insert( tokens[1], value );
254 } else if ( tokens[0] == "QDateTime" ) { 266 } else if ( tokens[0] == "QDateTime" ) {
255#if 0 267#if 0
256 int year = tokens[2].toInt(); 268 int year = tokens[2].toInt();
257 QDateTime dt( QDate( year, 269 QDateTime dt( QDate( year,
258 tokens[3].toInt(), 270 tokens[3].toInt(),
259 tokens[4].toInt() ), 271 tokens[4].toInt() ),
260 QTime( tokens[5].toInt(), tokens[6].toInt(), 272 QTime( tokens[5].toInt(), tokens[6].toInt(),
261 tokens[7].toInt() ) ); 273 tokens[7].toInt() ) );
262 mDateTimeMap.insert( tokens[1], dt ); 274 mDateTimeMap.insert( tokens[1], dt );
263#endif 275#endif
264 } 276 }
265 277
266 line = t.readLine(); 278 line = t.readLine();
267 } 279 }
268} 280}
269 281
270void KConfig::sync() 282void KConfig::sync()
271{ 283{
272 284
273 if ( !mDirty ) return; 285 if ( !mDirty ) return;
274 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 286 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
275 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 287 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
276 288
277//US I took the following code from a newer version of KDE 289//US I took the following code from a newer version of KDE
278 // Create the containing dir if needed 290 // Create the containing dir if needed
279 KURL path; 291 KURL path;
280 path.setPath(mFileName); 292 path.setPath(mFileName);
281 QString dir=path.directory(); 293 QString dir=path.directory();
282 KStandardDirs::makeDir(dir); 294 KStandardDirs::makeDir(dir);
283 295
284 QFile f( mFileName ); 296 QFile f( mFileName );
285 if ( !f.open( IO_WriteOnly ) ) { 297 if ( !f.open( IO_WriteOnly ) ) {
286 298
287 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 299 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
288 300
289 return; 301 return;
290 } 302 }
291 303
292 QTextStream t( &f ); 304 QTextStream t( &f );
293 305
294 QMap<QString,bool>::ConstIterator itBool; 306 QMap<QString,bool>::ConstIterator itBool;
295 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 307 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
296 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 308 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
297 } 309 }
298 310
299 QMap<QString,QString>::ConstIterator itString; 311 QMap<QString,QString>::ConstIterator itString;
300 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 312 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
301 t << "QString," << itString.key() << "," << (*itString ) << endl; 313 t << "QString," << itString.key() << "," << (*itString ) << endl;
302 } 314 }
303 315
304 QMap<QString,QDateTime>::ConstIterator itDateTime; 316 QMap<QString,QDateTime>::ConstIterator itDateTime;
305 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 317 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
306 QDateTime dt = *itDateTime; 318 QDateTime dt = *itDateTime;
307 t << "QDateTime," << itDateTime.key() << "," 319 t << "QDateTime," << itDateTime.key() << ","
308 << dt.date().year() << "," 320 << dt.date().year() << ","
309 << dt.date().month() << "," 321 << dt.date().month() << ","
310 << dt.date().day() << "," 322 << dt.date().day() << ","
311 << dt.time().hour() << "," 323 << dt.time().hour() << ","
312 << dt.time().minute() << "," 324 << dt.time().minute() << ","
313 << dt.time().second() << endl; 325 << dt.time().second() << endl;
314 } 326 }
315 327
316 f.close(); 328 f.close();
317 329
318 mDirty = false; 330 mDirty = false;
319} 331}
320 332
321 333
322//US I took the following deleteGroup method from a newer version from KDE. 334//US I took the following deleteGroup method from a newer version from KDE.
323/** 335/**
324 * Deletes a configuration entry group 336 * Deletes a configuration entry group
325 * 337 *
326 * If the group is not empty and bDeep is false, nothing gets 338 * If the group is not empty and bDeep is false, nothing gets
327 * deleted and false is returned. 339 * deleted and false is returned.
328 * If this group is the current group and it is deleted, the 340 * If this group is the current group and it is deleted, the
329 * current group is undefined and should be set with setGroup() 341 * current group is undefined and should be set with setGroup()
330 * before the next operation on the configuration object. 342 * before the next operation on the configuration object.
331 * 343 *
332 * @param group The name of the group 344 * @param group The name of the group
333 * returns true if we deleted at least one entry. 345 * returns true if we deleted at least one entry.
334 */ 346 */
335bool KConfig::deleteGroup( const QString& group) 347bool KConfig::deleteGroup( const QString& group)
336{ 348{
337 bool dirty = false; 349 bool dirty = false;
338 int pos; 350 int pos;
339 351
340 QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); 352 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
341 QMap<QString,bool>::Iterator delBool; 353 QMap<QString,bool>::Iterator delBool;
342 354
343 while ( itBool != mBoolMap.end() ) { 355 while ( itBool != mBoolMap.end() ) {
344 pos = itBool.key().find( group ); 356 pos = itBool.key().find( group );
345 if (pos == 0) { 357 if (pos == 0) {
346 delBool = itBool; 358 delBool = itBool;
347 ++itBool; 359 ++itBool;
348 mBoolMap.remove(delBool); 360 mBoolMap.remove(delBool);
349 dirty = true; 361 dirty = true;
350 } else 362 } else
351 ++itBool; 363 ++itBool;
352 364
353 } 365 }
354 /* 366 /*
355 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 367 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
356 { 368 {
357 pos = itBool.key().find( group ); 369 pos = itBool.key().find( group );
358 if (pos == 0) { 370 if (pos == 0) {
359 mBoolMap.remove(itBool); 371 mBoolMap.remove(itBool);
360 dirty = true; 372 dirty = true;
361 } 373 }
362 } 374 }
363 */ 375 */
364 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 376 QMap<QString,QString>::Iterator itString = mStringMap.begin();
365 QMap<QString,QString>::Iterator delString ; 377 QMap<QString,QString>::Iterator delString ;
366 while( itString != mStringMap.end() ) { 378 while( itString != mStringMap.end() ) {
367 pos = itString.key().find( group ); 379 pos = itString.key().find( group );
368 if (pos == 0) { 380 if (pos == 0) {
369 delString = itString; 381 delString = itString;
370 ++itString; 382 ++itString;
371 mStringMap.remove(delString); 383 mStringMap.remove(delString);
372 //qDebug("delte++++++++++++++++++ "); 384 //qDebug("delte++++++++++++++++++ ");
373 dirty = true; 385 dirty = true;
374 } else 386 } else
375 ++itString; 387 ++itString;
376 388
377 } 389 }
378 /* this leads to a memory access violation 390 /* this leads to a memory access violation
379 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 391 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
380 { 392 {
381 pos = itString.key().find( group ); 393 pos = itString.key().find( group );
382 if (pos == 0) { 394 if (pos == 0) {
383 mStringMap.remove(itString); 395 mStringMap.remove(itString);
384 dirty = true; 396 dirty = true;
385 } 397 }
386 } 398 }
387 */ 399 */
388 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 400 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
389 QMap<QString,QDateTime>::Iterator delDateTime; 401 QMap<QString,QDateTime>::Iterator delDateTime;
390 while ( itDateTime != mDateTimeMap.end() ) { 402 while ( itDateTime != mDateTimeMap.end() ) {
391 pos = itDateTime.key().find( group ); 403 pos = itDateTime.key().find( group );
392 if (pos == 0) { 404 if (pos == 0) {
393 delDateTime = itDateTime; 405 delDateTime = itDateTime;
394 ++itDateTime; 406 ++itDateTime;
395 mDateTimeMap.remove(delDateTime); 407 mDateTimeMap.remove(delDateTime);
396 dirty = true; 408 dirty = true;
397 } else 409 } else
398 ++itDateTime; 410 ++itDateTime;
399 411
400 } 412 }
401 /* 413 /*
402 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 414 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
403 { 415 {
404 pos = itDateTime.key().find( group ); 416 pos = itDateTime.key().find( group );
405 if (pos == 0) { 417 if (pos == 0) {
406 mDateTimeMap.remove(itDateTime); 418 mDateTimeMap.remove(itDateTime);
407 dirty = true; 419 dirty = true;
408 } 420 }
409 } 421 }
410 */ 422 */
411 423
412 if (dirty) 424 if (dirty)
413 mDirty = true; 425 mDirty = true;
414 426
415 return dirty; 427 return dirty;
416 428
417} 429}
418 430
419//US I took the following hasGroup method from a newer version from KDE. 431//US I took the following hasGroup method from a newer version from KDE.
420 /** 432 /**
421 * Returns true if the specified group is known about. 433 * Returns true if the specified group is known about.
422 * 434 *
423 * @param group The group to search for. 435 * @param group The group to search for.
424 * @return Whether the group exists. 436 * @return Whether the group exists.
425 */ 437 */
426bool KConfig::hasGroup(const QString &group) const 438bool KConfig::hasGroup(const QString &group) const
427{ 439{
428 QMap<QString,bool>::ConstIterator itBool; 440 QMap<QString,bool>::ConstIterator itBool;
429 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 441 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
430 { 442 {
431 if (itBool.key().find( group ) == 0) { 443 if (itBool.key().find( group ) == 0) {
432 return true; 444 return true;
433 } 445 }
434 } 446 }
435 447
436 QMap<QString,QString>::ConstIterator itString; 448 QMap<QString,QString>::ConstIterator itString;
437 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 449 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
438 { 450 {
439 if (itString.key().find( group ) == 0) { 451 if (itString.key().find( group ) == 0) {
440 return true; 452 return true;
441 } 453 }
442 } 454 }
443 455
444 QMap<QString,QDateTime>::ConstIterator itDateTime; 456 QMap<QString,QDateTime>::ConstIterator itDateTime;
445 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 457 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
446 { 458 {
447 if (itDateTime.key().find( group ) == 0) { 459 if (itDateTime.key().find( group ) == 0) {
448 return true; 460 return true;
449 } 461 }
450 } 462 }
451 463
452 return false; 464 return false;
453} 465}
454 466
455void KConfig::deleteEntry( const QString &key) 467void KConfig::deleteEntry( const QString &key)
456{ 468{
457 bool dirty = false; 469 bool dirty = false;
458 470
459 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 471 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
460 if ( itBool != mBoolMap.end() ) { 472 if ( itBool != mBoolMap.end() ) {
461 mBoolMap.remove(itBool); 473 mBoolMap.remove(itBool);
462 dirty = true; 474 dirty = true;
463 } 475 }
464 476
465 477
466 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 478 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
467 if ( itString != mStringMap.end() ) { 479 if ( itString != mStringMap.end() ) {
468 mStringMap.remove(itString); 480 mStringMap.remove(itString);
469 dirty = true; 481 dirty = true;
470 } 482 }
471 483
472 484
473 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 485 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
474 if ( itDateTime != mDateTimeMap.end() ) { 486 if ( itDateTime != mDateTimeMap.end() ) {
475 mDateTimeMap.remove(itDateTime); 487 mDateTimeMap.remove(itDateTime);
476 dirty = true; 488 dirty = true;
477 } 489 }
478 490
479 if (dirty) 491 if (dirty)
480 mDirty = true; 492 mDirty = true;
481 493
482} 494}
483 495
484//US 496//US
485QString KConfig::getFileName() 497QString KConfig::getFileName()
486{ 498{
487 return mFileName; 499 return mFileName;
488} 500}
489 501
490bool KConfig::hasKey( const QString &key) 502bool KConfig::hasKey( const QString &key)
491{ 503{
492 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 504 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
493 if ( itBool != mBoolMap.end() ) { 505 if ( itBool != mBoolMap.end() ) {
494 return true; 506 return true;
495 } 507 }
496 508
497 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 509 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
498 if ( itString != mStringMap.end() ) { 510 if ( itString != mStringMap.end() ) {
499 return true; 511 return true;
500 } 512 }
501 513
502 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 514 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
503 if ( itDateTime != mDateTimeMap.end() ) { 515 if ( itDateTime != mDateTimeMap.end() ) {
504 return true; 516 return true;
505 } 517 }
506 518
507 return false; 519 return false;
508} 520}
509 521