Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 95 |
1 files changed, 59 insertions, 36 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 98356fe..ffc0fac 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -305,14 +305,11 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | |||
305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
306 | 306 | ||
307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); |
308 | 308 | ||
309 | QString recurInMonthText; | 309 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); |
310 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 310 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); |
311 | recurInMonthText = i18n("Recur in the month of"); | 311 | mByDayLabel = new QLabel( i18n(" 1 of "), buttonGroup ); |
312 | } | ||
313 | |||
314 | mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); | ||
315 | buttonLayout->addWidget( mByMonthRadio, 0, 0 ); | ||
316 | 312 | ||
313 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | ||
317 | mByMonthCombo = new QComboBox( buttonGroup ); | 314 | mByMonthCombo = new QComboBox( buttonGroup ); |
318 | mByMonthCombo->insertItem( i18n("January") ); | 315 | mByMonthCombo->insertItem( i18n("January") ); |
@@ -328,30 +325,28 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | |||
328 | mByMonthCombo->insertItem( i18n("November") ); | 325 | mByMonthCombo->insertItem( i18n("November") ); |
329 | mByMonthCombo->insertItem( i18n("December") ); | 326 | mByMonthCombo->insertItem( i18n("December") ); |
330 | buttonLayout->addWidget( mByMonthCombo, 0, 1 ); | 327 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); |
331 | 328 | if ( QApplication::desktop()->width() <= 640 ) { | |
332 | mByMonthCombo->setSizeLimit( 6 ); | 329 | mByMonthCombo->setSizeLimit( 6 ); |
333 | |||
334 | buttonLayout->setRowStretch( 1, 1 ); | ||
335 | |||
336 | QString recurOnDayText; | ||
337 | if ( KOPrefs::instance()->mCompactDialogs ) { | ||
338 | recurOnDayText = i18n("This day"); | ||
339 | } else { | ||
340 | recurOnDayText = i18n("Recur on this day"); | ||
341 | } | 330 | } |
342 | 331 | ||
343 | mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup); | 332 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); |
344 | buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 ); | 333 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
334 | mDayOfLabel = new QLabel( i18n("1 of the year"), buttonGroup ); | ||
335 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); | ||
336 | |||
345 | } | 337 | } |
346 | 338 | ||
347 | void RecurYearly::setByDay() | 339 | void RecurYearly::setByDay( int doy ) |
348 | { | 340 | { |
349 | mByDayRadio->setChecked( true ); | 341 | mByDayRadio->setChecked( true ); |
342 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); | ||
350 | } | 343 | } |
351 | 344 | ||
352 | void RecurYearly::setByMonth( int month ) | 345 | void RecurYearly::setByMonth( int month, int day ) |
353 | { | 346 | { |
354 | mByMonthRadio->setChecked( true ); | 347 | mByMonthRadio->setChecked( true ); |
355 | mByMonthCombo->setCurrentItem( month - 1 ); | 348 | mByMonthCombo->setCurrentItem( month - 1 ); |
349 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | ||
350 | mDay = day; | ||
356 | } | 351 | } |
357 | 352 | ||
@@ -370,4 +365,8 @@ int RecurYearly::month() | |||
370 | return mByMonthCombo->currentItem() + 1; | 365 | return mByMonthCombo->currentItem() + 1; |
371 | } | 366 | } |
367 | int RecurYearly::day() | ||
368 | { | ||
369 | return mDay;//mByDayCombo->currentItem() + 1; | ||
370 | } | ||
372 | 371 | ||
373 | //////////////////////////// ExceptionsWidget ////////////////////////// | 372 | //////////////////////////// ExceptionsWidget ////////////////////////// |
@@ -845,4 +844,5 @@ void KOEditorRecurrence::setEnabled( bool enabled ) | |||
845 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 844 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
846 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
846 | mRuleBox->setEnabled( enabled ); | ||
847 | } | 847 | } |
848 | 848 | ||
@@ -896,15 +896,17 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | |||
896 | QBitArray days( 7 ); | 896 | QBitArray days( 7 ); |
897 | days.fill( 0 ); | 897 | days.fill( 0 ); |
898 | days.setBit( from.date().dayOfWeek()- 1); | ||
898 | mWeekly->setDays( days ); | 899 | mWeekly->setDays( days ); |
899 | |||
900 | mMonthly->setFrequency( 1 ); | 900 | mMonthly->setFrequency( 1 ); |
901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
901 | mMonthly->setByDay( from.date().day()-1 ); | 902 | mMonthly->setByDay( from.date().day()-1 ); |
902 | |||
903 | mYearly->setFrequency( 1 ); | 903 | mYearly->setFrequency( 1 ); |
904 | mYearly->setByDay(); | 904 | mYearly->setByDay( from.date().dayOfYear() ); |
905 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
905 | } | 906 | } |
906 | 907 | ||
907 | void KOEditorRecurrence::readEvent(Event *event) | 908 | void KOEditorRecurrence::readEvent(Event *event) |
908 | { | 909 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | ||
909 | QBitArray rDays( 7 ); | 911 | QBitArray rDays( 7 ); |
910 | QPtrList<Recurrence::rMonthPos> rmp; | 912 | QPtrList<Recurrence::rMonthPos> rmp; |
@@ -967,15 +969,33 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
967 | break; | 969 | break; |
968 | case Recurrence::rYearlyMonth: | 970 | case Recurrence::rYearlyMonth: |
969 | case Recurrence::rYearlyDay: | 971 | { |
970 | recurrenceType = RecurrenceChooser::Yearly; | 972 | recurrenceType = RecurrenceChooser::Yearly; |
971 | 973 | qDebug("Recurrence::rYearlyMonth: "); | |
974 | day = event->dtStart().date().day(); | ||
972 | rmd = r->yearNums(); | 975 | rmd = r->yearNums(); |
976 | if ( rmd.count() > 0 ) | ||
973 | month = *rmd.first(); | 977 | month = *rmd.first(); |
974 | if ( month == event->dtStart().date().month() ) { | 978 | else |
975 | mYearly->setByDay(); | 979 | month = event->dtStart().date().month() ; |
980 | mYearly->setByMonth( month, day ); | ||
981 | #if 0 | ||
982 | qDebug("2day = %d ",day ); | ||
983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | ||
984 | int month; | ||
985 | if ( !monthlist.isEmpty() ) { | ||
986 | month = monthlist.first()->rPos ; | ||
976 | } else { | 987 | } else { |
977 | mYearly->setByMonth( month ); | 988 | month = event->dtStart().date().month() ; |
989 | } | ||
990 | mYearly->setByMonth( day, month ); | ||
991 | #endif | ||
992 | mYearly->setFrequency( f ); | ||
978 | } | 993 | } |
979 | 994 | ||
995 | break; | ||
996 | case Recurrence::rYearlyDay: | ||
997 | qDebug("Recurrence::rYearlyDay: "); | ||
998 | recurrenceType = RecurrenceChooser::Yearly; | ||
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | ||
980 | mYearly->setFrequency( f ); | 1000 | mYearly->setFrequency( f ); |
981 | break; | 1001 | break; |
@@ -1063,12 +1083,14 @@ void KOEditorRecurrence::writeEvent( Event *event ) | |||
1063 | } | 1083 | } |
1064 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1084 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1085 | qDebug("RecurrenceChooser::Yearly "); | ||
1065 | int freq = mYearly->frequency(); | 1086 | int freq = mYearly->frequency(); |
1066 | 1087 | if ( mYearly->byDay() ) { | |
1067 | int month; | 1088 | if ( duration != 0 ) { |
1068 | if ( mYearly->byMonth() ) { | 1089 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1069 | month = mYearly->month(); | ||
1070 | } else { | 1090 | } else { |
1071 | month = event->dtStart().date().month(); | 1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1072 | } | 1092 | } |
1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | ||
1094 | } else { | ||
1073 | if ( duration != 0 ) { | 1095 | if ( duration != 0 ) { |
1074 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
@@ -1076,6 +1098,7 @@ void KOEditorRecurrence::writeEvent( Event *event ) | |||
1076 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1077 | } | 1099 | } |
1100 | r->addYearlyNum( mYearly->month() ); | ||
1101 | } | ||
1078 | 1102 | ||
1079 | r->addYearlyNum( month ); | ||
1080 | } | 1103 | } |
1081 | 1104 | ||