author | zautrix <zautrix> | 2004-08-20 23:53:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-20 23:53:07 (UTC) |
commit | ab07441b413dff6d478e2c3a39b823b4269931c5 (patch) (unidiff) | |
tree | 5de6576a6c0e20e4af2db7baa5019aa983e2195a /korganizer/koprefs.cpp | |
parent | bc33238f8038a03e04f25ea608c53e784616fee6 (diff) | |
download | kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.zip kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.gz kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.bz2 |
Sync fixes and fix of config loading bug
-rw-r--r-- | korganizer/koprefs.cpp | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 0db8e6d..dd978bf 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -390,67 +390,69 @@ QStringList KOPrefs::getDefaultList() | |||
390 | 390 | ||
391 | void KOPrefs::usrReadConfig() | 391 | void KOPrefs::usrReadConfig() |
392 | { | 392 | { |
393 | mLocaleDict = 0; | 393 | mLocaleDict = 0; |
394 | // pending LR fix translation | 394 | // pending LR fix translation |
395 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 395 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
396 | if ( mPreferredLanguage == 1 ) { | 396 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { |
397 | mLocaleDict = new QDict<QString>; | 397 | if ( mPreferredLanguage == 1 ) { |
398 | int i = 0; | ||
399 | QString fw ( germanwords[i] [0]); | ||
400 | while ( !fw.isEmpty() ) { | ||
401 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | ||
402 | ++i; | ||
403 | fw = germanwords[i] [0]; | ||
404 | } | ||
405 | |||
406 | setLocaleDict( mLocaleDict ); | ||
407 | } else { | ||
408 | QString fileName ; | ||
409 | if ( mPreferredLanguage == 3 ) | ||
410 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | ||
411 | else if ( mPreferredLanguage == 2 ) | ||
412 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | ||
413 | else return; | ||
414 | QFile file( fileName ); | ||
415 | if (file.open( IO_ReadOnly ) ) { | ||
416 | QTextStream ts( &file ); | ||
417 | ts.setCodec( QTextCodec::codecForLocale() ); | ||
418 | QString text = ts.read(); | ||
419 | file.close(); | ||
420 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
421 | QString line; | ||
422 | QString we; | ||
423 | QString wt; | ||
424 | int br = 0; | ||
425 | int nbr; | ||
426 | nbr = text.find ( "},", br ); | ||
427 | line = text.mid( br, nbr - br ); | ||
428 | br = nbr+1; | ||
429 | int se, ee, st, et; | ||
430 | mLocaleDict = new QDict<QString>; | 398 | mLocaleDict = new QDict<QString>; |
431 | QString end = "{ \"\",\"\" }"; | 399 | int i = 0; |
432 | while ( (line != end) && (br > 1) ) { | 400 | QString fw ( germanwords[i] [0]); |
433 | //qDebug("%d *%s* ", br, line.latin1()); | 401 | while ( !fw.isEmpty() ) { |
434 | se = line.find("\"")+1; | 402 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
435 | et = line.findRev("\"",-1); | 403 | ++i; |
436 | ee = line.find("\",\""); | 404 | fw = germanwords[i] [0]; |
437 | st = ee+3; | ||
438 | we = line.mid( se, ee-se ); | ||
439 | wt = line.mid( st, et-st ); | ||
440 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
441 | mLocaleDict->insert( we, new QString (wt) ); | ||
442 | nbr = text.find ( "}", br ); | ||
443 | line = text.mid( br, nbr - br ); | ||
444 | br = nbr+1; | ||
445 | } | 405 | } |
446 | //qDebug("end *%s* ", end.latin1()); | 406 | |
447 | |||
448 | setLocaleDict( mLocaleDict ); | 407 | setLocaleDict( mLocaleDict ); |
449 | } else { | 408 | } else { |
450 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 409 | QString fileName ; |
451 | } | 410 | if ( mPreferredLanguage == 3 ) |
411 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | ||
412 | else if ( mPreferredLanguage == 2 ) | ||
413 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | ||
414 | QFile file( fileName ); | ||
415 | if (file.open( IO_ReadOnly ) ) { | ||
416 | QTextStream ts( &file ); | ||
417 | ts.setEncoding( QTextStream::Latin1 ); | ||
418 | //ts.setCodec( QTextCodec::latin1 ); | ||
419 | QString text = ts.read(); | ||
420 | file.close(); | ||
421 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
422 | QString line; | ||
423 | QString we; | ||
424 | QString wt; | ||
425 | int br = 0; | ||
426 | int nbr; | ||
427 | nbr = text.find ( "},", br ); | ||
428 | line = text.mid( br, nbr - br ); | ||
429 | br = nbr+1; | ||
430 | int se, ee, st, et; | ||
431 | mLocaleDict = new QDict<QString>; | ||
432 | QString end = "{ \"\",\"\" }"; | ||
433 | while ( (line != end) && (br > 1) ) { | ||
434 | //qDebug("%d *%s* ", br, line.latin1()); | ||
435 | se = line.find("\"")+1; | ||
436 | et = line.findRev("\"",-1); | ||
437 | ee = line.find("\",\""); | ||
438 | st = ee+3; | ||
439 | we = line.mid( se, ee-se ); | ||
440 | wt = line.mid( st, et-st ); | ||
441 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
442 | mLocaleDict->insert( we, new QString (wt) ); | ||
443 | nbr = text.find ( "}", br ); | ||
444 | line = text.mid( br, nbr - br ); | ||
445 | br = nbr+1; | ||
446 | } | ||
447 | //qDebug("end *%s* ", end.latin1()); | ||
448 | |||
449 | setLocaleDict( mLocaleDict ); | ||
450 | } else { | ||
451 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | ||
452 | } | ||
452 | 453 | ||
453 | } | 454 | } |
455 | } | ||
454 | config()->setGroup("General"); | 456 | config()->setGroup("General"); |
455 | 457 | ||
456 | mCustomCategories = config()->readListEntry("Custom Categories"); | 458 | mCustomCategories = config()->readListEntry("Custom Categories"); |
@@ -460,8 +462,8 @@ void KOPrefs::usrReadConfig() | |||
460 | mTodoSummaryUser.clear(); | 462 | mTodoSummaryUser.clear(); |
461 | } | 463 | } |
462 | if (mLocationDefaults.isEmpty()) { | 464 | if (mLocationDefaults.isEmpty()) { |
463 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach") | 465 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
464 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden") | 466 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
465 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 467 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
466 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 468 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
467 | mLocationDefaults.sort(); | 469 | mLocationDefaults.sort(); |