Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index dea8981..de4e4f7 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -834,14 +834,34 @@ void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) mRecurrenceRange->setDateTimes( start, end ); mExceptions->setDefaults( end ); } +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 ); -void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) + 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 ); @@ -852,20 +872,12 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 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) { @@ -875,9 +887,9 @@ void KOEditorRecurrence::readEvent(Incidence *event) 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; @@ -896,9 +908,9 @@ void KOEditorRecurrence::readEvent(Incidence *event) 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 ); @@ -968,9 +980,9 @@ void KOEditorRecurrence::readEvent(Incidence *event) mYearly->setByDay( event->dtStart().date().dayOfYear() ); mYearly->setFrequency( f ); break; default: - setDefaults( event->dtStart(), dtEnd, true ); + setDefaults( event->dtStart(), dtEnd ); break; } mRecurrenceChooser->setType( recurrenceType ); |