-rw-r--r-- | microkde/kconfig.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 3f23ed2..b882adb 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -293,124 +293,162 @@ void KConfig::sync() | |||
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 | */ |
335 | bool KConfig::deleteGroup( const QString& group) | 335 | bool 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; |
341 | QMap<QString,bool>::Iterator delBool; | ||
342 | while ( itBool != mBoolMap.end() ) { | ||
343 | pos = itBool.key().find( group ); | ||
344 | if (pos == 0) { | ||
345 | delBool = itBool; | ||
346 | ++itBool; | ||
347 | mBoolMap.remove(delBool); | ||
348 | dirty = true; | ||
349 | } | ||
350 | |||
351 | } | ||
352 | /* | ||
341 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) | 353 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) |
342 | { | 354 | { |
343 | pos = itBool.key().find( group ); | 355 | pos = itBool.key().find( group ); |
344 | if (pos == 0) { | 356 | if (pos == 0) { |
345 | mBoolMap.remove(itBool); | 357 | mBoolMap.remove(itBool); |
346 | dirty = true; | 358 | dirty = true; |
347 | } | 359 | } |
348 | } | 360 | } |
361 | */ | ||
362 | QMap<QString,QString>::Iterator itString = mStringMap.begin(); | ||
363 | QMap<QString,QString>::Iterator delString ; | ||
364 | while( itString != mStringMap.end() ) { | ||
365 | pos = itString.key().find( group ); | ||
366 | if (pos == 0) { | ||
367 | delString = itString; | ||
368 | ++itString; | ||
369 | mStringMap.remove(delString); | ||
370 | //qDebug("delte++++++++++++++++++ "); | ||
371 | dirty = true; | ||
372 | } | ||
349 | 373 | ||
350 | QMap<QString,QString>::Iterator itString; | 374 | } |
375 | /* this leads to a memory access violation | ||
351 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) | 376 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) |
352 | { | 377 | { |
353 | pos = itString.key().find( group ); | 378 | pos = itString.key().find( group ); |
354 | if (pos == 0) { | 379 | if (pos == 0) { |
355 | mStringMap.remove(itString); | 380 | mStringMap.remove(itString); |
356 | dirty = true; | 381 | dirty = true; |
357 | } | 382 | } |
358 | } | 383 | } |
359 | 384 | */ | |
360 | QMap<QString,QDateTime>::Iterator itDateTime; | 385 | QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); |
386 | QMap<QString,QDateTime>::Iterator delDateTime; | ||
387 | while ( itDateTime != mDateTimeMap.end() ) { | ||
388 | pos = itDateTime.key().find( group ); | ||
389 | if (pos == 0) { | ||
390 | delDateTime = itDateTime; | ||
391 | ++itDateTime; | ||
392 | mDateTimeMap.remove(delDateTime); | ||
393 | dirty = true; | ||
394 | } | ||
395 | |||
396 | } | ||
397 | /* | ||
361 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) | 398 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) |
362 | { | 399 | { |
363 | pos = itDateTime.key().find( group ); | 400 | pos = itDateTime.key().find( group ); |
364 | if (pos == 0) { | 401 | if (pos == 0) { |
365 | mDateTimeMap.remove(itDateTime); | 402 | mDateTimeMap.remove(itDateTime); |
366 | dirty = true; | 403 | dirty = true; |
367 | } | 404 | } |
368 | } | 405 | } |
406 | */ | ||
369 | 407 | ||
370 | if (dirty) | 408 | if (dirty) |
371 | mDirty = true; | 409 | mDirty = true; |
372 | 410 | ||
373 | return dirty; | 411 | return dirty; |
374 | 412 | ||
375 | } | 413 | } |
376 | 414 | ||
377 | //US I took the following hasGroup method from a newer version from KDE. | 415 | //US I took the following hasGroup method from a newer version from KDE. |
378 | /** | 416 | /** |
379 | * Returns true if the specified group is known about. | 417 | * Returns true if the specified group is known about. |
380 | * | 418 | * |
381 | * @param group The group to search for. | 419 | * @param group The group to search for. |
382 | * @return Whether the group exists. | 420 | * @return Whether the group exists. |
383 | */ | 421 | */ |
384 | bool KConfig::hasGroup(const QString &group) const | 422 | bool KConfig::hasGroup(const QString &group) const |
385 | { | 423 | { |
386 | QMap<QString,bool>::ConstIterator itBool; | 424 | QMap<QString,bool>::ConstIterator itBool; |
387 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) | 425 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) |
388 | { | 426 | { |
389 | if (itBool.key().find( group ) == 0) { | 427 | if (itBool.key().find( group ) == 0) { |
390 | return true; | 428 | return true; |
391 | } | 429 | } |
392 | } | 430 | } |
393 | 431 | ||
394 | QMap<QString,QString>::ConstIterator itString; | 432 | QMap<QString,QString>::ConstIterator itString; |
395 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) | 433 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) |
396 | { | 434 | { |
397 | if (itString.key().find( group ) == 0) { | 435 | if (itString.key().find( group ) == 0) { |
398 | return true; | 436 | return true; |
399 | } | 437 | } |
400 | } | 438 | } |
401 | 439 | ||
402 | QMap<QString,QDateTime>::ConstIterator itDateTime; | 440 | QMap<QString,QDateTime>::ConstIterator itDateTime; |
403 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) | 441 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) |
404 | { | 442 | { |
405 | if (itDateTime.key().find( group ) == 0) { | 443 | if (itDateTime.key().find( group ) == 0) { |
406 | return true; | 444 | return true; |
407 | } | 445 | } |
408 | } | 446 | } |
409 | 447 | ||
410 | return false; | 448 | return false; |
411 | } | 449 | } |
412 | 450 | ||
413 | void KConfig::deleteEntry( const QString &key) | 451 | void KConfig::deleteEntry( const QString &key) |
414 | { | 452 | { |
415 | bool dirty = false; | 453 | bool dirty = false; |
416 | 454 | ||