summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-02 16:10:28 (UTC)
committer zautrix <zautrix>2005-07-02 16:10:28 (UTC)
commit20c9e9cb71ad64aebfa27157bb152ece4e34c00a (patch) (unidiff)
tree6ecd2ce2136875d974d5d361f611b39f5ad86a00
parent7b7c582bbb9908ec65c778b70baa6b2c2aa457fc (diff)
downloadkdepimpi-20c9e9cb71ad64aebfa27157bb152ece4e34c00a.zip
kdepimpi-20c9e9cb71ad64aebfa27157bb152ece4e34c00a.tar.gz
kdepimpi-20c9e9cb71ad64aebfa27157bb152ece4e34c00a.tar.bz2
fixxxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kconfig.cpp9
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
@@ -1,547 +1,550 @@
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 17
18 mTempGroup = ""; 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 28// we need the temp group for plugins on windows
29void KConfig::setTempGroup( const QString &group ) 29void 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
37QString KConfig::tempGroup() const { 37QString KConfig::tempGroup() const {
38 return mTempGroup; 38 return mTempGroup;
39} 39}
40 40
41void KConfig::setGroup( const QString &group ) 41void 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
51QString KConfig::group() const { 51QString KConfig::group() const {
52 return mGroup; 52 return mGroup;
53} 53}
54 54
55//US added method 55//US added method
56QValueList<int> KConfig::readIntListEntry( const QString & key) 56QValueList<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
91int KConfig::readNumEntry( const QString & key, int def ) 91int 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
101QString KConfig::readEntry( const QString &key, const QString &def ) 101QString 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
112QSize KConfig::readSizeEntry( const QString &key, QSize* def ) 112QSize 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
131QStringList KConfig::readListEntry( const QString &key ) 131QStringList 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
142bool KConfig::readBoolEntry( const QString &key, bool def ) 145bool 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
153QColor KConfig::readColorEntry( const QString & e, QColor *def ) 156QColor 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();
163 } 166 }
164 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); 167 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() );
165 return c; 168 return c;
166} 169}
167 170
168QFont KConfig::readFontEntry( const QString & e, QFont *def ) 171QFont KConfig::readFontEntry( const QString & e, QFont *def )
169{ 172{
170 QStringList font = readListEntry( e ); 173 QStringList font = readListEntry( e );
171 if ( font.isEmpty() ) 174 if ( font.isEmpty() )
172 return *def; 175 return *def;
173 QFont f; 176 QFont f;
174 f.setFamily( font[0]); 177 f.setFamily( font[0]);
175 f.setBold ( font[1] == "bold"); 178 f.setBold ( font[1] == "bold");
176 f.setPointSize ( font[2].toInt()); 179 f.setPointSize ( font[2].toInt());
177 f.setItalic( font[3] == "italic" ); 180 f.setItalic( font[3] == "italic" );
178 return f; 181 return f;
179} 182}
180 183
181QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 184QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
182{ 185{
183 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 186 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
184 187
185 if ( it == mDateTimeMap.end() ) { 188 if ( it == mDateTimeMap.end() ) {
186 if ( def ) return *def; 189 if ( def ) return *def;
187 else return QDateTime(); 190 else return QDateTime();
188 } 191 }
189 192
190 return *it; 193 return *it;
191} 194}
192 195
193//US added method 196//US added method
194void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 197void KConfig::writeEntry( const QString &key, const QValueList<int> &value)
195{ 198{
196 QStringList valuesAsStrings; 199 QStringList valuesAsStrings;
197 200
198 QValueList<int>::ConstIterator it; 201 QValueList<int>::ConstIterator it;
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
209void KConfig::writeEntry( const QString & key , int num ) 212void 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
214void KConfig::writeEntry( const QString &key, const QString &value ) 217void 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
221void KConfig::writeEntry( const QString &key, const QStringList &value ) 224void 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
228void KConfig::writeEntry( const QString &key, bool value) 231void 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
235void KConfig::writeEntry( const QString & e, const QColor & c ) 238void 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
244void KConfig::writeEntry( const QString & e, const QSize & s ) 247void 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();
248 writeEntry( e, intlist ); 251 writeEntry( e, intlist );
249} 252}
250 253
251void KConfig::writeEntry( const QString & e , const QFont & f ) 254void KConfig::writeEntry( const QString & e , const QFont & f )
252{ 255{
253 QStringList font; 256 QStringList font;
254 font.append( f.family()); 257 font.append( f.family());
255 font.append( (!f.bold ()?"nonbold":"bold") ); 258 font.append( (!f.bold ()?"nonbold":"bold") );
256 font.append( QString::number ( f.pointSize () ) ); 259 font.append( QString::number ( f.pointSize () ) );
257 font.append( !f.italic ()?"nonitalic":"italic" ); 260 font.append( !f.italic ()?"nonitalic":"italic" );
258 writeEntry( e, font ); 261 writeEntry( e, font );
259} 262}
260 263
261void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 264void KConfig::writeEntry( const QString &key, const QDateTime &dt )
262{ 265{
263 mDateTimeMap.insert( mGroup + key, dt ); 266 mDateTimeMap.insert( mGroup + key, dt );
264} 267}
265 268
266void KConfig::load() 269void KConfig::load()
267{ 270{
268 271
269 272
270 QFile f( mFileName ); 273 QFile f( mFileName );
271 if ( !f.open( IO_ReadOnly ) ) { 274 if ( !f.open( IO_ReadOnly ) ) {
272 //qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 275 //qDebug("KConfig: could not open file %s ",mFileName.latin1() );
273 return; 276 return;
274 } 277 }
275 278
276 mBoolMap.clear(); 279 mBoolMap.clear();
277 mStringMap.clear(); 280 mStringMap.clear();
278 281
279 QTextStream t( &f ); 282 QTextStream t( &f );
280 t.setEncoding( QTextStream::Latin1 ); 283 t.setEncoding( QTextStream::Latin1 );
281 QString line = t.readLine(); 284 QString line = t.readLine();
282 285
283 while ( !line.isNull() ) { 286 while ( !line.isNull() ) {
284 QStringList tokens = QStringList::split( ",", line ); 287 QStringList tokens = QStringList::split( ",", line );
285 if ( tokens[0] == "bool" ) { 288 if ( tokens[0] == "bool" ) {
286 bool value = false; 289 bool value = false;
287 if ( tokens[2] == "1" ) value = true; 290 if ( tokens[2] == "1" ) value = true;
288 mBoolMap.insert( tokens[1], value ); 291 mBoolMap.insert( tokens[1], value );
289 } else if ( tokens[0] == "QString" ) { 292 } else if ( tokens[0] == "QString" ) {
290 QString value = tokens[2]; 293 QString value = tokens[2];
291 mStringMap.insert( tokens[1], value ); 294 mStringMap.insert( tokens[1], value );
292 } else if ( tokens[0] == "QDateTime" ) { 295 } else if ( tokens[0] == "QDateTime" ) {
293#if 0 296#if 0
294 int year = tokens[2].toInt(); 297 int year = tokens[2].toInt();
295 QDateTime dt( QDate( year, 298 QDateTime dt( QDate( year,
296 tokens[3].toInt(), 299 tokens[3].toInt(),
297 tokens[4].toInt() ), 300 tokens[4].toInt() ),
298 QTime( tokens[5].toInt(), tokens[6].toInt(), 301 QTime( tokens[5].toInt(), tokens[6].toInt(),
299 tokens[7].toInt() ) ); 302 tokens[7].toInt() ) );
300 mDateTimeMap.insert( tokens[1], dt ); 303 mDateTimeMap.insert( tokens[1], dt );
301#endif 304#endif
302 } 305 }
303 306
304 line = t.readLine(); 307 line = t.readLine();
305 } 308 }
306} 309}
307 310
308void KConfig::sync() 311void KConfig::sync()
309{ 312{
310 313
311 if ( !mDirty ) return; 314 if ( !mDirty ) return;
312 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 315 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
313 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 316 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
314 317
315//US I took the following code from a newer version of KDE 318//US I took the following code from a newer version of KDE
316 // Create the containing dir if needed 319 // Create the containing dir if needed
317 KURL path; 320 KURL path;
318 path.setPath(mFileName); 321 path.setPath(mFileName);
319 QString dir=path.directory(); 322 QString dir=path.directory();
320 KStandardDirs::makeDir(dir); 323 KStandardDirs::makeDir(dir);
321 324
322 QFile f( mFileName ); 325 QFile f( mFileName );
323 if ( !f.open( IO_WriteOnly ) ) { 326 if ( !f.open( IO_WriteOnly ) ) {
324 327
325 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 328 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
326 329
327 return; 330 return;
328 } 331 }
329 332
330 QTextStream t( &f ); 333 QTextStream t( &f );
331 t.setEncoding( QTextStream::Latin1 ); 334 t.setEncoding( QTextStream::Latin1 );
332 QMap<QString,bool>::ConstIterator itBool; 335 QMap<QString,bool>::ConstIterator itBool;
333 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 336 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
334 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 337 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
335 } 338 }
336 339
337 QMap<QString,QString>::ConstIterator itString; 340 QMap<QString,QString>::ConstIterator itString;
338 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 341 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
339 t << "QString," << itString.key() << "," << (*itString ) << endl; 342 t << "QString," << itString.key() << "," << (*itString ) << endl;
340 } 343 }
341 344
342 QMap<QString,QDateTime>::ConstIterator itDateTime; 345 QMap<QString,QDateTime>::ConstIterator itDateTime;
343 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 346 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
344 QDateTime dt = *itDateTime; 347 QDateTime dt = *itDateTime;
345 t << "QDateTime," << itDateTime.key() << "," 348 t << "QDateTime," << itDateTime.key() << ","
346 << dt.date().year() << "," 349 << dt.date().year() << ","
347 << dt.date().month() << "," 350 << dt.date().month() << ","
348 << dt.date().day() << "," 351 << dt.date().day() << ","
349 << dt.time().hour() << "," 352 << dt.time().hour() << ","
350 << dt.time().minute() << "," 353 << dt.time().minute() << ","
351 << dt.time().second() << endl; 354 << dt.time().second() << endl;
352 } 355 }
353 356
354 f.close(); 357 f.close();
355 358
356 mDirty = false; 359 mDirty = false;
357} 360}
358 361
359 362
360//US I took the following deleteGroup method from a newer version from KDE. 363//US I took the following deleteGroup method from a newer version from KDE.
361/** 364/**
362 * Deletes a configuration entry group 365 * Deletes a configuration entry group
363 * 366 *
364 * If the group is not empty and bDeep is false, nothing gets 367 * If the group is not empty and bDeep is false, nothing gets
365 * deleted and false is returned. 368 * deleted and false is returned.
366 * If this group is the current group and it is deleted, the 369 * If this group is the current group and it is deleted, the
367 * current group is undefined and should be set with setGroup() 370 * current group is undefined and should be set with setGroup()
368 * before the next operation on the configuration object. 371 * before the next operation on the configuration object.
369 * 372 *
370 * @param group The name of the group 373 * @param group The name of the group
371 * returns true if we deleted at least one entry. 374 * returns true if we deleted at least one entry.
372 */ 375 */
373bool KConfig::deleteGroup( const QString& group) 376bool KConfig::deleteGroup( const QString& group)
374{ 377{
375 bool dirty = false; 378 bool dirty = false;
376 int pos; 379 int pos;
377 380
378 QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); 381 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
379 QMap<QString,bool>::Iterator delBool; 382 QMap<QString,bool>::Iterator delBool;
380 383
381 while ( itBool != mBoolMap.end() ) { 384 while ( itBool != mBoolMap.end() ) {
382 pos = itBool.key().find( group ); 385 pos = itBool.key().find( group );
383 if (pos == 0) { 386 if (pos == 0) {
384 delBool = itBool; 387 delBool = itBool;
385 ++itBool; 388 ++itBool;
386 mBoolMap.remove(delBool); 389 mBoolMap.remove(delBool);
387 dirty = true; 390 dirty = true;
388 } else 391 } else
389 ++itBool; 392 ++itBool;
390 393
391 } 394 }
392 /* 395 /*
393 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 396 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
394 { 397 {
395 pos = itBool.key().find( group ); 398 pos = itBool.key().find( group );
396 if (pos == 0) { 399 if (pos == 0) {
397 mBoolMap.remove(itBool); 400 mBoolMap.remove(itBool);
398 dirty = true; 401 dirty = true;
399 } 402 }
400 } 403 }
401 */ 404 */
402 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 405 QMap<QString,QString>::Iterator itString = mStringMap.begin();
403 QMap<QString,QString>::Iterator delString ; 406 QMap<QString,QString>::Iterator delString ;
404 while( itString != mStringMap.end() ) { 407 while( itString != mStringMap.end() ) {
405 pos = itString.key().find( group ); 408 pos = itString.key().find( group );
406 if (pos == 0) { 409 if (pos == 0) {
407 delString = itString; 410 delString = itString;
408 ++itString; 411 ++itString;
409 mStringMap.remove(delString); 412 mStringMap.remove(delString);
410 //qDebug("delte++++++++++++++++++ "); 413 //qDebug("delte++++++++++++++++++ ");
411 dirty = true; 414 dirty = true;
412 } else 415 } else
413 ++itString; 416 ++itString;
414 417
415 } 418 }
416 /* this leads to a memory access violation 419 /* this leads to a memory access violation
417 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 420 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
418 { 421 {
419 pos = itString.key().find( group ); 422 pos = itString.key().find( group );
420 if (pos == 0) { 423 if (pos == 0) {
421 mStringMap.remove(itString); 424 mStringMap.remove(itString);
422 dirty = true; 425 dirty = true;
423 } 426 }
424 } 427 }
425 */ 428 */
426 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 429 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
427 QMap<QString,QDateTime>::Iterator delDateTime; 430 QMap<QString,QDateTime>::Iterator delDateTime;
428 while ( itDateTime != mDateTimeMap.end() ) { 431 while ( itDateTime != mDateTimeMap.end() ) {
429 pos = itDateTime.key().find( group ); 432 pos = itDateTime.key().find( group );
430 if (pos == 0) { 433 if (pos == 0) {
431 delDateTime = itDateTime; 434 delDateTime = itDateTime;
432 ++itDateTime; 435 ++itDateTime;
433 mDateTimeMap.remove(delDateTime); 436 mDateTimeMap.remove(delDateTime);
434 dirty = true; 437 dirty = true;
435 } else 438 } else
436 ++itDateTime; 439 ++itDateTime;
437 440
438 } 441 }
439 /* 442 /*
440 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 443 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
441 { 444 {
442 pos = itDateTime.key().find( group ); 445 pos = itDateTime.key().find( group );
443 if (pos == 0) { 446 if (pos == 0) {
444 mDateTimeMap.remove(itDateTime); 447 mDateTimeMap.remove(itDateTime);
445 dirty = true; 448 dirty = true;
446 } 449 }
447 } 450 }
448 */ 451 */
449 452
450 if (dirty) 453 if (dirty)
451 mDirty = true; 454 mDirty = true;
452 455
453 return dirty; 456 return dirty;
454 457
455} 458}
456 459
457//US I took the following hasGroup method from a newer version from KDE. 460//US I took the following hasGroup method from a newer version from KDE.
458 /** 461 /**
459 * Returns true if the specified group is known about. 462 * Returns true if the specified group is known about.
460 * 463 *
461 * @param group The group to search for. 464 * @param group The group to search for.
462 * @return Whether the group exists. 465 * @return Whether the group exists.
463 */ 466 */
464bool KConfig::hasGroup(const QString &group) const 467bool KConfig::hasGroup(const QString &group) const
465{ 468{
466 QMap<QString,bool>::ConstIterator itBool; 469 QMap<QString,bool>::ConstIterator itBool;
467 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 470 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
468 { 471 {
469 if (itBool.key().find( group ) == 0) { 472 if (itBool.key().find( group ) == 0) {
470 return true; 473 return true;
471 } 474 }
472 } 475 }
473 476
474 QMap<QString,QString>::ConstIterator itString; 477 QMap<QString,QString>::ConstIterator itString;
475 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 478 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
476 { 479 {
477 if (itString.key().find( group ) == 0) { 480 if (itString.key().find( group ) == 0) {
478 return true; 481 return true;
479 } 482 }
480 } 483 }
481 484
482 QMap<QString,QDateTime>::ConstIterator itDateTime; 485 QMap<QString,QDateTime>::ConstIterator itDateTime;
483 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 486 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
484 { 487 {
485 if (itDateTime.key().find( group ) == 0) { 488 if (itDateTime.key().find( group ) == 0) {
486 return true; 489 return true;
487 } 490 }
488 } 491 }
489 492
490 return false; 493 return false;
491} 494}
492 495
493void KConfig::deleteEntry( const QString &key) 496void KConfig::deleteEntry( const QString &key)
494{ 497{
495 bool dirty = false; 498 bool dirty = false;
496 499
497 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 500 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
498 if ( itBool != mBoolMap.end() ) { 501 if ( itBool != mBoolMap.end() ) {
499 mBoolMap.remove(itBool); 502 mBoolMap.remove(itBool);
500 dirty = true; 503 dirty = true;
501 } 504 }
502 505
503 506
504 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 507 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
505 if ( itString != mStringMap.end() ) { 508 if ( itString != mStringMap.end() ) {
506 mStringMap.remove(itString); 509 mStringMap.remove(itString);
507 dirty = true; 510 dirty = true;
508 } 511 }
509 512
510 513
511 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 514 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
512 if ( itDateTime != mDateTimeMap.end() ) { 515 if ( itDateTime != mDateTimeMap.end() ) {
513 mDateTimeMap.remove(itDateTime); 516 mDateTimeMap.remove(itDateTime);
514 dirty = true; 517 dirty = true;
515 } 518 }
516 519
517 if (dirty) 520 if (dirty)
518 mDirty = true; 521 mDirty = true;
519 522
520} 523}
521 524
522//US 525//US
523QString KConfig::getFileName() 526QString KConfig::getFileName()
524{ 527{
525 return mFileName; 528 return mFileName;
526} 529}
527 530
528bool KConfig::hasKey( const QString &key) 531bool KConfig::hasKey( const QString &key)
529{ 532{
530 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 533 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
531 if ( itBool != mBoolMap.end() ) { 534 if ( itBool != mBoolMap.end() ) {
532 return true; 535 return true;
533 } 536 }
534 537
535 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 538 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
536 if ( itString != mStringMap.end() ) { 539 if ( itString != mStringMap.end() ) {
537 return true; 540 return true;
538 } 541 }
539 542
540 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 543 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
541 if ( itDateTime != mDateTimeMap.end() ) { 544 if ( itDateTime != mDateTimeMap.end() ) {
542 return true; 545 return true;
543 } 546 }
544 547
545 return false; 548 return false;
546} 549}
547 550