author | zautrix <zautrix> | 2005-09-18 13:50:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-18 13:50:46 (UTC) |
commit | c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5 (patch) (unidiff) | |
tree | 94e7bdc361b68a3a569eebe14f66458b3795dd6a /korganizer | |
parent | e7cd095ea9e80e26c90cbc2d3bf36921b7541c19 (diff) | |
download | kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.zip kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.gz kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.bz2 |
delay
-rw-r--r-- | korganizer/calendarview.cpp | 13 | ||||
-rw-r--r-- | korganizer/calendarview.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 69 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 5 |
4 files changed, 69 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 79fb727..2ba8528 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2544,12 +2544,13 @@ bool CalendarView::saveCalendars() | |||
2544 | else | 2544 | else |
2545 | saveError += cal->mName + "\n"; | 2545 | saveError += cal->mName + "\n"; |
2546 | } | 2546 | } |
2547 | cal = calendars.next(); | 2547 | cal = calendars.next(); |
2548 | } | 2548 | } |
2549 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2550 | //saveError = "test error"; | ||
2550 | if ( !saveError.isEmpty() ) { | 2551 | if ( !saveError.isEmpty() ) { |
2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2552 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2553 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2553 | return false; | 2554 | return false; |
2554 | } | 2555 | } |
2555 | return true; | 2556 | return true; |
@@ -4460,22 +4461,24 @@ void CalendarView::printPreview() | |||
4460 | DateList tmpDateList = mNavigator->selectedDates(); | 4461 | DateList tmpDateList = mNavigator->selectedDates(); |
4461 | 4462 | ||
4462 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4463 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4463 | tmpDateList.last()); | 4464 | tmpDateList.last()); |
4464 | #endif | 4465 | #endif |
4465 | } | 4466 | } |
4466 | 4467 | bool CalendarView::exportICalendar( QString filename ) | |
4467 | void CalendarView::exportICalendar() | ||
4468 | { | 4468 | { |
4469 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | ||
4470 | |||
4471 | // Force correct extension | 4469 | // Force correct extension |
4472 | if (filename.right(4) != ".ics") filename += ".ics"; | 4470 | if (filename.right(4) != ".ics") filename += ".ics"; |
4473 | 4471 | ||
4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4472 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4475 | storage.save(); | 4473 | return storage.save(); |
4474 | } | ||
4475 | |||
4476 | bool CalendarView::exportICalendar() | ||
4477 | { | ||
4478 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | ||
4476 | } | 4479 | } |
4477 | 4480 | ||
4478 | bool CalendarView::exportVCalendar( QString filename ) | 4481 | bool CalendarView::exportVCalendar( QString filename ) |
4479 | { | 4482 | { |
4480 | if (mCalendar->journals().count() > 0) { | 4483 | if (mCalendar->journals().count() > 0) { |
4481 | int result = KMessageBox::warningContinueCancel(this, | 4484 | int result = KMessageBox::warningContinueCancel(this, |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index b223315..8670832 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -373,13 +373,14 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
373 | */ | 373 | */ |
374 | void print(); | 374 | void print(); |
375 | void printSetup(); | 375 | void printSetup(); |
376 | void printPreview(); | 376 | void printPreview(); |
377 | 377 | ||
378 | /** Export as iCalendar file */ | 378 | /** Export as iCalendar file */ |
379 | void exportICalendar(); | 379 | bool exportICalendar(); |
380 | bool exportICalendar( QString fn ); | ||
380 | 381 | ||
381 | /** Export as vCalendar file */ | 382 | /** Export as vCalendar file */ |
382 | bool exportVCalendar( QString fn); | 383 | bool exportVCalendar( QString fn); |
383 | 384 | ||
384 | /** pop up a dialog to show an existing appointment. */ | 385 | /** pop up a dialog to show an existing appointment. */ |
385 | void appointment_show(); | 386 | void appointment_show(); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2af605f..98d3e35 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -520,20 +520,39 @@ void MainWindow::showMaximized () | |||
520 | if ( mClosed ) | 520 | if ( mClosed ) |
521 | mView->goToday(); | 521 | mView->goToday(); |
522 | #endif | 522 | #endif |
523 | QWidget::showMaximized () ; | 523 | QWidget::showMaximized () ; |
524 | mClosed = false; | 524 | mClosed = false; |
525 | } | 525 | } |
526 | |||
527 | bool 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 | |||
526 | void MainWindow::closeEvent( QCloseEvent* ce ) | 545 | void MainWindow::closeEvent( QCloseEvent* ce ) |
527 | { | 546 | { |
528 | 547 | ||
529 | 548 | ||
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 | } |
537 | mClosed = true; | 556 | mClosed = true; |
538 | ce->accept(); | 557 | ce->accept(); |
539 | return; | 558 | return; |
@@ -543,13 +562,13 @@ void MainWindow::closeEvent( QCloseEvent* ce ) | |||
543 | switch( QMessageBox::information( this, "KO/Pi", | 562 | switch( QMessageBox::information( this, "KO/Pi", |
544 | i18n("Do you really want\nto close KO/Pi?"), | 563 | i18n("Do you really want\nto close KO/Pi?"), |
545 | i18n("Close"), i18n("No"), | 564 | i18n("Close"), i18n("No"), |
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 | } |
553 | mClosed = true; | 572 | mClosed = true; |
554 | ce->accept(); | 573 | ce->accept(); |
555 | break; | 574 | break; |
@@ -1162,12 +1181,16 @@ void MainWindow::initActions() | |||
1162 | this ); | 1181 | this ); |
1163 | action->addTo( importMenu ); | 1182 | action->addTo( importMenu ); |
1164 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1183 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
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 ); |
1171 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1194 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1172 | 1195 | ||
1173 | 1196 | ||
@@ -1964,13 +1987,13 @@ void MainWindow::slotModifiedChanged( bool ) | |||
1964 | // and for safety reasons after 10 minutes again | 1987 | // and for safety reasons after 10 minutes again |
1965 | if ( !mSyncManager->blockSave() ) | 1988 | if ( !mSyncManager->blockSave() ) |
1966 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1989 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
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; |
1974 | } | 1997 | } |
1975 | void MainWindow::saveStopTimer() | 1998 | void MainWindow::saveStopTimer() |
1976 | { | 1999 | { |
@@ -2014,18 +2037,20 @@ void MainWindow::backupAllFiles() | |||
2014 | } | 2037 | } |
2015 | // retval == 3: do nothing, try again later | 2038 | // retval == 3: do nothing, try again later |
2016 | } | 2039 | } |
2017 | void MainWindow::save() | 2040 | void 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 | } |
2029 | } | 2054 | } |
2030 | 2055 | ||
2031 | if ( mView->viewManager()->journalView() ) | 2056 | if ( mView->viewManager()->journalView() ) |
@@ -2572,17 +2597,21 @@ void MainWindow::importIcal() | |||
2572 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2597 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2573 | if ( fn == "" ) | 2598 | if ( fn == "" ) |
2574 | return; | 2599 | return; |
2575 | importFile( fn, true ); | 2600 | importFile( fn, true ); |
2576 | 2601 | ||
2577 | } | 2602 | } |
2578 | 2603 | void MainWindow::exportCalendar( bool iCalFormat ) | |
2579 | void 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; |
2586 | info.setFile( fn ); | 2615 | info.setFile( fn ); |
2587 | QString mes; | 2616 | QString mes; |
2588 | bool createbup = true; | 2617 | bool createbup = true; |
@@ -2593,23 +2622,35 @@ void MainWindow::exportVCalendar() | |||
2593 | 0, 1 ); | 2622 | 0, 1 ); |
2594 | if ( result != 0 ) { | 2623 | if ( result != 0 ) { |
2595 | createbup = false; | 2624 | createbup = false; |
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 |
2604 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2637 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2605 | setCaption(mes); | 2638 | setCaption(mes); |
2606 | } | 2639 | } |
2607 | } | 2640 | } |
2608 | 2641 | ||
2609 | } | 2642 | } |
2643 | void MainWindow::exportICalendar() | ||
2644 | { | ||
2645 | exportCalendar( true ); | ||
2646 | } | ||
2647 | void MainWindow::exportVCalendar() | ||
2648 | { | ||
2649 | exportCalendar( false ); | ||
2650 | } | ||
2610 | QString MainWindow::sentSyncFile() | 2651 | QString MainWindow::sentSyncFile() |
2611 | { | 2652 | { |
2612 | #ifdef DESKTOP_VERSION | 2653 | #ifdef DESKTOP_VERSION |
2613 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); | 2654 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); |
2614 | #else | 2655 | #else |
2615 | return QString( "/tmp/copysynccal.ics" ); | 2656 | return QString( "/tmp/copysynccal.ics" ); |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 657c0a8..71c069b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -90,12 +90,14 @@ class MainWindow : public QMainWindow | |||
90 | void printSel(); | 90 | void printSel(); |
91 | void printCal(); | 91 | void printCal(); |
92 | void printListView(); | 92 | void printListView(); |
93 | void saveCalendar(); | 93 | void saveCalendar(); |
94 | void loadCalendar(); | 94 | void loadCalendar(); |
95 | void exportVCalendar(); | 95 | void exportVCalendar(); |
96 | void exportICalendar(); | ||
97 | void exportCalendar( bool ); | ||
96 | void fillFilterMenu(); | 98 | void fillFilterMenu(); |
97 | void fillFilterMenuTB(); | 99 | void fillFilterMenuTB(); |
98 | void selectFilter( int ); | 100 | void selectFilter( int ); |
99 | void fillFilterMenuPopup(); | 101 | void fillFilterMenuPopup(); |
100 | void selectFilterPopup( int ); | 102 | void selectFilterPopup( int ); |
101 | void exportToPhone( int ); | 103 | void exportToPhone( int ); |
@@ -113,12 +115,13 @@ class MainWindow : public QMainWindow | |||
113 | protected: | 115 | protected: |
114 | int mFocusLoop; | 116 | int mFocusLoop; |
115 | void hideEvent ( QHideEvent * ); | 117 | void hideEvent ( QHideEvent * ); |
116 | QString sentSyncFile(); | 118 | QString sentSyncFile(); |
117 | void displayText( QString, QString); | 119 | void displayText( QString, QString); |
118 | void enableIncidenceActions( bool ); | 120 | void enableIncidenceActions( bool ); |
121 | bool askForQuitOnSaveError(); | ||
119 | 122 | ||
120 | private: | 123 | private: |
121 | 124 | ||
122 | QCString mCStringMess; | 125 | QCString mCStringMess; |
123 | QByteArray mByteData; | 126 | QByteArray mByteData; |
124 | 127 | ||
@@ -171,13 +174,13 @@ class MainWindow : public QMainWindow | |||
171 | QAction *mToggleFilter; | 174 | QAction *mToggleFilter; |
172 | QAction *mToggleAllday; | 175 | QAction *mToggleAllday; |
173 | QAction *actionFilterMenuTB; | 176 | QAction *actionFilterMenuTB; |
174 | 177 | ||
175 | void closeEvent( QCloseEvent* ce ); | 178 | void closeEvent( QCloseEvent* ce ); |
176 | QTimer mSaveTimer; | 179 | QTimer mSaveTimer; |
177 | QTime mSaveTime; | 180 | QDateTime mSaveTimerStart; |
178 | int mSaveDelay; | 181 | int mSaveDelay; |
179 | //bool mBlockSaveFlag; | 182 | //bool mBlockSaveFlag; |
180 | bool mCalendarModifiedFlag; | 183 | bool mCalendarModifiedFlag; |
181 | QPixmap loadPixmap( QString ); | 184 | QPixmap loadPixmap( QString ); |
182 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; | 185 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; |
183 | }; | 186 | }; |