summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorrecurrence.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorrecurrence.cpp42
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
@@ -835,12 +835,32 @@ void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime 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 );
@@ -853,18 +873,10 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
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)
@@ -876,7 +888,7 @@ void KOEditorRecurrence::readEvent(Incidence *event)
else
dtEnd = ((Todo*)event)->dtDue();
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
QBitArray rDays( 7 );
QPtrList<Recurrence::rMonthPos> rmp;
QPtrList<int> rmd;
@@ -897,7 +909,7 @@ void KOEditorRecurrence::readEvent(Incidence *event)
switch ( recurs ) {
case Recurrence::rNone:
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
break;
case Recurrence::rDaily:
recurrenceType = RecurrenceChooser::Daily;
@@ -969,7 +981,7 @@ void KOEditorRecurrence::readEvent(Incidence *event)
mYearly->setFrequency( f );
break;
default:
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
break;
}