-rw-r--r-- | korganizer/kolistview.cpp | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 4c815d8..1b4397f 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -450,105 +450,91 @@ void KOListView::updateList() | |||
450 | void KOListView::clearList() | 450 | void KOListView::clearList() |
451 | { | 451 | { |
452 | clear (); | 452 | clear (); |
453 | } | 453 | } |
454 | 454 | ||
455 | void KOListView::setCat() | 455 | void KOListView::setCat() |
456 | { | 456 | { |
457 | 457 | ||
458 | bool set = true; | 458 | bool set = true; |
459 | int result = KMessageBox::warningYesNoCancel(this, | 459 | int result = KMessageBox::warningYesNoCancel(this, |
460 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 460 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
461 | i18n("Set categories"), | 461 | i18n("Set categories"), |
462 | i18n("Add"), | 462 | i18n("Add"), |
463 | i18n("Reset")); | 463 | i18n("Reset")); |
464 | if (result == KMessageBox::Cancel) return; | 464 | if (result == KMessageBox::Cancel) return; |
465 | if (result == KMessageBox::Yes) set = false; | 465 | if (result == KMessageBox::Yes) set = false; |
466 | setCategories( set ); | 466 | setCategories( set ); |
467 | } | 467 | } |
468 | 468 | ||
469 | void KOListView::setAlarm() | 469 | void KOListView::setAlarm() |
470 | { | 470 | { |
471 | KOAlarmPrefs kap( this); | 471 | KOAlarmPrefs kap( this); |
472 | if ( !kap.exec() ) | 472 | if ( !kap.exec() ) |
473 | return; | 473 | return; |
474 | QPtrList<KOListViewItem> sel ; | 474 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
475 | QListViewItem *qitem = mListView->firstChild (); | 475 | Incidence* inc = delSel.first(); |
476 | while ( qitem ) { | ||
477 | if ( qitem->isSelected() ) { | ||
478 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | ||
479 | if ( inc->typeID() != journalID ) { | ||
480 | if ( inc->typeID() == todoID ) { | ||
481 | if ( ((Todo*)inc)->hasDueDate() ) | ||
482 | sel.append(((KOListViewItem *)qitem)); | ||
483 | } else | ||
484 | sel.append(((KOListViewItem *)qitem)); | ||
485 | } | ||
486 | } | ||
487 | qitem = qitem->nextSibling(); | ||
488 | } | ||
489 | int count = 0; | 476 | int count = 0; |
490 | KOListViewItem * item, *temp; | 477 | while ( inc ) { |
491 | item = sel.first(); | 478 | ++count; |
492 | Incidence* inc; | 479 | if (kap.mAlarmButton->isChecked()) { |
493 | while ( item ) { | 480 | if (inc->alarms().count() == 0) |
494 | inc = item->data(); | 481 | inc->newAlarm(); |
495 | ++count; | 482 | QPtrList<Alarm> alarms = inc->alarms(); |
496 | if (kap.mAlarmButton->isChecked()) { | 483 | Alarm *alarm; |
497 | if (inc->alarms().count() == 0) | 484 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
498 | inc->newAlarm(); | 485 | alarm->setEnabled(true); |
499 | QPtrList<Alarm> alarms = inc->alarms(); | 486 | int j = kap.mAlarmTimeEdit->value()* -60; |
500 | Alarm *alarm; | 487 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
501 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 488 | j = j * 60; |
502 | alarm->setEnabled(true); | 489 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
503 | int j = kap.mAlarmTimeEdit->value()* -60; | 490 | j = j * (60 * 24); |
504 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 491 | alarm->setStartOffset( j ); |
505 | j = j * 60; | 492 | |
506 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 493 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
507 | j = j * (60 * 24); | 494 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
508 | alarm->setStartOffset( j ); | ||
509 | |||
510 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
511 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
512 | } | ||
513 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
514 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
515 | else | ||
516 | alarm->setType(Alarm::Invalid); | ||
517 | //alarm->setAudioAlarm("default"); | ||
518 | // TODO: Deal with multiple alarms | ||
519 | break; // For now, stop after the first alarm | ||
520 | } | 495 | } |
521 | } else { | 496 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
522 | Alarm* alarm = inc->alarms().first(); | 497 | alarm->setAudioAlarm(kap.mAlarmSound); |
523 | if ( alarm ) { | 498 | else |
524 | alarm->setEnabled(false); | ||
525 | alarm->setType(Alarm::Invalid); | 499 | alarm->setType(Alarm::Invalid); |
526 | } | 500 | //alarm->setAudioAlarm("default"); |
501 | // TODO: Deal with multiple alarms | ||
502 | break; // For now, stop after the first alarm | ||
527 | } | 503 | } |
504 | } else { | ||
505 | Alarm* alarm = inc->alarms().first(); | ||
506 | if ( alarm ) { | ||
507 | alarm->setEnabled(false); | ||
508 | alarm->setType(Alarm::Invalid); | ||
509 | } | ||
510 | } | ||
511 | KOListViewItem* item = getItemForEvent(inc); | ||
512 | if (item) { | ||
528 | ListItemVisitor v(item, mStartDate ); | 513 | ListItemVisitor v(item, mStartDate ); |
529 | inc->accept(v); | 514 | inc->accept(v); |
530 | item = sel.next(); | 515 | } |
516 | inc = delSel.next(); | ||
531 | } | 517 | } |
532 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 518 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
533 | qDebug("KO: Set alarm for %d items", count); | 519 | qDebug("KO: Set alarm for %d items", count); |
534 | calendar()->reInitAlarmSettings(); | 520 | calendar()->reInitAlarmSettings(); |
535 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 521 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
536 | } | 522 | } |
537 | void KOListView::setCategories( bool removeOld ) | 523 | void KOListView::setCategories( bool removeOld ) |
538 | { | 524 | { |
539 | 525 | ||
540 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 526 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
541 | csd->setColorEnabled(); | 527 | csd->setColorEnabled(); |
542 | if (! csd->exec()) { | 528 | if (! csd->exec()) { |
543 | delete csd; | 529 | delete csd; |
544 | return; | 530 | return; |
545 | } | 531 | } |
546 | QStringList catList = csd->selectedCategories(); | 532 | QStringList catList = csd->selectedCategories(); |
547 | delete csd; | 533 | delete csd; |
548 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 534 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
549 | Incidence* inc = delSel.first(); | 535 | Incidence* inc = delSel.first(); |
550 | while ( inc ) { | 536 | while ( inc ) { |
551 | if ( removeOld ) { | 537 | if ( removeOld ) { |
552 | inc->setCategories( catList, false ); | 538 | inc->setCategories( catList, false ); |
553 | } else { | 539 | } else { |
554 | inc->addCategories( catList, false ); | 540 | inc->addCategories( catList, false ); |
@@ -678,49 +664,61 @@ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool | |||
678 | delSel.append( inc ); | 664 | delSel.append( inc ); |
679 | } else | 665 | } else |
680 | delSel.append( inc ); | 666 | delSel.append( inc ); |
681 | 667 | ||
682 | } | 668 | } |
683 | } | 669 | } |
684 | if ( inc->typeID() == todoID ) { | 670 | if ( inc->typeID() == todoID ) { |
685 | Todo * todo = (Todo*) inc; | 671 | Todo * todo = (Todo*) inc; |
686 | if ( todo->relations().count() ) { | 672 | if ( todo->relations().count() ) { |
687 | if ( askSubTodos ) { | 673 | if ( askSubTodos ) { |
688 | int result = KMessageBox::warningYesNoCancel(this, | 674 | int result = KMessageBox::warningYesNoCancel(this, |
689 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 675 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
690 | i18n("Todo has subtodos"), | 676 | i18n("Todo has subtodos"), |
691 | i18n("Yes"), | 677 | i18n("Yes"), |
692 | i18n("No")); | 678 | i18n("No")); |
693 | if ( result == KMessageBox::Cancel ) { | 679 | if ( result == KMessageBox::Cancel ) { |
694 | delSel.clear(); | 680 | delSel.clear(); |
695 | return delSel; | 681 | return delSel; |
696 | } | 682 | } |
697 | if (result == KMessageBox::Yes) | 683 | if (result == KMessageBox::Yes) |
698 | addSubTodos = true; | 684 | addSubTodos = true; |
699 | askSubTodos = false; | 685 | askSubTodos = false; |
700 | } | 686 | } |
701 | if ( addSubTodos ) { | 687 | if ( addSubTodos ) { |
702 | inc->addRelationsToList( &delSel ); | 688 | QPtrList<Incidence> tempSel ; |
689 | inc->addRelationsToList( &tempSel ); | ||
690 | Incidence* tempinc = tempSel.first(); | ||
691 | while ( tempinc ) { | ||
692 | if ( delSel.findRef( tempinc ) == -1 ) { | ||
693 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { | ||
694 | if ( ((Todo*)tempinc)->hasDueDate() ) | ||
695 | delSel.append( tempinc ); | ||
696 | } else | ||
697 | delSel.append( tempinc ); | ||
698 | } | ||
699 | tempinc = tempSel.next(); | ||
700 | } | ||
703 | } | 701 | } |
704 | } | 702 | } |
705 | } | 703 | } |
706 | } | 704 | } |
707 | item = item->nextSibling(); | 705 | item = item->nextSibling(); |
708 | } | 706 | } |
709 | return delSel; | 707 | return delSel; |
710 | } | 708 | } |
711 | 709 | ||
712 | void KOListView::writeToFile( bool iCal ) | 710 | void KOListView::writeToFile( bool iCal ) |
713 | { | 711 | { |
714 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 712 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
715 | if ( !iCal ) { | 713 | if ( !iCal ) { |
716 | bool journal = false; | 714 | bool journal = false; |
717 | Incidence *incidence = delSel.first(); | 715 | Incidence *incidence = delSel.first(); |
718 | while ( incidence ) { | 716 | while ( incidence ) { |
719 | if ( incidence->typeID() == journalID ) { | 717 | if ( incidence->typeID() == journalID ) { |
720 | journal = true; | 718 | journal = true; |
721 | break; | 719 | break; |
722 | } | 720 | } |
723 | incidence = delSel.next(); | 721 | incidence = delSel.next(); |
724 | } | 722 | } |
725 | if ( journal ) { | 723 | if ( journal ) { |
726 | int result = KMessageBox::warningContinueCancel(this, | 724 | int result = KMessageBox::warningContinueCancel(this, |