-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 12 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 89504db..0e74a99 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -393,295 +393,299 @@ ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : | |||
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 | ||
426 | void ExceptionsWidget::setDefaults( const QDateTime &from ) | 426 | void ExceptionsWidget::setDefaults( const QDateTime &from ) |
427 | { | 427 | { |
428 | mExceptionDateEdit->setDate( from.date() ); | 428 | mExceptionDateEdit->setDate( from.date() ); |
429 | } | 429 | } |
430 | 430 | ||
431 | void ExceptionsWidget::addException() | 431 | void 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 | ||
441 | void ExceptionsWidget::changeException() | 441 | void 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 | ||
451 | void ExceptionsWidget::deleteException() | 451 | void 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 | ||
460 | void ExceptionsWidget::setDates( const DateList &dates ) | 460 | void 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 | ||
471 | DateList ExceptionsWidget::dates() | 471 | DateList ExceptionsWidget::dates() |
472 | { | 472 | { |
473 | return mExceptionDates; | 473 | return mExceptionDates; |
474 | } | 474 | } |
475 | 475 | ||
476 | ///////////////////////// ExceptionsDialog /////////////////////////// | 476 | ///////////////////////// ExceptionsDialog /////////////////////////// |
477 | 477 | ||
478 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : | 478 | ExceptionsDialog::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 | ||
486 | void ExceptionsDialog::setDefaults( const QDateTime &from ) | 486 | void ExceptionsDialog::setDefaults( const QDateTime &from ) |
487 | { | 487 | { |
488 | mExceptions->setDefaults( from ); | 488 | mExceptions->setDefaults( from ); |
489 | } | 489 | } |
490 | 490 | ||
491 | void ExceptionsDialog::setDates( const DateList &dates ) | 491 | void ExceptionsDialog::setDates( const DateList &dates ) |
492 | { | 492 | { |
493 | mExceptions->setDates( dates ); | 493 | mExceptions->setDates( dates ); |
494 | } | 494 | } |
495 | 495 | ||
496 | DateList ExceptionsDialog::dates() | 496 | DateList ExceptionsDialog::dates() |
497 | { | 497 | { |
498 | return mExceptions->dates(); | 498 | return mExceptions->dates(); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// | 501 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// |
502 | 502 | ||
503 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | 503 | RecurrenceRangeWidget::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 | mRangeButtonGroup = 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 | mRangeButtonGroup->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 | mRangeButtonGroup->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 | mRangeButtonGroup->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 | ||
560 | RecurrenceRangeWidget::~RecurrenceRangeWidget() | ||
561 | { | ||
562 | delete mRangeButtonGroup; | ||
563 | } | ||
560 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 564 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
561 | { | 565 | { |
562 | mNoEndDateButton->setChecked( true ); | 566 | mNoEndDateButton->setChecked( true ); |
563 | 567 | ||
564 | setDateTimes( from ); | 568 | setDateTimes( from ); |
565 | mEndDateEdit->setDate( from.date() ); | 569 | mEndDateEdit->setDate( from.date() ); |
566 | } | 570 | } |
567 | 571 | ||
568 | void RecurrenceRangeWidget::setDuration( int duration ) | 572 | void RecurrenceRangeWidget::setDuration( int duration ) |
569 | { | 573 | { |
570 | if ( duration == -1 ) { | 574 | if ( duration == -1 ) { |
571 | mNoEndDateButton->setChecked( true ); | 575 | mNoEndDateButton->setChecked( true ); |
572 | } else if ( duration == 0 ) { | 576 | } else if ( duration == 0 ) { |
573 | mEndDateButton->setChecked( true ); | 577 | mEndDateButton->setChecked( true ); |
574 | } else { | 578 | } else { |
575 | mEndDurationButton->setChecked( true ); | 579 | mEndDurationButton->setChecked( true ); |
576 | mEndDurationEdit->setValue( duration ); | 580 | mEndDurationEdit->setValue( duration ); |
577 | } | 581 | } |
578 | } | 582 | } |
579 | 583 | ||
580 | int RecurrenceRangeWidget::duration() | 584 | int RecurrenceRangeWidget::duration() |
581 | { | 585 | { |
582 | if ( mNoEndDateButton->isChecked() ) { | 586 | if ( mNoEndDateButton->isChecked() ) { |
583 | return -1; | 587 | return -1; |
584 | } else if ( mEndDurationButton->isChecked() ) { | 588 | } else if ( mEndDurationButton->isChecked() ) { |
585 | return mEndDurationEdit->value(); | 589 | return mEndDurationEdit->value(); |
586 | } else { | 590 | } else { |
587 | return 0; | 591 | return 0; |
588 | } | 592 | } |
589 | } | 593 | } |
590 | 594 | ||
591 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) | 595 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) |
592 | { | 596 | { |
593 | mEndDateEdit->setDate( date ); | 597 | mEndDateEdit->setDate( date ); |
594 | } | 598 | } |
595 | 599 | ||
596 | QDate RecurrenceRangeWidget::endDate() | 600 | QDate RecurrenceRangeWidget::endDate() |
597 | { | 601 | { |
598 | return mEndDateEdit->date(); | 602 | return mEndDateEdit->date(); |
599 | } | 603 | } |
600 | 604 | ||
601 | void RecurrenceRangeWidget::showCurrentRange() | 605 | void RecurrenceRangeWidget::showCurrentRange() |
602 | { | 606 | { |
603 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); | 607 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); |
604 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); | 608 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); |
605 | } | 609 | } |
606 | 610 | ||
607 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, | 611 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, |
608 | const QDateTime & ) | 612 | const QDateTime & ) |
609 | { | 613 | { |
610 | mStartDateLabel->setText( i18n("Start date: %1") | 614 | mStartDateLabel->setText( i18n("Start date: %1") |
611 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); | 615 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); |
612 | 616 | ||
613 | if(!mEndDateButton->isChecked()) | 617 | if(!mEndDateButton->isChecked()) |
614 | mEndDateEdit->setDate( start.date() ); | 618 | mEndDateEdit->setDate( start.date() ); |
615 | } | 619 | } |
616 | 620 | ||
617 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// | 621 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// |
618 | 622 | ||
619 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, | 623 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, |
620 | const char *name ) : | 624 | const char *name ) : |
621 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) | 625 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) |
622 | { | 626 | { |
623 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 627 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
624 | setMainWidget( mRecurrenceRangeWidget ); | 628 | setMainWidget( mRecurrenceRangeWidget ); |
625 | } | 629 | } |
626 | 630 | ||
627 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) | 631 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) |
628 | { | 632 | { |
629 | mRecurrenceRangeWidget->setDefaults( from ); | 633 | mRecurrenceRangeWidget->setDefaults( from ); |
630 | } | 634 | } |
631 | 635 | ||
632 | void RecurrenceRangeDialog::setDuration( int duration ) | 636 | void RecurrenceRangeDialog::setDuration( int duration ) |
633 | { | 637 | { |
634 | mRecurrenceRangeWidget->setDuration( duration ); | 638 | mRecurrenceRangeWidget->setDuration( duration ); |
635 | } | 639 | } |
636 | 640 | ||
637 | int RecurrenceRangeDialog::duration() | 641 | int RecurrenceRangeDialog::duration() |
638 | { | 642 | { |
639 | return mRecurrenceRangeWidget->duration(); | 643 | return mRecurrenceRangeWidget->duration(); |
640 | } | 644 | } |
641 | 645 | ||
642 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) | 646 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) |
643 | { | 647 | { |
644 | mRecurrenceRangeWidget->setEndDate( date ); | 648 | mRecurrenceRangeWidget->setEndDate( date ); |
645 | } | 649 | } |
646 | 650 | ||
647 | QDate RecurrenceRangeDialog::endDate() | 651 | QDate RecurrenceRangeDialog::endDate() |
648 | { | 652 | { |
649 | return mRecurrenceRangeWidget->endDate(); | 653 | return mRecurrenceRangeWidget->endDate(); |
650 | } | 654 | } |
651 | 655 | ||
652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 656 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
653 | const QDateTime &end ) | 657 | const QDateTime &end ) |
654 | { | 658 | { |
655 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 659 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
656 | } | 660 | } |
657 | 661 | ||
658 | //////////////////////////// RecurrenceChooser //////////////////////// | 662 | //////////////////////////// RecurrenceChooser //////////////////////// |
659 | 663 | ||
660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 664 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
661 | QWidget( parent, name ) | 665 | QWidget( parent, name ) |
662 | { | 666 | { |
663 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 667 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
664 | 668 | ||
665 | mTypeCombo = new QComboBox( this ); | 669 | mTypeCombo = new QComboBox( this ); |
666 | mTypeCombo->insertItem( i18n("Daily") ); | 670 | mTypeCombo->insertItem( i18n("Daily") ); |
667 | mTypeCombo->insertItem( i18n("Weekly") ); | 671 | mTypeCombo->insertItem( i18n("Weekly") ); |
668 | mTypeCombo->insertItem( i18n("Monthly") ); | 672 | mTypeCombo->insertItem( i18n("Monthly") ); |
669 | mTypeCombo->insertItem( i18n("Yearly") ); | 673 | mTypeCombo->insertItem( i18n("Yearly") ); |
670 | 674 | ||
671 | topLayout->addWidget( mTypeCombo ); | 675 | topLayout->addWidget( mTypeCombo ); |
672 | 676 | ||
673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 677 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
674 | 678 | ||
675 | } | 679 | } |
676 | 680 | ||
677 | int RecurrenceChooser::type() | 681 | int RecurrenceChooser::type() |
678 | { | 682 | { |
679 | if ( mTypeCombo ) { | 683 | if ( mTypeCombo ) { |
680 | return mTypeCombo->currentItem(); | 684 | return mTypeCombo->currentItem(); |
681 | } else { | 685 | } else { |
682 | if ( mDailyButton->isChecked() ) return Daily; | 686 | if ( mDailyButton->isChecked() ) return Daily; |
683 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 687 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
684 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 688 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
685 | else return Yearly; | 689 | else return Yearly; |
686 | } | 690 | } |
687 | } | 691 | } |
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index f398f62..75e0c73 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -1,324 +1,327 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOEDITORRECURRENCE_H | 23 | #ifndef _KOEDITORRECURRENCE_H |
24 | #define _KOEDITORRECURRENCE_H | 24 | #define _KOEDITORRECURRENCE_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | #include <qbuttongroup.h> | ||
36 | 37 | ||
37 | #include <kdialogbase.h> | 38 | #include <kdialogbase.h> |
38 | 39 | ||
39 | #include <libkcal/event.h> | 40 | #include <libkcal/event.h> |
40 | 41 | ||
41 | #include "ktimeedit.h" | 42 | #include "ktimeedit.h" |
42 | 43 | ||
43 | class QWidgetStack; | 44 | class QWidgetStack; |
44 | class QSpinBox; | 45 | class QSpinBox; |
45 | 46 | ||
46 | class KDateEdit; | 47 | class KDateEdit; |
47 | 48 | ||
48 | using namespace KCal; | 49 | using namespace KCal; |
49 | 50 | ||
50 | class RecurBase : public QWidget | 51 | class RecurBase : public QWidget |
51 | { | 52 | { |
52 | public: | 53 | public: |
53 | RecurBase( QWidget *parent = 0, const char *name = 0 ); | 54 | RecurBase( QWidget *parent = 0, const char *name = 0 ); |
54 | 55 | ||
55 | void setFrequency( int ); | 56 | void setFrequency( int ); |
56 | int frequency(); | 57 | int frequency(); |
57 | 58 | ||
58 | QWidget *frequencyEdit(); | 59 | QWidget *frequencyEdit(); |
59 | 60 | ||
60 | private: | 61 | private: |
61 | QSpinBox *mFrequencyEdit; | 62 | QSpinBox *mFrequencyEdit; |
62 | }; | 63 | }; |
63 | 64 | ||
64 | class RecurDaily : public RecurBase | 65 | class RecurDaily : public RecurBase |
65 | { | 66 | { |
66 | public: | 67 | public: |
67 | RecurDaily( QWidget *parent = 0, const char *name = 0 ); | 68 | RecurDaily( QWidget *parent = 0, const char *name = 0 ); |
68 | }; | 69 | }; |
69 | 70 | ||
70 | class RecurWeekly : public RecurBase | 71 | class RecurWeekly : public RecurBase |
71 | { | 72 | { |
72 | public: | 73 | public: |
73 | RecurWeekly( QWidget *parent = 0, const char *name = 0 ); | 74 | RecurWeekly( QWidget *parent = 0, const char *name = 0 ); |
74 | 75 | ||
75 | void setDays( const QBitArray & ); | 76 | void setDays( const QBitArray & ); |
76 | QBitArray days(); | 77 | QBitArray days(); |
77 | 78 | ||
78 | private: | 79 | private: |
79 | QCheckBox *mDayBoxes[7]; | 80 | QCheckBox *mDayBoxes[7]; |
80 | }; | 81 | }; |
81 | 82 | ||
82 | class RecurMonthly : public RecurBase | 83 | class RecurMonthly : public RecurBase |
83 | { | 84 | { |
84 | public: | 85 | public: |
85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); | 86 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); |
86 | 87 | ||
87 | void setByDay( int day ); | 88 | void setByDay( int day ); |
88 | void setByPos( int count, int weekday ); | 89 | void setByPos( int count, int weekday ); |
89 | 90 | ||
90 | bool byDay(); | 91 | bool byDay(); |
91 | bool byPos(); | 92 | bool byPos(); |
92 | 93 | ||
93 | int day(); | 94 | int day(); |
94 | 95 | ||
95 | int count(); | 96 | int count(); |
96 | int weekday(); | 97 | int weekday(); |
97 | 98 | ||
98 | private: | 99 | private: |
99 | QRadioButton *mByDayRadio; | 100 | QRadioButton *mByDayRadio; |
100 | QComboBox *mByDayCombo; | 101 | QComboBox *mByDayCombo; |
101 | 102 | ||
102 | QRadioButton *mByPosRadio; | 103 | QRadioButton *mByPosRadio; |
103 | QComboBox *mByPosCountCombo; | 104 | QComboBox *mByPosCountCombo; |
104 | QComboBox *mByPosWeekdayCombo; | 105 | QComboBox *mByPosWeekdayCombo; |
105 | }; | 106 | }; |
106 | 107 | ||
107 | class RecurYearly : public RecurBase | 108 | class RecurYearly : public RecurBase |
108 | { | 109 | { |
109 | public: | 110 | public: |
110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); | 111 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); |
111 | 112 | ||
112 | void setByDay( int doy ); | 113 | void setByDay( int doy ); |
113 | void setByMonth( int month, int day ); | 114 | void setByMonth( int month, int day ); |
114 | 115 | ||
115 | bool byMonth(); | 116 | bool byMonth(); |
116 | bool byDay(); | 117 | bool byDay(); |
117 | 118 | ||
118 | int month(); | 119 | int month(); |
119 | int day(); | 120 | int day(); |
120 | 121 | ||
121 | private: | 122 | private: |
122 | int mDay; | 123 | int mDay; |
123 | QRadioButton *mByMonthRadio; | 124 | QRadioButton *mByMonthRadio; |
124 | QComboBox *mByMonthCombo; | 125 | QComboBox *mByMonthCombo; |
125 | QLabel* mByDayLabel; | 126 | QLabel* mByDayLabel; |
126 | QLabel* mDayOfLabel; | 127 | QLabel* mDayOfLabel; |
127 | QRadioButton *mByDayRadio; | 128 | QRadioButton *mByDayRadio; |
128 | }; | 129 | }; |
129 | 130 | ||
130 | class RecurrenceChooser : public QWidget | 131 | class RecurrenceChooser : public QWidget |
131 | { | 132 | { |
132 | Q_OBJECT | 133 | Q_OBJECT |
133 | public: | 134 | public: |
134 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); | 135 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); |
135 | 136 | ||
136 | enum { Daily, Weekly, Monthly, Yearly }; | 137 | enum { Daily, Weekly, Monthly, Yearly }; |
137 | 138 | ||
138 | void setType( int ); | 139 | void setType( int ); |
139 | int type(); | 140 | int type(); |
140 | 141 | ||
141 | signals: | 142 | signals: |
142 | void chosen( int ); | 143 | void chosen( int ); |
143 | 144 | ||
144 | protected slots: | 145 | protected slots: |
145 | void emitChoice(); | 146 | void emitChoice(); |
146 | 147 | ||
147 | private: | 148 | private: |
148 | QComboBox *mTypeCombo; | 149 | QComboBox *mTypeCombo; |
149 | 150 | ||
150 | QRadioButton *mDailyButton; | 151 | QRadioButton *mDailyButton; |
151 | QRadioButton *mWeeklyButton; | 152 | QRadioButton *mWeeklyButton; |
152 | QRadioButton *mMonthlyButton; | 153 | QRadioButton *mMonthlyButton; |
153 | QRadioButton *mYearlyButton; | 154 | QRadioButton *mYearlyButton; |
154 | }; | 155 | }; |
155 | 156 | ||
156 | class ExceptionsBase | 157 | class ExceptionsBase |
157 | { | 158 | { |
158 | public: | 159 | public: |
159 | virtual void setDefaults( const QDateTime &from ) = 0; | 160 | virtual void setDefaults( const QDateTime &from ) = 0; |
160 | virtual void setDates( const DateList & ) = 0; | 161 | virtual void setDates( const DateList & ) = 0; |
161 | virtual DateList dates() = 0; | 162 | virtual DateList dates() = 0; |
162 | }; | 163 | }; |
163 | 164 | ||
164 | class ExceptionsWidget : public QWidget, public ExceptionsBase | 165 | class ExceptionsWidget : public QWidget, public ExceptionsBase |
165 | { | 166 | { |
166 | Q_OBJECT | 167 | Q_OBJECT |
167 | public: | 168 | public: |
168 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); | 169 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); |
169 | 170 | ||
170 | void setDefaults( const QDateTime &from ); | 171 | void setDefaults( const QDateTime &from ); |
171 | 172 | ||
172 | void setDates( const DateList & ); | 173 | void setDates( const DateList & ); |
173 | DateList dates(); | 174 | DateList dates(); |
174 | 175 | ||
175 | protected slots: | 176 | protected slots: |
176 | void addException(); | 177 | void addException(); |
177 | void changeException(); | 178 | void changeException(); |
178 | void deleteException(); | 179 | void deleteException(); |
179 | 180 | ||
180 | private: | 181 | private: |
181 | KDateEdit *mExceptionDateEdit; | 182 | KDateEdit *mExceptionDateEdit; |
182 | QListBox *mExceptionList; | 183 | QListBox *mExceptionList; |
183 | DateList mExceptionDates; | 184 | DateList mExceptionDates; |
184 | }; | 185 | }; |
185 | 186 | ||
186 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase | 187 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase |
187 | { | 188 | { |
188 | public: | 189 | public: |
189 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); | 190 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); |
190 | 191 | ||
191 | void setDefaults( const QDateTime &from ); | 192 | void setDefaults( const QDateTime &from ); |
192 | 193 | ||
193 | void setDates( const DateList & ); | 194 | void setDates( const DateList & ); |
194 | DateList dates(); | 195 | DateList dates(); |
195 | 196 | ||
196 | private: | 197 | private: |
197 | ExceptionsWidget *mExceptions; | 198 | ExceptionsWidget *mExceptions; |
198 | }; | 199 | }; |
199 | 200 | ||
200 | class RecurrenceRangeBase | 201 | class RecurrenceRangeBase |
201 | { | 202 | { |
202 | public: | 203 | public: |
203 | virtual void setDefaults( const QDateTime &from ) = 0; | 204 | virtual void setDefaults( const QDateTime &from ) = 0; |
204 | 205 | ||
205 | virtual void setDuration( int ) = 0; | 206 | virtual void setDuration( int ) = 0; |
206 | virtual int duration() = 0; | 207 | virtual int duration() = 0; |
207 | 208 | ||
208 | virtual void setEndDate( const QDate & ) = 0; | 209 | virtual void setEndDate( const QDate & ) = 0; |
209 | virtual QDate endDate() = 0; | 210 | virtual QDate endDate() = 0; |
210 | 211 | ||
211 | virtual void setDateTimes( const QDateTime &start, | 212 | virtual void setDateTimes( const QDateTime &start, |
212 | const QDateTime &end = QDateTime() ) = 0; | 213 | const QDateTime &end = QDateTime() ) = 0; |
213 | }; | 214 | }; |
214 | 215 | ||
215 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase | 216 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase |
216 | { | 217 | { |
217 | Q_OBJECT | 218 | Q_OBJECT |
218 | public: | 219 | public: |
219 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); | 220 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); |
221 | ~RecurrenceRangeWidget(); | ||
220 | 222 | ||
221 | void setDefaults( const QDateTime &from ); | 223 | void setDefaults( const QDateTime &from ); |
222 | 224 | ||
223 | void setDuration( int ); | 225 | void setDuration( int ); |
224 | int duration(); | 226 | int duration(); |
225 | 227 | ||
226 | void setEndDate( const QDate & ); | 228 | void setEndDate( const QDate & ); |
227 | QDate endDate(); | 229 | QDate endDate(); |
228 | 230 | ||
229 | void setDateTimes( const QDateTime &start, | 231 | void setDateTimes( const QDateTime &start, |
230 | const QDateTime &end = QDateTime() ); | 232 | const QDateTime &end = QDateTime() ); |
231 | 233 | ||
232 | protected slots: | 234 | protected slots: |
233 | void showCurrentRange(); | 235 | void showCurrentRange(); |
234 | 236 | ||
235 | private: | 237 | private: |
238 | QButtonGroup *mRangeButtonGroup; | ||
236 | QGroupBox *mRangeGroupBox; | 239 | QGroupBox *mRangeGroupBox; |
237 | QLabel *mStartDateLabel; | 240 | QLabel *mStartDateLabel; |
238 | QRadioButton *mNoEndDateButton; | 241 | QRadioButton *mNoEndDateButton; |
239 | QRadioButton *mEndDurationButton; | 242 | QRadioButton *mEndDurationButton; |
240 | QSpinBox *mEndDurationEdit; | 243 | QSpinBox *mEndDurationEdit; |
241 | QRadioButton *mEndDateButton; | 244 | QRadioButton *mEndDateButton; |
242 | KDateEdit *mEndDateEdit; | 245 | KDateEdit *mEndDateEdit; |
243 | }; | 246 | }; |
244 | 247 | ||
245 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase | 248 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase |
246 | { | 249 | { |
247 | public: | 250 | public: |
248 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); | 251 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); |
249 | 252 | ||
250 | void setDefaults( const QDateTime &from ); | 253 | void setDefaults( const QDateTime &from ); |
251 | 254 | ||
252 | void setDuration( int ); | 255 | void setDuration( int ); |
253 | int duration(); | 256 | int duration(); |
254 | 257 | ||
255 | void setEndDate( const QDate & ); | 258 | void setEndDate( const QDate & ); |
256 | QDate endDate(); | 259 | QDate endDate(); |
257 | 260 | ||
258 | void setDateTimes( const QDateTime &start, | 261 | void setDateTimes( const QDateTime &start, |
259 | const QDateTime &end = QDateTime() ); | 262 | const QDateTime &end = QDateTime() ); |
260 | 263 | ||
261 | private: | 264 | private: |
262 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 265 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
263 | }; | 266 | }; |
264 | 267 | ||
265 | class KOEditorRecurrence : public QWidget | 268 | class KOEditorRecurrence : public QWidget |
266 | { | 269 | { |
267 | Q_OBJECT | 270 | Q_OBJECT |
268 | public: | 271 | public: |
269 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); | 272 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); |
270 | virtual ~KOEditorRecurrence(); | 273 | virtual ~KOEditorRecurrence(); |
271 | 274 | ||
272 | enum { Daily, Weekly, Monthly, Yearly }; | 275 | enum { Daily, Weekly, Monthly, Yearly }; |
273 | 276 | ||
274 | /** Read event object and setup widgets accordingly */ | 277 | /** Read event object and setup widgets accordingly */ |
275 | void readEvent( Incidence * ); | 278 | void readEvent( Incidence * ); |
276 | /** Write event settings to event object */ | 279 | /** Write event settings to event object */ |
277 | void writeEvent( Incidence * ); | 280 | void writeEvent( Incidence * ); |
278 | 281 | ||
279 | /** Check if the input is valid. */ | 282 | /** Check if the input is valid. */ |
280 | bool validateInput(); | 283 | bool validateInput(); |
281 | 284 | ||
282 | public slots: | 285 | public slots: |
283 | void setDefaultsDates( QDateTime from, QDateTime to ); | 286 | void setDefaultsDates( QDateTime from, QDateTime to ); |
284 | void setDefaults( QDateTime from, QDateTime to ); | 287 | void setDefaults( QDateTime from, QDateTime to ); |
285 | void setEnabled( bool ); | 288 | void setEnabled( bool ); |
286 | void setDateTimes( QDateTime start, QDateTime end ); | 289 | void setDateTimes( QDateTime start, QDateTime end ); |
287 | void setDateTimeStr( const QString & ); | 290 | void setDateTimeStr( const QString & ); |
288 | 291 | ||
289 | signals: | 292 | signals: |
290 | void dateTimesChanged( QDateTime start, QDateTime end ); | 293 | void dateTimesChanged( QDateTime start, QDateTime end ); |
291 | 294 | ||
292 | protected slots: | 295 | protected slots: |
293 | void showCurrentRule( int ); | 296 | void showCurrentRule( int ); |
294 | void showExceptionsDialog(); | 297 | void showExceptionsDialog(); |
295 | void showRecurrenceRangeDialog(); | 298 | void showRecurrenceRangeDialog(); |
296 | 299 | ||
297 | private: | 300 | private: |
298 | QCheckBox *mEnabledCheck; | 301 | QCheckBox *mEnabledCheck; |
299 | 302 | ||
300 | QGroupBox *mTimeGroupBox; | 303 | QGroupBox *mTimeGroupBox; |
301 | QLabel *mDateTimeLabel; | 304 | QLabel *mDateTimeLabel; |
302 | 305 | ||
303 | QGroupBox *mRuleBox; | 306 | QGroupBox *mRuleBox; |
304 | QWidgetStack *mRuleStack; | 307 | QWidgetStack *mRuleStack; |
305 | RecurrenceChooser *mRecurrenceChooser; | 308 | RecurrenceChooser *mRecurrenceChooser; |
306 | 309 | ||
307 | RecurDaily *mDaily; | 310 | RecurDaily *mDaily; |
308 | RecurWeekly *mWeekly; | 311 | RecurWeekly *mWeekly; |
309 | RecurMonthly *mMonthly; | 312 | RecurMonthly *mMonthly; |
310 | RecurYearly *mYearly; | 313 | RecurYearly *mYearly; |
311 | 314 | ||
312 | RecurrenceRangeBase *mRecurrenceRange; | 315 | RecurrenceRangeBase *mRecurrenceRange; |
313 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 316 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
314 | RecurrenceRangeDialog *mRecurrenceRangeDialog; | 317 | RecurrenceRangeDialog *mRecurrenceRangeDialog; |
315 | QPushButton *mRecurrenceRangeButton; | 318 | QPushButton *mRecurrenceRangeButton; |
316 | 319 | ||
317 | ExceptionsBase *mExceptions; | 320 | ExceptionsBase *mExceptions; |
318 | ExceptionsDialog *mExceptionsDialog; | 321 | ExceptionsDialog *mExceptionsDialog; |
319 | ExceptionsWidget *mExceptionsWidget; | 322 | ExceptionsWidget *mExceptionsWidget; |
320 | QPushButton *mExceptionsButton; | 323 | QPushButton *mExceptionsButton; |
321 | 324 | ||
322 | }; | 325 | }; |
323 | 326 | ||
324 | #endif | 327 | #endif |