summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -98,8 +98,6 @@ void Todo::setRunning( bool run )
98 mRunLastSave = QDateTime::currentDateTime(); 98 mRunLastSave = QDateTime::currentDateTime();
99 if ( mRunning ) { 99 if ( mRunning ) {
100 mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min 100 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
101 mRunStart = QDateTime::currentDateTime(); 101 mRunStart = QDateTime::currentDateTime();
102 mRunLastSave = QDateTime::currentDateTime();
103 mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS;
104 } else { 102 } else {
105 mRunSaveTimer->stop(); 103 mRunSaveTimer->stop();
@@ -115,20 +113,34 @@ void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
115 saveRunningInfoToFile( comment ); 113 saveRunningInfoToFile( comment );
116} 114}
115void Todo::restartSaveTimer( int secs )
116{
117 mRunSaveTimer->start( secs * 1000 );
118 mRunLastSave = QDateTime::currentDateTime();
119 mCurrentTimerDelay = secs;
120}
117void Todo::timerSlotSaveRunningInfoToFile() 121void Todo::timerSlotSaveRunningInfoToFile()
118{ 122{
119 mRunEnd = QDateTime::currentDateTime(); 123 mRunEnd = QDateTime::currentDateTime();
120 int secsTo = mRunLastSave.secsTo( mRunEnd ); 124 int secsTo = mRunLastSave.secsTo( mRunEnd );
121 if( secsTo == 8 ) ++secsTo; 125 //if( secsTo == 8 ) ++secsTo;
122 qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); 126 qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay );
123 if ( secsTo > mCurrentTimerDelay ) { 127 if ( secsTo > mCurrentTimerDelay ) {
124 qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); 128 qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS );
125 mRunSaveTimer->start( SAVETIMER_TIMEOUT_RETRY_SECONDS * 1000 ); 129 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
126 mRunLastSave = QDateTime::currentDateTime();
127 mCurrentTimerDelay = SAVETIMER_TIMEOUT_RETRY_SECONDS;
128 return; 130 return;
129 } 131 }
130 mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min 132 int msecs = mRunLastSave.time().msecsTo( mRunEnd.time());
131 mRunLastSave = QDateTime::currentDateTime(); 133 if ( msecs < 0 ) {
132 mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS; 134 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
135 return;
136 }
137 // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
138 if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) {
139 qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
140 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
141 return;
142
143 }
144 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
133 saveRunningInfoToFile( QString::null ); 145 saveRunningInfoToFile( QString::null );
134} 146}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index e6b8a21..71b7a4e 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -135,4 +135,5 @@ namespace KCal {
135 void timerSlotSaveRunningInfoToFile( ); 135 void timerSlotSaveRunningInfoToFile( );
136 private: 136 private:
137 void restartSaveTimer( int secs );
137 int mCurrentTimerDelay; 138 int mCurrentTimerDelay;
138 bool mRunning; 139 bool mRunning;