summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index eaea040..fecc7e2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1212,32 +1212,32 @@ void CalendarView::setSyncName( QString s )
1212{ 1212{
1213 mCurrentSyncName= s; 1213 mCurrentSyncName= s;
1214} 1214}
1215bool CalendarView::syncCalendar(QString filename, int mode) 1215bool CalendarView::syncCalendar(QString filename, int mode)
1216{ 1216{
1217 mGlobalSyncMode = SYNC_MODE_NORMAL; 1217 mGlobalSyncMode = SYNC_MODE_NORMAL;
1218 CalendarLocal* calendar = new CalendarLocal(); 1218 CalendarLocal* calendar = new CalendarLocal();
1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1220 FileStorage* storage = new FileStorage( calendar ); 1220 FileStorage* storage = new FileStorage( calendar );
1221 bool syncOK = false; 1221 bool syncOK = false;
1222 storage->setFileName( filename ); 1222 storage->setFileName( filename );
1223 // qDebug("loading ... "); 1223 // qDebug("loading ... ");
1224 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1224 if ( storage->load() ) {
1225 getEventViewerDialog()->setSyncMode( true ); 1225 getEventViewerDialog()->setSyncMode( true );
1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1227 getEventViewerDialog()->setSyncMode( false ); 1227 getEventViewerDialog()->setSyncMode( false );
1228 if ( syncOK ) { 1228 if ( syncOK ) {
1229 if ( KOPrefs::instance()->mWriteBackFile ) 1229 if ( KOPrefs::instance()->mWriteBackFile )
1230 { 1230 {
1231 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1231 storage->setSaveFormat( new ICalFormat() );
1232 storage->save(); 1232 storage->save();
1233 } 1233 }
1234 } 1234 }
1235 setModified( true ); 1235 setModified( true );
1236 } 1236 }
1237 delete storage; 1237 delete storage;
1238 delete calendar; 1238 delete calendar;
1239 if ( syncOK ) 1239 if ( syncOK )
1240 updateView(); 1240 updateView();
1241 return syncOK; 1241 return syncOK;
1242} 1242}
1243void CalendarView::syncPhone() 1243void CalendarView::syncPhone()
@@ -1490,42 +1490,44 @@ bool CalendarView::openCalendar(QString filename, bool merge)
1490 } 1490 }
1491 1491
1492 if (!QFile::exists(filename)) { 1492 if (!QFile::exists(filename)) {
1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 globalFlagBlockAgenda = 1; 1497 globalFlagBlockAgenda = 1;
1498 if (!merge) mCalendar->close(); 1498 if (!merge) mCalendar->close();
1499 1499
1500 mStorage->setFileName( filename ); 1500 mStorage->setFileName( filename );
1501 1501
1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1502 if ( mStorage->load() ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 if ( filename != MainWindow::defaultFileName() )
1518 saveCalendar( MainWindow::defaultFileName() );
1519 loadedFileVersion = QDateTime::currentDateTime(); 1517 loadedFileVersion = QDateTime::currentDateTime();
1518 if ( filename != MainWindow::defaultFileName() ) {
1519 saveCalendar( MainWindow::defaultFileName() );
1520 watchSavedFile();
1521 }
1520 return true; 1522 return true;
1521 } else { 1523 } else {
1522 // while failing to load, the calendar object could 1524 // while failing to load, the calendar object could
1523 // have become partially populated. Clear it out. 1525 // have become partially populated. Clear it out.
1524 if ( !merge ) mCalendar->close(); 1526 if ( !merge ) mCalendar->close();
1525 1527
1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1528 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1527 1529
1528 globalFlagBlockAgenda = 2; 1530 globalFlagBlockAgenda = 2;
1529 updateView(); 1531 updateView();
1530 } 1532 }
1531 return false; 1533 return false;
@@ -1591,25 +1593,25 @@ bool CalendarView::checkFileVersion(QString fn)
1591} 1593}
1592 1594
1593bool CalendarView::saveCalendar( QString filename ) 1595bool CalendarView::saveCalendar( QString filename )
1594{ 1596{
1595 1597
1596 // Store back all unsaved data into calendar object 1598 // Store back all unsaved data into calendar object
1597 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1599 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1598 if ( mViewManager->currentView() ) 1600 if ( mViewManager->currentView() )
1599 mViewManager->currentView()->flushView(); 1601 mViewManager->currentView()->flushView();
1600 1602
1601 //mStorage->setFileName( filename ); 1603 //mStorage->setFileName( filename );
1602 1604
1603 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1605 mStorage->setSaveFormat( new ICalFormat() );
1604 mStorage->setFileName( filename ); 1606 mStorage->setFileName( filename );
1605 bool success; 1607 bool success;
1606 success = mStorage->save(); 1608 success = mStorage->save();
1607 if ( !success ) { 1609 if ( !success ) {
1608 return false; 1610 return false;
1609 } 1611 }
1610 1612
1611 return true; 1613 return true;
1612} 1614}
1613 1615
1614void CalendarView::closeCalendar() 1616void CalendarView::closeCalendar()
1615{ 1617{
@@ -2292,25 +2294,25 @@ void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2292 Incidence *in = incidence->clone(); 2294 Incidence *in = incidence->clone();
2293 if ( addText ) 2295 if ( addText )
2294 description += in->summary() + "\n"; 2296 description += in->summary() + "\n";
2295 cal->addIncidence( in ); 2297 cal->addIncidence( in );
2296 incidence = delSel.next(); 2298 incidence = delSel.next();
2297 } 2299 }
2298 if ( beamDialog->beamVcal() ) { 2300 if ( beamDialog->beamVcal() ) {
2299 fn += ".vcs"; 2301 fn += ".vcs";
2300 FileStorage storage( cal, fn, new VCalFormat ); 2302 FileStorage storage( cal, fn, new VCalFormat );
2301 storage.save(); 2303 storage.save();
2302 } else { 2304 } else {
2303 fn += ".ics"; 2305 fn += ".ics";
2304 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2306 FileStorage storage( cal, fn, new ICalFormat( ) );
2305 storage.save(); 2307 storage.save();
2306 } 2308 }
2307 delete cal; 2309 delete cal;
2308 mes = i18n("KO/Pi: Ready for beaming"); 2310 mes = i18n("KO/Pi: Ready for beaming");
2309 setCaption(mes); 2311 setCaption(mes);
2310 2312
2311#ifndef DESKTOP_VERSION 2313#ifndef DESKTOP_VERSION
2312 Ir *ir = new Ir( this ); 2314 Ir *ir = new Ir( this );
2313 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2315 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2314 ir->send( fn, description, "text/x-vCalendar" ); 2316 ir->send( fn, description, "text/x-vCalendar" );
2315#endif 2317#endif
2316 } 2318 }
@@ -2847,25 +2849,25 @@ void CalendarView::action_mail()
2847 i18n("Can't generate mail:\nNo attendees defined.\n")); 2849 i18n("Can't generate mail:\nNo attendees defined.\n"));
2848 return; 2850 return;
2849 } 2851 }
2850 2852
2851 CalendarLocal cal_tmp; 2853 CalendarLocal cal_tmp;
2852 Event *event = 0; 2854 Event *event = 0;
2853 Event *ev = 0; 2855 Event *ev = 0;
2854 if ( incidence && incidence->type() == "Event" ) { 2856 if ( incidence && incidence->type() == "Event" ) {
2855 event = static_cast<Event *>(incidence); 2857 event = static_cast<Event *>(incidence);
2856 ev = new Event(*event); 2858 ev = new Event(*event);
2857 cal_tmp.addEvent(ev); 2859 cal_tmp.addEvent(ev);
2858 } 2860 }
2859 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2861 ICalFormat mForm();
2860 QString attachment = mForm.toString( &cal_tmp ); 2862 QString attachment = mForm.toString( &cal_tmp );
2861 if (ev) delete(ev); 2863 if (ev) delete(ev);
2862 2864
2863 mailClient.mailAttendees(currentSelection(), attachment); 2865 mailClient.mailAttendees(currentSelection(), attachment);
2864 2866
2865#endif 2867#endif
2866 2868
2867#if 0 2869#if 0
2868 Event *anEvent = 0; 2870 Event *anEvent = 0;
2869 if (mViewManager->currentView()->isEventView()) { 2871 if (mViewManager->currentView()->isEventView()) {
2870 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2872 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2871 } 2873 }
@@ -3132,25 +3134,25 @@ void CalendarView::printPreview()
3132 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3134 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3133 tmpDateList.last()); 3135 tmpDateList.last());
3134#endif 3136#endif
3135} 3137}
3136 3138
3137void CalendarView::exportICalendar() 3139void CalendarView::exportICalendar()
3138{ 3140{
3139 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3141 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3140 3142
3141 // Force correct extension 3143 // Force correct extension
3142 if (filename.right(4) != ".ics") filename += ".ics"; 3144 if (filename.right(4) != ".ics") filename += ".ics";
3143 3145
3144 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3146 FileStorage storage( mCalendar, filename, new ICalFormat() );
3145 storage.save(); 3147 storage.save();
3146} 3148}
3147 3149
3148bool CalendarView::exportVCalendar( QString filename ) 3150bool CalendarView::exportVCalendar( QString filename )
3149{ 3151{
3150 if (mCalendar->journals().count() > 0) { 3152 if (mCalendar->journals().count() > 0) {
3151 int result = KMessageBox::warningContinueCancel(this, 3153 int result = KMessageBox::warningContinueCancel(this,
3152 i18n("The journal entries can not be\nexported to a vCalendar file."), 3154 i18n("The journal entries can not be\nexported to a vCalendar file."),
3153 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3155 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3154 true); 3156 true);
3155 if (result != KMessageBox::Continue) return false; 3157 if (result != KMessageBox::Continue) return false;
3156 } 3158 }