author | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
commit | cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef (patch) (side-by-side diff) | |
tree | 963322cd4c539c084feb43dfde5eabe52ae4385f /korganizer | |
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 | 95 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 9 |
2 files changed, 65 insertions, 39 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 98356fe..ffc0fac 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -301,22 +301,19 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : QButtonGroup *buttonGroup = new QButtonGroup( this ); buttonGroup->setFrameStyle( QFrame::NoFrame ); topLayout->addWidget( buttonGroup, 1, AlignVCenter ); - QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); + QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); - QString recurInMonthText; - if ( !KOPrefs::instance()->mCompactDialogs ) { - recurInMonthText = i18n("Recur in the month of"); - } - - mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); - buttonLayout->addWidget( mByMonthRadio, 0, 0 ); + 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 ); mByMonthCombo->insertItem( i18n("January") ); mByMonthCombo->insertItem( i18n("February") ); mByMonthCombo->insertItem( i18n("March") ); mByMonthCombo->insertItem( i18n("April") ); mByMonthCombo->insertItem( i18n("May") ); @@ -324,38 +321,36 @@ RecurYearly::RecurYearly( QWidget *parent, const char *name ) : mByMonthCombo->insertItem( i18n("July") ); mByMonthCombo->insertItem( i18n("August") ); mByMonthCombo->insertItem( i18n("September") ); mByMonthCombo->insertItem( i18n("October") ); mByMonthCombo->insertItem( i18n("November") ); mByMonthCombo->insertItem( i18n("December") ); - buttonLayout->addWidget( mByMonthCombo, 0, 1 ); - + buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); + if ( QApplication::desktop()->width() <= 640 ) { 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 ); + 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 ) { mByMonthRadio->setChecked( true ); mByMonthCombo->setCurrentItem( month - 1 ); + mByDayLabel->setText(i18n("%1 of ").arg( day ) ); + mDay = day; } bool RecurYearly::byMonth() { return mByMonthRadio->isChecked(); } @@ -366,12 +361,16 @@ bool RecurYearly::byDay() } int RecurYearly::month() { return mByMonthCombo->currentItem() + 1; } +int RecurYearly::day() +{ + return mDay;//mByDayCombo->currentItem() + 1; +} //////////////////////////// ExceptionsWidget ////////////////////////// ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { @@ -841,12 +840,13 @@ void KOEditorRecurrence::setEnabled( bool enabled ) mTimeGroupBox->setEnabled( enabled ); if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); + mRuleBox->setEnabled( enabled ); } void KOEditorRecurrence::showCurrentRule( int current ) { switch ( current ) { case Daily: @@ -892,23 +892,25 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 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(); + mYearly->setByDay( from.date().dayOfYear() ); + mYearly->setByMonth( from.date().month(), from.date().day() ); } void KOEditorRecurrence::readEvent(Event *event) { + setDefaults( event->dtStart(), event->dtEnd(), true ); QBitArray rDays( 7 ); QPtrList<Recurrence::rMonthPos> rmp; QPtrList<int> rmd; int day = 0; int count = 0; int month = 0; @@ -963,23 +965,41 @@ void KOEditorRecurrence::readEvent(Event *event) mMonthly->setByDay( day ); mMonthly->setFrequency( f ); break; case Recurrence::rYearlyMonth: - case Recurrence::rYearlyDay: + { recurrenceType = RecurrenceChooser::Yearly; - + qDebug("Recurrence::rYearlyMonth: "); + day = event->dtStart().date().day(); rmd = r->yearNums(); + if ( rmd.count() > 0 ) month = *rmd.first(); - if ( month == event->dtStart().date().month() ) { - mYearly->setByDay(); + 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 { - mYearly->setByMonth( month ); + month = event->dtStart().date().month() ; + } + mYearly->setByMonth( day, month ); +#endif + mYearly->setFrequency( f ); } + break; + case Recurrence::rYearlyDay: + qDebug("Recurrence::rYearlyDay: "); + recurrenceType = RecurrenceChooser::Yearly; + mYearly->setByDay( event->dtStart().date().dayOfYear() ); mYearly->setFrequency( f ); break; default: setDefaults( event->dtStart(), event->dtEnd(), true ); break; } @@ -1059,27 +1079,30 @@ void KOEditorRecurrence::writeEvent( Event *event ) } else { r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); } r->addMonthlyDay( day ); } } else if ( recurrenceType == RecurrenceChooser::Yearly ) { + qDebug("RecurrenceChooser::Yearly "); int freq = mYearly->frequency(); - - int month; - if ( mYearly->byMonth() ) { - month = mYearly->month(); + if ( mYearly->byDay() ) { + if ( duration != 0 ) { + r->setYearly( Recurrence::rYearlyDay, freq, duration ); } else { - month = event->dtStart().date().month(); + r->setYearly( Recurrence::rYearlyDay, freq, endDate ); } + r->addYearlyNum( event->dtStart().date().dayOfYear() ); + } else { if ( duration != 0 ) { r->setYearly( Recurrence::rYearlyMonth, freq, duration ); } else { r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); } + r->addYearlyNum( mYearly->month() ); + } - r->addYearlyNum( month ); } event->setExDates( mExceptions->dates() ); } } diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index 4f0f0b2..2b59085 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h @@ -106,24 +106,27 @@ class RecurMonthly : public RecurBase class RecurYearly : public RecurBase { public: RecurYearly( QWidget *parent = 0, const char *name = 0 ); - void setByDay(); - void setByMonth( int month ); + void setByDay( int doy ); + void setByMonth( int month, int day ); bool byMonth(); bool byDay(); int month(); + int day(); private: + int mDay; QRadioButton *mByMonthRadio; QComboBox *mByMonthCombo; - + QLabel* mByDayLabel; + QLabel* mDayOfLabel; QRadioButton *mByDayRadio; }; class RecurrenceChooser : public QWidget { Q_OBJECT |