summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-04 14:45:19 (UTC)
committer zautrix <zautrix>2004-07-04 14:45:19 (UTC)
commit2978e6b5327f619dc8e295685f46640158e1fab0 (patch) (unidiff)
tree24bf8b27df9dfe91a12c0c7319d396eee8abbf67
parentdd549dd992f914d30c39c6c85297d689b9ac6308 (diff)
downloadkdepimpi-2978e6b5327f619dc8e295685f46640158e1fab0.zip
kdepimpi-2978e6b5327f619dc8e295685f46640158e1fab0.tar.gz
kdepimpi-2978e6b5327f619dc8e295685f46640158e1fab0.tar.bz2
Added missing initialization of iterator
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kconfig.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index b882adb..f8e362e 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -148,358 +148,359 @@ QFont KConfig::readFontEntry( const QString & e, QFont *def )
148} 148}
149 149
150QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 150QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
151{ 151{
152 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 152 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
153 153
154 if ( it == mDateTimeMap.end() ) { 154 if ( it == mDateTimeMap.end() ) {
155 if ( def ) return *def; 155 if ( def ) return *def;
156 else return QDateTime(); 156 else return QDateTime();
157 } 157 }
158 158
159 return *it; 159 return *it;
160} 160}
161 161
162//US added method 162//US added method
163void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 163void KConfig::writeEntry( const QString &key, const QValueList<int> &value)
164{ 164{
165 QStringList valuesAsStrings; 165 QStringList valuesAsStrings;
166 166
167 QValueList<int>::ConstIterator it; 167 QValueList<int>::ConstIterator it;
168 168
169 for( it = value.begin(); it != value.end(); ++it ) 169 for( it = value.begin(); it != value.end(); ++it )
170 { 170 {
171 valuesAsStrings << QString::number(*it); 171 valuesAsStrings << QString::number(*it);
172 } 172 }
173 173
174 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); 174 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") );
175 mDirty = true; 175 mDirty = true;
176} 176}
177 177
178void KConfig::writeEntry( const QString & key , int num ) 178void KConfig::writeEntry( const QString & key , int num )
179{ 179{
180 writeEntry( key, QString::number ( num ) ); 180 writeEntry( key, QString::number ( num ) );
181} 181}
182 182
183void KConfig::writeEntry( const QString &key, const QString &value ) 183void KConfig::writeEntry( const QString &key, const QString &value )
184{ 184{
185 mStringMap.insert( mGroup + key, value ); 185 mStringMap.insert( mGroup + key, value );
186 186
187 mDirty = true; 187 mDirty = true;
188} 188}
189 189
190void KConfig::writeEntry( const QString &key, const QStringList &value ) 190void KConfig::writeEntry( const QString &key, const QStringList &value )
191{ 191{
192 mStringMap.insert( mGroup + key, value.join(":") ); 192 mStringMap.insert( mGroup + key, value.join(":") );
193 193
194 mDirty = true; 194 mDirty = true;
195} 195}
196 196
197void KConfig::writeEntry( const QString &key, bool value) 197void KConfig::writeEntry( const QString &key, bool value)
198{ 198{
199 mBoolMap.insert( mGroup + key, value ); 199 mBoolMap.insert( mGroup + key, value );
200 200
201 mDirty = true; 201 mDirty = true;
202} 202}
203 203
204void KConfig::writeEntry( const QString & e, const QColor & c ) 204void KConfig::writeEntry( const QString & e, const QColor & c )
205{ 205{
206 QStringList l; 206 QStringList l;
207 l.append( QString::number ( c.red() ) ); 207 l.append( QString::number ( c.red() ) );
208 l.append( QString::number ( c.green() ) ); 208 l.append( QString::number ( c.green() ) );
209 l.append( QString::number ( c.blue() ) ); 209 l.append( QString::number ( c.blue() ) );
210 writeEntry( e, l ); 210 writeEntry( e, l );
211} 211}
212 212
213void KConfig::writeEntry( const QString & e , const QFont & f ) 213void KConfig::writeEntry( const QString & e , const QFont & f )
214{ 214{
215 QStringList font; 215 QStringList font;
216 font.append( f.family()); 216 font.append( f.family());
217 font.append( (!f.bold ()?"nonbold":"bold") ); 217 font.append( (!f.bold ()?"nonbold":"bold") );
218 font.append( QString::number ( f.pointSize () ) ); 218 font.append( QString::number ( f.pointSize () ) );
219 font.append( !f.italic ()?"nonitalic":"italic" ); 219 font.append( !f.italic ()?"nonitalic":"italic" );
220 writeEntry( e, font ); 220 writeEntry( e, font );
221} 221}
222 222
223void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 223void KConfig::writeEntry( const QString &key, const QDateTime &dt )
224{ 224{
225 mDateTimeMap.insert( mGroup + key, dt ); 225 mDateTimeMap.insert( mGroup + key, dt );
226} 226}
227 227
228void KConfig::load() 228void KConfig::load()
229{ 229{
230 kdDebug() << "KConfig::load(): " << mFileName << endl; 230 kdDebug() << "KConfig::load(): " << mFileName << endl;
231 231
232 QFile f( mFileName ); 232 QFile f( mFileName );
233 if ( !f.open( IO_ReadOnly ) ) { 233 if ( !f.open( IO_ReadOnly ) ) {
234 qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 234 qDebug("KConfig: could not open file %s ",mFileName.latin1() );
235 return; 235 return;
236 } 236 }
237 237
238 mBoolMap.clear(); 238 mBoolMap.clear();
239 mStringMap.clear(); 239 mStringMap.clear();
240 240
241 QTextStream t( &f ); 241 QTextStream t( &f );
242 242
243 QString line = t.readLine(); 243 QString line = t.readLine();
244 244
245 while ( !line.isNull() ) { 245 while ( !line.isNull() ) {
246 QStringList tokens = QStringList::split( ",", line ); 246 QStringList tokens = QStringList::split( ",", line );
247 if ( tokens[0] == "bool" ) { 247 if ( tokens[0] == "bool" ) {
248 bool value = false; 248 bool value = false;
249 if ( tokens[2] == "1" ) value = true; 249 if ( tokens[2] == "1" ) value = true;
250 mBoolMap.insert( tokens[1], value ); 250 mBoolMap.insert( tokens[1], value );
251 } else if ( tokens[0] == "QString" ) { 251 } else if ( tokens[0] == "QString" ) {
252 QString value = tokens[2]; 252 QString value = tokens[2];
253 mStringMap.insert( tokens[1], value ); 253 mStringMap.insert( tokens[1], value );
254 } else if ( tokens[0] == "QDateTime" ) { 254 } else if ( tokens[0] == "QDateTime" ) {
255#if 0 255#if 0
256 int year = tokens[2].toInt(); 256 int year = tokens[2].toInt();
257 QDateTime dt( QDate( year, 257 QDateTime dt( QDate( year,
258 tokens[3].toInt(), 258 tokens[3].toInt(),
259 tokens[4].toInt() ), 259 tokens[4].toInt() ),
260 QTime( tokens[5].toInt(), tokens[6].toInt(), 260 QTime( tokens[5].toInt(), tokens[6].toInt(),
261 tokens[7].toInt() ) ); 261 tokens[7].toInt() ) );
262 mDateTimeMap.insert( tokens[1], dt ); 262 mDateTimeMap.insert( tokens[1], dt );
263#endif 263#endif
264 } 264 }
265 265
266 line = t.readLine(); 266 line = t.readLine();
267 } 267 }
268} 268}
269 269
270void KConfig::sync() 270void KConfig::sync()
271{ 271{
272 272
273 if ( !mDirty ) return; 273 if ( !mDirty ) return;
274 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 274 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
275 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 275 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
276 276
277//US I took the following code from a newer version of KDE 277//US I took the following code from a newer version of KDE
278 // Create the containing dir if needed 278 // Create the containing dir if needed
279 KURL path; 279 KURL path;
280 path.setPath(mFileName); 280 path.setPath(mFileName);
281 QString dir=path.directory(); 281 QString dir=path.directory();
282 KStandardDirs::makeDir(dir); 282 KStandardDirs::makeDir(dir);
283 283
284 QFile f( mFileName ); 284 QFile f( mFileName );
285 if ( !f.open( IO_WriteOnly ) ) { 285 if ( !f.open( IO_WriteOnly ) ) {
286 286
287 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 287 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
288 288
289 return; 289 return;
290 } 290 }
291 291
292 QTextStream t( &f ); 292 QTextStream t( &f );
293 293
294 QMap<QString,bool>::ConstIterator itBool; 294 QMap<QString,bool>::ConstIterator itBool;
295 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 295 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
296 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 296 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
297 } 297 }
298 298
299 QMap<QString,QString>::ConstIterator itString; 299 QMap<QString,QString>::ConstIterator itString;
300 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 300 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
301 t << "QString," << itString.key() << "," << (*itString ) << endl; 301 t << "QString," << itString.key() << "," << (*itString ) << endl;
302 } 302 }
303 303
304 QMap<QString,QDateTime>::ConstIterator itDateTime; 304 QMap<QString,QDateTime>::ConstIterator itDateTime;
305 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 305 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
306 QDateTime dt = *itDateTime; 306 QDateTime dt = *itDateTime;
307 t << "QDateTime," << itDateTime.key() << "," 307 t << "QDateTime," << itDateTime.key() << ","
308 << dt.date().year() << "," 308 << dt.date().year() << ","
309 << dt.date().month() << "," 309 << dt.date().month() << ","
310 << dt.date().day() << "," 310 << dt.date().day() << ","
311 << dt.time().hour() << "," 311 << dt.time().hour() << ","
312 << dt.time().minute() << "," 312 << dt.time().minute() << ","
313 << dt.time().second() << endl; 313 << dt.time().second() << endl;
314 } 314 }
315 315
316 f.close(); 316 f.close();
317 317
318 mDirty = false; 318 mDirty = false;
319} 319}
320 320
321 321
322//US I took the following deleteGroup method from a newer version from KDE. 322//US I took the following deleteGroup method from a newer version from KDE.
323/** 323/**
324 * Deletes a configuration entry group 324 * Deletes a configuration entry group
325 * 325 *
326 * If the group is not empty and bDeep is false, nothing gets 326 * If the group is not empty and bDeep is false, nothing gets
327 * deleted and false is returned. 327 * deleted and false is returned.
328 * If this group is the current group and it is deleted, the 328 * If this group is the current group and it is deleted, the
329 * current group is undefined and should be set with setGroup() 329 * current group is undefined and should be set with setGroup()
330 * before the next operation on the configuration object. 330 * before the next operation on the configuration object.
331 * 331 *
332 * @param group The name of the group 332 * @param group The name of the group
333 * returns true if we deleted at least one entry. 333 * returns true if we deleted at least one entry.
334 */ 334 */
335bool KConfig::deleteGroup( const QString& group) 335bool KConfig::deleteGroup( const QString& group)
336{ 336{
337 bool dirty = false; 337 bool dirty = false;
338 int pos; 338 int pos;
339 339
340 QMap<QString,bool>::Iterator itBool; 340 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
341 QMap<QString,bool>::Iterator delBool; 341 QMap<QString,bool>::Iterator delBool;
342
342 while ( itBool != mBoolMap.end() ) { 343 while ( itBool != mBoolMap.end() ) {
343 pos = itBool.key().find( group ); 344 pos = itBool.key().find( group );
344 if (pos == 0) { 345 if (pos == 0) {
345 delBool = itBool; 346 delBool = itBool;
346 ++itBool; 347 ++itBool;
347 mBoolMap.remove(delBool); 348 mBoolMap.remove(delBool);
348 dirty = true; 349 dirty = true;
349 } 350 }
350 351
351 } 352 }
352 /* 353 /*
353 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 354 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
354 { 355 {
355 pos = itBool.key().find( group ); 356 pos = itBool.key().find( group );
356 if (pos == 0) { 357 if (pos == 0) {
357 mBoolMap.remove(itBool); 358 mBoolMap.remove(itBool);
358 dirty = true; 359 dirty = true;
359 } 360 }
360 } 361 }
361 */ 362 */
362 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 363 QMap<QString,QString>::Iterator itString = mStringMap.begin();
363 QMap<QString,QString>::Iterator delString ; 364 QMap<QString,QString>::Iterator delString ;
364 while( itString != mStringMap.end() ) { 365 while( itString != mStringMap.end() ) {
365 pos = itString.key().find( group ); 366 pos = itString.key().find( group );
366 if (pos == 0) { 367 if (pos == 0) {
367 delString = itString; 368 delString = itString;
368 ++itString; 369 ++itString;
369 mStringMap.remove(delString); 370 mStringMap.remove(delString);
370 //qDebug("delte++++++++++++++++++ "); 371 //qDebug("delte++++++++++++++++++ ");
371 dirty = true; 372 dirty = true;
372 } 373 }
373 374
374 } 375 }
375 /* this leads to a memory access violation 376 /* this leads to a memory access violation
376 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 377 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
377 { 378 {
378 pos = itString.key().find( group ); 379 pos = itString.key().find( group );
379 if (pos == 0) { 380 if (pos == 0) {
380 mStringMap.remove(itString); 381 mStringMap.remove(itString);
381 dirty = true; 382 dirty = true;
382 } 383 }
383 } 384 }
384 */ 385 */
385 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 386 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
386 QMap<QString,QDateTime>::Iterator delDateTime; 387 QMap<QString,QDateTime>::Iterator delDateTime;
387 while ( itDateTime != mDateTimeMap.end() ) { 388 while ( itDateTime != mDateTimeMap.end() ) {
388 pos = itDateTime.key().find( group ); 389 pos = itDateTime.key().find( group );
389 if (pos == 0) { 390 if (pos == 0) {
390 delDateTime = itDateTime; 391 delDateTime = itDateTime;
391 ++itDateTime; 392 ++itDateTime;
392 mDateTimeMap.remove(delDateTime); 393 mDateTimeMap.remove(delDateTime);
393 dirty = true; 394 dirty = true;
394 } 395 }
395 396
396 } 397 }
397 /* 398 /*
398 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 399 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
399 { 400 {
400 pos = itDateTime.key().find( group ); 401 pos = itDateTime.key().find( group );
401 if (pos == 0) { 402 if (pos == 0) {
402 mDateTimeMap.remove(itDateTime); 403 mDateTimeMap.remove(itDateTime);
403 dirty = true; 404 dirty = true;
404 } 405 }
405 } 406 }
406 */ 407 */
407 408
408 if (dirty) 409 if (dirty)
409 mDirty = true; 410 mDirty = true;
410 411
411 return dirty; 412 return dirty;
412 413
413} 414}
414 415
415//US I took the following hasGroup method from a newer version from KDE. 416//US I took the following hasGroup method from a newer version from KDE.
416 /** 417 /**
417 * Returns true if the specified group is known about. 418 * Returns true if the specified group is known about.
418 * 419 *
419 * @param group The group to search for. 420 * @param group The group to search for.
420 * @return Whether the group exists. 421 * @return Whether the group exists.
421 */ 422 */
422bool KConfig::hasGroup(const QString &group) const 423bool KConfig::hasGroup(const QString &group) const
423{ 424{
424 QMap<QString,bool>::ConstIterator itBool; 425 QMap<QString,bool>::ConstIterator itBool;
425 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 426 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
426 { 427 {
427 if (itBool.key().find( group ) == 0) { 428 if (itBool.key().find( group ) == 0) {
428 return true; 429 return true;
429 } 430 }
430 } 431 }
431 432
432 QMap<QString,QString>::ConstIterator itString; 433 QMap<QString,QString>::ConstIterator itString;
433 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 434 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
434 { 435 {
435 if (itString.key().find( group ) == 0) { 436 if (itString.key().find( group ) == 0) {
436 return true; 437 return true;
437 } 438 }
438 } 439 }
439 440
440 QMap<QString,QDateTime>::ConstIterator itDateTime; 441 QMap<QString,QDateTime>::ConstIterator itDateTime;
441 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 442 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
442 { 443 {
443 if (itDateTime.key().find( group ) == 0) { 444 if (itDateTime.key().find( group ) == 0) {
444 return true; 445 return true;
445 } 446 }
446 } 447 }
447 448
448 return false; 449 return false;
449} 450}
450 451
451void KConfig::deleteEntry( const QString &key) 452void KConfig::deleteEntry( const QString &key)
452{ 453{
453 bool dirty = false; 454 bool dirty = false;
454 455
455 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 456 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
456 if ( itBool != mBoolMap.end() ) { 457 if ( itBool != mBoolMap.end() ) {
457 mBoolMap.remove(itBool); 458 mBoolMap.remove(itBool);
458 dirty = true; 459 dirty = true;
459 } 460 }
460 461
461 462
462 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 463 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
463 if ( itString != mStringMap.end() ) { 464 if ( itString != mStringMap.end() ) {
464 mStringMap.remove(itString); 465 mStringMap.remove(itString);
465 dirty = true; 466 dirty = true;
466 } 467 }
467 468
468 469
469 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 470 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
470 if ( itDateTime != mDateTimeMap.end() ) { 471 if ( itDateTime != mDateTimeMap.end() ) {
471 mDateTimeMap.remove(itDateTime); 472 mDateTimeMap.remove(itDateTime);
472 dirty = true; 473 dirty = true;
473 } 474 }
474 475
475 if (dirty) 476 if (dirty)
476 mDirty = true; 477 mDirty = true;
477 478
478} 479}
479 480
480//US 481//US
481QString KConfig::getFileName() 482QString KConfig::getFileName()
482{ 483{
483 return mFileName; 484 return mFileName;
484} 485}
485 486
486bool KConfig::hasKey( const QString &key) 487bool KConfig::hasKey( const QString &key)
487{ 488{
488 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 489 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
489 if ( itBool != mBoolMap.end() ) { 490 if ( itBool != mBoolMap.end() ) {
490 return true; 491 return true;
491 } 492 }
492 493
493 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 494 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
494 if ( itString != mStringMap.end() ) { 495 if ( itString != mStringMap.end() ) {
495 return true; 496 return true;
496 } 497 }
497 498
498 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 499 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
499 if ( itDateTime != mDateTimeMap.end() ) { 500 if ( itDateTime != mDateTimeMap.end() ) {
500 return true; 501 return true;
501 } 502 }
502 503
503 return false; 504 return false;
504} 505}
505 506