-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 @@ -67,96 +67,98 @@ Todo::Todo(const Todo &t) : QObject(),Incidence(t) } Todo::~Todo() { setRunning( false ); //qDebug("Todo::~Todo() "); } void Todo::setRunningFalse( QString s ) { if ( ! mRunning ) return; mRunning = false; if ( mRunSaveTimer ) mRunSaveTimer->stop(); saveRunningInfoToFile( s ); } void Todo::stopRunning() { if ( !mRunning ) return; if ( mRunSaveTimer ) mRunSaveTimer->stop(); mRunning = false; } void Todo::setRunning( bool run ) { if ( run == mRunning ) return; //qDebug("Todo::setRunning %d ", run); if ( !mRunSaveTimer ) { mRunSaveTimer = new QTimer ( this ); connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); } mRunning = run; mRunLastSave = QDateTime::currentDateTime(); if ( mRunning ) { restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); mRunStart = QDateTime::currentDateTime(); } else { mRunSaveTimer->stop(); saveRunningInfoToFile(); } mLastSavedFileName = ""; } void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) { if ( !mRunning) return; + if ( mRunSaveTimer ) + mRunSaveTimer->stop(); mRunning = false; mRunStart = start; mRunEnd = end; saveRunningInfoToFile( comment ); } void Todo::restartSaveTimer( int secs ) { mRunSaveTimer->start( secs * 1000 ); mRunLastSave = QDateTime::currentDateTime(); mCurrentTimerDelay = secs; } void Todo::timerSlotSaveRunningInfoToFile() { mRunEnd = QDateTime::currentDateTime(); int secsTo = mRunLastSave.secsTo( mRunEnd ); //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 ); restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); return; } 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 ); } void Todo::saveRunningInfoToFile() { mRunEnd = QDateTime::currentDateTime(); saveRunningInfoToFile( QString::null ); } void Todo::saveRunningInfoToFile( QString comment ) { #ifndef DESKTOP_VERSION //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); #endif //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); if ( mRunStart.secsTo ( mRunEnd) < 15 ) { |