summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorrecurrence.cpp125
-rw-r--r--korganizer/koeditorrecurrence.h9
-rw-r--r--libkcal/icalformatimpl.cpp20
-rw-r--r--libkcal/recurrence.cpp17
-rw-r--r--libkcal/recurrence.h6
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 ) :
- QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
-
- QString recurInMonthText;
- if ( !KOPrefs::instance()->mCompactDialogs ) {
- recurInMonthText = i18n("Recur in the month of");
- }
-
- mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup);
- buttonLayout->addWidget( mByMonthRadio, 0, 0 );
+ QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 );
+ mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup);
+ buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight);
+ mByDayLabel = new QLabel( i18n(" 1 of "), buttonGroup );
+
+ buttonLayout->addWidget( mByDayLabel, 0, 1 );
mByMonthCombo = new QComboBox( buttonGroup );
@@ -329,25 +326,21 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
mByMonthCombo->insertItem( i18n("December") );
- buttonLayout->addWidget( mByMonthCombo, 0, 1 );
-
- mByMonthCombo->setSizeLimit( 6 );
-
- buttonLayout->setRowStretch( 1, 1 );
-
- QString recurOnDayText;
- if ( KOPrefs::instance()->mCompactDialogs ) {
- recurOnDayText = i18n("This day");
- } else {
- recurOnDayText = i18n("Recur on this day");
- }
-
- mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup);
- buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 );
+ buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft );
+ if ( QApplication::desktop()->width() <= 640 ) {
+ mByMonthCombo->setSizeLimit( 6 );
+ }
+
+ mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup);
+ buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight);
+ mDayOfLabel = new QLabel( i18n("1 of the year"), buttonGroup );
+ buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 );
+
}
-void RecurYearly::setByDay()
+void RecurYearly::setByDay( int doy )
{
mByDayRadio->setChecked( true );
+ mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) );
}
-void RecurYearly::setByMonth( int month )
+void RecurYearly::setByMonth( int month, int day )
{
@@ -355,2 +348,4 @@ void RecurYearly::setByMonth( int month )
mByMonthCombo->setCurrentItem( month - 1 );
+ mByDayLabel->setText(i18n("%1 of ").arg( day ) );
+ mDay = day;
}
@@ -371,2 +366,6 @@ int RecurYearly::month()
}
+int RecurYearly::day()
+{
+ return mDay;//mByDayCombo->currentItem() + 1;
+}
@@ -846,2 +845,3 @@ void KOEditorRecurrence::setEnabled( bool enabled )
if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
+ mRuleBox->setEnabled( enabled );
}
@@ -897,9 +897,10 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
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();
+ mYearly->setByDay( from.date().dayOfYear() );
+ mYearly->setByMonth( from.date().month(), from.date().day() );
}
@@ -908,2 +909,3 @@ void KOEditorRecurrence::readEvent(Event *event)
{
+ setDefaults( event->dtStart(), event->dtEnd(), true );
QBitArray rDays( 7 );
@@ -968,15 +970,33 @@ void KOEditorRecurrence::readEvent(Event *event)
case Recurrence::rYearlyMonth:
- case Recurrence::rYearlyDay:
- recurrenceType = RecurrenceChooser::Yearly;
-
- rmd = r->yearNums();
- month = *rmd.first();
- if ( month == event->dtStart().date().month() ) {
- mYearly->setByDay();
- } else {
- mYearly->setByMonth( month );
- }
+ {
+ recurrenceType = RecurrenceChooser::Yearly;
+ qDebug("Recurrence::rYearlyMonth: ");
+ day = event->dtStart().date().day();
+ rmd = r->yearNums();
+ if ( rmd.count() > 0 )
+ month = *rmd.first();
+ else
+ month = event->dtStart().date().month() ;
+ mYearly->setByMonth( month, day );
+#if 0
+ qDebug("2day = %d ",day );
+ QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
+ int month;
+ if ( !monthlist.isEmpty() ) {
+ month = monthlist.first()->rPos ;
+ } else {
+ month = event->dtStart().date().month() ;
+ }
+ mYearly->setByMonth( day, month );
+#endif
+ mYearly->setFrequency( f );
+ }
- mYearly->setFrequency( f );
break;
+ case Recurrence::rYearlyDay:
+ qDebug("Recurrence::rYearlyDay: ");
+ recurrenceType = RecurrenceChooser::Yearly;
+ mYearly->setByDay( event->dtStart().date().dayOfYear() );
+ mYearly->setFrequency( f );
+ break;
default:
@@ -1064,17 +1084,20 @@ void KOEditorRecurrence::writeEvent( Event *event )
} else if ( recurrenceType == RecurrenceChooser::Yearly ) {
+ qDebug("RecurrenceChooser::Yearly ");
int freq = mYearly->frequency();
-
- int month;
- if ( mYearly->byMonth() ) {
- month = mYearly->month();
- } else {
- month = event->dtStart().date().month();
- }
- if ( duration != 0 ) {
- r->setYearly( Recurrence::rYearlyMonth, freq, duration );
+ if ( mYearly->byDay() ) {
+ if ( duration != 0 ) {
+ r->setYearly( Recurrence::rYearlyDay, freq, duration );
+ } else {
+ r->setYearly( Recurrence::rYearlyDay, freq, endDate );
+ }
+ r->addYearlyNum( event->dtStart().date().dayOfYear() );
} else {
- r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
+ if ( duration != 0 ) {
+ r->setYearly( Recurrence::rYearlyMonth, freq, duration );
+ } else {
+ r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
+ }
+ r->addYearlyNum( mYearly->month() );
}
- r->addYearlyNum( month );
}
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
- void setByDay();
- void setByMonth( int month );
+ void setByDay( int doy );
+ void setByMonth( int month, int day );
@@ -118,7 +118,10 @@ class RecurYearly : public RecurBase
int month();
+ int day();
private:
+ int mDay;
QRadioButton *mByMonthRadio;
QComboBox *mByMonthCombo;
-
+ QLabel* mByDayLabel;
+ QLabel* mDayOfLabel;
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
frequ = ICAL_MONTHLY_RECURRENCE;
- interv = 12;
+ interv = 12* r.interval;
}
@@ -1501,2 +1501,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre
if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
+ qDebug(" YEARLY DAY OF YEAR");
if (!icaltime_is_null_time(r.until)) {
@@ -1515,2 +1516,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre
if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
+ qDebug("YEARLY POS NOT SUPPORTED BY GUI");
if (!icaltime_is_null_time(r.until)) {
@@ -1545,2 +1547,3 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre
} else {
+ qDebug("YEARLY MONTH ");
if (!icaltime_is_null_time(r.until)) {
@@ -1554,11 +1557,12 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre
}
- }
- if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
- index = 0;
- while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
- recur->addYearlyNum(day);
+ if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
+ index = 0;
+ while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
+ recur->addYearlyNum(day);
+ }
+ } else {
+ recur->addYearlyNum(incidence->dtStart().date().month());
}
- } else {
- recur->addYearlyNum(incidence->dtStart().date().month());
}
+
}
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)
{
- if (mRecurReadOnly || recurs != rMonthlyDay
+ if (mRecurReadOnly || (recurs != rMonthlyDay && recurs != rYearlyMonth)
|| _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number
@@ -727,3 +727,16 @@ const QPtrList<int> &Recurrence::yearNums() const
}
-
+void Recurrence::addYearlyMonth(short _rPos )
+{
+ if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number
+ return;
+ rMonthPos *tmpPos = new rMonthPos;
+ if ( _rPos > 0) {
+ tmpPos->rPos = _rPos;
+ tmpPos->negative = false;
+ } else {
+ tmpPos->rPos = -_rPos; // take abs()
+ tmpPos->negative = true;
+ }
+ rMonthPositions.append(tmpPos);
+}
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
static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; }
-
+ void addYearlyMonth(short _rPos ); // added LR
/**
@@ -296,2 +296,4 @@ class Recurrence
QString recurrenceText() const;
+ bool getYearlyMonthMonths(int day, QValueList<int>&,
+ QValueList<int> &leaplist) const;
@@ -348,4 +350,2 @@ class Recurrence
bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const;
- bool getYearlyMonthMonths(int day, QValueList<int>&,
- QValueList<int> &leaplist) const;