author | zautrix <zautrix> | 2005-06-09 08:27:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-09 08:27:24 (UTC) |
commit | 12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262 (patch) (unidiff) | |
tree | ac59de32cdf3ae5b8430b9039232f596a8a6a063 /korganizer | |
parent | b0eb8251185b7c9d664af23da94480c7fcfcf8be (diff) | |
download | kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.zip kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.tar.gz kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.tar.bz2 |
select lisz view fixes
-rw-r--r-- | korganizer/kolistview.cpp | 108 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 |
2 files changed, 51 insertions, 58 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 5797d1b..1f3b4c6 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -380,24 +380,25 @@ void KOListView::updateList() | |||
380 | void KOListView::clearList() | 380 | void KOListView::clearList() |
381 | { | 381 | { |
382 | clear (); | 382 | clear (); |
383 | } | 383 | } |
384 | void KOListView::addCat( ) | 384 | void KOListView::addCat( ) |
385 | { | 385 | { |
386 | setCategories( false ); | 386 | setCategories( false ); |
387 | } | 387 | } |
388 | void KOListView::setCat() | 388 | void KOListView::setCat() |
389 | { | 389 | { |
390 | setCategories( true ); | 390 | setCategories( true ); |
391 | } | 391 | } |
392 | |||
392 | void KOListView::setAlarm() | 393 | void KOListView::setAlarm() |
393 | { | 394 | { |
394 | KOAlarmPrefs kap( this); | 395 | KOAlarmPrefs kap( this); |
395 | if ( !kap.exec() ) | 396 | if ( !kap.exec() ) |
396 | return; | 397 | return; |
397 | QStringList itemList; | 398 | QStringList itemList; |
398 | QPtrList<KOListViewItem> sel ; | 399 | QPtrList<KOListViewItem> sel ; |
399 | QListViewItem *qitem = mListView->firstChild (); | 400 | QListViewItem *qitem = mListView->firstChild (); |
400 | while ( qitem ) { | 401 | while ( qitem ) { |
401 | if ( qitem->isSelected() ) { | 402 | if ( qitem->isSelected() ) { |
402 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 403 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
403 | if ( inc->typeID() != journalID ) { | 404 | if ( inc->typeID() != journalID ) { |
@@ -505,35 +506,26 @@ void KOListView::setCategories( bool removeOld ) | |||
505 | inc->addCategories( catList, setSub ); | 506 | inc->addCategories( catList, setSub ); |
506 | } | 507 | } |
507 | ListItemVisitor v(item, mStartDate ); | 508 | ListItemVisitor v(item, mStartDate ); |
508 | inc->accept(v); | 509 | inc->accept(v); |
509 | item = sel.next(); | 510 | item = sel.next(); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 513 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
513 | } | 514 | } |
514 | 515 | ||
515 | void KOListView::beamSelected() | 516 | void KOListView::beamSelected() |
516 | { | 517 | { |
517 | int icount = 0; | 518 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
518 | QPtrList<Incidence> delSel ; | 519 | int icount = delSel.count(); |
519 | QListViewItem *item = mListView->firstChild (); | ||
520 | while ( item ) { | ||
521 | if ( item->isSelected() ) { | ||
522 | delSel.append(((KOListViewItem *)item)->data()); | ||
523 | ++icount; | ||
524 | } | ||
525 | |||
526 | item = item->nextSibling(); | ||
527 | } | ||
528 | if ( icount ) { | 520 | if ( icount ) { |
529 | emit beamIncidenceList( delSel ); | 521 | emit beamIncidenceList( delSel ); |
530 | return; | 522 | return; |
531 | QString fn ; | 523 | QString fn ; |
532 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 524 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
533 | QString mes; | 525 | QString mes; |
534 | bool createbup = true; | 526 | bool createbup = true; |
535 | if ( createbup ) { | 527 | if ( createbup ) { |
536 | QString description = "\n"; | 528 | QString description = "\n"; |
537 | CalendarLocal* cal = new CalendarLocal(); | 529 | CalendarLocal* cal = new CalendarLocal(); |
538 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 530 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
539 | Incidence *incidence = delSel.first(); | 531 | Incidence *incidence = delSel.first(); |
@@ -566,35 +558,26 @@ void KOListView::beamDone( Ir *ir ) | |||
566 | } | 558 | } |
567 | 559 | ||
568 | void KOListView::saveDescriptionToFile() | 560 | void KOListView::saveDescriptionToFile() |
569 | { | 561 | { |
570 | 562 | ||
571 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 563 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
572 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 564 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
573 | i18n("Continue"), i18n("Cancel"), 0, | 565 | i18n("Continue"), i18n("Cancel"), 0, |
574 | 0, 1 ); | 566 | 0, 1 ); |
575 | if ( result != 0 ) { | 567 | if ( result != 0 ) { |
576 | return; | 568 | return; |
577 | } | 569 | } |
578 | int icount = 0; | 570 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
579 | QPtrList<Incidence> delSel ; | 571 | int icount = delSel.count(); |
580 | QListViewItem *item = mListView->firstChild (); | ||
581 | while ( item ) { | ||
582 | if ( item->isSelected() ) { | ||
583 | delSel.append(((KOListViewItem *)item)->data()); | ||
584 | ++icount; | ||
585 | } | ||
586 | |||
587 | item = item->nextSibling(); | ||
588 | } | ||
589 | if ( icount ) { | 572 | if ( icount ) { |
590 | QString fn = KOPrefs::instance()->mLastSaveFile; | 573 | QString fn = KOPrefs::instance()->mLastSaveFile; |
591 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 574 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
592 | 575 | ||
593 | if ( fn == "" ) | 576 | if ( fn == "" ) |
594 | return; | 577 | return; |
595 | QFileInfo info; | 578 | QFileInfo info; |
596 | info.setFile( fn ); | 579 | info.setFile( fn ); |
597 | QString mes; | 580 | QString mes; |
598 | bool createbup = true; | 581 | bool createbup = true; |
599 | if ( info. exists() ) { | 582 | if ( info. exists() ) { |
600 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 583 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
@@ -650,77 +633,95 @@ void KOListView::saveDescriptionToFile() | |||
650 | topLevelWidget()->setCaption(mes); | 633 | topLevelWidget()->setCaption(mes); |
651 | } | 634 | } |
652 | } | 635 | } |
653 | } | 636 | } |
654 | void KOListView::saveToFileVCS() | 637 | void KOListView::saveToFileVCS() |
655 | { | 638 | { |
656 | writeToFile( false ); | 639 | writeToFile( false ); |
657 | } | 640 | } |
658 | void KOListView::saveToFile() | 641 | void KOListView::saveToFile() |
659 | { | 642 | { |
660 | writeToFile( true ); | 643 | writeToFile( true ); |
661 | } | 644 | } |
662 | void KOListView::writeToFile( bool iCal ) | 645 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
663 | { | 646 | { |
664 | |||
665 | int icount = 0; | ||
666 | QPtrList<Incidence> delSel ; | 647 | QPtrList<Incidence> delSel ; |
667 | QListViewItem *item = mListView->firstChild (); | ||
668 | bool journal = iCal; // warn only for vCal | ||
669 | bool addSubTodos = false; | 648 | bool addSubTodos = false; |
670 | bool askSubTodos = true; | 649 | bool askSubTodos = true; |
650 | QListViewItem *item = mListView->firstChild (); | ||
671 | while ( item ) { | 651 | while ( item ) { |
672 | if ( item->isSelected() ) { | 652 | if ( item->isSelected() ) { |
673 | if ( !journal ) | ||
674 | if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) | ||
675 | journal = true; | ||
676 | Incidence* inc = ((KOListViewItem *)item)->data(); | 653 | Incidence* inc = ((KOListViewItem *)item)->data(); |
677 | if ( addSubTodos ) { | 654 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
678 | if ( delSel.findRef( inc ) == -1 ) | 655 | if ( (inc->typeID() == todoID && includeTodos) || |
679 | delSel.append( inc ); | 656 | (inc->typeID() == eventID && includeEvents) || |
680 | } else | 657 | (inc->typeID() == journalID && includeJournals) ) { |
681 | delSel.append(inc); | 658 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
659 | if ( ((Todo*)inc)->hasDueDate() ) | ||
660 | delSel.append( inc ); | ||
661 | } else | ||
662 | delSel.append( inc ); | ||
663 | |||
664 | } | ||
665 | } | ||
682 | if ( inc->typeID() == todoID ) { | 666 | if ( inc->typeID() == todoID ) { |
683 | Todo * todo = (Todo*) inc; | 667 | Todo * todo = (Todo*) inc; |
684 | if ( todo->relations().count() ) { | 668 | if ( todo->relations().count() ) { |
685 | if ( askSubTodos ) { | 669 | if ( askSubTodos ) { |
686 | int result = KMessageBox::warningYesNoCancel(this, | 670 | int result = KMessageBox::warningYesNoCancel(this, |
687 | i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"), | 671 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
688 | i18n("Todo has subtodos"), | 672 | i18n("Todo has subtodos"), |
689 | i18n("Yes"), | 673 | i18n("Yes"), |
690 | i18n("No")); | 674 | i18n("No")); |
691 | if ( result == KMessageBox::Cancel ) { | 675 | if ( result == KMessageBox::Cancel ) { |
692 | return; | 676 | delSel.clear(); |
677 | return delSel; | ||
693 | } | 678 | } |
694 | if (result == KMessageBox::Yes) | 679 | if (result == KMessageBox::Yes) |
695 | addSubTodos = true; | 680 | addSubTodos = true; |
696 | askSubTodos = false; | 681 | askSubTodos = false; |
697 | } | 682 | } |
698 | if ( addSubTodos ) { | 683 | if ( addSubTodos ) { |
699 | inc->addRelationsToList( &delSel ); | 684 | inc->addRelationsToList( &delSel ); |
700 | } | 685 | } |
701 | } | 686 | } |
702 | } | 687 | } |
703 | ++icount; | ||
704 | } | 688 | } |
705 | item = item->nextSibling(); | 689 | item = item->nextSibling(); |
706 | } | 690 | } |
707 | if ( !iCal && journal ) { | 691 | return delSel; |
708 | int result = KMessageBox::warningContinueCancel(this, | 692 | } |
709 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 693 | |
710 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 694 | void KOListView::writeToFile( bool iCal ) |
711 | true); | 695 | { |
712 | if (result != KMessageBox::Continue) return; | 696 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
697 | if ( !iCal ) { | ||
698 | bool journal = false; | ||
699 | Incidence *incidence = delSel.first(); | ||
700 | while ( incidence ) { | ||
701 | if ( incidence->typeID() == journalID ) { | ||
702 | journal = true; | ||
703 | break; | ||
704 | } | ||
705 | incidence = delSel.next(); | ||
706 | } | ||
707 | if ( journal ) { | ||
708 | int result = KMessageBox::warningContinueCancel(this, | ||
709 | i18n("The journal entries can not be\nexported to a vCalendar file."), | ||
710 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | ||
711 | true); | ||
712 | if (result != KMessageBox::Continue) return; | ||
713 | } | ||
713 | } | 714 | } |
714 | if ( icount ) { | 715 | if ( delSel.count() ) { |
715 | QString fn = KOPrefs::instance()->mLastSaveFile; | 716 | QString fn = KOPrefs::instance()->mLastSaveFile; |
716 | QString extension; | 717 | QString extension; |
717 | if ( iCal ) { | 718 | if ( iCal ) { |
718 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 719 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
719 | fn = fn.left( fn.length() -3) + "ics"; | 720 | fn = fn.left( fn.length() -3) + "ics"; |
720 | } | 721 | } |
721 | } else { | 722 | } else { |
722 | if ( fn.right( 4 ).lower() == ".ics" ) { | 723 | if ( fn.right( 4 ).lower() == ".ics" ) { |
723 | fn = fn.left( fn.length() -3) + "vcs"; | 724 | fn = fn.left( fn.length() -3) + "vcs"; |
724 | } | 725 | } |
725 | } | 726 | } |
726 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 727 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
@@ -777,36 +778,27 @@ void KOListView::hideAll() | |||
777 | while ( item ) { | 778 | while ( item ) { |
778 | QListViewItem * del = item; | 779 | QListViewItem * del = item; |
779 | item = delSel.next(); | 780 | item = delSel.next(); |
780 | delete del; | 781 | delete del; |
781 | } | 782 | } |
782 | } | 783 | } |
783 | void KOListView::printList() | 784 | void KOListView::printList() |
784 | { | 785 | { |
785 | mListView->printList(); | 786 | mListView->printList(); |
786 | } | 787 | } |
787 | void KOListView::deleteAll() | 788 | void KOListView::deleteAll() |
788 | { | 789 | { |
789 | int icount = 0; | 790 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; |
790 | QPtrList<Incidence> delSel ; | 791 | if ( delSel.count() ) { |
791 | QListViewItem *item = mListView->firstChild (); | 792 | int icount = delSel.count(); |
792 | while ( item ) { | ||
793 | if ( item->isSelected() ) { | ||
794 | delSel.append(((KOListViewItem *)item)->data()); | ||
795 | ++icount; | ||
796 | } | ||
797 | |||
798 | item = item->nextSibling(); | ||
799 | } | ||
800 | if ( icount ) { | ||
801 | Incidence *incidence = delSel.first(); | 793 | Incidence *incidence = delSel.first(); |
802 | Incidence *toDelete; | 794 | Incidence *toDelete; |
803 | KOPrefs *p = KOPrefs::instance(); | 795 | KOPrefs *p = KOPrefs::instance(); |
804 | bool confirm = p->mConfirm; | 796 | bool confirm = p->mConfirm; |
805 | QString mess; | 797 | QString mess; |
806 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 798 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
807 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 799 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
808 | p->mConfirm = false; | 800 | p->mConfirm = false; |
809 | int delCounter = 0; | 801 | int delCounter = 0; |
810 | QDialog dia ( this, "p-dialog", true ); | 802 | QDialog dia ( this, "p-dialog", true ); |
811 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 803 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
812 | QVBoxLayout lay( &dia ); | 804 | QVBoxLayout lay( &dia ); |
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index c25592d..9da5497 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h | |||
@@ -253,24 +253,25 @@ class KOListView : public KOEventView | |||
253 | void addTodos(QPtrList<Todo> eventList); | 253 | void addTodos(QPtrList<Todo> eventList); |
254 | void addJournals(QPtrList<Journal> eventList); | 254 | void addJournals(QPtrList<Journal> eventList); |
255 | virtual void printPreview(CalPrinter *calPrinter, | 255 | virtual void printPreview(CalPrinter *calPrinter, |
256 | const QDate &, const QDate &); | 256 | const QDate &, const QDate &); |
257 | 257 | ||
258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); | 258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); |
259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); | 259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); |
260 | void updateList(); | 260 | void updateList(); |
261 | void clearList(); | 261 | void clearList(); |
262 | void setStartDate(const QDate &start); | 262 | void setStartDate(const QDate &start); |
263 | int count(); | 263 | int count(); |
264 | QString getWhatsThisText(QPoint p); | 264 | QString getWhatsThisText(QPoint p); |
265 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); | ||
265 | signals: | 266 | signals: |
266 | void signalNewEvent(); | 267 | void signalNewEvent(); |
267 | void beamIncidenceList(QPtrList<Incidence>); | 268 | void beamIncidenceList(QPtrList<Incidence>); |
268 | 269 | ||
269 | public slots: | 270 | public slots: |
270 | void hideAll(); | 271 | void hideAll(); |
271 | void printList(); | 272 | void printList(); |
272 | void resetFocus(); | 273 | void resetFocus(); |
273 | virtual void updateView(); | 274 | virtual void updateView(); |
274 | virtual void showDates(const QDate &start, const QDate &end); | 275 | virtual void showDates(const QDate &start, const QDate &end); |
275 | virtual void showEvents(QPtrList<Event> eventList); | 276 | virtual void showEvents(QPtrList<Event> eventList); |
276 | void clearSelection(); | 277 | void clearSelection(); |