-rw-r--r-- | korganizer/mainwindow.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 70baf5c..2af605f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -402,7 +402,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : //toggleBeamReceive(); setCaption(i18n("Loading calendar files ... please wait" )); - QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); + mSaveDelay = 0; + QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); } MainWindow::~MainWindow() { @@ -1966,6 +1967,8 @@ void MainWindow::slotModifiedChanged( bool ) else 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; } @@ -2013,6 +2016,17 @@ 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() ) mView->viewManager()->journalView()->checkModified(); @@ -2024,6 +2038,7 @@ void MainWindow::save() slotModifiedChanged( true ); return; } + mSaveDelay = 0; mSyncManager->setBlockSave(true); if ( mView->checkAllFileVersions() ) { if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ @@ -2034,13 +2049,14 @@ 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 ..." )); qDebug("KO: Start saving data to file!"); 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; savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |