-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 22 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 |
3 files changed, 23 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 14094bb..79fb727 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2491,26 +2491,26 @@ bool CalendarView::checkAllFileVersions() | |||
2491 | } | 2491 | } |
2492 | cal = calendars.next(); | 2492 | cal = calendars.next(); |
2493 | } | 2493 | } |
2494 | loadedFileVersion = storeTemp; | 2494 | loadedFileVersion = storeTemp; |
2495 | return true; | 2495 | return true; |
2496 | } | 2496 | } |
2497 | bool CalendarView::checkFileVersion(QString fn) | 2497 | bool CalendarView::checkFileVersion(QString fn) |
2498 | { | 2498 | { |
2499 | QFileInfo finf ( fn ); | 2499 | QFileInfo finf ( fn ); |
2500 | if ( !finf.exists() ) | 2500 | if ( !finf.exists() ) |
2501 | return true; | 2501 | return true; |
2502 | QDateTime dt = finf.lastModified (); | 2502 | QDateTime dt = finf.lastModified (); |
2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2503 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2504 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2505 | if ( dt <= loadedFileVersion ) | 2505 | if ( dt <= loadedFileVersion ) |
2506 | return true; | 2506 | return true; |
2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2509 | i18n("Sync+save")); | 2509 | i18n("Sync+save")); |
2510 | 2510 | ||
2511 | if ( km == KMessageBox::Cancel ) | 2511 | if ( km == KMessageBox::Cancel ) |
2512 | return false; | 2512 | return false; |
2513 | if ( km == KMessageBox::Yes ) | 2513 | if ( km == KMessageBox::Yes ) |
2514 | return true; | 2514 | return true; |
2515 | 2515 | ||
2516 | setSyncDevice("deleteaftersync" ); | 2516 | setSyncDevice("deleteaftersync" ); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 70baf5c..2af605f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -393,25 +393,26 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
393 | 393 | ||
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | infrared = 0; | 395 | infrared = 0; |
396 | #endif | 396 | #endif |
397 | updateFilterToolbar(); | 397 | updateFilterToolbar(); |
398 | updateWeek( mView->startDate() ); | 398 | updateWeek( mView->startDate() ); |
399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
401 | mBRdisabled = false; | 401 | mBRdisabled = false; |
402 | //toggleBeamReceive(); | 402 | //toggleBeamReceive(); |
403 | 403 | ||
404 | setCaption(i18n("Loading calendar files ... please wait" )); | 404 | setCaption(i18n("Loading calendar files ... please wait" )); |
405 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | 405 | mSaveDelay = 0; |
406 | QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); | ||
406 | } | 407 | } |
407 | MainWindow::~MainWindow() | 408 | MainWindow::~MainWindow() |
408 | { | 409 | { |
409 | //qDebug("MainWindow::~MainWindow() "); | 410 | //qDebug("MainWindow::~MainWindow() "); |
410 | //save toolbar location | 411 | //save toolbar location |
411 | delete mCalendar; | 412 | delete mCalendar; |
412 | delete mSyncManager; | 413 | delete mSyncManager; |
413 | #ifndef DESKTOP_VERSION | 414 | #ifndef DESKTOP_VERSION |
414 | if ( infrared ) | 415 | if ( infrared ) |
415 | delete infrared; | 416 | delete infrared; |
416 | #endif | 417 | #endif |
417 | 418 | ||
@@ -1957,24 +1958,26 @@ void MainWindow::slotModifiedChanged( bool ) | |||
1957 | int msec; | 1958 | int msec; |
1958 | if ( mCalendarModifiedFlag ) { | 1959 | if ( mCalendarModifiedFlag ) { |
1959 | //qDebug(" MainWindow timer is running "); | 1960 | //qDebug(" MainWindow timer is running "); |
1960 | return; | 1961 | return; |
1961 | } | 1962 | } |
1962 | // we store the changes after 1 minute, | 1963 | // we store the changes after 1 minute, |
1963 | // and for safety reasons after 10 minutes again | 1964 | // and for safety reasons after 10 minutes again |
1964 | if ( !mSyncManager->blockSave() ) | 1965 | if ( !mSyncManager->blockSave() ) |
1965 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1966 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1966 | else | 1967 | else |
1967 | msec = 1000 * 600; | 1968 | msec = 1000 * 600; |
1968 | mSaveTimer.start( msec, true ); // 1 minute | 1969 | mSaveTimer.start( msec, true ); // 1 minute |
1970 | mSaveTime.restart(); | ||
1971 | mSaveDelay = msec/1000; | ||
1969 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1972 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1970 | mCalendarModifiedFlag = true; | 1973 | mCalendarModifiedFlag = true; |
1971 | } | 1974 | } |
1972 | void MainWindow::saveStopTimer() | 1975 | void MainWindow::saveStopTimer() |
1973 | { | 1976 | { |
1974 | mSaveTimer.stop(); | 1977 | mSaveTimer.stop(); |
1975 | } | 1978 | } |
1976 | void MainWindow::backupAllFiles() | 1979 | void MainWindow::backupAllFiles() |
1977 | { | 1980 | { |
1978 | QDate reference ( 2000,1,1); | 1981 | QDate reference ( 2000,1,1); |
1979 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1982 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1980 | setCaption(i18n("Creating backup ... please wait ..." )); | 1983 | setCaption(i18n("Creating backup ... please wait ..." )); |
@@ -2004,52 +2007,65 @@ void MainWindow::backupAllFiles() | |||
2004 | KOPrefs::instance()->mLastBackupDate = daysTo; | 2007 | KOPrefs::instance()->mLastBackupDate = daysTo; |
2005 | setCaption(i18n("Backup succesfully finished" )); | 2008 | setCaption(i18n("Backup succesfully finished" )); |
2006 | } else if ( retval == 2 ){ | 2009 | } else if ( retval == 2 ){ |
2007 | setCaption(i18n("Backup globally disabled" )); | 2010 | setCaption(i18n("Backup globally disabled" )); |
2008 | qDebug("KO: Backup globally cancelled."); | 2011 | qDebug("KO: Backup globally cancelled."); |
2009 | // backup globally cancelled | 2012 | // backup globally cancelled |
2010 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2013 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2011 | } | 2014 | } |
2012 | // retval == 3: do nothing, try again later | 2015 | // retval == 3: do nothing, try again later |
2013 | } | 2016 | } |
2014 | void MainWindow::save() | 2017 | void MainWindow::save() |
2015 | { | 2018 | { |
2019 | if ( mSaveDelay ) { | ||
2020 | if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) { | ||
2021 | qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 ); | ||
2022 | qDebug("KO: Restarting save timer"); | ||
2023 | int msec = 10000; | ||
2024 | mSaveTimer.start( msec, true ); // 1 minute | ||
2025 | mSaveTime.restart(); | ||
2026 | mSaveDelay = msec/1000; | ||
2027 | return; | ||
2028 | } | ||
2029 | } | ||
2016 | 2030 | ||
2017 | if ( mView->viewManager()->journalView() ) | 2031 | if ( mView->viewManager()->journalView() ) |
2018 | mView->viewManager()->journalView()->checkModified(); | 2032 | mView->viewManager()->journalView()->checkModified(); |
2019 | if ( !mCalendarModifiedFlag ) { | 2033 | if ( !mCalendarModifiedFlag ) { |
2020 | qDebug("KO: Calendar not modified. Nothing saved."); | 2034 | qDebug("KO: Calendar not modified. Nothing saved."); |
2021 | return; | 2035 | return; |
2022 | } | 2036 | } |
2023 | if ( mSyncManager->blockSave() ) { | 2037 | if ( mSyncManager->blockSave() ) { |
2024 | slotModifiedChanged( true ); | 2038 | slotModifiedChanged( true ); |
2025 | return; | 2039 | return; |
2026 | } | 2040 | } |
2041 | mSaveDelay = 0; | ||
2027 | mSyncManager->setBlockSave(true); | 2042 | mSyncManager->setBlockSave(true); |
2028 | if ( mView->checkAllFileVersions() ) { | 2043 | if ( mView->checkAllFileVersions() ) { |
2029 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2044 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2030 | QDate reference ( 2000,1,1); | 2045 | QDate reference ( 2000,1,1); |
2031 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2046 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2032 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2047 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2033 | backupAllFiles(); | 2048 | backupAllFiles(); |
2034 | } | 2049 | } |
2035 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2050 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2036 | } | 2051 | } |
2037 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 2052 | QTime neededSaveTime; |
2053 | neededSaveTime.start(); | ||
2038 | if ( !isMinimized () ) | 2054 | if ( !isMinimized () ) |
2039 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2055 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2040 | qDebug("KO: Start saving data to file!"); | 2056 | qDebug("KO: Start saving data to file!"); |
2041 | if ( mView->saveCalendars() ) | 2057 | if ( mView->saveCalendars() ) |
2042 | mCalendarModifiedFlag = false; | 2058 | mCalendarModifiedFlag = false; |
2043 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 2059 | int msNeeded = neededSaveTime.elapsed(); |
2044 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2060 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2045 | QString savemes; | 2061 | QString savemes; |
2046 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2062 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2047 | if ( !isMinimized () ) | 2063 | if ( !isMinimized () ) |
2048 | setCaption(savemes); | 2064 | setCaption(savemes); |
2049 | else | 2065 | else |
2050 | qDebug(savemes); | 2066 | qDebug(savemes); |
2051 | } else { | 2067 | } else { |
2052 | setCaption(i18n("Saving cancelled!")); | 2068 | setCaption(i18n("Saving cancelled!")); |
2053 | mCalendarModifiedFlag = false; | 2069 | mCalendarModifiedFlag = false; |
2054 | slotModifiedChanged( true ); | 2070 | slotModifiedChanged( true ); |
2055 | } | 2071 | } |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index fdcf7c4..657c0a8 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -165,20 +165,22 @@ class MainWindow : public QMainWindow | |||
165 | QAction *mMoveAction; | 165 | QAction *mMoveAction; |
166 | QAction *mBeamAction; | 166 | QAction *mBeamAction; |
167 | QAction *mCancelAction; | 167 | QAction *mCancelAction; |
168 | QAction *mPrintSelAction; | 168 | QAction *mPrintSelAction; |
169 | 169 | ||
170 | QAction *mToggleNav; | 170 | QAction *mToggleNav; |
171 | QAction *mToggleFilter; | 171 | QAction *mToggleFilter; |
172 | QAction *mToggleAllday; | 172 | QAction *mToggleAllday; |
173 | QAction *actionFilterMenuTB; | 173 | QAction *actionFilterMenuTB; |
174 | 174 | ||
175 | void closeEvent( QCloseEvent* ce ); | 175 | void closeEvent( QCloseEvent* ce ); |
176 | QTimer mSaveTimer; | 176 | QTimer mSaveTimer; |
177 | QTime mSaveTime; | ||
178 | int mSaveDelay; | ||
177 | //bool mBlockSaveFlag; | 179 | //bool mBlockSaveFlag; |
178 | bool mCalendarModifiedFlag; | 180 | bool mCalendarModifiedFlag; |
179 | QPixmap loadPixmap( QString ); | 181 | QPixmap loadPixmap( QString ); |
180 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; | 182 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; |
181 | }; | 183 | }; |
182 | 184 | ||
183 | 185 | ||
184 | #endif | 186 | #endif |