00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qtooltip.h>
00025 #include <qfiledialog.h>
00026 #include <qlayout.h>
00027 #include <qvbox.h>
00028 #include <qbuttongroup.h>
00029 #include <qvgroupbox.h>
00030 #include <qwidgetstack.h>
00031 #include <qdatetime.h>
00032 #include <qlistbox.h>
00033 #include <qspinbox.h>
00034 #include <qcheckbox.h>
00035 #include <qgroupbox.h>
00036 #include <qwidgetstack.h>
00037 #include <qradiobutton.h>
00038 #include <qlabel.h>
00039 #include <qpushbutton.h>
00040
00041 #include <kdialog.h>
00042 #include <kglobal.h>
00043 #include <klocale.h>
00044 #include <kiconloader.h>
00045 #include <kdebug.h>
00046 #include <knumvalidator.h>
00047 #include <kcalendarsystem.h>
00048 #include <kmessagebox.h>
00049
00050 #include <libkdepim/kdateedit.h>
00051 #include <libkcal/todo.h>
00052
00053 #include "koprefs.h"
00054 #include "koglobals.h"
00055
00056 #include "koeditorrecurrence.h"
00057 #include "koeditorrecurrence.moc"
00058
00060
00061 RecurBase::RecurBase( QWidget *parent, const char *name ) :
00062 QWidget( parent, name )
00063 {
00064 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
00065 mFrequencyEdit->setValue( 1 );
00066 }
00067
00068 QWidget *RecurBase::frequencyEdit()
00069 {
00070 return mFrequencyEdit;
00071 }
00072
00073 void RecurBase::setFrequency( int f )
00074 {
00075 if ( f < 1 ) f = 1;
00076
00077 mFrequencyEdit->setValue( f );
00078 }
00079
00080 int RecurBase::frequency()
00081 {
00082 return mFrequencyEdit->value();
00083 }
00084
00085 QComboBox *RecurBase::createWeekCountCombo( QWidget *parent, const char *name )
00086 {
00087 QComboBox *combo = new QComboBox( parent, name );
00088 if ( !combo ) return 0;
00089 combo->insertItem( i18n("1st") );
00090 combo->insertItem( i18n("2nd") );
00091 combo->insertItem( i18n("3rd") );
00092 combo->insertItem( i18n("4th") );
00093 combo->insertItem( i18n("5th") );
00094 combo->insertItem( i18n("Last") );
00095 combo->insertItem( i18n("2nd Last") );
00096 combo->insertItem( i18n("3rd Last") );
00097 combo->insertItem( i18n("4th Last") );
00098 combo->insertItem( i18n("5th Last") );
00099 return combo;
00100 }
00101
00102 QComboBox *RecurBase::createWeekdayCombo( QWidget *parent, const char *name )
00103 {
00104 QComboBox *combo = new QComboBox( parent, name );
00105 if ( !combo ) return 0;
00106 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00107 for( int i = 1; i <= 7; ++i ) {
00108 combo->insertItem( calSys->weekDayName( i ) );
00109 }
00110 return combo;
00111 }
00112
00113 QComboBox *RecurBase::createMonthNameCombo( QWidget *parent, const char *name )
00114 {
00115 QComboBox *combo = new QComboBox( parent, name );
00116 if ( !combo ) return 0;
00117 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00118 for( int i = 1; i <= 12; ++i ) {
00119
00120 QDate dt( 2005, i, 1 );
00121 combo->insertItem( calSys->monthName( dt ) );
00122 }
00123 return combo;
00124 }
00125
00126 QBoxLayout *RecurBase::createFrequencySpinBar( QWidget *parent, QLayout *layout,
00127 QString everyText, QString unitText )
00128 {
00129 QBoxLayout *freqLayout = new QHBoxLayout( layout );
00130
00131 QLabel *preLabel = new QLabel( everyText, parent );
00132 freqLayout->addWidget( preLabel );
00133
00134 freqLayout->addWidget( frequencyEdit() );
00135 preLabel->setBuddy( frequencyEdit() );
00136
00137 QLabel *postLabel = new QLabel( unitText, parent );
00138 freqLayout->addWidget( postLabel );
00139 freqLayout->addStretch();
00140 return freqLayout;
00141 }
00142
00144
00145 RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
00146 RecurBase( parent, name )
00147 {
00148 QBoxLayout *topLayout = new QVBoxLayout( this );
00149 topLayout->setSpacing( KDialog::spacingHint() );
00150
00151 createFrequencySpinBar( this, topLayout, i18n("&Recur every"), i18n("day(s)") );
00152 }
00153
00154
00156
00157 RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) :
00158 RecurBase( parent, name )
00159 {
00160 QBoxLayout *topLayout = new QVBoxLayout( this );
00161 topLayout->setSpacing( KDialog::spacingHint() );
00162
00163
00164
00165 createFrequencySpinBar( this, topLayout, i18n("&Recur every"), i18n("week(s) on:") );
00166
00167 QHBox *dayBox = new QHBox( this );
00168 topLayout->addWidget( dayBox, 1, AlignVCenter );
00169
00170 int weekStart=KGlobal::locale()->weekStartDay();
00171 for ( int i = 0; i < 7; ++i ) {
00172
00173
00174
00175 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00176 QString weekDayName = calSys->weekDayName(
00177 (i + weekStart + 6)%7 + 1, true );
00178 if ( KOPrefs::instance()->mCompactDialogs ) {
00179 weekDayName = weekDayName.left( 1 );
00180 }
00181 mDayBoxes[ (i + weekStart + 6)%7 ] = new QCheckBox( weekDayName, dayBox );
00182 }
00183
00184 topLayout->addStretch( 1 );
00185 }
00186
00187 void RecurWeekly::setDays( const QBitArray &days )
00188 {
00189 for ( int i = 0; i < 7; ++i ) {
00190 mDayBoxes[ i ]->setChecked( days.testBit( i ) );
00191 }
00192 }
00193
00194 QBitArray RecurWeekly::days()
00195 {
00196 QBitArray days( 7 );
00197
00198 for ( int i = 0; i < 7; ++i ) {
00199 days.setBit( i, mDayBoxes[ i ]->isChecked() );
00200 }
00201
00202 return days;
00203 }
00204
00206
00207 RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) :
00208 RecurBase( parent, name )
00209 {
00210 QBoxLayout *topLayout = new QVBoxLayout( this );
00211 topLayout->setSpacing( KDialog::spacingHint() );
00212
00213 createFrequencySpinBar( this, topLayout, i18n("&Recur every"), i18n("month(s)") );
00214
00215 QButtonGroup *buttonGroup = new QButtonGroup( this );
00216 buttonGroup->setFrameStyle( QFrame::NoFrame );
00217 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
00218
00219 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
00220 buttonLayout->setSpacing( KDialog::spacingHint() );
00221
00222
00223 QString recurOnText;
00224 if ( !KOPrefs::instance()->mCompactDialogs ) {
00225 recurOnText = i18n("&Recur on the");
00226 }
00227
00228 mByDayRadio = new QRadioButton( recurOnText, buttonGroup );
00229 buttonLayout->addWidget( mByDayRadio, 0, 0 );
00230
00231 mByDayCombo = new QComboBox( buttonGroup );
00232 mByDayCombo->setSizeLimit( 7 );
00233 mByDayCombo->insertItem( i18n("1st") );
00234 mByDayCombo->insertItem( i18n("2nd") );
00235 mByDayCombo->insertItem( i18n("3rd") );
00236 mByDayCombo->insertItem( i18n("4th") );
00237 mByDayCombo->insertItem( i18n("5th") );
00238 mByDayCombo->insertItem( i18n("6th") );
00239 mByDayCombo->insertItem( i18n("7th") );
00240 mByDayCombo->insertItem( i18n("8th") );
00241 mByDayCombo->insertItem( i18n("9th") );
00242 mByDayCombo->insertItem( i18n("10th") );
00243 mByDayCombo->insertItem( i18n("11th") );
00244 mByDayCombo->insertItem( i18n("12th") );
00245 mByDayCombo->insertItem( i18n("13th") );
00246 mByDayCombo->insertItem( i18n("14th") );
00247 mByDayCombo->insertItem( i18n("15th") );
00248 mByDayCombo->insertItem( i18n("16th") );
00249 mByDayCombo->insertItem( i18n("17th") );
00250 mByDayCombo->insertItem( i18n("18th") );
00251 mByDayCombo->insertItem( i18n("19th") );
00252 mByDayCombo->insertItem( i18n("20th") );
00253 mByDayCombo->insertItem( i18n("21st") );
00254 mByDayCombo->insertItem( i18n("22nd") );
00255 mByDayCombo->insertItem( i18n("23rd") );
00256 mByDayCombo->insertItem( i18n("24th") );
00257 mByDayCombo->insertItem( i18n("25th") );
00258 mByDayCombo->insertItem( i18n("26th") );
00259 mByDayCombo->insertItem( i18n("27th") );
00260 mByDayCombo->insertItem( i18n("28th") );
00261 mByDayCombo->insertItem( i18n("29th") );
00262 mByDayCombo->insertItem( i18n("30th") );
00263 mByDayCombo->insertItem( i18n("31st") );
00264 buttonLayout->addWidget( mByDayCombo, 0, 1 );
00265
00266 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup );
00267 buttonLayout->addWidget( byDayLabel, 0, 2 );
00268
00269
00270 mByPosRadio = new QRadioButton( recurOnText, buttonGroup);
00271 buttonLayout->addWidget( mByPosRadio, 1, 0 );
00272
00273 mByPosCountCombo = createWeekCountCombo( buttonGroup );
00274 buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
00275
00276 mByPosWeekdayCombo = createWeekdayCombo( buttonGroup );
00277 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 );
00278 }
00279
00280 void RecurMonthly::setByDay( int day )
00281 {
00282 mByDayRadio->setChecked( true );
00283 mByDayCombo->setCurrentItem( day-1 );
00284 }
00285
00286 void RecurMonthly::setByPos( int count, int weekday )
00287 {
00288 mByPosRadio->setChecked( true );
00289 if (count>0)
00290 mByPosCountCombo->setCurrentItem( count - 1 );
00291 else
00292
00293 mByPosCountCombo->setCurrentItem( -count + 4 );
00294 mByPosWeekdayCombo->setCurrentItem( weekday );
00295 }
00296
00297 bool RecurMonthly::byDay()
00298 {
00299 return mByDayRadio->isChecked();
00300 }
00301
00302 bool RecurMonthly::byPos()
00303 {
00304 return mByPosRadio->isChecked();
00305 }
00306
00307 int RecurMonthly::day()
00308 {
00309 return mByDayCombo->currentItem() + 1;
00310 }
00311
00312 int RecurMonthly::count()
00313 {
00314 int pos=mByPosCountCombo->currentItem();
00315 if (pos<=4)
00316 return pos+1;
00317 else
00318 return -pos+4;
00319 }
00320
00321 int RecurMonthly::weekday()
00322 {
00323 return mByPosWeekdayCombo->currentItem();
00324 }
00325
00327
00328 RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
00329 RecurBase( parent, name )
00330 {
00331 QBoxLayout *topLayout = new QVBoxLayout( this );
00332 topLayout->setSpacing( KDialog::spacingHint() );
00333
00334 createFrequencySpinBar( this, topLayout, i18n("&Recur every"), i18n("year(s)") );
00335
00336
00337 QButtonGroup *buttonGroup = new QButtonGroup( this );
00338 buttonGroup->setFrameStyle( QFrame::NoFrame );
00339 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
00340
00341 QBoxLayout *buttonLayout = new QVBoxLayout( buttonGroup );
00342
00343
00344
00345 QBoxLayout *monthLayout = new QHBoxLayout( buttonLayout );
00346 QString recurInMonthText(
00347 i18n("part before XXX of 'Recur on day XXX of month YYY'",
00348 "&Recur on day "));
00349 if ( KOPrefs::instance()->mCompactDialogs ) {
00350 recurInMonthText = i18n("&Day ");
00351 }
00352 mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup );
00353 monthLayout->addWidget( mByMonthRadio );
00354 mByMonthSpin = new QSpinBox( 1, 31, 1, buttonGroup );
00355 monthLayout->addWidget( mByMonthSpin );
00356 QLabel *ofLabel = new QLabel(
00357 i18n("part between XXX and YYY of 'Recur on day XXX of month YYY'", " &of "),
00358 buttonGroup );
00359 monthLayout->addWidget( ofLabel );
00360
00361 mByMonthCombo = createMonthNameCombo( buttonGroup );
00362 monthLayout->addWidget( mByMonthCombo );
00363 ofLabel->setBuddy( mByMonthCombo );
00364
00365 monthLayout->addStretch( 1 );
00366
00367
00368
00369 QBoxLayout *posLayout = new QHBoxLayout( buttonLayout );
00370 QString recurOnPosText( i18n("Part before XXX in 'Recur on NNN. WEEKDAY of MONTH', short version", "&On" ) );
00371 if ( !KOPrefs::instance()->mCompactDialogs ) {
00372 recurOnPosText = i18n("Part before XXX in 'Recur on NNN. WEEKDAY of MONTH'", "&On the" );
00373 }
00374 mByPosRadio = new QRadioButton( recurOnPosText, buttonGroup );
00375 posLayout->addWidget( mByPosRadio );
00376
00377 mByPosDayCombo = createWeekCountCombo( buttonGroup );
00378 posLayout->addWidget( mByPosDayCombo );
00379
00380 mByPosWeekdayCombo = createWeekdayCombo( buttonGroup );
00381 posLayout->addWidget( mByPosWeekdayCombo );
00382
00383 ofLabel = new QLabel(
00384 i18n("part between WEEKDAY and MONTH in 'Recur on NNN. WEEKDAY of MONTH'", " o&f "),
00385 buttonGroup );
00386 posLayout->addWidget( ofLabel );
00387
00388 mByPosMonthCombo = createMonthNameCombo( buttonGroup );
00389 posLayout->addWidget( mByPosMonthCombo );
00390 ofLabel->setBuddy( mByPosMonthCombo );
00391
00392 posLayout->addStretch( 1 );
00393
00394
00395
00396 QBoxLayout *dayLayout = new QHBoxLayout( buttonLayout );
00397 QString recurOnDayText;
00398 if ( KOPrefs::instance()->mCompactDialogs ) {
00399 recurOnDayText = i18n("Day #");
00400 } else {
00401 recurOnDayText = i18n("Recur on &day #");
00402 }
00403 mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup );
00404 dayLayout->addWidget( mByDayRadio );
00405
00406 mByDaySpin = new QSpinBox( 1, 366, 1, buttonGroup );
00407 dayLayout->addWidget( mByDaySpin );
00408
00409 QString ofTheYear( i18n("part after NNN of 'Recur on day #NNN of the year'", " of the &year"));
00410 if ( KOPrefs::instance()->mCompactDialogs ) {
00411 ofTheYear = i18n("part after NNN of 'Recur on day #NNN of the year', short version",
00412 " of the year");
00413 }
00414 ofLabel = new QLabel( ofTheYear, buttonGroup );
00415 dayLayout->addWidget( ofLabel );
00416 ofLabel->setBuddy( mByDaySpin );
00417
00418 dayLayout->addStretch( 1 );
00419 }
00420
00421 void RecurYearly::setByDay( int day )
00422 {
00423 mByDayRadio->setChecked( true );
00424 mByDaySpin->setValue( day );
00425 }
00426
00427 void RecurYearly::setByPos( int count, int weekday, int month )
00428 {
00429 mByPosRadio->setChecked( true );
00430 if ( count > 0 )
00431 mByPosDayCombo->setCurrentItem( count - 1 );
00432 else
00433 mByPosDayCombo->setCurrentItem( -count + 4 );
00434 mByPosWeekdayCombo->setCurrentItem( weekday );
00435 mByPosMonthCombo->setCurrentItem( month-1 );
00436 }
00437
00438 void RecurYearly::setByMonth( int day, int month )
00439 {
00440 mByMonthRadio->setChecked( true );
00441 mByMonthSpin->setValue( day );
00442 mByMonthCombo->setCurrentItem( month - 1 );
00443 }
00444
00445 RecurYearly::YearlyType RecurYearly::getType()
00446 {
00447 if ( mByMonthRadio->isChecked() ) return byMonth;
00448 if ( mByPosRadio->isChecked() ) return byPos;
00449 if ( mByDayRadio->isChecked() ) return byDay;
00450 return byMonth;
00451 }
00452
00453 int RecurYearly::monthDay()
00454 {
00455 return mByMonthSpin->value();
00456 }
00457
00458 int RecurYearly::month()
00459 {
00460 return mByMonthCombo->currentItem() + 1;
00461 }
00462
00463 int RecurYearly::posCount()
00464 {
00465 int pos = mByPosDayCombo->currentItem();
00466 if ( pos <= 4 )
00467 return pos + 1;
00468 else
00469 return -pos + 4;
00470 }
00471
00472 int RecurYearly::posWeekday()
00473 {
00474 return mByPosWeekdayCombo->currentItem();
00475 }
00476
00477 int RecurYearly::posMonth()
00478 {
00479 return mByPosMonthCombo->currentItem() + 1;
00480 }
00481
00482 int RecurYearly::day()
00483 {
00484 return mByDaySpin->value();
00485 }
00486
00488
00489 ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
00490 QWidget( parent, name )
00491 {
00492 QBoxLayout *topLayout = new QVBoxLayout( this );
00493
00494 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("E&xceptions"),
00495 this );
00496 topLayout->addWidget( groupBox );
00497
00498 QWidget *box = new QWidget( groupBox );
00499
00500 QGridLayout *boxLayout = new QGridLayout( box );
00501
00502 mExceptionDateEdit = new KDateEdit( box );
00503 mExceptionDateEdit->setDate( QDate::currentDate() );
00504 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
00505
00506 QPushButton *addExceptionButton = new QPushButton( i18n("&Add"), box );
00507 boxLayout->addWidget( addExceptionButton, 1, 0 );
00508 QPushButton *changeExceptionButton = new QPushButton( i18n("&Change"), box );
00509 boxLayout->addWidget( changeExceptionButton, 2, 0 );
00510 QPushButton *deleteExceptionButton = new QPushButton( i18n("&Delete"), box );
00511 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
00512
00513 mExceptionList = new QListBox( box );
00514 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
00515
00516 boxLayout->setRowStretch( 4, 1 );
00517 boxLayout->setColStretch( 1, 3 );
00518
00519 connect( addExceptionButton, SIGNAL( clicked() ),
00520 SLOT( addException() ) );
00521 connect( changeExceptionButton, SIGNAL( clicked() ),
00522 SLOT( changeException() ) );
00523 connect( deleteExceptionButton, SIGNAL( clicked() ),
00524 SLOT( deleteException() ) );
00525 }
00526
00527 void ExceptionsWidget::addException()
00528 {
00529 QDate date = mExceptionDateEdit->date();
00530 QString dateStr = KGlobal::locale()->formatDate( date );
00531 if( !mExceptionList->findItem( dateStr ) ) {
00532 mExceptionDates.append( date );
00533 mExceptionList->insertItem( dateStr );
00534 }
00535 }
00536
00537 void ExceptionsWidget::changeException()
00538 {
00539 int pos = mExceptionList->currentItem();
00540 if ( pos < 0 ) return;
00541
00542 QDate date = mExceptionDateEdit->date();
00543 mExceptionDates[ pos ] = date;
00544 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
00545 }
00546
00547 void ExceptionsWidget::deleteException()
00548 {
00549 int pos = mExceptionList->currentItem();
00550 if ( pos < 0 ) return;
00551
00552 mExceptionDates.remove( mExceptionDates.at( pos ) );
00553 mExceptionList->removeItem( pos );
00554 }
00555
00556 void ExceptionsWidget::setDates( const DateList &dates )
00557 {
00558 mExceptionList->clear();
00559 mExceptionDates.clear();
00560 DateList::ConstIterator dit;
00561 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
00562 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
00563 mExceptionDates.append( *dit );
00564 }
00565 }
00566
00567 DateList ExceptionsWidget::dates()
00568 {
00569 return mExceptionDates;
00570 }
00571
00573
00574 ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
00575 KDialogBase( parent, name, true, i18n("Edit Exceptions"), Ok|Cancel )
00576 {
00577 mExceptions = new ExceptionsWidget( this );
00578 setMainWidget( mExceptions );
00579 }
00580
00581 void ExceptionsDialog::setDates( const DateList &dates )
00582 {
00583 mExceptions->setDates( dates );
00584 }
00585
00586 DateList ExceptionsDialog::dates()
00587 {
00588 return mExceptions->dates();
00589 }
00590
00592
00593 RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
00594 const char *name )
00595 : QWidget( parent, name )
00596 {
00597 QBoxLayout *topLayout = new QVBoxLayout( this );
00598
00599 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
00600 this );
00601 topLayout->addWidget( mRangeGroupBox );
00602
00603 QWidget *rangeBox = new QWidget( mRangeGroupBox );
00604 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
00605 rangeLayout->setSpacing( KDialog::spacingHint() );
00606
00607 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
00608 rangeLayout->addWidget( mStartDateLabel );
00609
00610 QButtonGroup *rangeButtonGroup = new QButtonGroup;
00611
00612 mNoEndDateButton = new QRadioButton( i18n("&No ending date"), rangeBox );
00613 rangeButtonGroup->insert( mNoEndDateButton );
00614 rangeLayout->addWidget( mNoEndDateButton );
00615
00616 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
00617 durationLayout->setSpacing( KDialog::spacingHint() );
00618
00619 mEndDurationButton = new QRadioButton( i18n("End &after"), rangeBox );
00620 rangeButtonGroup->insert( mEndDurationButton );
00621 durationLayout->addWidget( mEndDurationButton );
00622
00623 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
00624 durationLayout->addWidget( mEndDurationEdit );
00625
00626 QLabel *endDurationLabel = new QLabel( i18n("&occurrence(s)"), rangeBox );
00627 durationLayout ->addWidget( endDurationLabel );
00628 endDurationLabel->setBuddy( mEndDurationEdit );
00629
00630 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
00631 endDateLayout->setSpacing( KDialog::spacingHint() );
00632
00633 mEndDateButton = new QRadioButton( i18n("End &by:"), rangeBox );
00634 rangeButtonGroup->insert( mEndDateButton );
00635 endDateLayout->addWidget( mEndDateButton );
00636
00637 mEndDateEdit = new KDateEdit( rangeBox );
00638 endDateLayout->addWidget( mEndDateEdit );
00639
00640 endDateLayout->addStretch( 1 );
00641
00642 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
00643 SLOT( showCurrentRange() ) );
00644 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
00645 SLOT( showCurrentRange() ) );
00646 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
00647 SLOT( showCurrentRange() ) );
00648 }
00649
00650 void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
00651 {
00652 mNoEndDateButton->setChecked( true );
00653
00654 setDateTimes( from );
00655 setEndDate( from.date() );
00656 }
00657
00658 void RecurrenceRangeWidget::setDuration( int duration )
00659 {
00660 if ( duration == -1 ) {
00661 mNoEndDateButton->setChecked( true );
00662 } else if ( duration == 0 ) {
00663 mEndDateButton->setChecked( true );
00664 } else {
00665 mEndDurationButton->setChecked( true );
00666 mEndDurationEdit->setValue( duration );
00667 }
00668 }
00669
00670 int RecurrenceRangeWidget::duration()
00671 {
00672 if ( mNoEndDateButton->isChecked() ) {
00673 return -1;
00674 } else if ( mEndDurationButton->isChecked() ) {
00675 return mEndDurationEdit->value();
00676 } else {
00677 return 0;
00678 }
00679 }
00680
00681 void RecurrenceRangeWidget::setEndDate( const QDate &date )
00682 {
00683 mEndDateEdit->setDate( date );
00684 }
00685
00686 QDate RecurrenceRangeWidget::endDate()
00687 {
00688 return mEndDateEdit->date();
00689 }
00690
00691 void RecurrenceRangeWidget::showCurrentRange()
00692 {
00693 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
00694 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
00695 }
00696
00697 void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
00698 const QDateTime & )
00699 {
00700 mStartDateLabel->setText( i18n("Begins on: %1")
00701 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
00702 }
00703
00705
00706 RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
00707 const char *name ) :
00708 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
00709 {
00710 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
00711 setMainWidget( mRecurrenceRangeWidget );
00712 }
00713
00714 void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
00715 {
00716 mRecurrenceRangeWidget->setDefaults( from );
00717 }
00718
00719 void RecurrenceRangeDialog::setDuration( int duration )
00720 {
00721 mRecurrenceRangeWidget->setDuration( duration );
00722 }
00723
00724 int RecurrenceRangeDialog::duration()
00725 {
00726 return mRecurrenceRangeWidget->duration();
00727 }
00728
00729 void RecurrenceRangeDialog::setEndDate( const QDate &date )
00730 {
00731 mRecurrenceRangeWidget->setEndDate( date );
00732 }
00733
00734 QDate RecurrenceRangeDialog::endDate()
00735 {
00736 return mRecurrenceRangeWidget->endDate();
00737 }
00738
00739 void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
00740 const QDateTime &end )
00741 {
00742 mRecurrenceRangeWidget->setDateTimes( start, end );
00743 }
00744
00746
00747 RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
00748 QWidget( parent, name )
00749 {
00750 QBoxLayout *topLayout = new QVBoxLayout( this );
00751
00752 if ( KOPrefs::instance()->mCompactDialogs ) {
00753 mTypeCombo = new QComboBox( this );
00754 mTypeCombo->insertItem( i18n("Daily") );
00755 mTypeCombo->insertItem( i18n("Weekly") );
00756 mTypeCombo->insertItem( i18n("Monthly") );
00757 mTypeCombo->insertItem( i18n("Yearly") );
00758
00759 topLayout->addWidget( mTypeCombo );
00760
00761 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
00762 } else {
00763 mTypeCombo = 0;
00764
00765 QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this );
00766 ruleButtonGroup->setFrameStyle( QFrame::NoFrame );
00767 topLayout->addWidget( ruleButtonGroup );
00768
00769 mDailyButton = new QRadioButton( i18n("&Daily"), ruleButtonGroup );
00770 mWeeklyButton = new QRadioButton( i18n("&Weekly"), ruleButtonGroup );
00771 mMonthlyButton = new QRadioButton( i18n("&Monthly"), ruleButtonGroup );
00772 mYearlyButton = new QRadioButton( i18n("&Yearly"), ruleButtonGroup );
00773
00774 connect( mDailyButton, SIGNAL( toggled( bool ) ),
00775 SLOT( emitChoice() ) );
00776 connect( mWeeklyButton, SIGNAL( toggled( bool ) ),
00777 SLOT( emitChoice() ) );
00778 connect( mMonthlyButton, SIGNAL( toggled( bool ) ),
00779 SLOT( emitChoice() ) );
00780 connect( mYearlyButton, SIGNAL( toggled( bool ) ),
00781 SLOT( emitChoice() ) );
00782 }
00783 }
00784
00785 int RecurrenceChooser::type()
00786 {
00787 if ( mTypeCombo ) {
00788 return mTypeCombo->currentItem();
00789 } else {
00790 if ( mDailyButton->isChecked() ) return Daily;
00791 else if ( mWeeklyButton->isChecked() ) return Weekly;
00792 else if ( mMonthlyButton->isChecked() ) return Monthly;
00793 else return Yearly;
00794 }
00795 }
00796
00797 void RecurrenceChooser::setType( int type )
00798 {
00799 if ( mTypeCombo ) {
00800 mTypeCombo->setCurrentItem( type );
00801 } else {
00802 switch ( type ) {
00803 case Daily:
00804 mDailyButton->setChecked( true );
00805 break;
00806 case Weekly:
00807 mWeeklyButton->setChecked( true );
00808 break;
00809 case Monthly:
00810 mMonthlyButton->setChecked( true );
00811 break;
00812 case Yearly:
00813 default:
00814 mYearlyButton->setChecked( true );
00815 break;
00816 }
00817 }
00818 }
00819
00820 void RecurrenceChooser::emitChoice()
00821 {
00822 emit chosen ( type() );
00823 }
00824
00826
00827 KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
00828 QWidget( parent, name )
00829 {
00830 QGridLayout *topLayout = new QGridLayout( this );
00831 topLayout->setSpacing( KDialog::spacingHint() );
00832
00833 mEnabledCheck = new QCheckBox( i18n("&Enable recurrence"), this );
00834 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
00835 SLOT( setRecurrenceEnabled( bool ) ) );
00836 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
00837
00838
00839 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "),
00840 this );
00841 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
00842
00843 if ( KOPrefs::instance()->mCompactDialogs ) {
00844 mTimeGroupBox->hide();
00845 }
00846
00847
00848
00849
00850
00851 mDateTimeLabel = new QLabel( mTimeGroupBox );
00852
00853
00854
00855 Qt::Orientation orientation;
00856 if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal;
00857 else orientation = Vertical;
00858
00859 mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this );
00860 if ( KOPrefs::instance()->mCompactDialogs ) {
00861 topLayout->addWidget( mRuleBox, 2, 0 );
00862 } else {
00863 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
00864 }
00865
00866 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
00867 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
00868 SLOT( showCurrentRule( int ) ) );
00869
00870 if ( !KOPrefs::instance()->mCompactDialogs ) {
00871 QFrame *ruleSepFrame = new QFrame( mRuleBox );
00872 ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken );
00873 }
00874
00875 mRuleStack = new QWidgetStack( mRuleBox );
00876
00877 mDaily = new RecurDaily( mRuleStack );
00878 mRuleStack->addWidget( mDaily, 0 );
00879
00880 mWeekly = new RecurWeekly( mRuleStack );
00881 mRuleStack->addWidget( mWeekly, 0 );
00882
00883 mMonthly = new RecurMonthly( mRuleStack );
00884 mRuleStack->addWidget( mMonthly, 0 );
00885
00886 mYearly = new RecurYearly( mRuleStack );
00887 mRuleStack->addWidget( mYearly, 0 );
00888
00889 showCurrentRule( mRecurrenceChooser->type() );
00890
00891 if ( KOPrefs::instance()->mCompactDialogs ) {
00892 mRecurrenceRangeWidget = 0;
00893 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
00894 mRecurrenceRange = mRecurrenceRangeDialog;
00895 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
00896 this );
00897 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
00898 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
00899 SLOT( showRecurrenceRangeDialog() ) );
00900
00901 mExceptionsWidget = 0;
00902 mExceptionsDialog = new ExceptionsDialog( this );
00903 mExceptions = mExceptionsDialog;
00904 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
00905 topLayout->addWidget( mExceptionsButton, 4, 0 );
00906 connect( mExceptionsButton, SIGNAL( clicked() ),
00907 SLOT( showExceptionsDialog() ) );
00908
00909 } else {
00910 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
00911 mRecurrenceRangeDialog = 0;
00912 mRecurrenceRange = mRecurrenceRangeWidget;
00913 mRecurrenceRangeButton = 0;
00914 topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 );
00915
00916 mExceptionsWidget = new ExceptionsWidget( this );
00917 mExceptionsDialog = 0;
00918 mExceptions = mExceptionsWidget;
00919 mExceptionsButton = 0;
00920 topLayout->addWidget( mExceptionsWidget, 3, 1 );
00921 }
00922 }
00923
00924 KOEditorRecurrence::~KOEditorRecurrence()
00925 {
00926 }
00927
00928 void KOEditorRecurrence::setRecurrenceEnabled( bool enabled )
00929 {
00930
00931
00932 mTimeGroupBox->setEnabled( enabled );
00933 mRuleBox->setEnabled( enabled );
00934 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
00935 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
00936 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
00937 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
00938 }
00939
00940 void KOEditorRecurrence::showCurrentRule( int current )
00941 {
00942 switch ( current ) {
00943 case Daily:
00944 mRuleStack->raiseWidget( mDaily );
00945 break;
00946 case Weekly:
00947 mRuleStack->raiseWidget( mWeekly );
00948 break;
00949 case Monthly:
00950 mRuleStack->raiseWidget( mMonthly );
00951 break;
00952 default:
00953 case Yearly:
00954 mRuleStack->raiseWidget( mYearly );
00955 break;
00956 }
00957 }
00958
00959 void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
00960 {
00961
00962
00963 mEventStartDt = start;
00964 mRecurrenceRange->setDateTimes( start, end );
00965 mDaily->setDateTimes( start, end );
00966 mWeekly->setDateTimes( start, end );
00967 mMonthly->setDateTimes( start, end );
00968 mYearly->setDateTimes( start, end );
00969 }
00970
00971 void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
00972 {
00973 setDateTimes( from, to );
00974
00975 bool enabled = false;
00976 mEnabledCheck->setChecked( enabled );
00977 setRecurrenceEnabled( enabled );
00978
00979 mRecurrenceRange->setDefaults( from );
00980
00981 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
00982 showCurrentRule( mRecurrenceChooser->type() );
00983
00984 mDaily->setFrequency( 1 );
00985
00986 mWeekly->setFrequency( 1 );
00987 QBitArray days( 7 );
00988 days.fill( 0 );
00989 days.setBit( (from.date().dayOfWeek()+6) % 7 );
00990 mWeekly->setDays( days );
00991
00992 mMonthly->setFrequency( 1 );
00993 mMonthly->setByPos( ( from.date().day() - 1 ) / 7 + 1, from.date().dayOfWeek() - 1 );
00994 mMonthly->setByDay( from.date().day() );
00995
00996 mYearly->setFrequency( 1 );
00997 mYearly->setByDay( from.date().dayOfYear() );
00998 mYearly->setByPos( ( from.date().day() - 1 ) / 7 + 1,
00999 from.date().dayOfWeek() - 1, from.date().month() );
01000 mYearly->setByMonth( from.date().day(), from.date().month() );
01001 }
01002
01003 void KOEditorRecurrence::readIncidence(Incidence *incidence)
01004 {
01005 if (!incidence) return;
01006
01007 QBitArray rDays( 7 );
01008 QPtrList<Recurrence::rMonthPos> rmp;
01009 QPtrList<int> rmd;
01010 int day = 0;
01011 int count = 0;
01012 int month = 0;
01013
01014 if ( incidence->type() == "Todo" ) {
01015 Todo *todo = static_cast<Todo *>(incidence);
01016 setDefaults( todo->dtStart(true), todo->dtDue(), todo->doesFloat() );
01017 } else {
01018 setDefaults( incidence->dtStart(), incidence->dtEnd(), incidence->doesFloat() );
01019 }
01020
01021 int recurs = incidence->doesRecur();
01022 int f = 0;
01023 Recurrence *r = 0;
01024
01025 if ( recurs )
01026 {
01027 r = incidence->recurrence();
01028 f = r->frequency();
01029 }
01030
01031
01032 mEnabledCheck->setChecked( recurs );
01033 setRecurrenceEnabled( recurs );
01034
01035 int recurrenceType = RecurrenceChooser::Weekly;
01036
01037 switch ( recurs ) {
01038 case Recurrence::rNone:
01039 break;
01040 case Recurrence::rDaily:
01041 recurrenceType = RecurrenceChooser::Daily;
01042 mDaily->setFrequency( f );
01043 break;
01044 case Recurrence::rWeekly:
01045 recurrenceType = RecurrenceChooser::Weekly;
01046 mWeekly->setFrequency( f );
01047 mWeekly->setDays( r->days() );
01048 break;
01049 case Recurrence::rMonthlyPos:
01050
01051
01052
01053 recurrenceType = RecurrenceChooser::Monthly;
01054
01055 rmp = r->monthPositions();
01056 if ( rmp.first()->negative )
01057 count=-rmp.first()->rPos;
01058 else
01059
01060 count = rmp.first()->rPos;
01061 day = 0;
01062 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
01063 mMonthly->setByPos( count, day );
01064
01065 mMonthly->setFrequency( f );
01066
01067 break;
01068 case Recurrence::rMonthlyDay:
01069 recurrenceType = RecurrenceChooser::Monthly;
01070
01071 rmd = r->monthDays();
01072
01073
01074 if ( rmd.first() ) {
01075 day = *rmd.first();
01076 } else {
01077 day = incidence->dtStart().date().day();
01078 }
01079 mMonthly->setByDay( day );
01080
01081 mMonthly->setFrequency( f );
01082
01083 break;
01084 case Recurrence::rYearlyMonth: {
01085 recurrenceType = RecurrenceChooser::Yearly;
01086 rmd = r->monthDays();
01087 if ( rmd.first() ) {
01088 day = *rmd.first();
01089 } else {
01090 day = incidence->dtStart().date().day();
01091 }
01092 QValueList<int> monthlist;
01093 QValueList<int> leaplist;
01094 r->getYearlyMonthMonths( day, monthlist, leaplist );
01095 if ( !monthlist.isEmpty() ) {
01096 mYearly->setByMonth( day, monthlist.first() );
01097 }
01098 mYearly->setFrequency( f );
01099 break; }
01100 case Recurrence::rYearlyPos: {
01101 recurrenceType = RecurrenceChooser::Yearly;
01102 rmd = r->yearNums();
01103 if ( rmd.first() ) {
01104 month = *rmd.first();
01105 } else {
01106 month = incidence->dtStart().date().month();
01107 }
01108
01109 QPtrList<Recurrence::rMonthPos> monthPos( r->yearMonthPositions() );
01110 if ( monthPos.first() ) {
01111 Recurrence::rMonthPos *mp = monthPos.first();
01112 count = mp->rPos;
01113 if ( mp->negative ) count = -count;
01114 QBitArray days( mp->rDays );
01115 day = -1;
01116 for ( int i=6; i>=0; i-- ) {
01117 if ( days.testBit(i) ) day = i;
01118 }
01119 if ( day == -1 )
01120 day = incidence->dtStart().date().dayOfWeek();
01121 } else {
01122 count = ( incidence->dtStart().date().day() - 1 ) / 7;
01123 day = incidence->dtStart().date().dayOfWeek();
01124 }
01125 mYearly->setByPos( count, day, month );
01126 mYearly->setFrequency( f );
01127 break; }
01128 case Recurrence::rYearlyDay:
01129 recurrenceType = RecurrenceChooser::Yearly;
01130 rmd = r->yearNums();
01131 day = *rmd.first();
01132 mYearly->setByDay( day );
01133
01134 mYearly->setFrequency( f );
01135 break;
01136 default:
01137 break;
01138 }
01139
01140 mRecurrenceChooser->setType( recurrenceType );
01141 showCurrentRule( recurrenceType );
01142
01143 mRecurrenceRange->setDateTimes( incidence->recurrence()->recurStart() );
01144
01145 if ( incidence->doesRecur() ) {
01146 mRecurrenceRange->setDuration( r->duration() );
01147 if ( r->duration() == 0 ) mRecurrenceRange->setEndDate( r->endDate() );
01148 }
01149
01150 mExceptions->setDates( incidence->exDates() );
01151 }
01152
01153 void KOEditorRecurrence::writeIncidence( Incidence *incidence )
01154 {
01155 if ( !mEnabledCheck->isChecked() || !isEnabled() )
01156 {
01157 if ( incidence->doesRecur() )
01158 incidence->recurrence()->unsetRecurs();
01159 return;
01160 }
01161
01162 Recurrence *r = incidence->recurrence();
01163
01164
01165 r->unsetRecurs();
01166
01167 int duration = mRecurrenceRange->duration();
01168 QDate endDate;
01169 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
01170
01171 int recurrenceType = mRecurrenceChooser->type();
01172 if ( recurrenceType == RecurrenceChooser::Daily ) {
01173 int freq = mDaily->frequency();
01174 if ( duration != 0 ) r->setDaily( freq, duration );
01175 else r->setDaily( freq, endDate );
01176 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
01177 int freq = mWeekly->frequency();
01178 const QBitArray &days = mWeekly->days();
01179 if ( duration != 0 ) r->setWeekly( freq, days, duration );
01180 else r->setWeekly( freq, days, endDate );
01181 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
01182 int freq = mMonthly->frequency();
01183 if ( mMonthly->byPos() ) {
01184 int pos = mMonthly->count();
01185
01186 QBitArray days( 7 );
01187 days.fill( false );
01188
01189 days.setBit( mMonthly->weekday() );
01190 if ( duration != 0 )
01191 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
01192 else
01193 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
01194 r->addMonthlyPos( pos, days );
01195 } else {
01196
01197 if ( duration != 0 ) {
01198 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
01199 } else {
01200 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
01201 }
01202 r->addMonthlyDay( mMonthly->day() );
01203 }
01204 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
01205 int freq = mYearly->frequency();
01206
01207 switch ( mYearly->getType() ) {
01208 case RecurYearly::byMonth:
01209 if ( duration != 0 ) {
01210 r->setYearlyByDate( mYearly->monthDay(), r->feb29YearlyType(), freq, duration );
01211 } else {
01212 r->setYearlyByDate( mYearly->monthDay(), r->feb29YearlyType(), freq, endDate );
01213 }
01214 r->addYearlyNum( mYearly->month() );
01215 break;
01216 case RecurYearly::byPos: {
01217 if ( duration != 0 ) {
01218 r->setYearly( Recurrence::rYearlyPos, freq, duration );
01219 } else {
01220 r->setYearly( Recurrence::rYearlyPos, freq, endDate );
01221 }
01222 r->addYearlyNum( mYearly->posMonth() );
01223 QBitArray days( 7 );
01224 days.fill( false );
01225 days.setBit( mYearly->posWeekday() );
01226 r->addYearlyMonthPos( mYearly->posCount(), days );
01227 break; }
01228 case RecurYearly::byDay:
01229 if ( duration != 0 ) {
01230 r->setYearly( Recurrence::rYearlyDay, freq, duration );
01231 } else {
01232 r->setYearly( Recurrence::rYearlyDay, freq, endDate );
01233 }
01234 r->addYearlyNum( mYearly->day() );
01235 break;
01236 }
01237 }
01238 incidence->setExDates( mExceptions->dates() );
01239 }
01240
01241 void KOEditorRecurrence::setDateTimeStr( const QString &str )
01242 {
01243 mDateTimeLabel->setText( str );
01244 }
01245
01246 bool KOEditorRecurrence::validateInput()
01247 {
01248
01249
01250 if ( mEnabledCheck->isChecked() && (mRecurrenceRange->duration()==0) &&
01251 mEventStartDt.isValid() && ((mRecurrenceRange->endDate())<mEventStartDt.date()) ) {
01252 KMessageBox::sorry( 0,
01253 i18n("The end date '%1' of the recurrence must be after the start date '%2' of the event.")
01254 .arg( KGlobal::locale()->formatDate( mRecurrenceRange->endDate() ) )
01255 .arg( KGlobal::locale()->formatDate( mEventStartDt.date() ) ) );
01256 return false;
01257 }
01258 int recurrenceType = mRecurrenceChooser->type();
01259
01260 if( mEnabledCheck->isChecked() && recurrenceType == RecurrenceChooser::Weekly ) {
01261 const QBitArray &days = mWeekly->days();
01262 bool valid = false;
01263 for ( int i=0; i<7; ++i ) valid = valid || days.testBit( i );
01264 if ( !valid ) {
01265
01266 return false;
01267 }
01268 }
01269 return true;
01270 }
01271
01272 void KOEditorRecurrence::showExceptionsDialog()
01273 {
01274 DateList dates = mExceptions->dates();
01275 int result = mExceptionsDialog->exec();
01276 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
01277 }
01278
01279 void KOEditorRecurrence::showRecurrenceRangeDialog()
01280 {
01281 int duration = mRecurrenceRange->duration();
01282 QDate endDate = mRecurrenceRange->endDate();
01283
01284 int result = mRecurrenceRangeDialog->exec();
01285 if ( result == QDialog::Rejected ) {
01286 mRecurrenceRange->setDuration( duration );
01287 mRecurrenceRange->setEndDate( endDate );
01288 }
01289 }