Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 172 |
1 files changed, 89 insertions, 83 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index de4e4f7..89504db 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -899,6 +899,5 @@ void KOEditorRecurrence::readEvent(Incidence *event) - Recurrence *r = event->recurrence(); - int f = r->frequency(); + - int recurs = r->doesRecur(); + int recurs = event->doesRecur(); @@ -908,81 +907,83 @@ void KOEditorRecurrence::readEvent(Incidence *event) int recurrenceType = RecurrenceChooser::Weekly; - - switch ( recurs ) { - case Recurrence::rNone: - setDefaults( event->dtStart(), dtEnd ); - break; - case Recurrence::rDaily: - recurrenceType = RecurrenceChooser::Daily; - mDaily->setFrequency( f ); - break; - case Recurrence::rWeekly: - recurrenceType = RecurrenceChooser::Weekly; - mWeekly->setFrequency( f ); - mWeekly->setDays( r->days() ); - break; - case Recurrence::rMonthlyPos: - // we only handle one possibility in the list right now, - // so I have hardcoded calls with first(). If we make the GUI - // more extended, this can be changed. - recurrenceType = RecurrenceChooser::Monthly; - - rmp = r->monthPositions(); - if ( rmp.first()->negative ) - count = 5 - rmp.first()->rPos - 1; - else - count = rmp.first()->rPos - 1; - day = 0; - while ( !rmp.first()->rDays.testBit( day ) ) ++day; - mMonthly->setByPos( count, day ); - - mMonthly->setFrequency( f ); - - break; - case Recurrence::rMonthlyDay: - recurrenceType = RecurrenceChooser::Monthly; - - rmd = r->monthDays(); - day = *rmd.first() - 1; - mMonthly->setByDay( day ); - - mMonthly->setFrequency( f ); - - break; - case Recurrence::rYearlyMonth: - { - recurrenceType = RecurrenceChooser::Yearly; - //qDebug("Recurrence::rYearlyMonth: "); - day = event->dtStart().date().day(); - rmd = r->yearNums(); - if ( rmd.count() > 0 ) - month = *rmd.first(); - else - month = event->dtStart().date().month() ; - mYearly->setByMonth( month, day ); + if ( recurs ) { + Recurrence *r = event->recurrence(); + int f = r->frequency(); + switch ( recurs ) { + case Recurrence::rNone: + setDefaults( event->dtStart(), dtEnd ); + break; + case Recurrence::rDaily: + recurrenceType = RecurrenceChooser::Daily; + mDaily->setFrequency( f ); + break; + case Recurrence::rWeekly: + recurrenceType = RecurrenceChooser::Weekly; + mWeekly->setFrequency( f ); + mWeekly->setDays( r->days() ); + break; + case Recurrence::rMonthlyPos: + // we only handle one possibility in the list right now, + // so I have hardcoded calls with first(). If we make the GUI + // more extended, this can be changed. + recurrenceType = RecurrenceChooser::Monthly; + + rmp = r->monthPositions(); + if ( rmp.first()->negative ) + count = 5 - rmp.first()->rPos - 1; + else + count = rmp.first()->rPos - 1; + day = 0; + while ( !rmp.first()->rDays.testBit( day ) ) ++day; + mMonthly->setByPos( count, day ); + + mMonthly->setFrequency( f ); + + break; + case Recurrence::rMonthlyDay: + recurrenceType = RecurrenceChooser::Monthly; + + rmd = r->monthDays(); + day = *rmd.first() - 1; + mMonthly->setByDay( day ); + + mMonthly->setFrequency( f ); + + break; + case Recurrence::rYearlyMonth: + { + recurrenceType = RecurrenceChooser::Yearly; + //qDebug("Recurrence::rYearlyMonth: "); + day = event->dtStart().date().day(); + rmd = r->yearNums(); + if ( rmd.count() > 0 ) + month = *rmd.first(); + else + month = event->dtStart().date().month() ; + mYearly->setByMonth( month, day ); #if 0 - //qDebug("2day = %d ",day ); - QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); - int month; - if ( !monthlist.isEmpty() ) { - month = monthlist.first()->rPos ; - } else { - month = event->dtStart().date().month() ; - } - mYearly->setByMonth( day, month ); + //qDebug("2day = %d ",day ); + QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); + int month; + if ( !monthlist.isEmpty() ) { + month = monthlist.first()->rPos ; + } else { + month = event->dtStart().date().month() ; + } + mYearly->setByMonth( day, month ); #endif - mYearly->setFrequency( f ); - } + mYearly->setFrequency( f ); + } - break; - case Recurrence::rYearlyDay: - //qDebug("Recurrence::rYearlyDay: "); - recurrenceType = RecurrenceChooser::Yearly; - mYearly->setByDay( event->dtStart().date().dayOfYear() ); - mYearly->setFrequency( f ); - break; - default: - setDefaults( event->dtStart(), dtEnd ); - break; + break; + case Recurrence::rYearlyDay: + //qDebug("Recurrence::rYearlyDay: "); + recurrenceType = RecurrenceChooser::Yearly; + mYearly->setByDay( event->dtStart().date().dayOfYear() ); + mYearly->setFrequency( f ); + break; + default: + setDefaults( event->dtStart(), dtEnd ); + break; + } } - mRecurrenceChooser->setType( recurrenceType ); @@ -992,3 +993,4 @@ void KOEditorRecurrence::readEvent(Incidence *event) - if ( r->doesRecur() ) { + if ( event->doesRecur() ) { + Recurrence *r = event->recurrence(); mRecurrenceRange->setDuration( r->duration() ); @@ -1009,8 +1011,12 @@ void KOEditorRecurrence::writeEvent( Incidence *event ) { - Recurrence *r = event->recurrence(); + - // clear out any old settings; - r->unsetRecurs(); + if ( !mEnabledCheck->isChecked() ) { + if ( event->doesRecur() ) + event->recurrence()->unsetRecurs(); + } else { + Recurrence *r = event->recurrence(); - if ( mEnabledCheck->isChecked() ) { + // clear out any old settings; + r->unsetRecurs(); int duration = mRecurrenceRange->duration(); |