summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp69
1 files changed, 55 insertions, 14 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2af605f..98d3e35 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -525,2 +525,21 @@ void MainWindow::showMaximized ()
}
+
+bool MainWindow::askForQuitOnSaveError()
+{
+ bool retval = false;
+ switch( QMessageBox::information( this, "KO/Pi",
+ i18n("Error saving data") + "!\n" +
+ i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
+ i18n("Do you really want\nto close KO/Pi?"),
+ i18n(" Yes, close "), i18n("No"),
+ 0, 1 ) ) {
+ case 0:
+ retval = true;
+ break;
+ default:
+ break;
+ }
+ return retval;
+}
+
void MainWindow::closeEvent( QCloseEvent* ce )
@@ -532,3 +551,3 @@ void MainWindow::closeEvent( QCloseEvent* ce )
saveOnClose();
- if ( mCalendarModifiedFlag ) {
+ if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
ce->ignore();
@@ -548,3 +567,3 @@ void MainWindow::closeEvent( QCloseEvent* ce )
saveOnClose();
- if ( mCalendarModifiedFlag ) {
+ if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
ce->ignore();
@@ -1167,2 +1186,6 @@ void MainWindow::initActions()
//importMenu->insertSeparator();
+ action = new QAction( "export ical", i18n("Export All Data"), 0,
+ this );
+ action->addTo( exportMenu_X );
+ connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) );
action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
@@ -1969,3 +1992,3 @@ void MainWindow::slotModifiedChanged( bool )
mSaveTimer.start( msec, true ); // 1 minute
- mSaveTime.restart();
+ mSaveTimerStart = QDateTime::currentDateTime();
mSaveDelay = msec/1000;
@@ -2019,8 +2042,10 @@ void MainWindow::save()
if ( mSaveDelay ) {
- if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) {
- qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 );
- qDebug("KO: Restarting save timer");
- int msec = 10000;
- mSaveTimer.start( msec, true ); // 1 minute
- mSaveTime.restart();
+ int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
+ if ( mSaveDelay < elapsed ) {
+ qDebug("KO: Pending save after wakeup from suspend detected.");
+ qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
+ qDebug("KO: Restarting save timer to save in 15 sec.");
+ int msec = 15000;
+ mSaveTimer.start( msec, true );
+ mSaveTimerStart = QDateTime::currentDateTime();
mSaveDelay = msec/1000;
@@ -2577,7 +2602,11 @@ void MainWindow::importIcal()
}
-
-void MainWindow::exportVCalendar()
+void MainWindow::exportCalendar( bool iCalFormat )
{
QString fn = KOPrefs::instance()->mLastVcalFile;
- fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
+ if ( iCalFormat ) {
+ fn = QDir::homeDirPath()+"/kopiexport.ics";
+ fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
+ }
+ else
+ fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
if ( fn == "" )
@@ -2598,4 +2627,8 @@ void MainWindow::exportVCalendar()
if ( createbup ) {
- if ( mView->exportVCalendar( fn ) ) {
- KOPrefs::instance()->mLastVcalFile = fn;
+ bool success = false;
+ if ( iCalFormat )
+ success = mView->exportICalendar( fn );
+ else
+ success = mView->exportVCalendar( fn );
+ if ( success ) {
if ( fn.length() > 20 )
@@ -2609,2 +2642,10 @@ void MainWindow::exportVCalendar()
}
+void MainWindow::exportICalendar()
+{
+ exportCalendar( true );
+}
+void MainWindow::exportVCalendar()
+{
+ exportCalendar( false );
+}
QString MainWindow::sentSyncFile()