-rw-r--r-- | libkcal/todo.cpp | 34 |
1 files changed, 23 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 | |||
@@ -1,654 +1,666 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <kglobalsettings.h> | 22 | #include <kglobalsettings.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qfileinfo.h> | 26 | #include <qfileinfo.h> |
27 | 27 | ||
28 | #include "calendarlocal.h" | 28 | #include "calendarlocal.h" |
29 | #include "icalformat.h" | 29 | #include "icalformat.h" |
30 | #include "todo.h" | 30 | #include "todo.h" |
31 | 31 | ||
32 | #define SAVETIMER_TIMEOUT_SECONDS 300 | 32 | #define SAVETIMER_TIMEOUT_SECONDS 300 |
33 | //#define SAVETIMER_TIMEOUT_SECONDS 8 | 33 | //#define SAVETIMER_TIMEOUT_SECONDS 8 |
34 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 | 34 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 |
35 | 35 | ||
36 | using namespace KCal; | 36 | using namespace KCal; |
37 | 37 | ||
38 | Todo::Todo(): QObject(), Incidence() | 38 | Todo::Todo(): QObject(), Incidence() |
39 | { | 39 | { |
40 | // mStatus = TENTATIVE; | 40 | // mStatus = TENTATIVE; |
41 | 41 | ||
42 | mHasDueDate = false; | 42 | mHasDueDate = false; |
43 | setHasStartDate( false ); | 43 | setHasStartDate( false ); |
44 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 44 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
45 | mHasCompletedDate = false; | 45 | mHasCompletedDate = false; |
46 | mPercentComplete = 0; | 46 | mPercentComplete = 0; |
47 | mRunning = false; | 47 | mRunning = false; |
48 | mRunSaveTimer = 0; | 48 | mRunSaveTimer = 0; |
49 | setFloats( true ); | 49 | setFloats( true ); |
50 | mCurrentTimerDelay = 0; | 50 | mCurrentTimerDelay = 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) | 53 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) |
54 | { | 54 | { |
55 | mDtDue = t.mDtDue; | 55 | mDtDue = t.mDtDue; |
56 | mHasDueDate = t.mHasDueDate; | 56 | mHasDueDate = t.mHasDueDate; |
57 | mCompleted = t.mCompleted; | 57 | mCompleted = t.mCompleted; |
58 | mHasCompletedDate = t.mHasCompletedDate; | 58 | mHasCompletedDate = t.mHasCompletedDate; |
59 | mPercentComplete = t.mPercentComplete; | 59 | mPercentComplete = t.mPercentComplete; |
60 | mRunning = false; | 60 | mRunning = false; |
61 | mRunSaveTimer = 0; | 61 | mRunSaveTimer = 0; |
62 | mCurrentTimerDelay = 0; | 62 | mCurrentTimerDelay = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | Todo::~Todo() | 65 | Todo::~Todo() |
66 | { | 66 | { |
67 | setRunning( false ); | 67 | setRunning( false ); |
68 | //qDebug("Todo::~Todo() "); | 68 | //qDebug("Todo::~Todo() "); |
69 | } | 69 | } |
70 | 70 | ||
71 | void Todo::setRunningFalse( QString s ) | 71 | void Todo::setRunningFalse( QString s ) |
72 | { | 72 | { |
73 | if ( ! mRunning ) | 73 | if ( ! mRunning ) |
74 | return; | 74 | return; |
75 | mRunning = false; | 75 | mRunning = false; |
76 | if ( mRunSaveTimer ) | 76 | if ( mRunSaveTimer ) |
77 | mRunSaveTimer->stop(); | 77 | mRunSaveTimer->stop(); |
78 | saveRunningInfoToFile( s ); | 78 | saveRunningInfoToFile( s ); |
79 | } | 79 | } |
80 | void Todo::stopRunning() | 80 | void Todo::stopRunning() |
81 | { | 81 | { |
82 | if ( !mRunning ) | 82 | if ( !mRunning ) |
83 | return; | 83 | return; |
84 | if ( mRunSaveTimer ) | 84 | if ( mRunSaveTimer ) |
85 | mRunSaveTimer->stop(); | 85 | mRunSaveTimer->stop(); |
86 | mRunning = false; | 86 | mRunning = false; |
87 | } | 87 | } |
88 | void Todo::setRunning( bool run ) | 88 | void Todo::setRunning( bool run ) |
89 | { | 89 | { |
90 | if ( run == mRunning ) | 90 | if ( run == mRunning ) |
91 | return; | 91 | return; |
92 | //qDebug("Todo::setRunning %d ", run); | 92 | //qDebug("Todo::setRunning %d ", run); |
93 | if ( !mRunSaveTimer ) { | 93 | if ( !mRunSaveTimer ) { |
94 | mRunSaveTimer = new QTimer ( this ); | 94 | mRunSaveTimer = new QTimer ( this ); |
95 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); | 95 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); |
96 | } | 96 | } |
97 | mRunning = run; | 97 | mRunning = 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(); |
106 | saveRunningInfoToFile(); | 104 | saveRunningInfoToFile(); |
107 | } | 105 | } |
108 | } | 106 | } |
109 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) | 107 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) |
110 | { | 108 | { |
111 | if ( !mRunning) return; | 109 | if ( !mRunning) return; |
112 | mRunning = false; | 110 | mRunning = false; |
113 | mRunStart = start; | 111 | mRunStart = start; |
114 | mRunEnd = end; | 112 | mRunEnd = end; |
115 | saveRunningInfoToFile( comment ); | 113 | saveRunningInfoToFile( comment ); |
116 | } | 114 | } |
115 | void Todo::restartSaveTimer( int secs ) | ||
116 | { | ||
117 | mRunSaveTimer->start( secs * 1000 ); | ||
118 | mRunLastSave = QDateTime::currentDateTime(); | ||
119 | mCurrentTimerDelay = secs; | ||
120 | } | ||
117 | void Todo::timerSlotSaveRunningInfoToFile() | 121 | void 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 | } |
135 | void Todo::saveRunningInfoToFile() | 147 | void Todo::saveRunningInfoToFile() |
136 | { | 148 | { |
137 | mRunEnd = QDateTime::currentDateTime(); | 149 | mRunEnd = QDateTime::currentDateTime(); |
138 | saveRunningInfoToFile( QString::null ); | 150 | saveRunningInfoToFile( QString::null ); |
139 | } | 151 | } |
140 | void Todo::saveRunningInfoToFile( QString comment ) | 152 | void Todo::saveRunningInfoToFile( QString comment ) |
141 | { | 153 | { |
142 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 154 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
143 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { | 155 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { |
144 | qDebug("Running time < 15 seconds. Skipped. "); | 156 | qDebug("Running time < 15 seconds. Skipped. "); |
145 | return; | 157 | return; |
146 | } | 158 | } |
147 | QString dir = KGlobalSettings::timeTrackerDir(); | 159 | QString dir = KGlobalSettings::timeTrackerDir(); |
148 | //qDebug("%s ", dir.latin1()); | 160 | //qDebug("%s ", dir.latin1()); |
149 | QString file = "%1%2%3-%4%5%6-"; | 161 | QString file = "%1%2%3-%4%5%6-"; |
150 | 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 ); | 162 | 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 ); |
151 | file.replace ( QRegExp (" "), "0" ); | 163 | file.replace ( QRegExp (" "), "0" ); |
152 | file += uid(); | 164 | file += uid(); |
153 | //qDebug("File %s ",file.latin1() ); | 165 | //qDebug("File %s ",file.latin1() ); |
154 | CalendarLocal cal; | 166 | CalendarLocal cal; |
155 | cal.setLocalTime(); | 167 | cal.setLocalTime(); |
156 | Todo * to = (Todo*) clone(); | 168 | Todo * to = (Todo*) clone(); |
157 | to->setFloats( false ); | 169 | to->setFloats( false ); |
158 | to->setDtStart( mRunStart ); | 170 | to->setDtStart( mRunStart ); |
159 | to->setHasStartDate( true ); | 171 | to->setHasStartDate( true ); |
160 | to->setDtDue( mRunEnd ); | 172 | to->setDtDue( mRunEnd ); |
161 | to->setHasDueDate( true ); | 173 | to->setHasDueDate( true ); |
162 | to->setUid( file ); | 174 | to->setUid( file ); |
163 | if ( !comment.isEmpty() ) { | 175 | if ( !comment.isEmpty() ) { |
164 | QString des = to->description(); | 176 | QString des = to->description(); |
165 | if ( des.isEmpty () ) | 177 | if ( des.isEmpty () ) |
166 | to->setDescription( "TT-Note: " + comment ); | 178 | to->setDescription( "TT-Note: " + comment ); |
167 | else | 179 | else |
168 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 180 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
169 | } | 181 | } |
170 | cal.addIncidence( to ); | 182 | cal.addIncidence( to ); |
171 | ICalFormat format( false ); | 183 | ICalFormat format( false ); |
172 | file = dir +"/" +file +".ics"; | 184 | file = dir +"/" +file +".ics"; |
173 | format.save( &cal, file ); | 185 | format.save( &cal, file ); |
174 | saveParents(); | 186 | saveParents(); |
175 | 187 | ||
176 | } | 188 | } |
177 | void Todo::saveParents() | 189 | void Todo::saveParents() |
178 | { | 190 | { |
179 | if (!relatedTo() ) | 191 | if (!relatedTo() ) |
180 | return; | 192 | return; |
181 | Incidence * inc = relatedTo(); | 193 | Incidence * inc = relatedTo(); |
182 | if ( inc->typeID() != todoID ) | 194 | if ( inc->typeID() != todoID ) |
183 | return; | 195 | return; |
184 | Todo* to = (Todo*)inc; | 196 | Todo* to = (Todo*)inc; |
185 | bool saveTodo = false; | 197 | bool saveTodo = false; |
186 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 198 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
187 | QFileInfo fi ( file ); | 199 | QFileInfo fi ( file ); |
188 | if ( fi.exists() ) { | 200 | if ( fi.exists() ) { |
189 | if ( fi.lastModified () < to->lastModified ()) | 201 | if ( fi.lastModified () < to->lastModified ()) |
190 | saveTodo = true; | 202 | saveTodo = true; |
191 | } else { | 203 | } else { |
192 | saveTodo = true; | 204 | saveTodo = true; |
193 | } | 205 | } |
194 | if ( saveTodo ) { | 206 | if ( saveTodo ) { |
195 | CalendarLocal cal; | 207 | CalendarLocal cal; |
196 | cal.setLocalTime(); | 208 | cal.setLocalTime(); |
197 | Todo * par = (Todo *) to->clone(); | 209 | Todo * par = (Todo *) to->clone(); |
198 | cal.addIncidence( par ); | 210 | cal.addIncidence( par ); |
199 | ICalFormat format( false ); | 211 | ICalFormat format( false ); |
200 | format.save( &cal, file ); | 212 | format.save( &cal, file ); |
201 | } | 213 | } |
202 | to->saveParents(); | 214 | to->saveParents(); |
203 | } | 215 | } |
204 | 216 | ||
205 | int Todo::runTime() | 217 | int Todo::runTime() |
206 | { | 218 | { |
207 | if ( !mRunning ) | 219 | if ( !mRunning ) |
208 | return 0; | 220 | return 0; |
209 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 221 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
210 | } | 222 | } |
211 | bool Todo::hasRunningSub() | 223 | bool Todo::hasRunningSub() |
212 | { | 224 | { |
213 | if ( mRunning ) | 225 | if ( mRunning ) |
214 | return true; | 226 | return true; |
215 | Incidence *aTodo; | 227 | Incidence *aTodo; |
216 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 228 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
217 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 229 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
218 | return true; | 230 | return true; |
219 | } | 231 | } |
220 | return false; | 232 | return false; |
221 | } | 233 | } |
222 | Incidence *Todo::clone() | 234 | Incidence *Todo::clone() |
223 | { | 235 | { |
224 | return new Todo(*this); | 236 | return new Todo(*this); |
225 | } | 237 | } |
226 | 238 | ||
227 | bool Todo::contains ( Todo* from ) | 239 | bool Todo::contains ( Todo* from ) |
228 | { | 240 | { |
229 | 241 | ||
230 | if ( !from->summary().isEmpty() ) | 242 | if ( !from->summary().isEmpty() ) |
231 | if ( !summary().startsWith( from->summary() )) | 243 | if ( !summary().startsWith( from->summary() )) |
232 | return false; | 244 | return false; |
233 | if ( from->hasStartDate() ) { | 245 | if ( from->hasStartDate() ) { |
234 | if ( !hasStartDate() ) | 246 | if ( !hasStartDate() ) |
235 | return false; | 247 | return false; |
236 | if ( from->dtStart() != dtStart()) | 248 | if ( from->dtStart() != dtStart()) |
237 | return false; | 249 | return false; |
238 | } | 250 | } |
239 | if ( from->hasDueDate() ){ | 251 | if ( from->hasDueDate() ){ |
240 | if ( !hasDueDate() ) | 252 | if ( !hasDueDate() ) |
241 | return false; | 253 | return false; |
242 | if ( from->dtDue() != dtDue()) | 254 | if ( from->dtDue() != dtDue()) |
243 | return false; | 255 | return false; |
244 | } | 256 | } |
245 | if ( !from->location().isEmpty() ) | 257 | if ( !from->location().isEmpty() ) |
246 | if ( !location().startsWith( from->location() ) ) | 258 | if ( !location().startsWith( from->location() ) ) |
247 | return false; | 259 | return false; |
248 | if ( !from->description().isEmpty() ) | 260 | if ( !from->description().isEmpty() ) |
249 | if ( !description().startsWith( from->description() )) | 261 | if ( !description().startsWith( from->description() )) |
250 | return false; | 262 | return false; |
251 | if ( from->alarms().count() ) { | 263 | if ( from->alarms().count() ) { |
252 | Alarm *a = from->alarms().first(); | 264 | Alarm *a = from->alarms().first(); |
253 | if ( a->enabled() ){ | 265 | if ( a->enabled() ){ |
254 | if ( !alarms().count() ) | 266 | if ( !alarms().count() ) |
255 | return false; | 267 | return false; |
256 | Alarm *b = alarms().first(); | 268 | Alarm *b = alarms().first(); |
257 | if( ! b->enabled() ) | 269 | if( ! b->enabled() ) |
258 | return false; | 270 | return false; |
259 | if ( ! (a->offset() == b->offset() )) | 271 | if ( ! (a->offset() == b->offset() )) |
260 | return false; | 272 | return false; |
261 | } | 273 | } |
262 | } | 274 | } |
263 | 275 | ||
264 | QStringList cat = categories(); | 276 | QStringList cat = categories(); |
265 | QStringList catFrom = from->categories(); | 277 | QStringList catFrom = from->categories(); |
266 | QString nCat; | 278 | QString nCat; |
267 | unsigned int iii; | 279 | unsigned int iii; |
268 | for ( iii = 0; iii < catFrom.count();++iii ) { | 280 | for ( iii = 0; iii < catFrom.count();++iii ) { |
269 | nCat = catFrom[iii]; | 281 | nCat = catFrom[iii]; |
270 | if ( !nCat.isEmpty() ) | 282 | if ( !nCat.isEmpty() ) |
271 | if ( !cat.contains( nCat )) { | 283 | if ( !cat.contains( nCat )) { |
272 | return false; | 284 | return false; |
273 | } | 285 | } |
274 | } | 286 | } |
275 | if ( from->isCompleted() ) { | 287 | if ( from->isCompleted() ) { |
276 | if ( !isCompleted() ) | 288 | if ( !isCompleted() ) |
277 | return false; | 289 | return false; |
278 | } | 290 | } |
279 | if( priority() != from->priority() ) | 291 | if( priority() != from->priority() ) |
280 | return false; | 292 | return false; |
281 | 293 | ||
282 | 294 | ||
283 | return true; | 295 | return true; |
284 | 296 | ||
285 | } | 297 | } |
286 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 298 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
287 | { | 299 | { |
288 | 300 | ||
289 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 301 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
290 | if ( ! ret ) | 302 | if ( ! ret ) |
291 | return false; | 303 | return false; |
292 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 304 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
293 | if ( t1.hasDueDate() ) { | 305 | if ( t1.hasDueDate() ) { |
294 | if ( t1.doesFloat() == t2.doesFloat() ) { | 306 | if ( t1.doesFloat() == t2.doesFloat() ) { |
295 | if ( t1.doesFloat() ) { | 307 | if ( t1.doesFloat() ) { |
296 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 308 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
297 | return false; | 309 | return false; |
298 | } else | 310 | } else |
299 | if ( t1.dtDue() != t2.dtDue() ) | 311 | if ( t1.dtDue() != t2.dtDue() ) |
300 | return false; | 312 | return false; |
301 | } else | 313 | } else |
302 | return false;// float != | 314 | return false;// float != |
303 | } | 315 | } |
304 | 316 | ||
305 | } else | 317 | } else |
306 | return false; | 318 | return false; |
307 | if ( t1.percentComplete() != t2.percentComplete() ) | 319 | if ( t1.percentComplete() != t2.percentComplete() ) |
308 | return false; | 320 | return false; |
309 | if ( t1.isCompleted() ) { | 321 | if ( t1.isCompleted() ) { |
310 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 322 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
311 | if ( t1.hasCompletedDate() ) { | 323 | if ( t1.hasCompletedDate() ) { |
312 | if ( t1.completed() != t2.completed() ) | 324 | if ( t1.completed() != t2.completed() ) |
313 | return false; | 325 | return false; |
314 | } | 326 | } |
315 | 327 | ||
316 | } else | 328 | } else |
317 | return false; | 329 | return false; |
318 | } | 330 | } |
319 | return true; | 331 | return true; |
320 | 332 | ||
321 | } | 333 | } |
322 | 334 | ||
323 | void Todo::setDtDue(const QDateTime &dtDue) | 335 | void Todo::setDtDue(const QDateTime &dtDue) |
324 | { | 336 | { |
325 | //int diffsecs = mDtDue.secsTo(dtDue); | 337 | //int diffsecs = mDtDue.secsTo(dtDue); |
326 | 338 | ||
327 | /*if (mReadOnly) return; | 339 | /*if (mReadOnly) return; |
328 | const QPtrList<Alarm>& alarms = alarms(); | 340 | const QPtrList<Alarm>& alarms = alarms(); |
329 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 341 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
330 | if (alarm->enabled()) { | 342 | if (alarm->enabled()) { |
331 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 343 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
332 | } | 344 | } |
333 | }*/ | 345 | }*/ |
334 | mDtDue = getEvenTime(dtDue); | 346 | mDtDue = getEvenTime(dtDue); |
335 | 347 | ||
336 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 348 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
337 | 349 | ||
338 | /*const QPtrList<Alarm>& alarms = alarms(); | 350 | /*const QPtrList<Alarm>& alarms = alarms(); |
339 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 351 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
340 | alarm->setAlarmStart(mDtDue);*/ | 352 | alarm->setAlarmStart(mDtDue);*/ |
341 | updated(); | 353 | updated(); |
342 | } | 354 | } |
343 | 355 | ||
344 | QDateTime Todo::dtDue() const | 356 | QDateTime Todo::dtDue() const |
345 | { | 357 | { |
346 | return mDtDue; | 358 | return mDtDue; |
347 | } | 359 | } |
348 | 360 | ||
349 | QString Todo::dtDueTimeStr() const | 361 | QString Todo::dtDueTimeStr() const |
350 | { | 362 | { |
351 | return KGlobal::locale()->formatTime(mDtDue.time()); | 363 | return KGlobal::locale()->formatTime(mDtDue.time()); |
352 | } | 364 | } |
353 | 365 | ||
354 | QString Todo::dtDueDateStr(bool shortfmt) const | 366 | QString Todo::dtDueDateStr(bool shortfmt) const |
355 | { | 367 | { |
356 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 368 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
357 | } | 369 | } |
358 | 370 | ||
359 | QString Todo::dtDueStr(bool shortfmt) const | 371 | QString Todo::dtDueStr(bool shortfmt) const |
360 | { | 372 | { |
361 | if ( doesFloat() ) | 373 | if ( doesFloat() ) |
362 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 374 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
363 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 375 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
364 | } | 376 | } |
365 | // retval 0 : no found | 377 | // retval 0 : no found |
366 | // 1 : due for date found | 378 | // 1 : due for date found |
367 | // 2 : overdue for date found | 379 | // 2 : overdue for date found |
368 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 380 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
369 | { | 381 | { |
370 | int retval = 0; | 382 | int retval = 0; |
371 | if ( isCompleted() ) | 383 | if ( isCompleted() ) |
372 | return 0; | 384 | return 0; |
373 | if ( hasDueDate() ) { | 385 | if ( hasDueDate() ) { |
374 | if ( dtDue().date() < date ) | 386 | if ( dtDue().date() < date ) |
375 | return 2; | 387 | return 2; |
376 | // we do not return, because we may find an overdue sub todo | 388 | // we do not return, because we may find an overdue sub todo |
377 | if ( dtDue().date() == date ) | 389 | if ( dtDue().date() == date ) |
378 | retval = 1; | 390 | retval = 1; |
379 | } | 391 | } |
380 | if ( checkSubtodos ) { | 392 | if ( checkSubtodos ) { |
381 | Incidence *aTodo; | 393 | Incidence *aTodo; |
382 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 394 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
383 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 395 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
384 | if ( ret == 2 ) | 396 | if ( ret == 2 ) |
385 | return 2; | 397 | return 2; |
386 | if ( ret == 1) | 398 | if ( ret == 1) |
387 | retval = 1; | 399 | retval = 1; |
388 | } | 400 | } |
389 | } | 401 | } |
390 | return retval; | 402 | return retval; |
391 | } | 403 | } |
392 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 404 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
393 | { | 405 | { |
394 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 406 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
395 | } | 407 | } |
396 | bool Todo::hasDueDate() const | 408 | bool Todo::hasDueDate() const |
397 | { | 409 | { |
398 | return mHasDueDate; | 410 | return mHasDueDate; |
399 | } | 411 | } |
400 | 412 | ||
401 | void Todo::setHasDueDate(bool f) | 413 | void Todo::setHasDueDate(bool f) |
402 | { | 414 | { |
403 | if (mReadOnly) return; | 415 | if (mReadOnly) return; |
404 | mHasDueDate = f; | 416 | mHasDueDate = f; |
405 | updated(); | 417 | updated(); |
406 | } | 418 | } |
407 | 419 | ||
408 | 420 | ||
409 | #if 0 | 421 | #if 0 |
410 | void Todo::setStatus(const QString &statStr) | 422 | void Todo::setStatus(const QString &statStr) |
411 | { | 423 | { |
412 | if (mReadOnly) return; | 424 | if (mReadOnly) return; |
413 | QString ss(statStr.upper()); | 425 | QString ss(statStr.upper()); |
414 | 426 | ||
415 | if (ss == "X-ACTION") | 427 | if (ss == "X-ACTION") |
416 | mStatus = NEEDS_ACTION; | 428 | mStatus = NEEDS_ACTION; |
417 | else if (ss == "NEEDS ACTION") | 429 | else if (ss == "NEEDS ACTION") |
418 | mStatus = NEEDS_ACTION; | 430 | mStatus = NEEDS_ACTION; |
419 | else if (ss == "ACCEPTED") | 431 | else if (ss == "ACCEPTED") |
420 | mStatus = ACCEPTED; | 432 | mStatus = ACCEPTED; |
421 | else if (ss == "SENT") | 433 | else if (ss == "SENT") |
422 | mStatus = SENT; | 434 | mStatus = SENT; |
423 | else if (ss == "TENTATIVE") | 435 | else if (ss == "TENTATIVE") |
424 | mStatus = TENTATIVE; | 436 | mStatus = TENTATIVE; |
425 | else if (ss == "CONFIRMED") | 437 | else if (ss == "CONFIRMED") |
426 | mStatus = CONFIRMED; | 438 | mStatus = CONFIRMED; |
427 | else if (ss == "DECLINED") | 439 | else if (ss == "DECLINED") |
428 | mStatus = DECLINED; | 440 | mStatus = DECLINED; |
429 | else if (ss == "COMPLETED") | 441 | else if (ss == "COMPLETED") |
430 | mStatus = COMPLETED; | 442 | mStatus = COMPLETED; |
431 | else if (ss == "DELEGATED") | 443 | else if (ss == "DELEGATED") |
432 | mStatus = DELEGATED; | 444 | mStatus = DELEGATED; |
433 | 445 | ||
434 | updated(); | 446 | updated(); |
435 | } | 447 | } |
436 | 448 | ||
437 | void Todo::setStatus(int status) | 449 | void Todo::setStatus(int status) |
438 | { | 450 | { |
439 | if (mReadOnly) return; | 451 | if (mReadOnly) return; |
440 | mStatus = status; | 452 | mStatus = status; |
441 | updated(); | 453 | updated(); |
442 | } | 454 | } |
443 | 455 | ||
444 | int Todo::status() const | 456 | int Todo::status() const |
445 | { | 457 | { |
446 | return mStatus; | 458 | return mStatus; |
447 | } | 459 | } |
448 | 460 | ||
449 | QString Todo::statusStr() const | 461 | QString Todo::statusStr() const |
450 | { | 462 | { |
451 | switch(mStatus) { | 463 | switch(mStatus) { |
452 | case NEEDS_ACTION: | 464 | case NEEDS_ACTION: |
453 | return QString("NEEDS ACTION"); | 465 | return QString("NEEDS ACTION"); |
454 | break; | 466 | break; |
455 | case ACCEPTED: | 467 | case ACCEPTED: |
456 | return QString("ACCEPTED"); | 468 | return QString("ACCEPTED"); |
457 | break; | 469 | break; |
458 | case SENT: | 470 | case SENT: |
459 | return QString("SENT"); | 471 | return QString("SENT"); |
460 | break; | 472 | break; |
461 | case TENTATIVE: | 473 | case TENTATIVE: |
462 | return QString("TENTATIVE"); | 474 | return QString("TENTATIVE"); |
463 | break; | 475 | break; |
464 | case CONFIRMED: | 476 | case CONFIRMED: |
465 | return QString("CONFIRMED"); | 477 | return QString("CONFIRMED"); |
466 | break; | 478 | break; |
467 | case DECLINED: | 479 | case DECLINED: |
468 | return QString("DECLINED"); | 480 | return QString("DECLINED"); |
469 | break; | 481 | break; |
470 | case COMPLETED: | 482 | case COMPLETED: |
471 | return QString("COMPLETED"); | 483 | return QString("COMPLETED"); |
472 | break; | 484 | break; |
473 | case DELEGATED: | 485 | case DELEGATED: |
474 | return QString("DELEGATED"); | 486 | return QString("DELEGATED"); |
475 | break; | 487 | break; |
476 | } | 488 | } |
477 | return QString(""); | 489 | return QString(""); |
478 | } | 490 | } |
479 | #endif | 491 | #endif |
480 | 492 | ||
481 | bool Todo::isCompleted() const | 493 | bool Todo::isCompleted() const |
482 | { | 494 | { |
483 | if (mPercentComplete == 100) { | 495 | if (mPercentComplete == 100) { |
484 | return true; | 496 | return true; |
485 | } | 497 | } |
486 | else return false; | 498 | else return false; |
487 | } | 499 | } |
488 | 500 | ||
489 | void Todo::setCompleted(bool completed) | 501 | void Todo::setCompleted(bool completed) |
490 | { | 502 | { |
491 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 503 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
492 | if ( !setRecurDates() ) | 504 | if ( !setRecurDates() ) |
493 | completed = false; | 505 | completed = false; |
494 | } | 506 | } |
495 | if (completed) mPercentComplete = 100; | 507 | if (completed) mPercentComplete = 100; |
496 | else { | 508 | else { |
497 | mPercentComplete = 0; | 509 | mPercentComplete = 0; |
498 | mHasCompletedDate = false; | 510 | mHasCompletedDate = false; |
499 | } | 511 | } |
500 | updated(); | 512 | updated(); |
501 | } | 513 | } |
502 | 514 | ||
503 | QDateTime Todo::completed() const | 515 | QDateTime Todo::completed() const |
504 | { | 516 | { |
505 | return mCompleted; | 517 | return mCompleted; |
506 | } | 518 | } |
507 | 519 | ||
508 | QString Todo::completedStr( bool shortF ) const | 520 | QString Todo::completedStr( bool shortF ) const |
509 | { | 521 | { |
510 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 522 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
511 | } | 523 | } |
512 | 524 | ||
513 | void Todo::setCompleted(const QDateTime &completed) | 525 | void Todo::setCompleted(const QDateTime &completed) |
514 | { | 526 | { |
515 | //qDebug("Todo::setCompleted "); | 527 | //qDebug("Todo::setCompleted "); |
516 | if ( mHasCompletedDate ) { | 528 | if ( mHasCompletedDate ) { |
517 | // qDebug("has completed data - return "); | 529 | // qDebug("has completed data - return "); |
518 | return; | 530 | return; |
519 | } | 531 | } |
520 | mHasCompletedDate = true; | 532 | mHasCompletedDate = true; |
521 | mPercentComplete = 100; | 533 | mPercentComplete = 100; |
522 | mCompleted = getEvenTime(completed); | 534 | mCompleted = getEvenTime(completed); |
523 | updated(); | 535 | updated(); |
524 | } | 536 | } |
525 | 537 | ||
526 | bool Todo::hasCompletedDate() const | 538 | bool Todo::hasCompletedDate() const |
527 | { | 539 | { |
528 | return mHasCompletedDate; | 540 | return mHasCompletedDate; |
529 | } | 541 | } |
530 | 542 | ||
531 | int Todo::percentComplete() const | 543 | int Todo::percentComplete() const |
532 | { | 544 | { |
533 | return mPercentComplete; | 545 | return mPercentComplete; |
534 | } | 546 | } |
535 | bool Todo::setRecurDates() | 547 | bool Todo::setRecurDates() |
536 | { | 548 | { |
537 | if ( !mHasRecurrenceID ) | 549 | if ( !mHasRecurrenceID ) |
538 | return true; | 550 | return true; |
539 | int secs = mDtStart.secsTo( dtDue() ); | 551 | int secs = mDtStart.secsTo( dtDue() ); |
540 | bool ok; | 552 | bool ok; |
541 | qDebug("T:setRecurDates() "); | 553 | qDebug("T:setRecurDates() "); |
542 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 554 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
543 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 555 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
544 | if ( ok ) { | 556 | if ( ok ) { |
545 | mRecurrenceID = next; | 557 | mRecurrenceID = next; |
546 | mDtStart = next; | 558 | mDtStart = next; |
547 | setDtDue( next.addSecs( secs ) ); | 559 | setDtDue( next.addSecs( secs ) ); |
548 | if ( QDateTime::currentDateTime() > next) | 560 | if ( QDateTime::currentDateTime() > next) |
549 | return false; | 561 | return false; |
550 | } else { | 562 | } else { |
551 | setHasRecurrenceID( false ); | 563 | setHasRecurrenceID( false ); |
552 | recurrence()->unsetRecurs(); | 564 | recurrence()->unsetRecurs(); |
553 | } | 565 | } |
554 | return true; | 566 | return true; |
555 | } | 567 | } |
556 | void Todo::setPercentComplete(int v) | 568 | void Todo::setPercentComplete(int v) |
557 | { | 569 | { |
558 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 570 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
559 | if ( !setRecurDates() ) | 571 | if ( !setRecurDates() ) |
560 | v = 0; | 572 | v = 0; |
561 | } | 573 | } |
562 | mPercentComplete = v; | 574 | mPercentComplete = v; |
563 | if ( v != 100 ) | 575 | if ( v != 100 ) |
564 | mHasCompletedDate = false; | 576 | mHasCompletedDate = false; |
565 | updated(); | 577 | updated(); |
566 | } | 578 | } |
567 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 579 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
568 | { | 580 | { |
569 | *ok = false; | 581 | *ok = false; |
570 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { | 582 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { |
571 | return QDateTime (); | 583 | return QDateTime (); |
572 | } | 584 | } |
573 | // if the recurring todo is set to complete and requested time < start time of todo | 585 | // if the recurring todo is set to complete and requested time < start time of todo |
574 | // we want to get the alarm. | 586 | // we want to get the alarm. |
575 | bool iscompleted = isCompleted(); | 587 | bool iscompleted = isCompleted(); |
576 | if ( iscompleted && doesRecur() ) { | 588 | if ( iscompleted && doesRecur() ) { |
577 | Todo * to = (Todo*) this; | 589 | Todo * to = (Todo*) this; |
578 | to->checkSetCompletedFalse(); | 590 | to->checkSetCompletedFalse(); |
579 | iscompleted = isCompleted(); | 591 | iscompleted = isCompleted(); |
580 | if ( hasStartDate() && start_dt < dtStart() ){ | 592 | if ( hasStartDate() && start_dt < dtStart() ){ |
581 | iscompleted = false; | 593 | iscompleted = false; |
582 | } | 594 | } |
583 | } | 595 | } |
584 | if ( iscompleted ) { | 596 | if ( iscompleted ) { |
585 | return QDateTime (); | 597 | return QDateTime (); |
586 | } | 598 | } |
587 | QDateTime incidenceStart; | 599 | QDateTime incidenceStart; |
588 | incidenceStart = dtDue(); | 600 | incidenceStart = dtDue(); |
589 | bool enabled = false; | 601 | bool enabled = false; |
590 | Alarm* alarm; | 602 | Alarm* alarm; |
591 | int off = 0; | 603 | int off = 0; |
592 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 604 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
593 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 605 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
594 | // *ok = false; | 606 | // *ok = false; |
595 | // return incidenceStart; | 607 | // return incidenceStart; |
596 | // } | 608 | // } |
597 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 609 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
598 | if (alarm->enabled()) { | 610 | if (alarm->enabled()) { |
599 | if ( alarm->hasTime () ) { | 611 | if ( alarm->hasTime () ) { |
600 | if ( alarm->time() < alarmStart ) { | 612 | if ( alarm->time() < alarmStart ) { |
601 | alarmStart = alarm->time(); | 613 | alarmStart = alarm->time(); |
602 | enabled = true; | 614 | enabled = true; |
603 | off = alarmStart.secsTo( incidenceStart ); | 615 | off = alarmStart.secsTo( incidenceStart ); |
604 | } | 616 | } |
605 | 617 | ||
606 | } else { | 618 | } else { |
607 | int secs = alarm->startOffset().asSeconds(); | 619 | int secs = alarm->startOffset().asSeconds(); |
608 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 620 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
609 | alarmStart = incidenceStart.addSecs( secs ); | 621 | alarmStart = incidenceStart.addSecs( secs ); |
610 | enabled = true; | 622 | enabled = true; |
611 | off = -secs; | 623 | off = -secs; |
612 | } | 624 | } |
613 | } | 625 | } |
614 | } | 626 | } |
615 | } | 627 | } |
616 | if ( enabled ) { | 628 | if ( enabled ) { |
617 | if ( alarmStart > start_dt ) { | 629 | if ( alarmStart > start_dt ) { |
618 | *ok = true; | 630 | *ok = true; |
619 | * offset = off; | 631 | * offset = off; |
620 | return alarmStart; | 632 | return alarmStart; |
621 | } | 633 | } |
622 | } | 634 | } |
623 | *ok = false; | 635 | *ok = false; |
624 | return QDateTime (); | 636 | return QDateTime (); |
625 | 637 | ||
626 | } | 638 | } |
627 | 639 | ||
628 | void Todo::checkSetCompletedFalse() | 640 | void Todo::checkSetCompletedFalse() |
629 | { | 641 | { |
630 | if ( !mHasRecurrenceID ) { | 642 | if ( !mHasRecurrenceID ) { |
631 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 643 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
632 | return; | 644 | return; |
633 | } | 645 | } |
634 | // qDebug("Todo::checkSetCompletedFalse()"); | 646 | // qDebug("Todo::checkSetCompletedFalse()"); |
635 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 647 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
636 | if ( mPercentComplete == 100 ) { | 648 | if ( mPercentComplete == 100 ) { |
637 | QDateTime dt = QDateTime::currentDateTime(); | 649 | QDateTime dt = QDateTime::currentDateTime(); |
638 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 650 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
639 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 651 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
640 | setCompleted( false ); | 652 | setCompleted( false ); |
641 | qDebug("Todo::checkSetCompletedFalse "); | 653 | qDebug("Todo::checkSetCompletedFalse "); |
642 | } | 654 | } |
643 | } | 655 | } |
644 | } | 656 | } |
645 | QString Todo::durationText() | 657 | QString Todo::durationText() |
646 | { | 658 | { |
647 | if ( mHasDueDate && hasStartDate() ) { | 659 | if ( mHasDueDate && hasStartDate() ) { |
648 | int sec = dtStart().secsTo( dtDue() ); | 660 | int sec = dtStart().secsTo( dtDue() ); |
649 | if ( doesFloat() ) | 661 | if ( doesFloat() ) |
650 | sec += 86400; | 662 | sec += 86400; |
651 | return durationText4Time( sec ); | 663 | return durationText4Time( sec ); |
652 | } | 664 | } |
653 | return "---"; | 665 | return "---"; |
654 | } | 666 | } |