-rw-r--r-- | korganizer/koprefs.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 31ef338..9147af3 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -475,128 +475,136 @@ void KOPrefs::usrReadConfig() | |||
475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); | 475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); |
476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
477 | if ( kkf->mCalNumber == 1 ) { | 477 | if ( kkf->mCalNumber == 1 ) { |
478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
479 | } | 479 | } |
480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
481 | if ( kkf->mName == i18n("Birthdays") ) { | 481 | if ( kkf->mName == i18n("Birthdays") ) { |
482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
483 | } | 483 | } |
484 | if ( kkf->isRelative ) | 484 | if ( kkf->isRelative ) |
485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); | 485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); |
486 | } | 486 | } |
487 | 487 | ||
488 | KPimPrefs::usrReadConfig(); | 488 | KPimPrefs::usrReadConfig(); |
489 | } | 489 | } |
490 | 490 | ||
491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
492 | { | 492 | { |
493 | return mDefCalColors[num-1]; | 493 | return mDefCalColors[num-1]; |
494 | } | 494 | } |
495 | 495 | ||
496 | KopiCalendarFile * KOPrefs::getNewCalendar() | 496 | KopiCalendarFile * KOPrefs::getNewCalendar() |
497 | { | 497 | { |
498 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 498 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
499 | kkf->mCalNumber = mNextAvailableCalendar; | 499 | kkf->mCalNumber = mNextAvailableCalendar; |
500 | mDefCalColors.resize( mNextAvailableCalendar ); | 500 | mDefCalColors.resize( mNextAvailableCalendar ); |
501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
502 | ++mNextAvailableCalendar; | 502 | ++mNextAvailableCalendar; |
503 | kkf->mDefaultColor = mEventColor; | 503 | kkf->mDefaultColor = mEventColor; |
504 | kkf->mName = i18n("New Calendar"); | 504 | kkf->mName = i18n("New Calendar"); |
505 | mCalendars.append( kkf ); | 505 | mCalendars.append( kkf ); |
506 | return kkf; | 506 | return kkf; |
507 | } | 507 | } |
508 | void KOPrefs::deleteCalendar( int num ) | 508 | void KOPrefs::deleteCalendar( int num ) |
509 | { | 509 | { |
510 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
511 | while ( kkf ) { | 511 | while ( kkf ) { |
512 | if ( kkf->mCalNumber == num ) { | 512 | if ( kkf->mCalNumber == num ) { |
513 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 513 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
514 | mCalendars.remove( kkf ); | 514 | mCalendars.remove( kkf ); |
515 | delete kkf; | 515 | delete kkf; |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | kkf = mCalendars.next(); | 518 | kkf = mCalendars.next(); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | int KOPrefs::getCalendarID( const QString & name ) | 521 | int KOPrefs::getCalendarID( const QString & name ) |
522 | { | 522 | { |
523 | KopiCalendarFile * kkf = mCalendars.first(); | 523 | KopiCalendarFile * kkf = mCalendars.first(); |
524 | while ( kkf ) { | 524 | while ( kkf ) { |
525 | if ( name == kkf->mName) | 525 | if ( name == kkf->mName) |
526 | return kkf->mCalNumber; | 526 | return kkf->mCalNumber; |
527 | kkf = mCalendars.next(); | 527 | kkf = mCalendars.next(); |
528 | } | 528 | } |
529 | return 1; | 529 | return 1; |
530 | } | 530 | } |
531 | int KOPrefs::getFuzzyCalendarID( const QString & name ) | 531 | int KOPrefs::getFuzzyCalendarID( const QString & name ) |
532 | { | 532 | { |
533 | KopiCalendarFile * kkf = mCalendars.first(); | 533 | KopiCalendarFile * kkf = mCalendars.first(); |
534 | while ( kkf ) { | 534 | while ( kkf ) { |
535 | if ( name.lower() == kkf->mName.lower()) | 535 | if ( name.lower() == kkf->mName.lower()) |
536 | return kkf->mCalNumber; | 536 | return kkf->mCalNumber; |
537 | kkf = mCalendars.next(); | 537 | kkf = mCalendars.next(); |
538 | } | 538 | } |
539 | QString name2 = name; | ||
540 | name2.replace (QRegExp ("_")," " ); | ||
541 | kkf = mCalendars.first(); | ||
542 | while ( kkf ) { | ||
543 | if ( name2.lower() == kkf->mName.lower()) | ||
544 | return kkf->mCalNumber; | ||
545 | kkf = mCalendars.next(); | ||
546 | } | ||
539 | return 0; | 547 | return 0; |
540 | } | 548 | } |
541 | QString KOPrefs::calName( int calNum) const | 549 | QString KOPrefs::calName( int calNum) const |
542 | { | 550 | { |
543 | return (mDefCalColors[calNum-1])->mName; | 551 | return (mDefCalColors[calNum-1])->mName; |
544 | } | 552 | } |
545 | QColor KOPrefs::defaultColor( int calNum ) const | 553 | QColor KOPrefs::defaultColor( int calNum ) const |
546 | { | 554 | { |
547 | if ( calNum == 1 ) return mEventColor; | 555 | if ( calNum == 1 ) return mEventColor; |
548 | return (mDefCalColors[calNum-1])->mDefaultColor; | 556 | return (mDefCalColors[calNum-1])->mDefaultColor; |
549 | } | 557 | } |
550 | void KOPrefs::usrWriteConfig() | 558 | void KOPrefs::usrWriteConfig() |
551 | { | 559 | { |
552 | config()->setGroup("General"); | 560 | config()->setGroup("General"); |
553 | config()->writeEntry("Custom Categories",mCustomCategories); | 561 | config()->writeEntry("Custom Categories",mCustomCategories); |
554 | 562 | ||
555 | config()->setGroup("Personal Settings"); | 563 | config()->setGroup("Personal Settings"); |
556 | config()->writeEntry("user_name",mName); | 564 | config()->writeEntry("user_name",mName); |
557 | config()->writeEntry("user_email",mEmail); | 565 | config()->writeEntry("user_email",mEmail); |
558 | 566 | ||
559 | config()->setGroup("Category Colors"); | 567 | config()->setGroup("Category Colors"); |
560 | QDictIterator<QColor> it(mCategoryColors); | 568 | QDictIterator<QColor> it(mCategoryColors); |
561 | while (it.current()) { | 569 | while (it.current()) { |
562 | config()->writeEntry(it.currentKey(),*(it.current())); | 570 | config()->writeEntry(it.currentKey(),*(it.current())); |
563 | ++it; | 571 | ++it; |
564 | } | 572 | } |
565 | KConfig fc (locateLocal("config","kopicalendarrc")); | 573 | KConfig fc (locateLocal("config","kopicalendarrc")); |
566 | fc.setGroup("CC"); | 574 | fc.setGroup("CC"); |
567 | fc.deleteGroup( "CC"); | 575 | fc.deleteGroup( "CC"); |
568 | fc.setGroup("CC"); | 576 | fc.setGroup("CC"); |
569 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 577 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
570 | int numCal = 1; | 578 | int numCal = 1; |
571 | int writeCal = 0; | 579 | int writeCal = 0; |
572 | while ( numCal < mNextAvailableCalendar ) { | 580 | while ( numCal < mNextAvailableCalendar ) { |
573 | KopiCalendarFile * kkf = mCalendars.first(); | 581 | KopiCalendarFile * kkf = mCalendars.first(); |
574 | while ( kkf ) { | 582 | while ( kkf ) { |
575 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 583 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
576 | if ( kkf->mCalNumber == numCal ) { | 584 | if ( kkf->mCalNumber == numCal ) { |
577 | ++writeCal; | 585 | ++writeCal; |
578 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 586 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
579 | QString prefix = "Cal_" + QString::number( writeCal ); | 587 | QString prefix = "Cal_" + QString::number( writeCal ); |
580 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 588 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
581 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 589 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
582 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 590 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
583 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 591 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
584 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 592 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
585 | fc.writeEntry( prefix+"_Name", kkf->mName); | 593 | fc.writeEntry( prefix+"_Name", kkf->mName); |
586 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 594 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
587 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 595 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
588 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 596 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
589 | } | 597 | } |
590 | kkf = mCalendars.next(); | 598 | kkf = mCalendars.next(); |
591 | } | 599 | } |
592 | ++numCal; | 600 | ++numCal; |
593 | } | 601 | } |
594 | fc.sync(); | 602 | fc.sync(); |
595 | KPimPrefs::usrWriteConfig(); | 603 | KPimPrefs::usrWriteConfig(); |
596 | } | 604 | } |
597 | 605 | ||
598 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 606 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
599 | { | 607 | { |
600 | mCategoryColors.replace(cat,new QColor(color)); | 608 | mCategoryColors.replace(cat,new QColor(color)); |
601 | } | 609 | } |
602 | 610 | ||