-rw-r--r-- | libkcal/todo.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 3d2de61..7362bdf 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -195,180 +195,185 @@ QString Todo::dtDueStr(bool shortfmt) const | |||
195 | } | 195 | } |
196 | 196 | ||
197 | bool Todo::hasDueDate() const | 197 | bool Todo::hasDueDate() const |
198 | { | 198 | { |
199 | return mHasDueDate; | 199 | return mHasDueDate; |
200 | } | 200 | } |
201 | 201 | ||
202 | void Todo::setHasDueDate(bool f) | 202 | void Todo::setHasDueDate(bool f) |
203 | { | 203 | { |
204 | if (mReadOnly) return; | 204 | if (mReadOnly) return; |
205 | mHasDueDate = f; | 205 | mHasDueDate = f; |
206 | updated(); | 206 | updated(); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | #if 0 | 210 | #if 0 |
211 | void Todo::setStatus(const QString &statStr) | 211 | void Todo::setStatus(const QString &statStr) |
212 | { | 212 | { |
213 | if (mReadOnly) return; | 213 | if (mReadOnly) return; |
214 | QString ss(statStr.upper()); | 214 | QString ss(statStr.upper()); |
215 | 215 | ||
216 | if (ss == "X-ACTION") | 216 | if (ss == "X-ACTION") |
217 | mStatus = NEEDS_ACTION; | 217 | mStatus = NEEDS_ACTION; |
218 | else if (ss == "NEEDS ACTION") | 218 | else if (ss == "NEEDS ACTION") |
219 | mStatus = NEEDS_ACTION; | 219 | mStatus = NEEDS_ACTION; |
220 | else if (ss == "ACCEPTED") | 220 | else if (ss == "ACCEPTED") |
221 | mStatus = ACCEPTED; | 221 | mStatus = ACCEPTED; |
222 | else if (ss == "SENT") | 222 | else if (ss == "SENT") |
223 | mStatus = SENT; | 223 | mStatus = SENT; |
224 | else if (ss == "TENTATIVE") | 224 | else if (ss == "TENTATIVE") |
225 | mStatus = TENTATIVE; | 225 | mStatus = TENTATIVE; |
226 | else if (ss == "CONFIRMED") | 226 | else if (ss == "CONFIRMED") |
227 | mStatus = CONFIRMED; | 227 | mStatus = CONFIRMED; |
228 | else if (ss == "DECLINED") | 228 | else if (ss == "DECLINED") |
229 | mStatus = DECLINED; | 229 | mStatus = DECLINED; |
230 | else if (ss == "COMPLETED") | 230 | else if (ss == "COMPLETED") |
231 | mStatus = COMPLETED; | 231 | mStatus = COMPLETED; |
232 | else if (ss == "DELEGATED") | 232 | else if (ss == "DELEGATED") |
233 | mStatus = DELEGATED; | 233 | mStatus = DELEGATED; |
234 | 234 | ||
235 | updated(); | 235 | updated(); |
236 | } | 236 | } |
237 | 237 | ||
238 | void Todo::setStatus(int status) | 238 | void Todo::setStatus(int status) |
239 | { | 239 | { |
240 | if (mReadOnly) return; | 240 | if (mReadOnly) return; |
241 | mStatus = status; | 241 | mStatus = status; |
242 | updated(); | 242 | updated(); |
243 | } | 243 | } |
244 | 244 | ||
245 | int Todo::status() const | 245 | int Todo::status() const |
246 | { | 246 | { |
247 | return mStatus; | 247 | return mStatus; |
248 | } | 248 | } |
249 | 249 | ||
250 | QString Todo::statusStr() const | 250 | QString Todo::statusStr() const |
251 | { | 251 | { |
252 | switch(mStatus) { | 252 | switch(mStatus) { |
253 | case NEEDS_ACTION: | 253 | case NEEDS_ACTION: |
254 | return QString("NEEDS ACTION"); | 254 | return QString("NEEDS ACTION"); |
255 | break; | 255 | break; |
256 | case ACCEPTED: | 256 | case ACCEPTED: |
257 | return QString("ACCEPTED"); | 257 | return QString("ACCEPTED"); |
258 | break; | 258 | break; |
259 | case SENT: | 259 | case SENT: |
260 | return QString("SENT"); | 260 | return QString("SENT"); |
261 | break; | 261 | break; |
262 | case TENTATIVE: | 262 | case TENTATIVE: |
263 | return QString("TENTATIVE"); | 263 | return QString("TENTATIVE"); |
264 | break; | 264 | break; |
265 | case CONFIRMED: | 265 | case CONFIRMED: |
266 | return QString("CONFIRMED"); | 266 | return QString("CONFIRMED"); |
267 | break; | 267 | break; |
268 | case DECLINED: | 268 | case DECLINED: |
269 | return QString("DECLINED"); | 269 | return QString("DECLINED"); |
270 | break; | 270 | break; |
271 | case COMPLETED: | 271 | case COMPLETED: |
272 | return QString("COMPLETED"); | 272 | return QString("COMPLETED"); |
273 | break; | 273 | break; |
274 | case DELEGATED: | 274 | case DELEGATED: |
275 | return QString("DELEGATED"); | 275 | return QString("DELEGATED"); |
276 | break; | 276 | break; |
277 | } | 277 | } |
278 | return QString(""); | 278 | return QString(""); |
279 | } | 279 | } |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | bool Todo::isCompleted() const | 282 | bool Todo::isCompleted() const |
283 | { | 283 | { |
284 | if (mPercentComplete == 100) return true; | 284 | if (mPercentComplete == 100) return true; |
285 | else return false; | 285 | else return false; |
286 | } | 286 | } |
287 | 287 | ||
288 | void Todo::setCompleted(bool completed) | 288 | void Todo::setCompleted(bool completed) |
289 | { | 289 | { |
290 | if (completed) mPercentComplete = 100; | 290 | if (completed) mPercentComplete = 100; |
291 | else mPercentComplete = 0; | 291 | else { |
292 | mPercentComplete = 0; | ||
293 | mHasCompletedDate = false; | ||
294 | } | ||
292 | updated(); | 295 | updated(); |
293 | } | 296 | } |
294 | 297 | ||
295 | QDateTime Todo::completed() const | 298 | QDateTime Todo::completed() const |
296 | { | 299 | { |
297 | return mCompleted; | 300 | return mCompleted; |
298 | } | 301 | } |
299 | 302 | ||
300 | QString Todo::completedStr() const | 303 | QString Todo::completedStr() const |
301 | { | 304 | { |
302 | return KGlobal::locale()->formatDateTime(mCompleted); | 305 | return KGlobal::locale()->formatDateTime(mCompleted); |
303 | } | 306 | } |
304 | 307 | ||
305 | void Todo::setCompleted(const QDateTime &completed) | 308 | void Todo::setCompleted(const QDateTime &completed) |
306 | { | 309 | { |
307 | mHasCompletedDate = true; | 310 | mHasCompletedDate = true; |
308 | mPercentComplete = 100; | 311 | mPercentComplete = 100; |
309 | mCompleted = getEvenTime(completed); | 312 | mCompleted = getEvenTime(completed); |
310 | updated(); | 313 | updated(); |
311 | } | 314 | } |
312 | 315 | ||
313 | bool Todo::hasCompletedDate() const | 316 | bool Todo::hasCompletedDate() const |
314 | { | 317 | { |
315 | return mHasCompletedDate; | 318 | return mHasCompletedDate; |
316 | } | 319 | } |
317 | 320 | ||
318 | int Todo::percentComplete() const | 321 | int Todo::percentComplete() const |
319 | { | 322 | { |
320 | return mPercentComplete; | 323 | return mPercentComplete; |
321 | } | 324 | } |
322 | 325 | ||
323 | void Todo::setPercentComplete(int v) | 326 | void Todo::setPercentComplete(int v) |
324 | { | 327 | { |
325 | mPercentComplete = v; | 328 | mPercentComplete = v; |
329 | if ( v != 100 ) | ||
330 | mHasCompletedDate = false; | ||
326 | updated(); | 331 | updated(); |
327 | } | 332 | } |
328 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 333 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
329 | { | 334 | { |
330 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 335 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
331 | *ok = false; | 336 | *ok = false; |
332 | return QDateTime (); | 337 | return QDateTime (); |
333 | } | 338 | } |
334 | QDateTime incidenceStart; | 339 | QDateTime incidenceStart; |
335 | incidenceStart = dtDue(); | 340 | incidenceStart = dtDue(); |
336 | bool enabled = false; | 341 | bool enabled = false; |
337 | Alarm* alarm; | 342 | Alarm* alarm; |
338 | int off; | 343 | int off; |
339 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 344 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
340 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 345 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
341 | // *ok = false; | 346 | // *ok = false; |
342 | // return incidenceStart; | 347 | // return incidenceStart; |
343 | // } | 348 | // } |
344 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 349 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
345 | if (alarm->enabled()) { | 350 | if (alarm->enabled()) { |
346 | if ( alarm->hasTime () ) { | 351 | if ( alarm->hasTime () ) { |
347 | if ( alarm->time() < alarmStart ) { | 352 | if ( alarm->time() < alarmStart ) { |
348 | alarmStart = alarm->time(); | 353 | alarmStart = alarm->time(); |
349 | enabled = true; | 354 | enabled = true; |
350 | off = alarmStart.secsTo( incidenceStart ); | 355 | off = alarmStart.secsTo( incidenceStart ); |
351 | } | 356 | } |
352 | 357 | ||
353 | } else { | 358 | } else { |
354 | int secs = alarm->startOffset().asSeconds(); | 359 | int secs = alarm->startOffset().asSeconds(); |
355 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 360 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
356 | alarmStart = incidenceStart.addSecs( secs ); | 361 | alarmStart = incidenceStart.addSecs( secs ); |
357 | enabled = true; | 362 | enabled = true; |
358 | off = -secs; | 363 | off = -secs; |
359 | } | 364 | } |
360 | } | 365 | } |
361 | } | 366 | } |
362 | } | 367 | } |
363 | if ( enabled ) { | 368 | if ( enabled ) { |
364 | if ( alarmStart > QDateTime::currentDateTime() ) { | 369 | if ( alarmStart > QDateTime::currentDateTime() ) { |
365 | *ok = true; | 370 | *ok = true; |
366 | * offset = off; | 371 | * offset = off; |
367 | return alarmStart; | 372 | return alarmStart; |
368 | } | 373 | } |
369 | } | 374 | } |
370 | *ok = false; | 375 | *ok = false; |
371 | return QDateTime (); | 376 | return QDateTime (); |
372 | 377 | ||
373 | } | 378 | } |
374 | 379 | ||