summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-09-17 22:07:21 (UTC)
committer zautrix <zautrix>2005-09-17 22:07:21 (UTC)
commit64199073c047a30f3cff85fe6ee30691ff0db2f7 (patch) (unidiff)
tree5ff49088999f2c02fb2a40760b881c02f50cfc35 /korganizer
parente228113016abd6f75824633da9520c1ec1763f23 (diff)
downloadkdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.zip
kdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.tar.gz
kdepimpi-64199073c047a30f3cff85fe6ee30691ff0db2f7.tar.bz2
savetimer
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/mainwindow.cpp22
-rw-r--r--korganizer/mainwindow.h2
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
@@ -2500,8 +2500,8 @@ bool CalendarView::checkFileVersion(QString 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)) ,
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 );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index fdcf7c4..657c0a8 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -174,6 +174,8 @@ class MainWindow : public QMainWindow
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 );