summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-19 08:56:03 (UTC)
committer zautrix <zautrix>2005-04-19 08:56:03 (UTC)
commit5d7012677b05091bbf16c7405f792bf02720d775 (patch) (unidiff)
tree1c31bcd5f90347edcdcdd359e377a6141853ec7d
parentfacfeef650a79cdd97414c47a571ae6ba30d36b3 (diff)
downloadkdepimpi-5d7012677b05091bbf16c7405f792bf02720d775.zip
kdepimpi-5d7012677b05091bbf16c7405f792bf02720d775.tar.gz
kdepimpi-5d7012677b05091bbf16c7405f792bf02720d775.tar.bz2
rec fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorrecurrence.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 47e73dd..e165017 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -352,757 +352,757 @@ void RecurYearly::setByDay( int doy )
352} 352}
353 353
354void RecurYearly::setByMonth( int month, int day ) 354void RecurYearly::setByMonth( int month, int day )
355{ 355{
356 mByMonthRadio->setChecked( true ); 356 mByMonthRadio->setChecked( true );
357 mByMonthCombo->setCurrentItem( month - 1 ); 357 mByMonthCombo->setCurrentItem( month - 1 );
358 mByDayLabel->setText(i18n("%1 of ").arg( day ) ); 358 mByDayLabel->setText(i18n("%1 of ").arg( day ) );
359 mDay = day; 359 mDay = day;
360} 360}
361 361
362bool RecurYearly::byMonth() 362bool RecurYearly::byMonth()
363{ 363{
364 return mByMonthRadio->isChecked(); 364 return mByMonthRadio->isChecked();
365} 365}
366 366
367bool RecurYearly::byDay() 367bool RecurYearly::byDay()
368{ 368{
369 return mByDayRadio->isChecked(); 369 return mByDayRadio->isChecked();
370} 370}
371 371
372int RecurYearly::month() 372int RecurYearly::month()
373{ 373{
374 return mByMonthCombo->currentItem() + 1; 374 return mByMonthCombo->currentItem() + 1;
375} 375}
376int RecurYearly::day() 376int RecurYearly::day()
377{ 377{
378 return mDay;//mByDayCombo->currentItem() + 1; 378 return mDay;//mByDayCombo->currentItem() + 1;
379} 379}
380 380
381//////////////////////////// ExceptionsWidget ////////////////////////// 381//////////////////////////// ExceptionsWidget //////////////////////////
382 382
383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : 383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
384 QWidget( parent, name ) 384 QWidget( parent, name )
385{ 385{
386 QBoxLayout *topLayout = new QVBoxLayout( this ); 386 QBoxLayout *topLayout = new QVBoxLayout( this );
387 387
388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), 388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"),
389 this ); 389 this );
390 topLayout->addWidget( groupBox ); 390 topLayout->addWidget( groupBox );
391 391
392 QWidget *box = new QWidget( groupBox ); 392 QWidget *box = new QWidget( groupBox );
393 393
394 QGridLayout *boxLayout = new QGridLayout( box ); 394 QGridLayout *boxLayout = new QGridLayout( box );
395 395
396 mExceptionDateEdit = new KDateEdit( box ); 396 mExceptionDateEdit = new KDateEdit( box );
397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); 397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
398 398
399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); 399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box );
400 boxLayout->addWidget( addExceptionButton, 1, 0 ); 400 boxLayout->addWidget( addExceptionButton, 1, 0 );
401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); 401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box );
402 boxLayout->addWidget( changeExceptionButton, 2, 0 ); 402 boxLayout->addWidget( changeExceptionButton, 2, 0 );
403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); 403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box );
404 boxLayout->addWidget( deleteExceptionButton, 3, 0 ); 404 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
405 405
406 mExceptionList = new QListBox( box ); 406 mExceptionList = new QListBox( box );
407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); 407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
408 408
409 boxLayout->setRowStretch( 4, 1 ); 409 boxLayout->setRowStretch( 4, 1 );
410 boxLayout->setColStretch( 1, 3 ); 410 boxLayout->setColStretch( 1, 3 );
411 411
412 connect( addExceptionButton, SIGNAL( clicked() ), 412 connect( addExceptionButton, SIGNAL( clicked() ),
413 SLOT( addException() ) ); 413 SLOT( addException() ) );
414 connect( changeExceptionButton, SIGNAL( clicked() ), 414 connect( changeExceptionButton, SIGNAL( clicked() ),
415 SLOT( changeException() ) ); 415 SLOT( changeException() ) );
416 connect( deleteExceptionButton, SIGNAL( clicked() ), 416 connect( deleteExceptionButton, SIGNAL( clicked() ),
417 SLOT( deleteException() ) ); 417 SLOT( deleteException() ) );
418 if ( QApplication::desktop()->width() < 480 ) { 418 if ( QApplication::desktop()->width() < 480 ) {
419 setMinimumWidth( 220 ); 419 setMinimumWidth( 220 );
420 } else { 420 } else {
421 setMinimumWidth( 440 ); 421 setMinimumWidth( 440 );
422 mExceptionDateEdit->setMinimumWidth( 200 ); 422 mExceptionDateEdit->setMinimumWidth( 200 );
423 } 423 }
424} 424}
425 425
426void ExceptionsWidget::setDefaults( const QDateTime &from ) 426void ExceptionsWidget::setDefaults( const QDateTime &from )
427{ 427{
428 mExceptionDateEdit->setDate( from.date() ); 428 mExceptionDateEdit->setDate( from.date() );
429} 429}
430 430
431void ExceptionsWidget::addException() 431void ExceptionsWidget::addException()
432{ 432{
433 QDate date = mExceptionDateEdit->date(); 433 QDate date = mExceptionDateEdit->date();
434 QString dateStr = KGlobal::locale()->formatDate( date ); 434 QString dateStr = KGlobal::locale()->formatDate( date );
435 if( !mExceptionList->findItem( dateStr ) ) { 435 if( !mExceptionList->findItem( dateStr ) ) {
436 mExceptionDates.append( date ); 436 mExceptionDates.append( date );
437 mExceptionList->insertItem( dateStr ); 437 mExceptionList->insertItem( dateStr );
438 } 438 }
439} 439}
440 440
441void ExceptionsWidget::changeException() 441void ExceptionsWidget::changeException()
442{ 442{
443 int pos = mExceptionList->currentItem(); 443 int pos = mExceptionList->currentItem();
444 if ( pos < 0 ) return; 444 if ( pos < 0 ) return;
445 445
446 QDate date = mExceptionDateEdit->date(); 446 QDate date = mExceptionDateEdit->date();
447 mExceptionDates[ pos ] = date; 447 mExceptionDates[ pos ] = date;
448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); 448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
449} 449}
450 450
451void ExceptionsWidget::deleteException() 451void ExceptionsWidget::deleteException()
452{ 452{
453 int pos = mExceptionList->currentItem(); 453 int pos = mExceptionList->currentItem();
454 if ( pos < 0 ) return; 454 if ( pos < 0 ) return;
455 455
456 mExceptionDates.remove( mExceptionDates.at( pos ) ); 456 mExceptionDates.remove( mExceptionDates.at( pos ) );
457 mExceptionList->removeItem( pos ); 457 mExceptionList->removeItem( pos );
458} 458}
459 459
460void ExceptionsWidget::setDates( const DateList &dates ) 460void ExceptionsWidget::setDates( const DateList &dates )
461{ 461{
462 mExceptionList->clear(); 462 mExceptionList->clear();
463 mExceptionDates.clear(); 463 mExceptionDates.clear();
464 DateList::ConstIterator dit; 464 DateList::ConstIterator dit;
465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) { 465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); 466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
467 mExceptionDates.append( *dit ); 467 mExceptionDates.append( *dit );
468 } 468 }
469} 469}
470 470
471DateList ExceptionsWidget::dates() 471DateList ExceptionsWidget::dates()
472{ 472{
473 return mExceptionDates; 473 return mExceptionDates;
474} 474}
475 475
476///////////////////////// ExceptionsDialog /////////////////////////// 476///////////////////////// ExceptionsDialog ///////////////////////////
477 477
478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : 478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) 479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
480{ 480{
481 mExceptions = new ExceptionsWidget( this ); 481 mExceptions = new ExceptionsWidget( this );
482 setMainWidget( mExceptions ); 482 setMainWidget( mExceptions );
483 resize(220,10); 483 resize(220,10);
484} 484}
485 485
486void ExceptionsDialog::setDefaults( const QDateTime &from ) 486void ExceptionsDialog::setDefaults( const QDateTime &from )
487{ 487{
488 mExceptions->setDefaults( from ); 488 mExceptions->setDefaults( from );
489} 489}
490 490
491void ExceptionsDialog::setDates( const DateList &dates ) 491void ExceptionsDialog::setDates( const DateList &dates )
492{ 492{
493 mExceptions->setDates( dates ); 493 mExceptions->setDates( dates );
494} 494}
495 495
496DateList ExceptionsDialog::dates() 496DateList ExceptionsDialog::dates()
497{ 497{
498 return mExceptions->dates(); 498 return mExceptions->dates();
499} 499}
500 500
501///////////////////////// RecurrenceRangeWidget /////////////////////////// 501///////////////////////// RecurrenceRangeWidget ///////////////////////////
502 502
503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, 503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
504 const char *name ) 504 const char *name )
505 : QWidget( parent, name ) 505 : QWidget( parent, name )
506{ 506{
507 QBoxLayout *topLayout = new QVBoxLayout( this ); 507 QBoxLayout *topLayout = new QVBoxLayout( this );
508 508
509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), 509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
510 this ); 510 this );
511 topLayout->addWidget( mRangeGroupBox ); 511 topLayout->addWidget( mRangeGroupBox );
512 512
513 QWidget *rangeBox = new QWidget( mRangeGroupBox ); 513 QWidget *rangeBox = new QWidget( mRangeGroupBox );
514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); 514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
515 rangeLayout->setSpacing( KDialog::spacingHint() ); 515 rangeLayout->setSpacing( KDialog::spacingHint() );
516 rangeLayout->setMargin( KDialog::marginHintSmall() ); 516 rangeLayout->setMargin( KDialog::marginHintSmall() );
517 517
518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); 518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
519 rangeLayout->addWidget( mStartDateLabel ); 519 rangeLayout->addWidget( mStartDateLabel );
520 520
521 QButtonGroup *rangeButtonGroup = new QButtonGroup; 521 QButtonGroup *rangeButtonGroup = new QButtonGroup;
522 522
523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); 523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
524 rangeButtonGroup->insert( mNoEndDateButton ); 524 rangeButtonGroup->insert( mNoEndDateButton );
525 rangeLayout->addWidget( mNoEndDateButton ); 525 rangeLayout->addWidget( mNoEndDateButton );
526 526
527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); 527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
528 durationLayout->setSpacing( KDialog::spacingHint() ); 528 durationLayout->setSpacing( KDialog::spacingHint() );
529 529
530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); 530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
531 rangeButtonGroup->insert( mEndDurationButton ); 531 rangeButtonGroup->insert( mEndDurationButton );
532 durationLayout->addWidget( mEndDurationButton ); 532 durationLayout->addWidget( mEndDurationButton );
533 533
534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); 534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
535 durationLayout->addWidget( mEndDurationEdit ); 535 durationLayout->addWidget( mEndDurationEdit );
536 536
537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); 537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
538 durationLayout ->addWidget( endDurationLabel ); 538 durationLayout ->addWidget( endDurationLabel );
539 539
540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); 540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
541 endDateLayout->setSpacing( KDialog::spacingHint() ); 541 endDateLayout->setSpacing( KDialog::spacingHint() );
542 542
543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); 543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
544 rangeButtonGroup->insert( mEndDateButton ); 544 rangeButtonGroup->insert( mEndDateButton );
545 endDateLayout->addWidget( mEndDateButton ); 545 endDateLayout->addWidget( mEndDateButton );
546 546
547 mEndDateEdit = new KDateEdit( rangeBox ); 547 mEndDateEdit = new KDateEdit( rangeBox );
548 endDateLayout->addWidget( mEndDateEdit ); 548 endDateLayout->addWidget( mEndDateEdit );
549 549
550 //endDateLayout->addStretch( 1 ); 550 //endDateLayout->addStretch( 1 );
551 551
552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), 552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
553 SLOT( showCurrentRange() ) ); 553 SLOT( showCurrentRange() ) );
554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ), 554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
555 SLOT( showCurrentRange() ) ); 555 SLOT( showCurrentRange() ) );
556 connect( mEndDateButton, SIGNAL( toggled( bool ) ), 556 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
557 SLOT( showCurrentRange() ) ); 557 SLOT( showCurrentRange() ) );
558} 558}
559 559
560void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) 560void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
561{ 561{
562 mNoEndDateButton->setChecked( true ); 562 mNoEndDateButton->setChecked( true );
563 563
564 setDateTimes( from ); 564 setDateTimes( from );
565 mEndDateEdit->setDate( from.date() ); 565 mEndDateEdit->setDate( from.date() );
566} 566}
567 567
568void RecurrenceRangeWidget::setDuration( int duration ) 568void RecurrenceRangeWidget::setDuration( int duration )
569{ 569{
570 if ( duration == -1 ) { 570 if ( duration == -1 ) {
571 mNoEndDateButton->setChecked( true ); 571 mNoEndDateButton->setChecked( true );
572 } else if ( duration == 0 ) { 572 } else if ( duration == 0 ) {
573 mEndDateButton->setChecked( true ); 573 mEndDateButton->setChecked( true );
574 } else { 574 } else {
575 mEndDurationButton->setChecked( true ); 575 mEndDurationButton->setChecked( true );
576 mEndDurationEdit->setValue( duration ); 576 mEndDurationEdit->setValue( duration );
577 } 577 }
578} 578}
579 579
580int RecurrenceRangeWidget::duration() 580int RecurrenceRangeWidget::duration()
581{ 581{
582 if ( mNoEndDateButton->isChecked() ) { 582 if ( mNoEndDateButton->isChecked() ) {
583 return -1; 583 return -1;
584 } else if ( mEndDurationButton->isChecked() ) { 584 } else if ( mEndDurationButton->isChecked() ) {
585 return mEndDurationEdit->value(); 585 return mEndDurationEdit->value();
586 } else { 586 } else {
587 return 0; 587 return 0;
588 } 588 }
589} 589}
590 590
591void RecurrenceRangeWidget::setEndDate( const QDate &date ) 591void RecurrenceRangeWidget::setEndDate( const QDate &date )
592{ 592{
593 mEndDateEdit->setDate( date ); 593 mEndDateEdit->setDate( date );
594} 594}
595 595
596QDate RecurrenceRangeWidget::endDate() 596QDate RecurrenceRangeWidget::endDate()
597{ 597{
598 return mEndDateEdit->date(); 598 return mEndDateEdit->date();
599} 599}
600 600
601void RecurrenceRangeWidget::showCurrentRange() 601void RecurrenceRangeWidget::showCurrentRange()
602{ 602{
603 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); 603 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
604 mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); 604 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
605} 605}
606 606
607void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, 607void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
608 const QDateTime & ) 608 const QDateTime & )
609{ 609{
610 mStartDateLabel->setText( i18n("Start date: %1") 610 mStartDateLabel->setText( i18n("Start date: %1")
611 .arg( KGlobal::locale()->formatDate( start.date() ) ) ); 611 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
612 612
613 if(!mEndDateButton->isChecked()) 613 if(!mEndDateButton->isChecked())
614 mEndDateEdit->setDate( start.date() ); 614 mEndDateEdit->setDate( start.date() );
615} 615}
616 616
617///////////////////////// RecurrenceRangeDialog /////////////////////////// 617///////////////////////// RecurrenceRangeDialog ///////////////////////////
618 618
619RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, 619RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
620 const char *name ) : 620 const char *name ) :
621 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) 621 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
622{ 622{
623 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 623 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
624 setMainWidget( mRecurrenceRangeWidget ); 624 setMainWidget( mRecurrenceRangeWidget );
625} 625}
626 626
627void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) 627void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
628{ 628{
629 mRecurrenceRangeWidget->setDefaults( from ); 629 mRecurrenceRangeWidget->setDefaults( from );
630} 630}
631 631
632void RecurrenceRangeDialog::setDuration( int duration ) 632void RecurrenceRangeDialog::setDuration( int duration )
633{ 633{
634 mRecurrenceRangeWidget->setDuration( duration ); 634 mRecurrenceRangeWidget->setDuration( duration );
635} 635}
636 636
637int RecurrenceRangeDialog::duration() 637int RecurrenceRangeDialog::duration()
638{ 638{
639 return mRecurrenceRangeWidget->duration(); 639 return mRecurrenceRangeWidget->duration();
640} 640}
641 641
642void RecurrenceRangeDialog::setEndDate( const QDate &date ) 642void RecurrenceRangeDialog::setEndDate( const QDate &date )
643{ 643{
644 mRecurrenceRangeWidget->setEndDate( date ); 644 mRecurrenceRangeWidget->setEndDate( date );
645} 645}
646 646
647QDate RecurrenceRangeDialog::endDate() 647QDate RecurrenceRangeDialog::endDate()
648{ 648{
649 return mRecurrenceRangeWidget->endDate(); 649 return mRecurrenceRangeWidget->endDate();
650} 650}
651 651
652void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, 652void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
653 const QDateTime &end ) 653 const QDateTime &end )
654{ 654{
655 mRecurrenceRangeWidget->setDateTimes( start, end ); 655 mRecurrenceRangeWidget->setDateTimes( start, end );
656} 656}
657 657
658//////////////////////////// RecurrenceChooser //////////////////////// 658//////////////////////////// RecurrenceChooser ////////////////////////
659 659
660RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : 660RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
661 QWidget( parent, name ) 661 QWidget( parent, name )
662{ 662{
663 QBoxLayout *topLayout = new QVBoxLayout( this ); 663 QBoxLayout *topLayout = new QVBoxLayout( this );
664 664
665 mTypeCombo = new QComboBox( this ); 665 mTypeCombo = new QComboBox( this );
666 mTypeCombo->insertItem( i18n("Daily") ); 666 mTypeCombo->insertItem( i18n("Daily") );
667 mTypeCombo->insertItem( i18n("Weekly") ); 667 mTypeCombo->insertItem( i18n("Weekly") );
668 mTypeCombo->insertItem( i18n("Monthly") ); 668 mTypeCombo->insertItem( i18n("Monthly") );
669 mTypeCombo->insertItem( i18n("Yearly") ); 669 mTypeCombo->insertItem( i18n("Yearly") );
670 670
671 topLayout->addWidget( mTypeCombo ); 671 topLayout->addWidget( mTypeCombo );
672 672
673 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); 673 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
674 674
675} 675}
676 676
677int RecurrenceChooser::type() 677int RecurrenceChooser::type()
678{ 678{
679 if ( mTypeCombo ) { 679 if ( mTypeCombo ) {
680 return mTypeCombo->currentItem(); 680 return mTypeCombo->currentItem();
681 } else { 681 } else {
682 if ( mDailyButton->isChecked() ) return Daily; 682 if ( mDailyButton->isChecked() ) return Daily;
683 else if ( mWeeklyButton->isChecked() ) return Weekly; 683 else if ( mWeeklyButton->isChecked() ) return Weekly;
684 else if ( mMonthlyButton->isChecked() ) return Monthly; 684 else if ( mMonthlyButton->isChecked() ) return Monthly;
685 else return Yearly; 685 else return Yearly;
686 } 686 }
687} 687}
688 688
689void RecurrenceChooser::setType( int type ) 689void RecurrenceChooser::setType( int type )
690{ 690{
691 if ( mTypeCombo ) { 691 if ( mTypeCombo ) {
692 mTypeCombo->setCurrentItem( type ); 692 mTypeCombo->setCurrentItem( type );
693 } else { 693 } else {
694 switch ( type ) { 694 switch ( type ) {
695 case Daily: 695 case Daily:
696 mDailyButton->setChecked( true ); 696 mDailyButton->setChecked( true );
697 break; 697 break;
698 case Weekly: 698 case Weekly:
699 mWeeklyButton->setChecked( true ); 699 mWeeklyButton->setChecked( true );
700 break; 700 break;
701 case Monthly: 701 case Monthly:
702 mMonthlyButton->setChecked( true ); 702 mMonthlyButton->setChecked( true );
703 break; 703 break;
704 case Yearly: 704 case Yearly:
705 default: 705 default:
706 mYearlyButton->setChecked( true ); 706 mYearlyButton->setChecked( true );
707 break; 707 break;
708 } 708 }
709 } 709 }
710} 710}
711 711
712void RecurrenceChooser::emitChoice() 712void RecurrenceChooser::emitChoice()
713{ 713{
714 emit chosen ( type() ); 714 emit chosen ( type() );
715} 715}
716 716
717/////////////////////////////// Main Widget ///////////////////////////// 717/////////////////////////////// Main Widget /////////////////////////////
718 718
719KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : 719KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
720 QWidget( parent, name ) 720 QWidget( parent, name )
721{ 721{
722 QGridLayout *topLayout = new QGridLayout( this, 2,2 ); 722 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
723 topLayout->setSpacing( KDialog::spacingHint() ); 723 topLayout->setSpacing( KDialog::spacingHint() );
724 topLayout->setMargin( KDialog::marginHintSmall() ); 724 topLayout->setMargin( KDialog::marginHintSmall() );
725 725
726 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); 726 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
727 connect( mEnabledCheck, SIGNAL( toggled( bool ) ), 727 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
728 SLOT( setEnabled( bool ) ) ); 728 SLOT( setEnabled( bool ) ) );
729 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); 729 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
730 730
731 731
732 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), 732 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"),
733 this ); 733 this );
734 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); 734 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
735 735
736 if ( QApplication::desktop()->width() <= 320) { 736 if ( QApplication::desktop()->width() <= 640 ) {
737 mTimeGroupBox->hide(); 737 mTimeGroupBox->hide();
738 } 738 }
739 739
740// QFrame *timeFrame = new QFrame( mTimeGroupBox ); 740// QFrame *timeFrame = new QFrame( mTimeGroupBox );
741// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); 741// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
742// layoutTimeFrame->setSpacing( KDialog::spacingHint() ); 742// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
743 743
744 mDateTimeLabel = new QLabel( mTimeGroupBox ); 744 mDateTimeLabel = new QLabel( mTimeGroupBox );
745// mDateTimeLabel = new QLabel( timeFrame ); 745// mDateTimeLabel = new QLabel( timeFrame );
746// layoutTimeFrame->addWidget( mDateTimeLabel ); 746// layoutTimeFrame->addWidget( mDateTimeLabel );
747 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); 747 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
748 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); 748 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) );
749 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); 749 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this );
750 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 750 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
751 mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); 751 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
752 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), 752 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
753 SLOT( showCurrentRule( int ) ) ); 753 SLOT( showCurrentRule( int ) ) );
754 754
755 755
756 mRuleStack = new QWidgetStack( mRuleBox ); 756 mRuleStack = new QWidgetStack( mRuleBox );
757 757
758 mDaily = new RecurDaily( mRuleStack ); 758 mDaily = new RecurDaily( mRuleStack );
759 mRuleStack->addWidget( mDaily, 0 ); 759 mRuleStack->addWidget( mDaily, 0 );
760 760
761 mWeekly = new RecurWeekly( mRuleStack ); 761 mWeekly = new RecurWeekly( mRuleStack );
762 mRuleStack->addWidget( mWeekly, 0 ); 762 mRuleStack->addWidget( mWeekly, 0 );
763 763
764 mMonthly = new RecurMonthly( mRuleStack ); 764 mMonthly = new RecurMonthly( mRuleStack );
765 mRuleStack->addWidget( mMonthly, 0 ); 765 mRuleStack->addWidget( mMonthly, 0 );
766 766
767 mYearly = new RecurYearly( mRuleStack ); 767 mYearly = new RecurYearly( mRuleStack );
768 mRuleStack->addWidget( mYearly, 0 ); 768 mRuleStack->addWidget( mYearly, 0 );
769 769
770 showCurrentRule( mRecurrenceChooser->type() ); 770 showCurrentRule( mRecurrenceChooser->type() );
771 mRecurrenceRangeWidget = 0; 771 mRecurrenceRangeWidget = 0;
772 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); 772 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
773 mRecurrenceRange = mRecurrenceRangeDialog; 773 mRecurrenceRange = mRecurrenceRangeDialog;
774 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), 774 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
775 this ); 775 this );
776 776
777 connect( mRecurrenceRangeButton, SIGNAL( clicked() ), 777 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
778 SLOT( showRecurrenceRangeDialog() ) ); 778 SLOT( showRecurrenceRangeDialog() ) );
779 779
780 mExceptionsWidget = 0; 780 mExceptionsWidget = 0;
781 mExceptionsDialog = new ExceptionsDialog( this ); 781 mExceptionsDialog = new ExceptionsDialog( this );
782 mExceptions = mExceptionsDialog; 782 mExceptions = mExceptionsDialog;
783 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); 783 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
784 if ( QApplication::desktop()->width() < 320 ) { 784 if ( QApplication::desktop()->width() < 320 ) {
785 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); 785 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
786 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); 786 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
787 } else { 787 } else {
788 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); 788 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
789 topLayout->addWidget( mExceptionsButton, 3, 1 ); 789 topLayout->addWidget( mExceptionsButton, 3, 1 );
790 } 790 }
791 connect( mExceptionsButton, SIGNAL( clicked() ), 791 connect( mExceptionsButton, SIGNAL( clicked() ),
792 SLOT( showExceptionsDialog() ) ); 792 SLOT( showExceptionsDialog() ) );
793} 793}
794 794
795KOEditorRecurrence::~KOEditorRecurrence() 795KOEditorRecurrence::~KOEditorRecurrence()
796{ 796{
797} 797}
798 798
799void KOEditorRecurrence::setEnabled( bool enabled ) 799void KOEditorRecurrence::setEnabled( bool enabled )
800{ 800{
801// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; 801// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
802 802
803 mTimeGroupBox->setEnabled( enabled ); 803 mTimeGroupBox->setEnabled( enabled );
804 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); 804 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
805 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); 805 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
806 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); 806 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
807 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); 807 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
808 mRuleBox->setEnabled( enabled ); 808 mRuleBox->setEnabled( enabled );
809} 809}
810 810
811void KOEditorRecurrence::showCurrentRule( int current ) 811void KOEditorRecurrence::showCurrentRule( int current )
812{ 812{
813 switch ( current ) { 813 switch ( current ) {
814 case Daily: 814 case Daily:
815 mRuleStack->raiseWidget( mDaily ); 815 mRuleStack->raiseWidget( mDaily );
816 break; 816 break;
817 case Weekly: 817 case Weekly:
818 mRuleStack->raiseWidget( mWeekly ); 818 mRuleStack->raiseWidget( mWeekly );
819 break; 819 break;
820 case Monthly: 820 case Monthly:
821 mRuleStack->raiseWidget( mMonthly ); 821 mRuleStack->raiseWidget( mMonthly );
822 break; 822 break;
823 default: 823 default:
824 case Yearly: 824 case Yearly:
825 mRuleStack->raiseWidget( mYearly ); 825 mRuleStack->raiseWidget( mYearly );
826 break; 826 break;
827 } 827 }
828} 828}
829 829
830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
831{ 831{
832// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; 832// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
833 833
834 mRecurrenceRange->setDateTimes( start, end ); 834 mRecurrenceRange->setDateTimes( start, end );
835 mExceptions->setDefaults( end ); 835 mExceptions->setDefaults( end );
836 836
837} 837}
838 838
839void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 839void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
840{ 840{
841 841
842 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); 842 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
843 setDateTimes( from, to ); 843 setDateTimes( from, to );
844 844
845 bool enabled = false; 845 bool enabled = false;
846 mEnabledCheck->setChecked( enabled ); 846 mEnabledCheck->setChecked( enabled );
847 setEnabled( enabled ); 847 setEnabled( enabled );
848 848
849 mExceptions->setDefaults( to ); 849 mExceptions->setDefaults( to );
850 mRecurrenceRange->setDefaults( to ); 850 mRecurrenceRange->setDefaults( to );
851 851
852 mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); 852 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
853 showCurrentRule( mRecurrenceChooser->type() ); 853 showCurrentRule( mRecurrenceChooser->type() );
854 854
855 mDaily->setFrequency( 1 ); 855 mDaily->setFrequency( 1 );
856 856
857 mWeekly->setFrequency( 1 ); 857 mWeekly->setFrequency( 1 );
858 QBitArray days( 7 ); 858 QBitArray days( 7 );
859 days.fill( 0 ); 859 days.fill( 0 );
860 days.setBit( from.date().dayOfWeek()- 1); 860 days.setBit( from.date().dayOfWeek()- 1);
861 mWeekly->setDays( days ); 861 mWeekly->setDays( days );
862 mMonthly->setFrequency( 1 ); 862 mMonthly->setFrequency( 1 );
863 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); 863 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
864 mMonthly->setByDay( from.date().day()-1 ); 864 mMonthly->setByDay( from.date().day()-1 );
865 mYearly->setFrequency( 1 ); 865 mYearly->setFrequency( 1 );
866 mYearly->setByDay( from.date().dayOfYear() ); 866 mYearly->setByDay( from.date().dayOfYear() );
867 mYearly->setByMonth( from.date().month(), from.date().day() ); 867 mYearly->setByMonth( from.date().month(), from.date().day() );
868} 868}
869 869
870void KOEditorRecurrence::readEvent(Incidence *event) 870void KOEditorRecurrence::readEvent(Incidence *event)
871{ 871{
872 872
873 QDateTime dtEnd; 873 QDateTime dtEnd;
874 if ( event->type() == "Event" ) 874 if ( event->type() == "Event" )
875 dtEnd = ((Event*)event)->dtEnd(); 875 dtEnd = ((Event*)event)->dtEnd();
876 else 876 else
877 dtEnd = ((Todo*)event)->dtDue(); 877 dtEnd = ((Todo*)event)->dtDue();
878 878
879 setDefaults( event->dtStart(), dtEnd, true ); 879 setDefaults( event->dtStart(), dtEnd, true );
880 QBitArray rDays( 7 ); 880 QBitArray rDays( 7 );
881 QPtrList<Recurrence::rMonthPos> rmp; 881 QPtrList<Recurrence::rMonthPos> rmp;
882 QPtrList<int> rmd; 882 QPtrList<int> rmd;
883 int day = 0; 883 int day = 0;
884 int count = 0; 884 int count = 0;
885 int month = 0; 885 int month = 0;
886 setDateTimes( event->dtStart(), dtEnd ); 886 setDateTimes( event->dtStart(), dtEnd );
887 887
888 Recurrence *r = event->recurrence(); 888 Recurrence *r = event->recurrence();
889 int f = r->frequency(); 889 int f = r->frequency();
890 890
891 int recurs = r->doesRecur(); 891 int recurs = r->doesRecur();
892 892
893 mEnabledCheck->setChecked( recurs ); 893 mEnabledCheck->setChecked( recurs );
894 setEnabled( recurs ); 894 setEnabled( recurs );
895 895
896 int recurrenceType = RecurrenceChooser::Weekly; 896 int recurrenceType = RecurrenceChooser::Weekly;
897 897
898 switch ( recurs ) { 898 switch ( recurs ) {
899 case Recurrence::rNone: 899 case Recurrence::rNone:
900 setDefaults( event->dtStart(), dtEnd, true ); 900 setDefaults( event->dtStart(), dtEnd, true );
901 break; 901 break;
902 case Recurrence::rDaily: 902 case Recurrence::rDaily:
903 recurrenceType = RecurrenceChooser::Daily; 903 recurrenceType = RecurrenceChooser::Daily;
904 mDaily->setFrequency( f ); 904 mDaily->setFrequency( f );
905 break; 905 break;
906 case Recurrence::rWeekly: 906 case Recurrence::rWeekly:
907 recurrenceType = RecurrenceChooser::Weekly; 907 recurrenceType = RecurrenceChooser::Weekly;
908 mWeekly->setFrequency( f ); 908 mWeekly->setFrequency( f );
909 mWeekly->setDays( r->days() ); 909 mWeekly->setDays( r->days() );
910 break; 910 break;
911 case Recurrence::rMonthlyPos: 911 case Recurrence::rMonthlyPos:
912 // we only handle one possibility in the list right now, 912 // we only handle one possibility in the list right now,
913 // so I have hardcoded calls with first(). If we make the GUI 913 // so I have hardcoded calls with first(). If we make the GUI
914 // more extended, this can be changed. 914 // more extended, this can be changed.
915 recurrenceType = RecurrenceChooser::Monthly; 915 recurrenceType = RecurrenceChooser::Monthly;
916 916
917 rmp = r->monthPositions(); 917 rmp = r->monthPositions();
918 if ( rmp.first()->negative ) 918 if ( rmp.first()->negative )
919 count = 5 - rmp.first()->rPos - 1; 919 count = 5 - rmp.first()->rPos - 1;
920 else 920 else
921 count = rmp.first()->rPos - 1; 921 count = rmp.first()->rPos - 1;
922 day = 0; 922 day = 0;
923 while ( !rmp.first()->rDays.testBit( day ) ) ++day; 923 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
924 mMonthly->setByPos( count, day ); 924 mMonthly->setByPos( count, day );
925 925
926 mMonthly->setFrequency( f ); 926 mMonthly->setFrequency( f );
927 927
928 break; 928 break;
929 case Recurrence::rMonthlyDay: 929 case Recurrence::rMonthlyDay:
930 recurrenceType = RecurrenceChooser::Monthly; 930 recurrenceType = RecurrenceChooser::Monthly;
931 931
932 rmd = r->monthDays(); 932 rmd = r->monthDays();
933 day = *rmd.first() - 1; 933 day = *rmd.first() - 1;
934 mMonthly->setByDay( day ); 934 mMonthly->setByDay( day );
935 935
936 mMonthly->setFrequency( f ); 936 mMonthly->setFrequency( f );
937 937
938 break; 938 break;
939 case Recurrence::rYearlyMonth: 939 case Recurrence::rYearlyMonth:
940 { 940 {
941 recurrenceType = RecurrenceChooser::Yearly; 941 recurrenceType = RecurrenceChooser::Yearly;
942 //qDebug("Recurrence::rYearlyMonth: "); 942 //qDebug("Recurrence::rYearlyMonth: ");
943 day = event->dtStart().date().day(); 943 day = event->dtStart().date().day();
944 rmd = r->yearNums(); 944 rmd = r->yearNums();
945 if ( rmd.count() > 0 ) 945 if ( rmd.count() > 0 )
946 month = *rmd.first(); 946 month = *rmd.first();
947 else 947 else
948 month = event->dtStart().date().month() ; 948 month = event->dtStart().date().month() ;
949 mYearly->setByMonth( month, day ); 949 mYearly->setByMonth( month, day );
950#if 0 950#if 0
951 //qDebug("2day = %d ",day ); 951 //qDebug("2day = %d ",day );
952 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); 952 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
953 int month; 953 int month;
954 if ( !monthlist.isEmpty() ) { 954 if ( !monthlist.isEmpty() ) {
955 month = monthlist.first()->rPos ; 955 month = monthlist.first()->rPos ;
956 } else { 956 } else {
957 month = event->dtStart().date().month() ; 957 month = event->dtStart().date().month() ;
958 } 958 }
959 mYearly->setByMonth( day, month ); 959 mYearly->setByMonth( day, month );
960#endif 960#endif
961 mYearly->setFrequency( f ); 961 mYearly->setFrequency( f );
962 } 962 }
963 963
964 break; 964 break;
965 case Recurrence::rYearlyDay: 965 case Recurrence::rYearlyDay:
966 //qDebug("Recurrence::rYearlyDay: "); 966 //qDebug("Recurrence::rYearlyDay: ");
967 recurrenceType = RecurrenceChooser::Yearly; 967 recurrenceType = RecurrenceChooser::Yearly;
968 mYearly->setByDay( event->dtStart().date().dayOfYear() ); 968 mYearly->setByDay( event->dtStart().date().dayOfYear() );
969 mYearly->setFrequency( f ); 969 mYearly->setFrequency( f );
970 break; 970 break;
971 default: 971 default:
972 setDefaults( event->dtStart(), dtEnd, true ); 972 setDefaults( event->dtStart(), dtEnd, true );
973 break; 973 break;
974 } 974 }
975 975
976 mRecurrenceChooser->setType( recurrenceType ); 976 mRecurrenceChooser->setType( recurrenceType );
977 showCurrentRule( recurrenceType ); 977 showCurrentRule( recurrenceType );
978 978
979 mRecurrenceRange->setDateTimes( event->dtStart() ); 979 mRecurrenceRange->setDateTimes( event->dtStart() );
980 980
981 if ( r->doesRecur() ) { 981 if ( r->doesRecur() ) {
982 mRecurrenceRange->setDuration( r->duration() ); 982 mRecurrenceRange->setDuration( r->duration() );
983 if ( r->duration() == 0 ) 983 if ( r->duration() == 0 )
984 { 984 {
985 if ( r->endDate() < event->dtStart().date() ) 985 if ( r->endDate() < event->dtStart().date() )
986 mRecurrenceRange->setEndDate( event->dtStart().date() ); 986 mRecurrenceRange->setEndDate( event->dtStart().date() );
987 else 987 else
988 mRecurrenceRange->setEndDate( r->endDate() ); 988 mRecurrenceRange->setEndDate( r->endDate() );
989 } else 989 } else
990 mRecurrenceRange->setEndDate( event->dtStart().date() ); 990 mRecurrenceRange->setEndDate( event->dtStart().date() );
991 } 991 }
992 992
993 mExceptions->setDates( event->exDates() ); 993 mExceptions->setDates( event->exDates() );
994} 994}
995 995
996void KOEditorRecurrence::writeEvent( Incidence *event ) 996void KOEditorRecurrence::writeEvent( Incidence *event )
997{ 997{
998 Recurrence *r = event->recurrence(); 998 Recurrence *r = event->recurrence();
999 999
1000 // clear out any old settings; 1000 // clear out any old settings;
1001 r->unsetRecurs(); 1001 r->unsetRecurs();
1002 1002
1003 if ( mEnabledCheck->isChecked() ) { 1003 if ( mEnabledCheck->isChecked() ) {
1004 int duration = mRecurrenceRange->duration(); 1004 int duration = mRecurrenceRange->duration();
1005 QDate endDate; 1005 QDate endDate;
1006 if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); 1006 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1007 1007
1008 int recurrenceType = mRecurrenceChooser->type(); 1008 int recurrenceType = mRecurrenceChooser->type();
1009 1009
1010 if ( recurrenceType == RecurrenceChooser::Daily ) { 1010 if ( recurrenceType == RecurrenceChooser::Daily ) {
1011 int freq = mDaily->frequency(); 1011 int freq = mDaily->frequency();
1012 if ( duration != 0 ) r->setDaily( freq, duration ); 1012 if ( duration != 0 ) r->setDaily( freq, duration );
1013 else r->setDaily( freq, endDate ); 1013 else r->setDaily( freq, endDate );
1014 } else if ( recurrenceType == RecurrenceChooser::Weekly ) { 1014 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1015 int freq = mWeekly->frequency(); 1015 int freq = mWeekly->frequency();
1016 QBitArray days = mWeekly->days(); 1016 QBitArray days = mWeekly->days();
1017 int j; 1017 int j;
1018 bool found = false; 1018 bool found = false;
1019 for (j = 0; j < 7 ; ++j ) { 1019 for (j = 0; j < 7 ; ++j ) {
1020 found |=days.at(j); 1020 found |=days.at(j);
1021 } 1021 }
1022 if ( !found ) { 1022 if ( !found ) {
1023 days.setBit( event->dtStart().date().dayOfWeek()-1); 1023 days.setBit( event->dtStart().date().dayOfWeek()-1);
1024 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); 1024 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
1025 } 1025 }
1026 if ( duration != 0 ) r->setWeekly( freq, days, duration ); 1026 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1027 else r->setWeekly( freq, days, endDate ); 1027 else r->setWeekly( freq, days, endDate );
1028 } else if ( recurrenceType == RecurrenceChooser::Monthly ) { 1028 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1029 int freq = mMonthly->frequency(); 1029 int freq = mMonthly->frequency();
1030 if ( mMonthly->byPos() ) { 1030 if ( mMonthly->byPos() ) {
1031 int pos = mMonthly->count(); 1031 int pos = mMonthly->count();
1032 1032
1033 QBitArray days( 7 ); 1033 QBitArray days( 7 );
1034 days.fill( false ); 1034 days.fill( false );
1035 1035
1036 days.setBit( mMonthly->weekday() ); 1036 days.setBit( mMonthly->weekday() );
1037 if ( duration != 0 ) 1037 if ( duration != 0 )
1038 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 1038 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1039 else 1039 else
1040 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 1040 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1041 r->addMonthlyPos( pos, days ); 1041 r->addMonthlyPos( pos, days );
1042 } else { 1042 } else {
1043 // it's by day 1043 // it's by day
1044 int day = mMonthly->day(); 1044 int day = mMonthly->day();
1045 1045
1046 if ( duration != 0 ) { 1046 if ( duration != 0 ) {
1047 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 1047 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1048 } else { 1048 } else {
1049 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 1049 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1050 } 1050 }
1051 r->addMonthlyDay( day ); 1051 r->addMonthlyDay( day );
1052 } 1052 }
1053 } else if ( recurrenceType == RecurrenceChooser::Yearly ) { 1053 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1054 //qDebug("RecurrenceChooser::Yearly "); 1054 //qDebug("RecurrenceChooser::Yearly ");
1055 int freq = mYearly->frequency(); 1055 int freq = mYearly->frequency();
1056 if ( mYearly->byDay() ) { 1056 if ( mYearly->byDay() ) {
1057 if ( duration != 0 ) { 1057 if ( duration != 0 ) {
1058 r->setYearly( Recurrence::rYearlyDay, freq, duration ); 1058 r->setYearly( Recurrence::rYearlyDay, freq, duration );
1059 } else { 1059 } else {
1060 r->setYearly( Recurrence::rYearlyDay, freq, endDate ); 1060 r->setYearly( Recurrence::rYearlyDay, freq, endDate );
1061 } 1061 }
1062 r->addYearlyNum( event->dtStart().date().dayOfYear() ); 1062 r->addYearlyNum( event->dtStart().date().dayOfYear() );
1063 } else { 1063 } else {
1064 if ( duration != 0 ) { 1064 if ( duration != 0 ) {
1065 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 1065 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1066 } else { 1066 } else {
1067 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 1067 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1068 } 1068 }
1069 r->addYearlyNum( mYearly->month() ); 1069 r->addYearlyNum( mYearly->month() );
1070 } 1070 }
1071 1071
1072 } 1072 }
1073 1073
1074 event->setExDates( mExceptions->dates() ); 1074 event->setExDates( mExceptions->dates() );
1075 } 1075 }
1076} 1076}
1077 1077
1078void KOEditorRecurrence::setDateTimeStr( const QString &str ) 1078void KOEditorRecurrence::setDateTimeStr( const QString &str )
1079{ 1079{
1080 mDateTimeLabel->setText( str ); 1080 mDateTimeLabel->setText( str );
1081} 1081}
1082 1082
1083bool KOEditorRecurrence::validateInput() 1083bool KOEditorRecurrence::validateInput()
1084{ 1084{
1085 // Check input here 1085 // Check input here
1086 1086
1087 return true; 1087 return true;
1088} 1088}
1089 1089
1090void KOEditorRecurrence::showExceptionsDialog() 1090void KOEditorRecurrence::showExceptionsDialog()
1091{ 1091{
1092 DateList dates = mExceptions->dates(); 1092 DateList dates = mExceptions->dates();
1093 int result = mExceptionsDialog->exec(); 1093 int result = mExceptionsDialog->exec();
1094 if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); 1094 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1095} 1095}
1096 1096
1097void KOEditorRecurrence::showRecurrenceRangeDialog() 1097void KOEditorRecurrence::showRecurrenceRangeDialog()
1098{ 1098{
1099 int duration = mRecurrenceRange->duration(); 1099 int duration = mRecurrenceRange->duration();
1100 QDate endDate = mRecurrenceRange->endDate(); 1100 QDate endDate = mRecurrenceRange->endDate();
1101 1101
1102 int result = mRecurrenceRangeDialog->exec(); 1102 int result = mRecurrenceRangeDialog->exec();
1103 if ( result == QDialog::Rejected ) { 1103 if ( result == QDialog::Rejected ) {
1104 mRecurrenceRange->setDuration( duration ); 1104 mRecurrenceRange->setDuration( duration );
1105 mRecurrenceRange->setEndDate( endDate ); 1105 mRecurrenceRange->setEndDate( endDate );
1106 } 1106 }
1107 1107
1108} 1108}