summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Unidiff
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
@@ -523,6 +523,25 @@ void MainWindow::showMaximized ()
523 QWidget::showMaximized () ; 523 QWidget::showMaximized () ;
524 mClosed = false; 524 mClosed = false;
525} 525}
526
527bool MainWindow::askForQuitOnSaveError()
528{
529 bool retval = false;
530 switch( QMessageBox::information( this, "KO/Pi",
531 i18n("Error saving data") + "!\n" +
532 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
533 i18n("Do you really want\nto close KO/Pi?"),
534 i18n(" Yes, close "), i18n("No"),
535 0, 1 ) ) {
536 case 0:
537 retval = true;
538 break;
539 default:
540 break;
541 }
542 return retval;
543}
544
526void MainWindow::closeEvent( QCloseEvent* ce ) 545void MainWindow::closeEvent( QCloseEvent* ce )
527{ 546{
528 547
@@ -530,7 +549,7 @@ void MainWindow::closeEvent( QCloseEvent* ce )
530 549
531 if ( ! KOPrefs::instance()->mAskForQuit ) { 550 if ( ! KOPrefs::instance()->mAskForQuit ) {
532 saveOnClose(); 551 saveOnClose();
533 if ( mCalendarModifiedFlag ) { 552 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
534 ce->ignore(); 553 ce->ignore();
535 return; 554 return;
536 } 555 }
@@ -546,7 +565,7 @@ void MainWindow::closeEvent( QCloseEvent* ce )
546 0, 0 ) ) { 565 0, 0 ) ) {
547 case 0: 566 case 0:
548 saveOnClose(); 567 saveOnClose();
549 if ( mCalendarModifiedFlag ) { 568 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
550 ce->ignore(); 569 ce->ignore();
551 return; 570 return;
552 } 571 }
@@ -1165,6 +1184,10 @@ void MainWindow::initActions()
1165 importMenu->insertSeparator(); 1184 importMenu->insertSeparator();
1166 importMenu->insertItem( i18n("Import"), importMenu_X ); 1185 importMenu->insertItem( i18n("Import"), importMenu_X );
1167 //importMenu->insertSeparator(); 1186 //importMenu->insertSeparator();
1187 action = new QAction( "export ical", i18n("Export All Data"), 0,
1188 this );
1189 action->addTo( exportMenu_X );
1190 connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) );
1168 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1191 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1169 this ); 1192 this );
1170 action->addTo( exportMenu_X ); 1193 action->addTo( exportMenu_X );
@@ -1967,7 +1990,7 @@ void MainWindow::slotModifiedChanged( bool )
1967 else 1990 else
1968 msec = 1000 * 600; 1991 msec = 1000 * 600;
1969 mSaveTimer.start( msec, true ); // 1 minute 1992 mSaveTimer.start( msec, true ); // 1 minute
1970 mSaveTime.restart(); 1993 mSaveTimerStart = QDateTime::currentDateTime();
1971 mSaveDelay = msec/1000; 1994 mSaveDelay = msec/1000;
1972 qDebug("KO: Saving File in %d secs!", msec/1000); 1995 qDebug("KO: Saving File in %d secs!", msec/1000);
1973 mCalendarModifiedFlag = true; 1996 mCalendarModifiedFlag = true;
@@ -2017,12 +2040,14 @@ void MainWindow::backupAllFiles()
2017void MainWindow::save() 2040void MainWindow::save()
2018{ 2041{
2019 if ( mSaveDelay ) { 2042 if ( mSaveDelay ) {
2020 if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) { 2043 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
2021 qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 ); 2044 if ( mSaveDelay < elapsed ) {
2022 qDebug("KO: Restarting save timer"); 2045 qDebug("KO: Pending save after wakeup from suspend detected.");
2023 int msec = 10000; 2046 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
2024 mSaveTimer.start( msec, true ); // 1 minute 2047 qDebug("KO: Restarting save timer to save in 15 sec.");
2025 mSaveTime.restart(); 2048 int msec = 15000;
2049 mSaveTimer.start( msec, true );
2050 mSaveTimerStart = QDateTime::currentDateTime();
2026 mSaveDelay = msec/1000; 2051 mSaveDelay = msec/1000;
2027 return; 2052 return;
2028 } 2053 }
@@ -2575,11 +2600,15 @@ void MainWindow::importIcal()
2575 importFile( fn, true ); 2600 importFile( fn, true );
2576 2601
2577} 2602}
2578 2603void MainWindow::exportCalendar( bool iCalFormat )
2579void MainWindow::exportVCalendar()
2580{ 2604{
2581 QString fn = KOPrefs::instance()->mLastVcalFile; 2605 QString fn = KOPrefs::instance()->mLastVcalFile;
2582 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2606 if ( iCalFormat ) {
2607 fn = QDir::homeDirPath()+"/kopiexport.ics";
2608 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
2609 }
2610 else
2611 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2583 if ( fn == "" ) 2612 if ( fn == "" )
2584 return; 2613 return;
2585 QFileInfo info; 2614 QFileInfo info;
@@ -2596,8 +2625,12 @@ void MainWindow::exportVCalendar()
2596 } 2625 }
2597 } 2626 }
2598 if ( createbup ) { 2627 if ( createbup ) {
2599 if ( mView->exportVCalendar( fn ) ) { 2628 bool success = false;
2600 KOPrefs::instance()->mLastVcalFile = fn; 2629 if ( iCalFormat )
2630 success = mView->exportICalendar( fn );
2631 else
2632 success = mView->exportVCalendar( fn );
2633 if ( success ) {
2601 if ( fn.length() > 20 ) 2634 if ( fn.length() > 20 )
2602 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2635 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2603 else 2636 else
@@ -2607,6 +2640,14 @@ void MainWindow::exportVCalendar()
2607 } 2640 }
2608 2641
2609} 2642}
2643void MainWindow::exportICalendar()
2644{
2645 exportCalendar( true );
2646}
2647void MainWindow::exportVCalendar()
2648{
2649 exportCalendar( false );
2650}
2610QString MainWindow::sentSyncFile() 2651QString MainWindow::sentSyncFile()
2611{ 2652{
2612#ifdef DESKTOP_VERSION 2653#ifdef DESKTOP_VERSION