Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index dea8981..de4e4f7 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -822,95 +822,107 @@ void KOEditorRecurrence::showCurrentRule( int current ) break; default: case Yearly: mRuleStack->raiseWidget( mYearly ); break; } } void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) { // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; mRecurrenceRange->setDateTimes( start, end ); mExceptions->setDefaults( end ); } - -void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) +void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) +{ + setDateTimes( from, to ); + QBitArray days( 7 ); + days.fill( 0 ); + days.setBit( from.date().dayOfWeek()- 1); + mWeekly->setDays( days ); + bool byPos = mMonthly->byPos(); + if ( byPos ) + mMonthly->setByDay( from.date().day()-1 ); + mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); + if ( ! byPos) + mMonthly->setByDay( from.date().day()-1 ); + + bool byDay = mYearly->byDay(); + if ( ! byDay ) + mYearly->setByDay( from.date().dayOfYear() ); + mYearly->setByMonth( from.date().month(), from.date().day() ); + if ( byDay ) + mYearly->setByDay( from.date().dayOfYear() ); +} +void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) { // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); - setDateTimes( from, to ); + //setDateTimes( from, to ); bool enabled = false; mEnabledCheck->setChecked( enabled ); setEnabled( enabled ); mExceptions->setDefaults( to ); mRecurrenceRange->setDefaults( to ); mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); showCurrentRule( mRecurrenceChooser->type() ); mDaily->setFrequency( 1 ); - mWeekly->setFrequency( 1 ); - QBitArray days( 7 ); - days.fill( 0 ); - days.setBit( from.date().dayOfWeek()- 1); - mWeekly->setDays( days ); mMonthly->setFrequency( 1 ); - mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); - mMonthly->setByDay( from.date().day()-1 ); mYearly->setFrequency( 1 ); - mYearly->setByDay( from.date().dayOfYear() ); - mYearly->setByMonth( from.date().month(), from.date().day() ); + setDefaultsDates( from, to ); } void KOEditorRecurrence::readEvent(Incidence *event) { QDateTime dtEnd; if ( event->typeID() == eventID ) dtEnd = ((Event*)event)->dtEnd(); else dtEnd = ((Todo*)event)->dtDue(); - setDefaults( event->dtStart(), dtEnd, true ); + setDefaults( event->dtStart(), dtEnd ); QBitArray rDays( 7 ); QPtrList<Recurrence::rMonthPos> rmp; QPtrList<int> rmd; int day = 0; int count = 0; int month = 0; setDateTimes( event->dtStart(), dtEnd ); Recurrence *r = event->recurrence(); int f = r->frequency(); int recurs = r->doesRecur(); mEnabledCheck->setChecked( recurs ); setEnabled( recurs ); int recurrenceType = RecurrenceChooser::Weekly; switch ( recurs ) { case Recurrence::rNone: - setDefaults( event->dtStart(), dtEnd, true ); + 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; @@ -956,33 +968,33 @@ void KOEditorRecurrence::readEvent(Incidence *event) } else { month = event->dtStart().date().month() ; } mYearly->setByMonth( day, month ); #endif 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, true ); + setDefaults( event->dtStart(), dtEnd ); break; } mRecurrenceChooser->setType( recurrenceType ); showCurrentRule( recurrenceType ); mRecurrenceRange->setDateTimes( event->dtStart() ); if ( r->doesRecur() ) { mRecurrenceRange->setDuration( r->duration() ); if ( r->duration() == 0 ) { if ( r->endDate() < event->dtStart().date() ) mRecurrenceRange->setEndDate( event->dtStart().date() ); else mRecurrenceRange->setEndDate( r->endDate() ); |