author | zautrix <zautrix> | 2005-03-11 19:38:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-11 19:38:46 (UTC) |
commit | efa425789895481dd918a55af27895a7917d2a20 (patch) (unidiff) | |
tree | cb6b6d495c17dd649fcc6387a41b2db2eef1d39d /korganizer | |
parent | 1166a4797a91cedd5002a3513d5028c5e86016f0 (diff) | |
download | kdepimpi-efa425789895481dd918a55af27895a7917d2a20.zip kdepimpi-efa425789895481dd918a55af27895a7917d2a20.tar.gz kdepimpi-efa425789895481dd918a55af27895a7917d2a20.tar.bz2 |
better kopi export
-rw-r--r-- | korganizer/kolistview.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index f235705..3519985 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -601,97 +601,109 @@ void KOListView::saveDescriptionToFile() | |||
601 | QTextStream ts( &file ); | 601 | QTextStream ts( &file ); |
602 | ts << text; | 602 | ts << text; |
603 | file.close(); | 603 | file.close(); |
604 | //qDebug("%s ", text.latin1()); | 604 | //qDebug("%s ", text.latin1()); |
605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
606 | KOPrefs::instance()->mLastSaveFile = fn; | 606 | KOPrefs::instance()->mLastSaveFile = fn; |
607 | topLevelWidget()->setCaption(mes); | 607 | topLevelWidget()->setCaption(mes); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | void KOListView::saveToFileVCS() | 611 | void KOListView::saveToFileVCS() |
612 | { | 612 | { |
613 | writeToFile( false ); | 613 | writeToFile( false ); |
614 | } | 614 | } |
615 | void KOListView::saveToFile() | 615 | void KOListView::saveToFile() |
616 | { | 616 | { |
617 | writeToFile( true ); | 617 | writeToFile( true ); |
618 | } | 618 | } |
619 | void KOListView::writeToFile( bool iCal ) | 619 | void KOListView::writeToFile( bool iCal ) |
620 | { | 620 | { |
621 | 621 | ||
622 | int icount = 0; | 622 | int icount = 0; |
623 | QPtrList<Incidence> delSel ; | 623 | QPtrList<Incidence> delSel ; |
624 | QListViewItem *item = mListView->firstChild (); | 624 | QListViewItem *item = mListView->firstChild (); |
625 | bool journal = iCal; // warn only for vCal | ||
625 | while ( item ) { | 626 | while ( item ) { |
626 | if ( item->isSelected() ) { | 627 | if ( item->isSelected() ) { |
628 | if ( !journal ) | ||
629 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") | ||
630 | journal = true; | ||
627 | delSel.append(((KOListViewItem *)item)->data()); | 631 | delSel.append(((KOListViewItem *)item)->data()); |
628 | ++icount; | 632 | ++icount; |
629 | } | 633 | } |
630 | 634 | ||
631 | item = item->nextSibling(); | 635 | item = item->nextSibling(); |
632 | } | 636 | } |
637 | if ( !iCal && journal ) { | ||
638 | int result = KMessageBox::warningContinueCancel(this, | ||
639 | i18n("The journal entries can not be\nexported to a vCalendar file."), | ||
640 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | ||
641 | true); | ||
642 | if (result != KMessageBox::Continue) return; | ||
643 | } | ||
633 | if ( icount ) { | 644 | if ( icount ) { |
634 | QString fn = KOPrefs::instance()->mLastSaveFile; | 645 | QString fn = KOPrefs::instance()->mLastSaveFile; |
635 | QString extension; | 646 | QString extension; |
636 | if ( iCal ) { | 647 | if ( iCal ) { |
637 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 648 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
638 | fn = fn.left( fn.length() -3) + "ics"; | 649 | fn = fn.left( fn.length() -3) + "ics"; |
639 | } | 650 | } |
640 | } else { | 651 | } else { |
641 | if ( fn.right( 4 ).lower() == ".ics" ) { | 652 | if ( fn.right( 4 ).lower() == ".ics" ) { |
642 | fn = fn.left( fn.length() -3) + "vcs"; | 653 | fn = fn.left( fn.length() -3) + "vcs"; |
643 | } | 654 | } |
644 | } | 655 | } |
645 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 656 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
646 | 657 | ||
647 | if ( fn == "" ) | 658 | if ( fn == "" ) |
648 | return; | 659 | return; |
649 | QFileInfo info; | 660 | QFileInfo info; |
650 | info.setFile( fn ); | 661 | info.setFile( fn ); |
651 | QString mes; | 662 | QString mes; |
652 | bool createbup = true; | 663 | bool createbup = true; |
653 | if ( info. exists() ) { | 664 | if ( info. exists() ) { |
654 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 665 | 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, | 666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
656 | i18n("Overwrite!"), i18n("Cancel"), 0, | 667 | i18n("Overwrite!"), i18n("Cancel"), 0, |
657 | 0, 1 ); | 668 | 0, 1 ); |
658 | if ( result != 0 ) { | 669 | if ( result != 0 ) { |
659 | createbup = false; | 670 | createbup = false; |
660 | } | 671 | } |
661 | } | 672 | } |
662 | if ( createbup ) { | 673 | if ( createbup ) { |
663 | CalendarLocal cal; | 674 | CalendarLocal cal; |
664 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 675 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
665 | Incidence *incidence = delSel.first(); | 676 | Incidence *incidence = delSel.first(); |
666 | while ( incidence ) { | 677 | while ( incidence ) { |
667 | cal.addIncidence( incidence->clone() ); | 678 | cal.addIncidence( incidence->clone() ); |
668 | incidence = delSel.next(); | 679 | incidence = delSel.next(); |
669 | } | 680 | } |
670 | if ( iCal ) { | 681 | if ( iCal ) { |
671 | ICalFormat format; | 682 | ICalFormat format; |
672 | format.save( &cal, fn ); | 683 | format.save( &cal, fn ); |
673 | } else { | 684 | } else { |
685 | |||
674 | VCalFormat format; | 686 | VCalFormat format; |
675 | format.save( &cal, fn ); | 687 | format.save( &cal, fn ); |
676 | } | 688 | } |
677 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 689 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
678 | KOPrefs::instance()->mLastSaveFile = fn; | 690 | KOPrefs::instance()->mLastSaveFile = fn; |
679 | topLevelWidget()->setCaption(mes); | 691 | topLevelWidget()->setCaption(mes); |
680 | } | 692 | } |
681 | } | 693 | } |
682 | } | 694 | } |
683 | void KOListView::deleteAll() | 695 | void KOListView::deleteAll() |
684 | { | 696 | { |
685 | int icount = 0; | 697 | int icount = 0; |
686 | QPtrList<Incidence> delSel ; | 698 | QPtrList<Incidence> delSel ; |
687 | QListViewItem *item = mListView->firstChild (); | 699 | QListViewItem *item = mListView->firstChild (); |
688 | while ( item ) { | 700 | while ( item ) { |
689 | if ( item->isSelected() ) { | 701 | if ( item->isSelected() ) { |
690 | delSel.append(((KOListViewItem *)item)->data()); | 702 | delSel.append(((KOListViewItem *)item)->data()); |
691 | ++icount; | 703 | ++icount; |
692 | } | 704 | } |
693 | 705 | ||
694 | item = item->nextSibling(); | 706 | item = item->nextSibling(); |
695 | } | 707 | } |
696 | if ( icount ) { | 708 | if ( icount ) { |
697 | Incidence *incidence = delSel.first(); | 709 | Incidence *incidence = delSel.first(); |