author | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
commit | cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef (patch) (unidiff) | |
tree | 963322cd4c539c084feb43dfde5eabe52ae4385f | |
parent | 8cc6d456812b5a9a386e81c9e46baccd56029537 (diff) | |
download | kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.zip kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.gz kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.bz2 |
Fixed some problems with the recurrence
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 125 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 9 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 20 | ||||
-rw-r--r-- | libkcal/recurrence.cpp | 17 | ||||
-rw-r--r-- | libkcal/recurrence.h | 6 |
5 files changed, 110 insertions, 67 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 98356fe..ffc0fac 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -306,12 +306,9 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | |||
306 | 306 | ||
307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); |
308 | |||
309 | QString recurInMonthText; | ||
310 | if ( !KOPrefs::instance()->mCompactDialogs ) { | ||
311 | recurInMonthText = i18n("Recur in the month of"); | ||
312 | } | ||
313 | |||
314 | mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); | ||
315 | buttonLayout->addWidget( mByMonthRadio, 0, 0 ); | ||
316 | 308 | ||
309 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); | ||
310 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); | ||
311 | mByDayLabel = new QLabel( i18n(" 1 of "), buttonGroup ); | ||
312 | |||
313 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | ||
317 | mByMonthCombo = new QComboBox( buttonGroup ); | 314 | mByMonthCombo = new QComboBox( buttonGroup ); |
@@ -329,25 +326,21 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | |||
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 | 330 | } | |
334 | buttonLayout->setRowStretch( 1, 1 ); | 331 | |
335 | 332 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); | |
336 | QString recurOnDayText; | 333 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
337 | if ( KOPrefs::instance()->mCompactDialogs ) { | 334 | mDayOfLabel = new QLabel( i18n("1 of the year"), buttonGroup ); |
338 | recurOnDayText = i18n("This day"); | 335 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); |
339 | } else { | 336 | |
340 | recurOnDayText = i18n("Recur on this day"); | ||
341 | } | ||
342 | |||
343 | mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup); | ||
344 | buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 ); | ||
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 | { |
@@ -355,2 +348,4 @@ void RecurYearly::setByMonth( int month ) | |||
355 | mByMonthCombo->setCurrentItem( month - 1 ); | 348 | mByMonthCombo->setCurrentItem( month - 1 ); |
349 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | ||
350 | mDay = day; | ||
356 | } | 351 | } |
@@ -371,2 +366,6 @@ int RecurYearly::month() | |||
371 | } | 366 | } |
367 | int RecurYearly::day() | ||
368 | { | ||
369 | return mDay;//mByDayCombo->currentItem() + 1; | ||
370 | } | ||
372 | 371 | ||
@@ -846,2 +845,3 @@ void KOEditorRecurrence::setEnabled( bool enabled ) | |||
846 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
846 | mRuleBox->setEnabled( enabled ); | ||
847 | } | 847 | } |
@@ -897,9 +897,10 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | |||
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 | } |
@@ -908,2 +909,3 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
908 | { | 909 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | ||
909 | QBitArray rDays( 7 ); | 911 | QBitArray rDays( 7 ); |
@@ -968,15 +970,33 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
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: "); | |
972 | rmd = r->yearNums(); | 974 | day = event->dtStart().date().day(); |
973 | month = *rmd.first(); | 975 | rmd = r->yearNums(); |
974 | if ( month == event->dtStart().date().month() ) { | 976 | if ( rmd.count() > 0 ) |
975 | mYearly->setByDay(); | 977 | month = *rmd.first(); |
976 | } else { | 978 | else |
977 | mYearly->setByMonth( month ); | 979 | month = event->dtStart().date().month() ; |
978 | } | 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 ; | ||
987 | } else { | ||
988 | month = event->dtStart().date().month() ; | ||
989 | } | ||
990 | mYearly->setByMonth( day, month ); | ||
991 | #endif | ||
992 | mYearly->setFrequency( f ); | ||
993 | } | ||
979 | 994 | ||
980 | mYearly->setFrequency( f ); | ||
981 | break; | 995 | break; |
996 | case Recurrence::rYearlyDay: | ||
997 | qDebug("Recurrence::rYearlyDay: "); | ||
998 | recurrenceType = RecurrenceChooser::Yearly; | ||
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | ||
1000 | mYearly->setFrequency( f ); | ||
1001 | break; | ||
982 | default: | 1002 | default: |
@@ -1064,17 +1084,20 @@ void KOEditorRecurrence::writeEvent( Event *event ) | |||
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(); | 1090 | } else { |
1070 | } else { | 1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1071 | month = event->dtStart().date().month(); | 1092 | } |
1072 | } | 1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1073 | if ( duration != 0 ) { | ||
1074 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1075 | } else { | 1094 | } else { |
1076 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1095 | if ( duration != 0 ) { |
1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1097 | } else { | ||
1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | ||
1099 | } | ||
1100 | r->addYearlyNum( mYearly->month() ); | ||
1077 | } | 1101 | } |
1078 | 1102 | ||
1079 | r->addYearlyNum( month ); | ||
1080 | } | 1103 | } |
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index 4f0f0b2..2b59085 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -111,4 +111,4 @@ class RecurYearly : public RecurBase | |||
111 | 111 | ||
112 | void setByDay(); | 112 | void setByDay( int doy ); |
113 | void setByMonth( int month ); | 113 | void setByMonth( int month, int day ); |
114 | 114 | ||
@@ -118,7 +118,10 @@ class RecurYearly : public RecurBase | |||
118 | int month(); | 118 | int month(); |
119 | int day(); | ||
119 | 120 | ||
120 | private: | 121 | private: |
122 | int mDay; | ||
121 | QRadioButton *mByMonthRadio; | 123 | QRadioButton *mByMonthRadio; |
122 | QComboBox *mByMonthCombo; | 124 | QComboBox *mByMonthCombo; |
123 | 125 | QLabel* mByDayLabel; | |
126 | QLabel* mDayOfLabel; | ||
124 | QRadioButton *mByDayRadio; | 127 | QRadioButton *mByDayRadio; |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 32a1337..964ffe3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -1394,3 +1394,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre | |||
1394 | frequ = ICAL_MONTHLY_RECURRENCE; | 1394 | frequ = ICAL_MONTHLY_RECURRENCE; |
1395 | interv = 12; | 1395 | interv = 12* r.interval; |
1396 | } | 1396 | } |
@@ -1501,2 +1501,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre | |||
1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1502 | qDebug(" YEARLY DAY OF YEAR"); | ||
1502 | if (!icaltime_is_null_time(r.until)) { | 1503 | if (!icaltime_is_null_time(r.until)) { |
@@ -1515,2 +1516,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre | |||
1515 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1516 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1517 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | ||
1516 | if (!icaltime_is_null_time(r.until)) { | 1518 | if (!icaltime_is_null_time(r.until)) { |
@@ -1545,2 +1547,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre | |||
1545 | } else { | 1547 | } else { |
1548 | qDebug("YEARLY MONTH "); | ||
1546 | if (!icaltime_is_null_time(r.until)) { | 1549 | if (!icaltime_is_null_time(r.until)) { |
@@ -1554,11 +1557,12 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre | |||
1554 | } | 1557 | } |
1555 | } | 1558 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1556 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1559 | index = 0; |
1557 | index = 0; | 1560 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1558 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1561 | recur->addYearlyNum(day); |
1559 | recur->addYearlyNum(day); | 1562 | } |
1563 | } else { | ||
1564 | recur->addYearlyNum(incidence->dtStart().date().month()); | ||
1560 | } | 1565 | } |
1561 | } else { | ||
1562 | recur->addYearlyNum(incidence->dtStart().date().month()); | ||
1563 | } | 1566 | } |
1567 | |||
1564 | } | 1568 | } |
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index 5fc5d1f..dd74e10 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp | |||
@@ -656,3 +656,3 @@ void Recurrence::addMonthlyDay(short _rDay) | |||
656 | { | 656 | { |
657 | if (mRecurReadOnly || recurs != rMonthlyDay | 657 | if (mRecurReadOnly || (recurs != rMonthlyDay && recurs != rYearlyMonth) |
658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number | 658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number |
@@ -727,3 +727,16 @@ const QPtrList<int> &Recurrence::yearNums() const | |||
727 | } | 727 | } |
728 | 728 | void Recurrence::addYearlyMonth(short _rPos ) | |
729 | { | ||
730 | if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number | ||
731 | return; | ||
732 | rMonthPos *tmpPos = new rMonthPos; | ||
733 | if ( _rPos > 0) { | ||
734 | tmpPos->rPos = _rPos; | ||
735 | tmpPos->negative = false; | ||
736 | } else { | ||
737 | tmpPos->rPos = -_rPos; // take abs() | ||
738 | tmpPos->negative = true; | ||
739 | } | ||
740 | rMonthPositions.append(tmpPos); | ||
741 | } | ||
729 | void Recurrence::addYearlyNum(short _rNum) | 742 | void Recurrence::addYearlyNum(short _rNum) |
diff --git a/libkcal/recurrence.h b/libkcal/recurrence.h index a0f6d84..b13d14f 100644 --- a/libkcal/recurrence.h +++ b/libkcal/recurrence.h | |||
@@ -290,3 +290,3 @@ class Recurrence | |||
290 | static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } | 290 | static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } |
291 | 291 | void addYearlyMonth(short _rPos ); // added LR | |
292 | /** | 292 | /** |
@@ -296,2 +296,4 @@ class Recurrence | |||
296 | QString recurrenceText() const; | 296 | QString recurrenceText() const; |
297 | bool getYearlyMonthMonths(int day, QValueList<int>&, | ||
298 | QValueList<int> &leaplist) const; | ||
297 | 299 | ||
@@ -348,4 +350,2 @@ class Recurrence | |||
348 | bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; | 350 | bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; |
349 | bool getYearlyMonthMonths(int day, QValueList<int>&, | ||
350 | QValueList<int> &leaplist) const; | ||
351 | 351 | ||