summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Unidiff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp22
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 ) :
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}
407MainWindow::~MainWindow() 408MainWindow::~MainWindow()
408{ 409{
@@ -1966,6 +1967,8 @@ void MainWindow::slotModifiedChanged( bool )
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}
@@ -2013,6 +2016,17 @@ void MainWindow::backupAllFiles()
2013} 2016}
2014void MainWindow::save() 2017void 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();
@@ -2024,6 +2038,7 @@ void MainWindow::save()
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 ){
@@ -2034,13 +2049,14 @@ void MainWindow::save()
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 );