-rw-r--r-- | libkcal/todo.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index e98af3c..d062492 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -60,24 +60,32 @@ Todo::~Todo() | |||
60 | setRunning( false ); | 60 | setRunning( false ); |
61 | //qDebug("Todo::~Todo() "); | 61 | //qDebug("Todo::~Todo() "); |
62 | } | 62 | } |
63 | 63 | ||
64 | void Todo::setRunningFalse( QString s ) | 64 | void Todo::setRunningFalse( QString s ) |
65 | { | 65 | { |
66 | if ( ! mRunning ) | 66 | if ( ! mRunning ) |
67 | return; | 67 | return; |
68 | mRunning = false; | 68 | mRunning = false; |
69 | mRunSaveTimer->stop(); | 69 | mRunSaveTimer->stop(); |
70 | saveRunningInfoToFile( s ); | 70 | saveRunningInfoToFile( s ); |
71 | } | 71 | } |
72 | void Todo::stopRunning() | ||
73 | { | ||
74 | if ( !mRunning ) | ||
75 | return; | ||
76 | if ( mRunSaveTimer ) | ||
77 | mRunSaveTimer->stop(); | ||
78 | mRunning = false; | ||
79 | } | ||
72 | void Todo::setRunning( bool run ) | 80 | void Todo::setRunning( bool run ) |
73 | { | 81 | { |
74 | if ( run == mRunning ) | 82 | if ( run == mRunning ) |
75 | return; | 83 | return; |
76 | //qDebug("Todo::setRunning %d ", run); | 84 | //qDebug("Todo::setRunning %d ", run); |
77 | if ( !mRunSaveTimer ) { | 85 | if ( !mRunSaveTimer ) { |
78 | mRunSaveTimer = new QTimer ( this ); | 86 | mRunSaveTimer = new QTimer ( this ); |
79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | 87 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); |
80 | } | 88 | } |
81 | mRunning = run; | 89 | mRunning = run; |
82 | if ( mRunning ) { | 90 | if ( mRunning ) { |
83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | 91 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min |
@@ -86,25 +94,25 @@ void Todo::setRunning( bool run ) | |||
86 | mRunSaveTimer->stop(); | 94 | mRunSaveTimer->stop(); |
87 | saveRunningInfoToFile(); | 95 | saveRunningInfoToFile(); |
88 | } | 96 | } |
89 | } | 97 | } |
90 | 98 | ||
91 | void Todo::saveRunningInfoToFile() | 99 | void Todo::saveRunningInfoToFile() |
92 | { | 100 | { |
93 | saveRunningInfoToFile( QString::null ); | 101 | saveRunningInfoToFile( QString::null ); |
94 | } | 102 | } |
95 | void Todo::saveRunningInfoToFile( QString comment ) | 103 | void Todo::saveRunningInfoToFile( QString comment ) |
96 | { | 104 | { |
97 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 105 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
98 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { | 106 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { |
99 | qDebug("Running time < 30 seconds. Skipped. "); | 107 | qDebug("Running time < 30 seconds. Skipped. "); |
100 | return; | 108 | return; |
101 | } | 109 | } |
102 | QString dir = KGlobalSettings::timeTrackerDir(); | 110 | QString dir = KGlobalSettings::timeTrackerDir(); |
103 | //qDebug("%s ", dir.latin1()); | 111 | //qDebug("%s ", dir.latin1()); |
104 | QString file = "%1%2%3-%4%5%6-"; | 112 | QString file = "%1%2%3-%4%5%6-"; |
105 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); | 113 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); |
106 | file.replace ( QRegExp (" "), "0" ); | 114 | file.replace ( QRegExp (" "), "0" ); |
107 | file += uid(); | 115 | file += uid(); |
108 | //qDebug("File %s ",file.latin1() ); | 116 | //qDebug("File %s ",file.latin1() ); |
109 | CalendarLocal cal; | 117 | CalendarLocal cal; |
110 | cal.setLocalTime(); | 118 | cal.setLocalTime(); |