summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp34
-rw-r--r--libkcal/todo.h1
2 files changed, 24 insertions, 11 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index de07496..f7d40ad 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -99,6 +99,4 @@ void Todo::setRunning( bool run )
if ( mRunning ) {
- mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min
+ restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
mRunStart = QDateTime::currentDateTime();
- mRunLastSave = QDateTime::currentDateTime();
- mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS;
} else {
@@ -116,2 +114,8 @@ void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
}
+void Todo::restartSaveTimer( int secs )
+{
+ mRunSaveTimer->start( secs * 1000 );
+ mRunLastSave = QDateTime::currentDateTime();
+ mCurrentTimerDelay = secs;
+}
void Todo::timerSlotSaveRunningInfoToFile()
@@ -120,14 +124,22 @@ void Todo::timerSlotSaveRunningInfoToFile()
int secsTo = mRunLastSave.secsTo( mRunEnd );
- if( secsTo == 8 ) ++secsTo;
+ //if( secsTo == 8 ) ++secsTo;
qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay );
if ( secsTo > mCurrentTimerDelay ) {
- qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS );
- mRunSaveTimer->start( SAVETIMER_TIMEOUT_RETRY_SECONDS * 1000 );
- mRunLastSave = QDateTime::currentDateTime();
- mCurrentTimerDelay = SAVETIMER_TIMEOUT_RETRY_SECONDS;
+ qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS );
+ restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
return;
}
- mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min
- mRunLastSave = QDateTime::currentDateTime();
- mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS;
+ int msecs = mRunLastSave.time().msecsTo( mRunEnd.time());
+ if ( msecs < 0 ) {
+ restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
+ return;
+ }
+ // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
+ if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) {
+ qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
+ restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
+ return;
+
+ }
+ restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
saveRunningInfoToFile( QString::null );
diff --git a/libkcal/todo.h b/libkcal/todo.h
index e6b8a21..71b7a4e 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -136,2 +136,3 @@ namespace KCal {
private:
+ void restartSaveTimer( int secs );
int mCurrentTimerDelay;