author | zautrix <zautrix> | 2005-06-30 11:54:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 11:54:09 (UTC) |
commit | 13eb32c82e736b033435e596111b7b0f3fe75608 (patch) (unidiff) | |
tree | eef906423ff08d368b6a803e6d8ae4b919936ca3 /korganizer/kolistview.cpp | |
parent | b03b54ce54c1391db8979db0df1369e1c68656fa (diff) | |
download | kdepimpi-13eb32c82e736b033435e596111b7b0f3fe75608.zip kdepimpi-13eb32c82e736b033435e596111b7b0f3fe75608.tar.gz kdepimpi-13eb32c82e736b033435e596111b7b0f3fe75608.tar.bz2 |
fixx
-rw-r--r-- | korganizer/kolistview.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 0c1ac7a..8f17e6e 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -574,208 +574,213 @@ void KOListView::setCategories( bool removeOld ) | |||
574 | if ( removeOld ) { | 574 | if ( removeOld ) { |
575 | inc->setCategories( catList, setSub ); | 575 | inc->setCategories( catList, setSub ); |
576 | } else { | 576 | } else { |
577 | inc->addCategories( catList, setSub ); | 577 | inc->addCategories( catList, setSub ); |
578 | } | 578 | } |
579 | ListItemVisitor v(item, mStartDate ); | 579 | ListItemVisitor v(item, mStartDate ); |
580 | inc->accept(v); | 580 | inc->accept(v); |
581 | item = sel.next(); | 581 | item = sel.next(); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 584 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
585 | } | 585 | } |
586 | 586 | ||
587 | void KOListView::beamSelected() | 587 | void KOListView::beamSelected() |
588 | { | 588 | { |
589 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 589 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
590 | int icount = delSel.count(); | 590 | int icount = delSel.count(); |
591 | if ( icount ) { | 591 | if ( icount ) { |
592 | emit beamIncidenceList( delSel ); | 592 | emit beamIncidenceList( delSel ); |
593 | return; | 593 | return; |
594 | QString fn ; | 594 | QString fn ; |
595 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 595 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
596 | QString mes; | 596 | QString mes; |
597 | bool createbup = true; | 597 | bool createbup = true; |
598 | if ( createbup ) { | 598 | if ( createbup ) { |
599 | QString description = "\n"; | 599 | QString description = "\n"; |
600 | CalendarLocal* cal = new CalendarLocal(); | 600 | CalendarLocal* cal = new CalendarLocal(); |
601 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 601 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
602 | Incidence *incidence = delSel.first(); | 602 | Incidence *incidence = delSel.first(); |
603 | while ( incidence ) { | 603 | while ( incidence ) { |
604 | Incidence *in = incidence->clone(); | 604 | Incidence *in = incidence->clone(); |
605 | description += in->summary() + "\n"; | 605 | description += in->summary() + "\n"; |
606 | cal->addIncidence( in ); | 606 | cal->addIncidence( in ); |
607 | incidence = delSel.next(); | 607 | incidence = delSel.next(); |
608 | } | 608 | } |
609 | FileStorage storage( cal, fn, new VCalFormat ); | 609 | FileStorage storage( cal, fn, new VCalFormat ); |
610 | storage.save(); | 610 | storage.save(); |
611 | delete cal; | 611 | delete cal; |
612 | mes = i18n("KO/Pi: Ready for beaming"); | 612 | mes = i18n("KO/Pi: Ready for beaming"); |
613 | topLevelWidget()->setCaption(mes); | 613 | topLevelWidget()->setCaption(mes); |
614 | 614 | ||
615 | #ifndef DESKTOP_VERSION | 615 | #ifndef DESKTOP_VERSION |
616 | Ir *ir = new Ir( this ); | 616 | Ir *ir = new Ir( this ); |
617 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 617 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
618 | ir->send( fn, description, "text/x-vCalendar" ); | 618 | ir->send( fn, description, "text/x-vCalendar" ); |
619 | #endif | 619 | #endif |
620 | } | 620 | } |
621 | } | 621 | } |
622 | } | 622 | } |
623 | void KOListView::beamDone( Ir *ir ) | 623 | void KOListView::beamDone( Ir *ir ) |
624 | { | 624 | { |
625 | #ifndef DESKTOP_VERSION | 625 | #ifndef DESKTOP_VERSION |
626 | delete ir; | 626 | delete ir; |
627 | #endif | 627 | #endif |
628 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 628 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOListView::saveDescriptionToFile() | 631 | void KOListView::saveDescriptionToFile() |
632 | { | 632 | { |
633 | 633 | ||
634 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 634 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
635 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 635 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
636 | i18n("Continue"), i18n("Cancel"), 0, | 636 | i18n("Continue"), i18n("Cancel"), 0, |
637 | 0, 1 ); | 637 | 0, 1 ); |
638 | if ( result != 0 ) { | 638 | if ( result != 0 ) { |
639 | return; | 639 | return; |
640 | } | 640 | } |
641 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 641 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
642 | int icount = delSel.count(); | 642 | int icount = delSel.count(); |
643 | if ( icount ) { | 643 | if ( icount ) { |
644 | QString fn = KOPrefs::instance()->mLastSaveFile; | 644 | QString fn = KOPrefs::instance()->mLastSaveFile; |
645 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 645 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
646 | 646 | ||
647 | if ( fn == "" ) | 647 | if ( fn == "" ) |
648 | return; | 648 | return; |
649 | QFileInfo info; | 649 | QFileInfo info; |
650 | info.setFile( fn ); | 650 | info.setFile( fn ); |
651 | QString mes; | 651 | QString mes; |
652 | bool createbup = true; | 652 | bool createbup = true; |
653 | if ( info. exists() ) { | 653 | if ( info. exists() ) { |
654 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 654 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
655 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 655 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
656 | i18n("Overwrite!"), i18n("Cancel"), 0, | 656 | i18n("Overwrite!"), i18n("Cancel"), 0, |
657 | 0, 1 ); | 657 | 0, 1 ); |
658 | if ( result != 0 ) { | 658 | if ( result != 0 ) { |
659 | createbup = false; | 659 | createbup = false; |
660 | } | 660 | } |
661 | } | 661 | } |
662 | if ( createbup ) { | 662 | if ( createbup ) { |
663 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 663 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
664 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 664 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
665 | Incidence *incidence = delSel.first(); | 665 | Incidence *incidence = delSel.first(); |
666 | icount = 0; | 666 | icount = 0; |
667 | while ( incidence ) { | 667 | while ( incidence ) { |
668 | if ( incidence->typeID() == journalID ) { | 668 | if ( incidence->typeID() == journalID ) { |
669 | text += "\n************************************\n"; | 669 | text += "\n************************************\n"; |
670 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 670 | if ( !incidence->summary().isEmpty() ) |
671 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | ||
672 | else | ||
673 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | ||
674 | if ( !incidence->location().isEmpty() ) | ||
675 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | ||
671 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 676 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
672 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 677 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
673 | ++icount; | 678 | ++icount; |
674 | 679 | ||
675 | } else { | 680 | } else { |
676 | if ( !incidence->description().isEmpty() ) { | 681 | if ( !incidence->description().isEmpty() ) { |
677 | text += "\n************************************\n"; | 682 | text += "\n************************************\n"; |
678 | if ( incidence->typeID() == todoID ) | 683 | if ( incidence->typeID() == todoID ) |
679 | text += i18n("To-Do: "); | 684 | text += i18n("To-Do: "); |
680 | text += incidence->summary(); | 685 | text += incidence->summary(); |
686 | if ( !incidence->location().isEmpty() ) | ||
687 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | ||
681 | if ( incidence->hasStartDate() ) | 688 | if ( incidence->hasStartDate() ) |
682 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 689 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
683 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 690 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
684 | if ( !incidence->location().isEmpty() ) | ||
685 | text += "\n" +i18n("Location: ") + incidence->location(); | ||
686 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 691 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
687 | ++icount; | 692 | ++icount; |
688 | 693 | ||
689 | } | 694 | } |
690 | } | 695 | } |
691 | incidence = delSel.next(); | 696 | incidence = delSel.next(); |
692 | } | 697 | } |
693 | QFile file( fn ); | 698 | QFile file( fn ); |
694 | if (!file.open( IO_WriteOnly ) ) { | 699 | if (!file.open( IO_WriteOnly ) ) { |
695 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 700 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
696 | return; | 701 | return; |
697 | } | 702 | } |
698 | QTextStream ts( &file ); | 703 | QTextStream ts( &file ); |
699 | ts << text; | 704 | ts << text; |
700 | file.close(); | 705 | file.close(); |
701 | //qDebug("%s ", text.latin1()); | 706 | //qDebug("%s ", text.latin1()); |
702 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 707 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
703 | KOPrefs::instance()->mLastSaveFile = fn; | 708 | KOPrefs::instance()->mLastSaveFile = fn; |
704 | topLevelWidget()->setCaption(mes); | 709 | topLevelWidget()->setCaption(mes); |
705 | } | 710 | } |
706 | } | 711 | } |
707 | } | 712 | } |
708 | void KOListView::saveToFileVCS() | 713 | void KOListView::saveToFileVCS() |
709 | { | 714 | { |
710 | writeToFile( false ); | 715 | writeToFile( false ); |
711 | } | 716 | } |
712 | void KOListView::saveToFile() | 717 | void KOListView::saveToFile() |
713 | { | 718 | { |
714 | writeToFile( true ); | 719 | writeToFile( true ); |
715 | } | 720 | } |
716 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 721 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
717 | { | 722 | { |
718 | QPtrList<Incidence> delSel ; | 723 | QPtrList<Incidence> delSel ; |
719 | bool addSubTodos = false; | 724 | bool addSubTodos = false; |
720 | bool askSubTodos = true; | 725 | bool askSubTodos = true; |
721 | QListViewItem *item = mListView->firstChild (); | 726 | QListViewItem *item = mListView->firstChild (); |
722 | while ( item ) { | 727 | while ( item ) { |
723 | if ( item->isSelected() ) { | 728 | if ( item->isSelected() ) { |
724 | Incidence* inc = ((KOListViewItem *)item)->data(); | 729 | Incidence* inc = ((KOListViewItem *)item)->data(); |
725 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { | 730 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
726 | if ( (inc->typeID() == todoID && includeTodos) || | 731 | if ( (inc->typeID() == todoID && includeTodos) || |
727 | (inc->typeID() == eventID && includeEvents) || | 732 | (inc->typeID() == eventID && includeEvents) || |
728 | (inc->typeID() == journalID && includeJournals) ) { | 733 | (inc->typeID() == journalID && includeJournals) ) { |
729 | if ( inc->typeID() == todoID && onlyDueTodos ) { | 734 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
730 | if ( ((Todo*)inc)->hasDueDate() ) | 735 | if ( ((Todo*)inc)->hasDueDate() ) |
731 | delSel.append( inc ); | 736 | delSel.append( inc ); |
732 | } else | 737 | } else |
733 | delSel.append( inc ); | 738 | delSel.append( inc ); |
734 | 739 | ||
735 | } | 740 | } |
736 | } | 741 | } |
737 | if ( inc->typeID() == todoID ) { | 742 | if ( inc->typeID() == todoID ) { |
738 | Todo * todo = (Todo*) inc; | 743 | Todo * todo = (Todo*) inc; |
739 | if ( todo->relations().count() ) { | 744 | if ( todo->relations().count() ) { |
740 | if ( askSubTodos ) { | 745 | if ( askSubTodos ) { |
741 | int result = KMessageBox::warningYesNoCancel(this, | 746 | int result = KMessageBox::warningYesNoCancel(this, |
742 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 747 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
743 | i18n("Todo has subtodos"), | 748 | i18n("Todo has subtodos"), |
744 | i18n("Yes"), | 749 | i18n("Yes"), |
745 | i18n("No")); | 750 | i18n("No")); |
746 | if ( result == KMessageBox::Cancel ) { | 751 | if ( result == KMessageBox::Cancel ) { |
747 | delSel.clear(); | 752 | delSel.clear(); |
748 | return delSel; | 753 | return delSel; |
749 | } | 754 | } |
750 | if (result == KMessageBox::Yes) | 755 | if (result == KMessageBox::Yes) |
751 | addSubTodos = true; | 756 | addSubTodos = true; |
752 | askSubTodos = false; | 757 | askSubTodos = false; |
753 | } | 758 | } |
754 | if ( addSubTodos ) { | 759 | if ( addSubTodos ) { |
755 | inc->addRelationsToList( &delSel ); | 760 | inc->addRelationsToList( &delSel ); |
756 | } | 761 | } |
757 | } | 762 | } |
758 | } | 763 | } |
759 | } | 764 | } |
760 | item = item->nextSibling(); | 765 | item = item->nextSibling(); |
761 | } | 766 | } |
762 | return delSel; | 767 | return delSel; |
763 | } | 768 | } |
764 | 769 | ||
765 | void KOListView::writeToFile( bool iCal ) | 770 | void KOListView::writeToFile( bool iCal ) |
766 | { | 771 | { |
767 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 772 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
768 | if ( !iCal ) { | 773 | if ( !iCal ) { |
769 | bool journal = false; | 774 | bool journal = false; |
770 | Incidence *incidence = delSel.first(); | 775 | Incidence *incidence = delSel.first(); |
771 | while ( incidence ) { | 776 | while ( incidence ) { |
772 | if ( incidence->typeID() == journalID ) { | 777 | if ( incidence->typeID() == journalID ) { |
773 | journal = true; | 778 | journal = true; |
774 | break; | 779 | break; |
775 | } | 780 | } |
776 | incidence = delSel.next(); | 781 | incidence = delSel.next(); |
777 | } | 782 | } |
778 | if ( journal ) { | 783 | if ( journal ) { |
779 | int result = KMessageBox::warningContinueCancel(this, | 784 | int result = KMessageBox::warningContinueCancel(this, |
780 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 785 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
781 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 786 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |