author | zautrix <zautrix> | 2005-10-22 15:25:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-22 15:25:31 (UTC) |
commit | a29a801e5500a8e5994afc317229698aeebe22e9 (patch) (unidiff) | |
tree | defdd25623ca6908e712ed41c0d30007cb96c439 | |
parent | 30550b912b291ccedc8ab100004ba8c5ed216097 (diff) | |
download | kdepimpi-a29a801e5500a8e5994afc317229698aeebe22e9.zip kdepimpi-a29a801e5500a8e5994afc317229698aeebe22e9.tar.gz kdepimpi-a29a801e5500a8e5994afc317229698aeebe22e9.tar.bz2 |
fixx
-rw-r--r-- | libkcal/todo.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 2201814..cc1c5ae 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -83,64 +83,66 @@ void Todo::setRunningFalse( QString s ) | |||
83 | } | 83 | } |
84 | void Todo::stopRunning() | 84 | void Todo::stopRunning() |
85 | { | 85 | { |
86 | if ( !mRunning ) | 86 | if ( !mRunning ) |
87 | return; | 87 | return; |
88 | if ( mRunSaveTimer ) | 88 | if ( mRunSaveTimer ) |
89 | mRunSaveTimer->stop(); | 89 | mRunSaveTimer->stop(); |
90 | mRunning = false; | 90 | mRunning = false; |
91 | } | 91 | } |
92 | void Todo::setRunning( bool run ) | 92 | void Todo::setRunning( bool run ) |
93 | { | 93 | { |
94 | if ( run == mRunning ) | 94 | if ( run == mRunning ) |
95 | return; | 95 | return; |
96 | //qDebug("Todo::setRunning %d ", run); | 96 | //qDebug("Todo::setRunning %d ", run); |
97 | if ( !mRunSaveTimer ) { | 97 | if ( !mRunSaveTimer ) { |
98 | mRunSaveTimer = new QTimer ( this ); | 98 | mRunSaveTimer = new QTimer ( this ); |
99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); | 99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); |
100 | } | 100 | } |
101 | mRunning = run; | 101 | mRunning = run; |
102 | mRunLastSave = QDateTime::currentDateTime(); | 102 | mRunLastSave = QDateTime::currentDateTime(); |
103 | if ( mRunning ) { | 103 | if ( mRunning ) { |
104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
105 | mRunStart = QDateTime::currentDateTime(); | 105 | mRunStart = QDateTime::currentDateTime(); |
106 | } else { | 106 | } else { |
107 | mRunSaveTimer->stop(); | 107 | mRunSaveTimer->stop(); |
108 | saveRunningInfoToFile(); | 108 | saveRunningInfoToFile(); |
109 | } | 109 | } |
110 | mLastSavedFileName = ""; | 110 | mLastSavedFileName = ""; |
111 | } | 111 | } |
112 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) | 112 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) |
113 | { | 113 | { |
114 | if ( !mRunning) return; | 114 | if ( !mRunning) return; |
115 | if ( mRunSaveTimer ) | ||
116 | mRunSaveTimer->stop(); | ||
115 | mRunning = false; | 117 | mRunning = false; |
116 | mRunStart = start; | 118 | mRunStart = start; |
117 | mRunEnd = end; | 119 | mRunEnd = end; |
118 | saveRunningInfoToFile( comment ); | 120 | saveRunningInfoToFile( comment ); |
119 | } | 121 | } |
120 | void Todo::restartSaveTimer( int secs ) | 122 | void Todo::restartSaveTimer( int secs ) |
121 | { | 123 | { |
122 | mRunSaveTimer->start( secs * 1000 ); | 124 | mRunSaveTimer->start( secs * 1000 ); |
123 | mRunLastSave = QDateTime::currentDateTime(); | 125 | mRunLastSave = QDateTime::currentDateTime(); |
124 | mCurrentTimerDelay = secs; | 126 | mCurrentTimerDelay = secs; |
125 | } | 127 | } |
126 | void Todo::timerSlotSaveRunningInfoToFile() | 128 | void Todo::timerSlotSaveRunningInfoToFile() |
127 | { | 129 | { |
128 | mRunEnd = QDateTime::currentDateTime(); | 130 | mRunEnd = QDateTime::currentDateTime(); |
129 | int secsTo = mRunLastSave.secsTo( mRunEnd ); | 131 | int secsTo = mRunLastSave.secsTo( mRunEnd ); |
130 | //if( secsTo == 8 ) ++secsTo; | 132 | //if( secsTo == 8 ) ++secsTo; |
131 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); | 133 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); |
132 | if ( secsTo > mCurrentTimerDelay ) { | 134 | if ( secsTo > mCurrentTimerDelay ) { |
133 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 135 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
134 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 136 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
135 | return; | 137 | return; |
136 | } | 138 | } |
137 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); | 139 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); |
138 | if ( msecs < 0 ) { | 140 | if ( msecs < 0 ) { |
139 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 141 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
140 | return; | 142 | return; |
141 | } | 143 | } |
142 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 144 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
143 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { | 145 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { |
144 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 146 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
145 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 147 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
146 | return; | 148 | return; |