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 }
00656
00657
void RecurrenceRangeWidget::setDuration(
int duration )
00658 {
00659
if ( duration == -1 ) {
00660 mNoEndDateButton->setChecked(
true );
00661 }
else if ( duration == 0 ) {
00662 mEndDateButton->setChecked(
true );
00663 }
else {
00664 mEndDurationButton->setChecked(
true );
00665 mEndDurationEdit->setValue( duration );
00666 }
00667 }
00668
00669
int RecurrenceRangeWidget::duration()
00670 {
00671
if ( mNoEndDateButton->isChecked() ) {
00672
return -1;
00673 }
else if ( mEndDurationButton->isChecked() ) {
00674
return mEndDurationEdit->value();
00675 }
else {
00676
return 0;
00677 }
00678 }
00679
00680
void RecurrenceRangeWidget::setEndDate(
const QDate &date )
00681 {
00682 mEndDateEdit->setDate( date );
00683 }
00684
00685
QDate RecurrenceRangeWidget::endDate()
00686 {
00687
return mEndDateEdit->date();
00688 }
00689
00690
void RecurrenceRangeWidget::showCurrentRange()
00691 {
00692 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
00693 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
00694 }
00695
00696
void RecurrenceRangeWidget::setDateTimes(
const QDateTime &start,
00697
const QDateTime & )
00698 {
00699 mStartDateLabel->setText( i18n(
"Begins on: %1")
00700 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
00701 }
00702
00704
00705 RecurrenceRangeDialog::RecurrenceRangeDialog(
QWidget *parent,
00706
const char *name ) :
00707 KDialogBase( parent, name, true, i18n(
"Edit Recurrence Range"), Ok|Cancel )
00708 {
00709 mRecurrenceRangeWidget =
new RecurrenceRangeWidget(
this );
00710 setMainWidget( mRecurrenceRangeWidget );
00711 }
00712
00713
void RecurrenceRangeDialog::setDefaults(
const QDateTime &from )
00714 {
00715 mRecurrenceRangeWidget->setDefaults( from );
00716 }
00717
00718
void RecurrenceRangeDialog::setDuration(
int duration )
00719 {
00720 mRecurrenceRangeWidget->setDuration( duration );
00721 }
00722
00723
int RecurrenceRangeDialog::duration()
00724 {
00725
return mRecurrenceRangeWidget->duration();
00726 }
00727
00728
void RecurrenceRangeDialog::setEndDate(
const QDate &date )
00729 {
00730 mRecurrenceRangeWidget->setEndDate( date );
00731 }
00732
00733
QDate RecurrenceRangeDialog::endDate()
00734 {
00735
return mRecurrenceRangeWidget->endDate();
00736 }
00737
00738
void RecurrenceRangeDialog::setDateTimes(
const QDateTime &start,
00739
const QDateTime &end )
00740 {
00741 mRecurrenceRangeWidget->setDateTimes( start, end );
00742 }
00743
00745
00746 RecurrenceChooser::RecurrenceChooser(
QWidget *parent,
const char *name ) :
00747
QWidget( parent, name )
00748 {
00749
QBoxLayout *topLayout =
new QVBoxLayout(
this );
00750
00751
if ( KOPrefs::instance()->mCompactDialogs ) {
00752 mTypeCombo =
new QComboBox(
this );
00753 mTypeCombo->insertItem( i18n(
"Daily") );
00754 mTypeCombo->insertItem( i18n(
"Weekly") );
00755 mTypeCombo->insertItem( i18n(
"Monthly") );
00756 mTypeCombo->insertItem( i18n(
"Yearly") );
00757
00758 topLayout->
addWidget( mTypeCombo );
00759
00760 connect( mTypeCombo, SIGNAL( activated(
int ) ), SLOT( emitChoice() ) );
00761 }
else {
00762 mTypeCombo = 0;
00763
00764 QButtonGroup *ruleButtonGroup =
new QButtonGroup( 1, Horizontal,
this );
00765 ruleButtonGroup->setFrameStyle( QFrame::NoFrame );
00766 topLayout->
addWidget( ruleButtonGroup );
00767
00768 mDailyButton =
new QRadioButton( i18n(
"&Daily"), ruleButtonGroup );
00769 mWeeklyButton =
new QRadioButton( i18n(
"&Weekly"), ruleButtonGroup );
00770 mMonthlyButton =
new QRadioButton( i18n(
"&Monthly"), ruleButtonGroup );
00771 mYearlyButton =
new QRadioButton( i18n(
"&Yearly"), ruleButtonGroup );
00772
00773 connect( mDailyButton, SIGNAL( toggled(
bool ) ),
00774 SLOT( emitChoice() ) );
00775 connect( mWeeklyButton, SIGNAL( toggled(
bool ) ),
00776 SLOT( emitChoice() ) );
00777 connect( mMonthlyButton, SIGNAL( toggled(
bool ) ),
00778 SLOT( emitChoice() ) );
00779 connect( mYearlyButton, SIGNAL( toggled(
bool ) ),
00780 SLOT( emitChoice() ) );
00781 }
00782 }
00783
00784
int RecurrenceChooser::type()
00785 {
00786
if ( mTypeCombo ) {
00787
return mTypeCombo->currentItem();
00788 }
else {
00789
if ( mDailyButton->isChecked() )
return Daily;
00790
else if ( mWeeklyButton->isChecked() )
return Weekly;
00791
else if ( mMonthlyButton->isChecked() )
return Monthly;
00792
else return Yearly;
00793 }
00794 }
00795
00796
void RecurrenceChooser::setType(
int type )
00797 {
00798
if ( mTypeCombo ) {
00799 mTypeCombo->setCurrentItem( type );
00800 }
else {
00801
switch ( type ) {
00802
case Daily:
00803 mDailyButton->setChecked(
true );
00804
break;
00805
case Weekly:
00806 mWeeklyButton->setChecked(
true );
00807
break;
00808
case Monthly:
00809 mMonthlyButton->setChecked(
true );
00810
break;
00811
case Yearly:
00812
default:
00813 mYearlyButton->setChecked(
true );
00814
break;
00815 }
00816 }
00817 }
00818
00819
void RecurrenceChooser::emitChoice()
00820 {
00821 emit chosen ( type() );
00822 }
00823
00825
00826 KOEditorRecurrence::KOEditorRecurrence(
QWidget* parent,
const char *name ) :
00827
QWidget( parent, name )
00828 {
00829
QGridLayout *topLayout =
new QGridLayout(
this );
00830 topLayout->setSpacing( KDialog::spacingHint() );
00831
00832 mEnabledCheck =
new QCheckBox( i18n(
"&Enable recurrence"),
this );
00833 connect( mEnabledCheck, SIGNAL( toggled(
bool ) ),
00834 SLOT( setRecurrenceEnabled(
bool ) ) );
00835 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
00836
00837
00838 mTimeGroupBox =
new QGroupBox( 1, Horizontal, i18n(
"Appointment Time "),
00839
this );
00840 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
00841
00842
if ( KOPrefs::instance()->mCompactDialogs ) {
00843 mTimeGroupBox->hide();
00844 }
00845
00846
00847
00848
00849
00850 mDateTimeLabel =
new QLabel( mTimeGroupBox );
00851
00852
00853
00854 Qt::Orientation orientation;
00855
if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal;
00856
else orientation = Vertical;
00857
00858 mRuleBox =
new QGroupBox( 1, orientation, i18n(
"Recurrence Rule"),
this );
00859
if ( KOPrefs::instance()->mCompactDialogs ) {
00860 topLayout->addWidget( mRuleBox, 2, 0 );
00861 }
else {
00862 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
00863 }
00864
00865 mRecurrenceChooser =
new RecurrenceChooser( mRuleBox );
00866 connect( mRecurrenceChooser, SIGNAL( chosen(
int ) ),
00867 SLOT( showCurrentRule(
int ) ) );
00868
00869
if ( !KOPrefs::instance()->mCompactDialogs ) {
00870
QFrame *ruleSepFrame =
new QFrame( mRuleBox );
00871 ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken );
00872 }
00873
00874 mRuleStack =
new QWidgetStack( mRuleBox );
00875
00876 mDaily =
new RecurDaily( mRuleStack );
00877 mRuleStack->addWidget( mDaily, 0 );
00878
00879 mWeekly =
new RecurWeekly( mRuleStack );
00880 mRuleStack->addWidget( mWeekly, 0 );
00881
00882 mMonthly =
new RecurMonthly( mRuleStack );
00883 mRuleStack->addWidget( mMonthly, 0 );
00884
00885 mYearly =
new RecurYearly( mRuleStack );
00886 mRuleStack->addWidget( mYearly, 0 );
00887
00888 showCurrentRule( mRecurrenceChooser->type() );
00889
00890
if ( KOPrefs::instance()->mCompactDialogs ) {
00891 mRecurrenceRangeWidget = 0;
00892 mRecurrenceRangeDialog =
new RecurrenceRangeDialog(
this );
00893 mRecurrenceRange = mRecurrenceRangeDialog;
00894 mRecurrenceRangeButton =
new QPushButton( i18n(
"Recurrence Range..."),
00895
this );
00896 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
00897 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
00898 SLOT( showRecurrenceRangeDialog() ) );
00899
00900 mExceptionsWidget = 0;
00901 mExceptionsDialog =
new ExceptionsDialog(
this );
00902 mExceptions = mExceptionsDialog;
00903 mExceptionsButton =
new QPushButton( i18n(
"Exceptions..."),
this );
00904 topLayout->addWidget( mExceptionsButton, 4, 0 );
00905 connect( mExceptionsButton, SIGNAL( clicked() ),
00906 SLOT( showExceptionsDialog() ) );
00907
00908 }
else {
00909 mRecurrenceRangeWidget =
new RecurrenceRangeWidget(
this );
00910 mRecurrenceRangeDialog = 0;
00911 mRecurrenceRange = mRecurrenceRangeWidget;
00912 mRecurrenceRangeButton = 0;
00913 topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 );
00914
00915 mExceptionsWidget =
new ExceptionsWidget(
this );
00916 mExceptionsDialog = 0;
00917 mExceptions = mExceptionsWidget;
00918 mExceptionsButton = 0;
00919 topLayout->addWidget( mExceptionsWidget, 3, 1 );
00920 }
00921 }
00922
00923 KOEditorRecurrence::~KOEditorRecurrence()
00924 {
00925 }
00926
00927
void KOEditorRecurrence::setRecurrenceEnabled(
bool enabled )
00928 {
00929
00930
00931 mTimeGroupBox->setEnabled( enabled );
00932 mRuleBox->setEnabled( enabled );
00933
if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
00934
if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
00935
if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
00936
if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
00937 }
00938
00939
void KOEditorRecurrence::showCurrentRule(
int current )
00940 {
00941
switch ( current ) {
00942
case Daily:
00943 mRuleStack->raiseWidget( mDaily );
00944
break;
00945
case Weekly:
00946 mRuleStack->raiseWidget( mWeekly );
00947
break;
00948
case Monthly:
00949 mRuleStack->raiseWidget( mMonthly );
00950
break;
00951
default:
00952
case Yearly:
00953 mRuleStack->raiseWidget( mYearly );
00954
break;
00955 }
00956 }
00957
00958
void KOEditorRecurrence::setDateTimes(
QDateTime start,
QDateTime end )
00959 {
00960
00961
00962 mEventStartDt = start;
00963 mRecurrenceRange->setDateTimes( start, end );
00964 mDaily->setDateTimes( start, end );
00965 mWeekly->setDateTimes( start, end );
00966 mMonthly->setDateTimes( start, end );
00967 mYearly->setDateTimes( start, end );
00968 }
00969
00970
void KOEditorRecurrence::setDefaults(
QDateTime from,
QDateTime to,
bool )
00971 {
00972 setDateTimes( from, to );
00973
00974
bool enabled =
false;
00975 mEnabledCheck->setChecked( enabled );
00976 setRecurrenceEnabled( enabled );
00977
00978 mRecurrenceRange->setDefaults( from );
00979
00980 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
00981 showCurrentRule( mRecurrenceChooser->type() );
00982
00983 mDaily->setFrequency( 1 );
00984
00985 mWeekly->setFrequency( 1 );
00986
QBitArray days( 7 );
00987 days.fill( 0 );
00988 days.setBit( (from.date().dayOfWeek()+6) % 7 );
00989 mWeekly->setDays( days );
00990
00991 mMonthly->setFrequency( 1 );
00992 mMonthly->setByPos( ( from.date().day() - 1 ) / 7 + 1, from.date().dayOfWeek() - 1 );
00993 mMonthly->setByDay( from.date().day() );
00994
00995 mYearly->setFrequency( 1 );
00996 mYearly->setByDay( from.date().dayOfYear() );
00997 mYearly->setByPos( ( from.date().day() - 1 ) / 7 + 1,
00998 from.date().dayOfWeek() - 1, from.date().month() );
00999 mYearly->setByMonth( from.date().day(), from.date().month() );
01000 }
01001
01002
void KOEditorRecurrence::readIncidence(Incidence *incidence)
01003 {
01004
if (!incidence)
return;
01005
01006
QBitArray rDays( 7 );
01007
QPtrList<Recurrence::rMonthPos> rmp;
01008
QPtrList<int> rmd;
01009
int day = 0;
01010
int count = 0;
01011
int month = 0;
01012
01013
if ( incidence->type() ==
"Todo" ) {
01014 Todo *todo = static_cast<Todo *>(incidence);
01015 setDefaults( todo->dtStart(
true), todo->dtDue(), todo->doesFloat() );
01016 }
else {
01017 setDefaults( incidence->dtStart(), incidence->dtEnd(), incidence->doesFloat() );
01018 }
01019
01020
int recurs = incidence->doesRecur();
01021
int f = 0;
01022 Recurrence *r = 0;
01023
01024
if ( recurs )
01025 {
01026 r = incidence->recurrence();
01027 f = r->frequency();
01028 }
01029
01030
01031 mEnabledCheck->setChecked( recurs );
01032 setRecurrenceEnabled( recurs );
01033
01034
int recurrenceType = RecurrenceChooser::Weekly;
01035
01036
switch ( recurs ) {
01037
case Recurrence::rNone:
01038
break;
01039
case Recurrence::rDaily:
01040 recurrenceType = RecurrenceChooser::Daily;
01041 mDaily->setFrequency( f );
01042
break;
01043
case Recurrence::rWeekly:
01044 recurrenceType = RecurrenceChooser::Weekly;
01045 mWeekly->setFrequency( f );
01046 mWeekly->setDays( r->days() );
01047
break;
01048
case Recurrence::rMonthlyPos:
01049
01050
01051
01052 recurrenceType = RecurrenceChooser::Monthly;
01053
01054 rmp = r->monthPositions();
01055
if ( rmp.first()->negative )
01056 count=-rmp.first()->rPos;
01057
else
01058
01059 count = rmp.first()->rPos;
01060 day = 0;
01061
while ( !rmp.first()->rDays.testBit( day ) ) ++day;
01062 mMonthly->setByPos( count, day );
01063
01064 mMonthly->setFrequency( f );
01065
01066
break;
01067
case Recurrence::rMonthlyDay:
01068 recurrenceType = RecurrenceChooser::Monthly;
01069
01070 rmd = r->monthDays();
01071
01072
01073
if ( rmd.first() ) {
01074 day = *rmd.first();
01075 }
else {
01076 day = incidence->dtStart().date().day();
01077 }
01078 mMonthly->setByDay( day );
01079
01080 mMonthly->setFrequency( f );
01081
01082
break;
01083
case Recurrence::rYearlyMonth: {
01084 recurrenceType = RecurrenceChooser::Yearly;
01085 rmd = r->monthDays();
01086
if ( rmd.first() ) {
01087 day = *rmd.first();
01088 }
else {
01089 day = incidence->dtStart().date().day();
01090 }
01091
QValueList<int> monthlist;
01092
QValueList<int> leaplist;
01093 r->getYearlyMonthMonths( day, monthlist, leaplist );
01094
if ( !monthlist.isEmpty() ) {
01095 mYearly->setByMonth( day, monthlist.first() );
01096 }
01097 mYearly->setFrequency( f );
01098
break; }
01099
case Recurrence::rYearlyPos: {
01100 recurrenceType = RecurrenceChooser::Yearly;
01101 rmd = r->yearNums();
01102
if ( rmd.first() ) {
01103 month = *rmd.first();
01104 }
else {
01105 month = incidence->dtStart().date().month();
01106 }
01107
01108
QPtrList<Recurrence::rMonthPos> monthPos( r->yearMonthPositions() );
01109
if ( monthPos.first() ) {
01110 Recurrence::rMonthPos *mp = monthPos.first();
01111 count = mp->rPos;
01112
if ( mp->negative ) count = -count;
01113
QBitArray days( mp->rDays );
01114 day = -1;
01115
for (
int i=6; i>=0; i-- ) {
01116
if ( days.testBit(i) ) day = i;
01117 }
01118
if ( day == -1 )
01119 day = incidence->dtStart().date().dayOfWeek();
01120 }
else {
01121 count = ( incidence->dtStart().date().day() - 1 ) / 7;
01122 day = incidence->dtStart().date().dayOfWeek();
01123 }
01124 mYearly->setByPos( count, day, month );
01125 mYearly->setFrequency( f );
01126
break; }
01127
case Recurrence::rYearlyDay:
01128 recurrenceType = RecurrenceChooser::Yearly;
01129 rmd = r->yearNums();
01130 day = *rmd.first();
01131 mYearly->setByDay( day );
01132
01133 mYearly->setFrequency( f );
01134
break;
01135
default:
01136
break;
01137 }
01138
01139 mRecurrenceChooser->setType( recurrenceType );
01140 showCurrentRule( recurrenceType );
01141
01142 mRecurrenceRange->setDateTimes( incidence->recurrence()->recurStart() );
01143
01144
if ( incidence->doesRecur() ) {
01145 mRecurrenceRange->setDuration( r->duration() );
01146
if ( r->duration() == 0 ) mRecurrenceRange->setEndDate( r->endDate() );
01147 }
01148
01149 mExceptions->setDates( incidence->exDates() );
01150 }
01151
01152
void KOEditorRecurrence::writeIncidence( Incidence *incidence )
01153 {
01154
if ( !mEnabledCheck->isChecked() || !isEnabled() )
01155 {
01156
if ( incidence->doesRecur() )
01157 incidence->recurrence()->unsetRecurs();
01158
return;
01159 }
01160
01161 Recurrence *r = incidence->recurrence();
01162 Incidence *oldIncidence = incidence->clone();
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
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
01239 incidence->setExDates( mExceptions->dates() );
01240
01241
if ( incidence->type() ==
"Todo" && *(oldIncidence->recurrence()) != *r ) {
01242 Todo *todo = static_cast<Todo *>(incidence);
01243 todo->setDtDue( todo->dtDue(),
true );
01244
if ( todo->hasStartDate() )
01245 todo->setDtStart( todo->dtStart() );
01246 }
01247 }
01248
01249
void KOEditorRecurrence::setDateTimeStr(
const QString &str )
01250 {
01251 mDateTimeLabel->setText( str );
01252 }
01253
01254
bool KOEditorRecurrence::validateInput()
01255 {
01256
01257
01258
if ( mEnabledCheck->isChecked() && (mRecurrenceRange->duration()==0) &&
01259 mEventStartDt.isValid() && ((mRecurrenceRange->endDate())<mEventStartDt.date()) ) {
01260 KMessageBox::sorry( 0,
01261 i18n(
"The end date '%1' of the recurrence must be after the start date '%2' of the event.")
01262 .arg( KGlobal::locale()->formatDate( mRecurrenceRange->endDate() ) )
01263 .arg( KGlobal::locale()->formatDate( mEventStartDt.date() ) ) );
01264
return false;
01265 }
01266
01267
return true;
01268 }
01269
01270
void KOEditorRecurrence::showExceptionsDialog()
01271 {
01272 DateList dates = mExceptions->dates();
01273
int result = mExceptionsDialog->exec();
01274
if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
01275 }
01276
01277
void KOEditorRecurrence::showRecurrenceRangeDialog()
01278 {
01279
int duration = mRecurrenceRange->duration();
01280
QDate endDate = mRecurrenceRange->endDate();
01281
01282
int result = mRecurrenceRangeDialog->exec();
01283
if ( result == QDialog::Rejected ) {
01284 mRecurrenceRange->setDuration( duration );
01285 mRecurrenceRange->setEndDate( endDate );
01286 }
01287 }