-rw-r--r-- | korganizer/koprefs.cpp | 85 |
1 files changed, 81 insertions, 4 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 8f951ee..179f586 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -320,3 +320,3 @@ KOPrefs::KOPrefs() : | |||
320 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 320 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
321 | 321 | mCalendars.setAutoDelete( true ); | |
322 | } | 322 | } |
@@ -328,3 +328,4 @@ KOPrefs::~KOPrefs() | |||
328 | mInstance = insd.setObject(0); | 328 | mInstance = insd.setObject(0); |
329 | 329 | mCalendars.setAutoDelete( true ); | |
330 | mCalendars.clear(); | ||
330 | //qDebug("KOPrefs::~KOPrefs() "); | 331 | //qDebug("KOPrefs::~KOPrefs() "); |
@@ -437,2 +438,27 @@ void KOPrefs::usrReadConfig() | |||
437 | } | 438 | } |
439 | config()->setGroup("CCal"); | ||
440 | int numCals = config()->readNumEntry("NumberCalendars",0 ); | ||
441 | mNextAvailableCalendar = 1; | ||
442 | if ( numCals == 0 ) { | ||
443 | KopiCalendarFile *kkf = getNewCalendar(); | ||
444 | kkf->isStandard = true; | ||
445 | kkf->mName = i18n("Standard Calendar"); | ||
446 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | ||
447 | } | ||
448 | while ( mNextAvailableCalendar <= numCals ) { | ||
449 | qDebug("Read cal #%d ", mNextAvailableCalendar ); | ||
450 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | ||
451 | KopiCalendarFile *kkf = getNewCalendar(); | ||
452 | kkf->isStandard = config()->readBoolEntry( prefix+"_isStandard", false ); | ||
453 | kkf->isEnabled = config()->readBoolEntry( prefix+"_isEnabled", true); | ||
454 | kkf->isAlarmEnabled = config()->readBoolEntry( prefix+"_isAlarmEnabled", true); | ||
455 | kkf->isReadOnly = config()->readBoolEntry( prefix+"_isReadOnly", false); | ||
456 | kkf->mName = config()->readEntry( prefix+"_Name", "Calendar"); | ||
457 | kkf->mFileName = config()->readEntry( prefix+"_FileName", kkf->mFileName); | ||
458 | kkf->mDefaultColor = config()->readColorEntry( prefix+"_Color",&mEventColor); | ||
459 | if ( kkf->mCalNumber == 1 ) { | ||
460 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | ||
461 | //kkf->mName = i18n("Standard Calendar"); | ||
462 | } | ||
463 | } | ||
438 | 464 | ||
@@ -442,2 +468,31 @@ void KOPrefs::usrReadConfig() | |||
442 | 468 | ||
469 | KopiCalendarFile * KOPrefs::getNewCalendar() | ||
470 | { | ||
471 | KopiCalendarFile * kkf = new KopiCalendarFile(); | ||
472 | kkf->mCalNumber = mNextAvailableCalendar; | ||
473 | mDefCalColors.resize( mNextAvailableCalendar ); | ||
474 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | ||
475 | ++mNextAvailableCalendar; | ||
476 | kkf->mDefaultColor = mEventColor; | ||
477 | kkf->mName = i18n("New Calendar"); | ||
478 | mCalendars.append( kkf ); | ||
479 | return kkf; | ||
480 | } | ||
481 | void KOPrefs::deleteCalendar( int num ) | ||
482 | { | ||
483 | KopiCalendarFile * kkf = mCalendars.first(); | ||
484 | while ( kkf ) { | ||
485 | if ( kkf->mCalNumber == num ) { | ||
486 | qDebug("KOPrefs::deleteCalendar %d ", num ); | ||
487 | mCalendars.remove( kkf ); | ||
488 | delete kkf; | ||
489 | return; | ||
490 | } | ||
491 | kkf = mCalendars.next(); | ||
492 | } | ||
493 | } | ||
494 | QColor KOPrefs::defaultColor( int calNum ) const | ||
495 | { | ||
496 | return (mDefCalColors[calNum-1])->mDefaultColor; | ||
497 | } | ||
443 | void KOPrefs::usrWriteConfig() | 498 | void KOPrefs::usrWriteConfig() |
@@ -457,4 +512,26 @@ void KOPrefs::usrWriteConfig() | |||
457 | } | 512 | } |
458 | 513 | config()->setGroup("CCal"); | |
459 | 514 | config()->writeEntry("NumberCalendars",mCalendars.count()); | |
515 | int numCal = 1; | ||
516 | int writeCal = 0; | ||
517 | while ( numCal < mNextAvailableCalendar ) { | ||
518 | KopiCalendarFile * kkf = mCalendars.first(); | ||
519 | while ( kkf ) { | ||
520 | qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | ||
521 | if ( kkf->mCalNumber == numCal ) { | ||
522 | ++writeCal; | ||
523 | qDebug("Write calendar %d %d ", numCal , writeCal); | ||
524 | QString prefix = "Cal_" + QString::number( writeCal ); | ||
525 | config()->writeEntry( prefix+"_isStandard", kkf->isStandard ); | ||
526 | config()->writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | ||
527 | config()->writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | ||
528 | config()->writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | ||
529 | config()->writeEntry( prefix+"_Name", kkf->mName); | ||
530 | config()->writeEntry( prefix+"_FileName", kkf->mFileName); | ||
531 | config()->writeEntry( prefix+"_Color",kkf->mDefaultColor); | ||
532 | } | ||
533 | kkf = mCalendars.next(); | ||
534 | } | ||
535 | ++numCal; | ||
536 | } | ||
460 | KPimPrefs::usrWriteConfig(); | 537 | KPimPrefs::usrWriteConfig(); |