-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 @@ -2501,6 +2501,6 @@ bool CalendarView::checkFileVersion(QString fn) return true; QDateTime dt = finf.lastModified (); - qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); - qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); + //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); + //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); if ( dt <= loadedFileVersion ) return true; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 70baf5c..2af605f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -403,5 +403,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : setCaption(i18n("Loading calendar files ... please wait" )); - QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); + mSaveDelay = 0; + QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); } MainWindow::~MainWindow() @@ -1967,4 +1968,6 @@ void MainWindow::slotModifiedChanged( bool ) msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute + mSaveTime.restart(); + mSaveDelay = msec/1000; qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; @@ -2014,4 +2017,15 @@ void MainWindow::backupAllFiles() 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(); + mSaveDelay = msec/1000; + return; + } + } if ( mView->viewManager()->journalView() ) @@ -2025,4 +2039,5 @@ void MainWindow::save() return; } + mSaveDelay = 0; mSyncManager->setBlockSave(true); if ( mView->checkAllFileVersions() ) { @@ -2035,5 +2050,6 @@ void MainWindow::save() ; // KPimGlobalPrefs::instance()->mLastBackupDate } - QTime neededSaveTime = QDateTime::currentDateTime().time(); + QTime neededSaveTime; + neededSaveTime.start(); if ( !isMinimized () ) setCaption(i18n("KO/Pi:Saving Data to File ..." )); @@ -2041,5 +2057,5 @@ void MainWindow::save() if ( mView->saveCalendars() ) mCalendarModifiedFlag = false; - int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); + int msNeeded = neededSaveTime.elapsed(); qDebug("KO: Needed %d ms for saving.",msNeeded ); QString savemes; diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index fdcf7c4..657c0a8 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -175,4 +175,6 @@ class MainWindow : public QMainWindow void closeEvent( QCloseEvent* ce ); QTimer mSaveTimer; + QTime mSaveTime; + int mSaveDelay; //bool mBlockSaveFlag; bool mCalendarModifiedFlag; |