From 1166a4797a91cedd5002a3513d5028c5e86016f0 Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 11 Mar 2005 19:26:02 +0000 Subject: better kopi export --- (limited to 'korganizer') diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 710a9f9..f235705 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -265,12 +265,14 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, i18n("Delete all selected"),this, SLOT(deleteAll()),true); mPopupMenu->insertSeparator(); - mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), - i18n("Save selected to file..."),this, - SLOT(saveToFile()),true); - mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), - i18n("Save Journal/Description..."),this, - SLOT(saveDescriptionToFile()),true); + QPopupMenu * exportPO = new QPopupMenu ( this ); + mPopupMenu->insertItem( i18n("Export selected"), exportPO ); + exportPO->insertItem( i18n("As iCal (ics) file..."),this, + SLOT(saveToFile())); + exportPO->insertItem( i18n("As vCal (vcs) file..."),this, + SLOT(saveToFileVCS())); + exportPO->insertItem( i18n("Journal/Details..."),this, + SLOT(saveDescriptionToFile())); // mPopupMenu->insertSeparator(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Add Categ. to selected..."),this, @@ -606,8 +608,16 @@ void KOListView::saveDescriptionToFile() } } } +void KOListView::saveToFileVCS() +{ + writeToFile( false ); +} void KOListView::saveToFile() { + writeToFile( true ); +} +void KOListView::writeToFile( bool iCal ) +{ int icount = 0; QPtrList delSel ; @@ -622,6 +632,16 @@ void KOListView::saveToFile() } if ( icount ) { QString fn = KOPrefs::instance()->mLastSaveFile; + QString extension; + if ( iCal ) { + if ( fn.right( 4 ).lower() == ".vcs" ) { + fn = fn.left( fn.length() -3) + "ics"; + } + } else { + if ( fn.right( 4 ).lower() == ".ics" ) { + fn = fn.left( fn.length() -3) + "vcs"; + } + } fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); if ( fn == "" ) @@ -647,8 +667,13 @@ void KOListView::saveToFile() cal.addIncidence( incidence->clone() ); incidence = delSel.next(); } - ICalFormat format; - format.save( &cal, fn ); + if ( iCal ) { + ICalFormat format; + format.save( &cal, fn ); + } else { + VCalFormat format; + format.save( &cal, fn ); + } mes = i18n("KO/Pi:Saved %1").arg(fn ); KOPrefs::instance()->mLastSaveFile = fn; topLevelWidget()->setCaption(mes); diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index c86449d..0d9c525 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -272,6 +272,7 @@ class KOListView : public KOEventView void hideDates(); void deleteAll(); void saveToFile(); + void saveToFileVCS(); void saveDescriptionToFile(); void beamSelected(); void updateConfig(); @@ -288,6 +289,7 @@ class KOListView : public KOEventView void processSelectionChange(QListViewItem *); protected: + void writeToFile( bool iCal ); void addEvents(QPtrList eventList); void addIncidence(Incidence *); KOListViewItem *getItemForEvent(Event *event); -- cgit v0.9.0.2