author | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
commit | 766b53919de14b8faec22db32b6a750acde0b760 (patch) (unidiff) | |
tree | bb07c0af89b0dddf4257a61e9f5b1cf23c4a282a /korganizer/kolistview.cpp | |
parent | b4d85da57e2d558ec088af6f3b2a34b1854462c0 (diff) | |
download | kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.zip kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.gz kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/kolistview.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 7783dd4..d25f671 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -424,217 +424,212 @@ QString KOListView::getWhatsThisText(QPoint p) | |||
424 | if ( item ) | 424 | if ( item ) |
425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
426 | KOPrefs::instance()->mWTshowDetails, | 426 | KOPrefs::instance()->mWTshowDetails, |
427 | KOPrefs::instance()->mWTshowCreated, | 427 | KOPrefs::instance()->mWTshowCreated, |
428 | KOPrefs::instance()->mWTshowChanged); | 428 | KOPrefs::instance()->mWTshowChanged); |
429 | return i18n("That is the list view" ); | 429 | return i18n("That is the list view" ); |
430 | 430 | ||
431 | } | 431 | } |
432 | 432 | ||
433 | void KOListView::setCalendar( int c ) | 433 | void KOListView::setCalendar( int c ) |
434 | { | 434 | { |
435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
437 | i18n("Continue"), i18n("Cancel"), 0, | 437 | i18n("Continue"), i18n("Cancel"), 0, |
438 | 0, 1 ); | 438 | 0, 1 ); |
439 | if ( result != 0 ) { | 439 | if ( result != 0 ) { |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
444 | int icount = delSel.count(); | 444 | int icount = delSel.count(); |
445 | if ( icount ) { | 445 | if ( icount ) { |
446 | Incidence *incidence = delSel.first(); | 446 | Incidence *incidence = delSel.first(); |
447 | while ( incidence ) { | 447 | while ( incidence ) { |
448 | incidence->setCalID( c ); | 448 | incidence->setCalID( c ); |
449 | KOListViewItem * item = getItemForEvent( incidence ); | 449 | KOListViewItem * item = getItemForEvent( incidence ); |
450 | if ( item ) { | 450 | if ( item ) { |
451 | ListItemVisitor v(item, mStartDate ); | 451 | ListItemVisitor v(item, mStartDate ); |
452 | incidence->accept(v); | 452 | incidence->accept(v); |
453 | } | 453 | } |
454 | incidence = delSel.next(); | 454 | incidence = delSel.next(); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
458 | KopiCalendarFile * cal = calendars.first(); | 458 | KopiCalendarFile * cal = calendars.first(); |
459 | while ( cal ) { | 459 | while ( cal ) { |
460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
463 | if ( cal->isStandard ) | 463 | if ( cal->isStandard ) |
464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
465 | cal = calendars.next(); | 465 | cal = calendars.next(); |
466 | } | 466 | } |
467 | mCalendar->setSyncEventsReadOnly(); | 467 | mCalendar->setSyncEventsReadOnly(); |
468 | mCalendar->reInitAlarmSettings(); | 468 | mCalendar->reInitAlarmSettings(); |
469 | 469 | ||
470 | } | 470 | } |
471 | void KOListView::populateCalPopup() | 471 | void KOListView::populateCalPopup() |
472 | { | 472 | { |
473 | mCalPopup->clear(); | 473 | mCalPopup->clear(); |
474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
475 | while ( kkf ) { | 475 | while ( kkf ) { |
476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
478 | mCalPopup->setItemEnabled( index, false ); | 478 | mCalPopup->setItemEnabled( index, false ); |
479 | kkf = KOPrefs::instance()->mCalendars.next(); | 479 | kkf = KOPrefs::instance()->mCalendars.next(); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | void KOListView::updateList() | 482 | void KOListView::updateList() |
483 | { | 483 | { |
484 | // qDebug(" KOListView::updateList() "); | 484 | // qDebug(" KOListView::updateList() "); |
485 | 485 | ||
486 | } | 486 | } |
487 | 487 | ||
488 | void KOListView::clearList() | 488 | void KOListView::clearList() |
489 | { | 489 | { |
490 | clear (); | 490 | clear (); |
491 | } | 491 | } |
492 | 492 | ||
493 | void KOListView::setCat() | 493 | void KOListView::setCat() |
494 | { | 494 | { |
495 | 495 | ||
496 | bool set = true; | 496 | bool set = true; |
497 | int result = KMessageBox::warningYesNoCancel(this, | 497 | int result = KMessageBox::warningYesNoCancel(this, |
498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
499 | i18n("Set categories"), | 499 | i18n("Set categories"), |
500 | i18n("Add"), | 500 | i18n("Add"), |
501 | i18n("Reset")); | 501 | i18n("Reset")); |
502 | if (result == KMessageBox::Cancel) return; | 502 | if (result == KMessageBox::Cancel) return; |
503 | if (result == KMessageBox::Yes) set = false; | 503 | if (result == KMessageBox::Yes) set = false; |
504 | setCategories( set ); | 504 | setCategories( set ); |
505 | } | 505 | } |
506 | 506 | ||
507 | void KOListView::setAlarm() | 507 | void KOListView::setAlarm() |
508 | { | 508 | { |
509 | KOAlarmPrefs kap( this); | 509 | KOAlarmPrefs kap( this); |
510 | if ( !kap.exec() ) | 510 | if ( !kap.exec() ) |
511 | return; | 511 | return; |
512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos | 512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
513 | Incidence* inc = delSel.first(); | 513 | Incidence* inc = delSel.first(); |
514 | int count = 0; | 514 | int count = 0; |
515 | while ( inc ) { | 515 | while ( inc ) { |
516 | ++count; | 516 | ++count; |
517 | if (kap.mAlarmButton->isChecked()) { | 517 | if (kap.mAlarmButton->isChecked()) { |
518 | if (inc->alarms().count() == 0) | 518 | if (inc->alarms().count() == 0) |
519 | inc->newAlarm(); | 519 | inc->newAlarm(); |
520 | Alarm *alarm = inc->alarms().first(); | ||
521 | alarm->setEnabled(true); | ||
522 | int j = kap.mAlarmTimeEdit->value()* -60; | ||
523 | if (kap.mAlarmIncrCombo->currentItem() == 1) | ||
524 | j = j * 60; | ||
525 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | ||
526 | j = j * (60 * 24); | ||
527 | alarm->setStartOffset( j ); | ||
528 | |||
529 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
530 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
531 | } | ||
532 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
533 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
534 | else | ||
535 | alarm->setType(Alarm::Invalid); | ||
536 | } else { | ||
520 | QPtrList<Alarm> alarms = inc->alarms(); | 537 | QPtrList<Alarm> alarms = inc->alarms(); |
521 | Alarm *alarm; | 538 | Alarm *alarm; |
522 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 539 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
523 | alarm->setEnabled(true); | ||
524 | int j = kap.mAlarmTimeEdit->value()* -60; | ||
525 | if (kap.mAlarmIncrCombo->currentItem() == 1) | ||
526 | j = j * 60; | ||
527 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | ||
528 | j = j * (60 * 24); | ||
529 | alarm->setStartOffset( j ); | ||
530 | |||
531 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
532 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
533 | } | ||
534 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
535 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
536 | else | ||
537 | alarm->setType(Alarm::Invalid); | ||
538 | //alarm->setAudioAlarm("default"); | ||
539 | // TODO: Deal with multiple alarms | ||
540 | break; // For now, stop after the first alarm | ||
541 | } | ||
542 | } else { | ||
543 | Alarm* alarm = inc->alarms().first(); | ||
544 | if ( alarm ) { | ||
545 | alarm->setEnabled(false); | 540 | alarm->setEnabled(false); |
546 | alarm->setType(Alarm::Invalid); | 541 | alarm->setType(Alarm::Invalid); |
547 | } | 542 | } |
548 | } | 543 | } |
549 | KOListViewItem* item = getItemForEvent(inc); | 544 | KOListViewItem* item = getItemForEvent(inc); |
550 | if (item) { | 545 | if (item) { |
551 | ListItemVisitor v(item, mStartDate ); | 546 | ListItemVisitor v(item, mStartDate ); |
552 | inc->accept(v); | 547 | inc->accept(v); |
553 | } | 548 | } |
554 | inc = delSel.next(); | 549 | inc = delSel.next(); |
555 | } | 550 | } |
556 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 551 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
557 | qDebug("KO: Set alarm for %d items", count); | 552 | qDebug("KO: Set alarm for %d items", count); |
558 | calendar()->reInitAlarmSettings(); | 553 | calendar()->reInitAlarmSettings(); |
559 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 554 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
560 | } | 555 | } |
561 | void KOListView::setCategories( bool removeOld ) | 556 | void KOListView::setCategories( bool removeOld ) |
562 | { | 557 | { |
563 | 558 | ||
564 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 559 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
565 | csd->setColorEnabled(); | 560 | csd->setColorEnabled(); |
566 | if (! csd->exec()) { | 561 | if (! csd->exec()) { |
567 | delete csd; | 562 | delete csd; |
568 | return; | 563 | return; |
569 | } | 564 | } |
570 | QStringList catList = csd->selectedCategories(); | 565 | QStringList catList = csd->selectedCategories(); |
571 | delete csd; | 566 | delete csd; |
572 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 567 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
573 | Incidence* inc = delSel.first(); | 568 | Incidence* inc = delSel.first(); |
574 | while ( inc ) { | 569 | while ( inc ) { |
575 | if ( removeOld ) { | 570 | if ( removeOld ) { |
576 | inc->setCategories( catList, false ); | 571 | inc->setCategories( catList, false ); |
577 | } else { | 572 | } else { |
578 | inc->addCategories( catList, false ); | 573 | inc->addCategories( catList, false ); |
579 | } | 574 | } |
580 | KOListViewItem* item = getItemForEvent(inc); | 575 | KOListViewItem* item = getItemForEvent(inc); |
581 | if (item) { | 576 | if (item) { |
582 | ListItemVisitor v(item, mStartDate ); | 577 | ListItemVisitor v(item, mStartDate ); |
583 | inc->accept(v); | 578 | inc->accept(v); |
584 | } | 579 | } |
585 | inc = delSel.next(); | 580 | inc = delSel.next(); |
586 | } | 581 | } |
587 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 582 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
588 | } | 583 | } |
589 | 584 | ||
590 | void KOListView::beamSelected() | 585 | void KOListView::beamSelected() |
591 | { | 586 | { |
592 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 587 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
593 | if ( delSel.count() ) | 588 | if ( delSel.count() ) |
594 | emit beamIncidenceList( delSel ); | 589 | emit beamIncidenceList( delSel ); |
595 | } | 590 | } |
596 | 591 | ||
597 | void KOListView::saveDescriptionToFile() | 592 | void KOListView::saveDescriptionToFile() |
598 | { | 593 | { |
599 | 594 | ||
600 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 595 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
601 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 596 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
602 | i18n("Continue"), i18n("Cancel"), 0, | 597 | i18n("Continue"), i18n("Cancel"), 0, |
603 | 0, 1 ); | 598 | 0, 1 ); |
604 | if ( result != 0 ) { | 599 | if ( result != 0 ) { |
605 | return; | 600 | return; |
606 | } | 601 | } |
607 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 602 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
608 | int icount = delSel.count(); | 603 | int icount = delSel.count(); |
609 | if ( icount ) { | 604 | if ( icount ) { |
610 | QString fn = KOPrefs::instance()->mLastSaveFile; | 605 | QString fn = KOPrefs::instance()->mLastSaveFile; |
611 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 606 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
612 | 607 | ||
613 | if ( fn == "" ) | 608 | if ( fn == "" ) |
614 | return; | 609 | return; |
615 | QFileInfo info; | 610 | QFileInfo info; |
616 | info.setFile( fn ); | 611 | info.setFile( fn ); |
617 | QString mes; | 612 | QString mes; |
618 | bool createbup = true; | 613 | bool createbup = true; |
619 | if ( info. exists() ) { | 614 | if ( info. exists() ) { |
620 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 615 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
621 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 616 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
622 | i18n("Overwrite!"), i18n("Cancel"), 0, | 617 | i18n("Overwrite!"), i18n("Cancel"), 0, |
623 | 0, 1 ); | 618 | 0, 1 ); |
624 | if ( result != 0 ) { | 619 | if ( result != 0 ) { |
625 | createbup = false; | 620 | createbup = false; |
626 | } | 621 | } |
627 | } | 622 | } |
628 | if ( createbup ) { | 623 | if ( createbup ) { |
629 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 624 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
630 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 625 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
631 | Incidence *incidence = delSel.first(); | 626 | Incidence *incidence = delSel.first(); |
632 | icount = 0; | 627 | icount = 0; |
633 | while ( incidence ) { | 628 | while ( incidence ) { |
634 | if ( incidence->typeID() == journalID ) { | 629 | if ( incidence->typeID() == journalID ) { |
635 | text += "\n************************************\n"; | 630 | text += "\n************************************\n"; |
636 | if ( !incidence->summary().isEmpty() ) | 631 | if ( !incidence->summary().isEmpty() ) |
637 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | 632 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); |
638 | else | 633 | else |
639 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 634 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
640 | if ( !incidence->location().isEmpty() ) | 635 | if ( !incidence->location().isEmpty() ) |