-rw-r--r-- | libkcal/todo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index d7431c7..473247a 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -326,252 +326,252 @@ int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | |||
326 | return 2; | 326 | return 2; |
327 | // we do not return, because we may find an overdue sub todo | 327 | // we do not return, because we may find an overdue sub todo |
328 | if ( dtDue().date() == date ) | 328 | if ( dtDue().date() == date ) |
329 | retval = 1; | 329 | retval = 1; |
330 | } | 330 | } |
331 | if ( checkSubtodos ) { | 331 | if ( checkSubtodos ) { |
332 | Incidence *aTodo; | 332 | Incidence *aTodo; |
333 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 333 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
334 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 334 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
335 | if ( ret == 2 ) | 335 | if ( ret == 2 ) |
336 | return 2; | 336 | return 2; |
337 | if ( ret == 1) | 337 | if ( ret == 1) |
338 | retval = 1; | 338 | retval = 1; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | return retval; | 341 | return retval; |
342 | } | 342 | } |
343 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 343 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
344 | { | 344 | { |
345 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 345 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
346 | } | 346 | } |
347 | bool Todo::hasDueDate() const | 347 | bool Todo::hasDueDate() const |
348 | { | 348 | { |
349 | return mHasDueDate; | 349 | return mHasDueDate; |
350 | } | 350 | } |
351 | 351 | ||
352 | void Todo::setHasDueDate(bool f) | 352 | void Todo::setHasDueDate(bool f) |
353 | { | 353 | { |
354 | if (mReadOnly) return; | 354 | if (mReadOnly) return; |
355 | mHasDueDate = f; | 355 | mHasDueDate = f; |
356 | updated(); | 356 | updated(); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | #if 0 | 360 | #if 0 |
361 | void Todo::setStatus(const QString &statStr) | 361 | void Todo::setStatus(const QString &statStr) |
362 | { | 362 | { |
363 | if (mReadOnly) return; | 363 | if (mReadOnly) return; |
364 | QString ss(statStr.upper()); | 364 | QString ss(statStr.upper()); |
365 | 365 | ||
366 | if (ss == "X-ACTION") | 366 | if (ss == "X-ACTION") |
367 | mStatus = NEEDS_ACTION; | 367 | mStatus = NEEDS_ACTION; |
368 | else if (ss == "NEEDS ACTION") | 368 | else if (ss == "NEEDS ACTION") |
369 | mStatus = NEEDS_ACTION; | 369 | mStatus = NEEDS_ACTION; |
370 | else if (ss == "ACCEPTED") | 370 | else if (ss == "ACCEPTED") |
371 | mStatus = ACCEPTED; | 371 | mStatus = ACCEPTED; |
372 | else if (ss == "SENT") | 372 | else if (ss == "SENT") |
373 | mStatus = SENT; | 373 | mStatus = SENT; |
374 | else if (ss == "TENTATIVE") | 374 | else if (ss == "TENTATIVE") |
375 | mStatus = TENTATIVE; | 375 | mStatus = TENTATIVE; |
376 | else if (ss == "CONFIRMED") | 376 | else if (ss == "CONFIRMED") |
377 | mStatus = CONFIRMED; | 377 | mStatus = CONFIRMED; |
378 | else if (ss == "DECLINED") | 378 | else if (ss == "DECLINED") |
379 | mStatus = DECLINED; | 379 | mStatus = DECLINED; |
380 | else if (ss == "COMPLETED") | 380 | else if (ss == "COMPLETED") |
381 | mStatus = COMPLETED; | 381 | mStatus = COMPLETED; |
382 | else if (ss == "DELEGATED") | 382 | else if (ss == "DELEGATED") |
383 | mStatus = DELEGATED; | 383 | mStatus = DELEGATED; |
384 | 384 | ||
385 | updated(); | 385 | updated(); |
386 | } | 386 | } |
387 | 387 | ||
388 | void Todo::setStatus(int status) | 388 | void Todo::setStatus(int status) |
389 | { | 389 | { |
390 | if (mReadOnly) return; | 390 | if (mReadOnly) return; |
391 | mStatus = status; | 391 | mStatus = status; |
392 | updated(); | 392 | updated(); |
393 | } | 393 | } |
394 | 394 | ||
395 | int Todo::status() const | 395 | int Todo::status() const |
396 | { | 396 | { |
397 | return mStatus; | 397 | return mStatus; |
398 | } | 398 | } |
399 | 399 | ||
400 | QString Todo::statusStr() const | 400 | QString Todo::statusStr() const |
401 | { | 401 | { |
402 | switch(mStatus) { | 402 | switch(mStatus) { |
403 | case NEEDS_ACTION: | 403 | case NEEDS_ACTION: |
404 | return QString("NEEDS ACTION"); | 404 | return QString("NEEDS ACTION"); |
405 | break; | 405 | break; |
406 | case ACCEPTED: | 406 | case ACCEPTED: |
407 | return QString("ACCEPTED"); | 407 | return QString("ACCEPTED"); |
408 | break; | 408 | break; |
409 | case SENT: | 409 | case SENT: |
410 | return QString("SENT"); | 410 | return QString("SENT"); |
411 | break; | 411 | break; |
412 | case TENTATIVE: | 412 | case TENTATIVE: |
413 | return QString("TENTATIVE"); | 413 | return QString("TENTATIVE"); |
414 | break; | 414 | break; |
415 | case CONFIRMED: | 415 | case CONFIRMED: |
416 | return QString("CONFIRMED"); | 416 | return QString("CONFIRMED"); |
417 | break; | 417 | break; |
418 | case DECLINED: | 418 | case DECLINED: |
419 | return QString("DECLINED"); | 419 | return QString("DECLINED"); |
420 | break; | 420 | break; |
421 | case COMPLETED: | 421 | case COMPLETED: |
422 | return QString("COMPLETED"); | 422 | return QString("COMPLETED"); |
423 | break; | 423 | break; |
424 | case DELEGATED: | 424 | case DELEGATED: |
425 | return QString("DELEGATED"); | 425 | return QString("DELEGATED"); |
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | return QString(""); | 428 | return QString(""); |
429 | } | 429 | } |
430 | #endif | 430 | #endif |
431 | 431 | ||
432 | bool Todo::isCompleted() const | 432 | bool Todo::isCompleted() const |
433 | { | 433 | { |
434 | if (mPercentComplete == 100) { | 434 | if (mPercentComplete == 100) { |
435 | return true; | 435 | return true; |
436 | } | 436 | } |
437 | else return false; | 437 | else return false; |
438 | } | 438 | } |
439 | 439 | ||
440 | void Todo::setCompleted(bool completed) | 440 | void Todo::setCompleted(bool completed) |
441 | { | 441 | { |
442 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 442 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
443 | if ( !setRecurDates() ) | 443 | if ( !setRecurDates() ) |
444 | completed = false; | 444 | completed = false; |
445 | } | 445 | } |
446 | if (completed) mPercentComplete = 100; | 446 | if (completed) mPercentComplete = 100; |
447 | else { | 447 | else { |
448 | mPercentComplete = 0; | 448 | mPercentComplete = 0; |
449 | mHasCompletedDate = false; | 449 | mHasCompletedDate = false; |
450 | } | 450 | } |
451 | updated(); | 451 | updated(); |
452 | } | 452 | } |
453 | 453 | ||
454 | QDateTime Todo::completed() const | 454 | QDateTime Todo::completed() const |
455 | { | 455 | { |
456 | return mCompleted; | 456 | return mCompleted; |
457 | } | 457 | } |
458 | 458 | ||
459 | QString Todo::completedStr( bool shortF ) const | 459 | QString Todo::completedStr( bool shortF ) const |
460 | { | 460 | { |
461 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 461 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
462 | } | 462 | } |
463 | 463 | ||
464 | void Todo::setCompleted(const QDateTime &completed) | 464 | void Todo::setCompleted(const QDateTime &completed) |
465 | { | 465 | { |
466 | //qDebug("Todo::setCompleted "); | 466 | //qDebug("Todo::setCompleted "); |
467 | if ( mHasCompletedDate ) { | 467 | if ( mHasCompletedDate ) { |
468 | // qDebug("has completed data - return "); | 468 | // qDebug("has completed data - return "); |
469 | return; | 469 | return; |
470 | } | 470 | } |
471 | mHasCompletedDate = true; | 471 | mHasCompletedDate = true; |
472 | mPercentComplete = 100; | 472 | mPercentComplete = 100; |
473 | mCompleted = getEvenTime(completed); | 473 | mCompleted = getEvenTime(completed); |
474 | updated(); | 474 | updated(); |
475 | } | 475 | } |
476 | 476 | ||
477 | bool Todo::hasCompletedDate() const | 477 | bool Todo::hasCompletedDate() const |
478 | { | 478 | { |
479 | return mHasCompletedDate; | 479 | return mHasCompletedDate; |
480 | } | 480 | } |
481 | 481 | ||
482 | int Todo::percentComplete() const | 482 | int Todo::percentComplete() const |
483 | { | 483 | { |
484 | return mPercentComplete; | 484 | return mPercentComplete; |
485 | } | 485 | } |
486 | bool Todo::setRecurDates() | 486 | bool Todo::setRecurDates() |
487 | { | 487 | { |
488 | if ( !mHasRecurrenceID ) | 488 | if ( !mHasRecurrenceID ) |
489 | return true; | 489 | return true; |
490 | int secs = mDtStart.secsTo( dtDue() ); | 490 | int secs = mDtStart.secsTo( dtDue() ); |
491 | bool ok; | 491 | bool ok; |
492 | qDebug("T:setRecurDates() "); | 492 | qDebug("T:setRecurDates() "); |
493 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 493 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
494 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 494 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
495 | if ( ok ) { | 495 | if ( ok ) { |
496 | mRecurrenceID = next; | 496 | mRecurrenceID = next; |
497 | mDtStart = next; | 497 | mDtStart = next; |
498 | setDtDue( next.addSecs( secs ) ); | 498 | setDtDue( next.addSecs( secs ) ); |
499 | if ( QDateTime::currentDateTime() > next) | 499 | if ( QDateTime::currentDateTime() > next) |
500 | return false; | 500 | return false; |
501 | } else { | 501 | } else { |
502 | setHasRecurrenceID( false ); | 502 | setHasRecurrenceID( false ); |
503 | recurrence()->unsetRecurs(); | 503 | recurrence()->unsetRecurs(); |
504 | } | 504 | } |
505 | return true; | 505 | return true; |
506 | } | 506 | } |
507 | void Todo::setPercentComplete(int v) | 507 | void Todo::setPercentComplete(int v) |
508 | { | 508 | { |
509 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 509 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
510 | if ( !setRecurDates() ) | 510 | if ( !setRecurDates() ) |
511 | v = 0; | 511 | v = 0; |
512 | } | 512 | } |
513 | mPercentComplete = v; | 513 | mPercentComplete = v; |
514 | if ( v != 100 ) | 514 | if ( v != 100 ) |
515 | mHasCompletedDate = false; | 515 | mHasCompletedDate = false; |
516 | updated(); | 516 | updated(); |
517 | } | 517 | } |
518 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 518 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
519 | { | 519 | { |
520 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 520 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
521 | *ok = false; | 521 | *ok = false; |
522 | return QDateTime (); | 522 | return QDateTime (); |
523 | } | 523 | } |
524 | QDateTime incidenceStart; | 524 | QDateTime incidenceStart; |
525 | incidenceStart = dtDue(); | 525 | incidenceStart = dtDue(); |
526 | bool enabled = false; | 526 | bool enabled = false; |
527 | Alarm* alarm; | 527 | Alarm* alarm; |
528 | int off = 0; | 528 | int off = 0; |
529 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 529 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
530 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 530 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
531 | // *ok = false; | 531 | // *ok = false; |
532 | // return incidenceStart; | 532 | // return incidenceStart; |
533 | // } | 533 | // } |
534 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 534 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
535 | if (alarm->enabled()) { | 535 | if (alarm->enabled()) { |
536 | if ( alarm->hasTime () ) { | 536 | if ( alarm->hasTime () ) { |
537 | if ( alarm->time() < alarmStart ) { | 537 | if ( alarm->time() < alarmStart ) { |
538 | alarmStart = alarm->time(); | 538 | alarmStart = alarm->time(); |
539 | enabled = true; | 539 | enabled = true; |
540 | off = alarmStart.secsTo( incidenceStart ); | 540 | off = alarmStart.secsTo( incidenceStart ); |
541 | } | 541 | } |
542 | 542 | ||
543 | } else { | 543 | } else { |
544 | int secs = alarm->startOffset().asSeconds(); | 544 | int secs = alarm->startOffset().asSeconds(); |
545 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 545 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
546 | alarmStart = incidenceStart.addSecs( secs ); | 546 | alarmStart = incidenceStart.addSecs( secs ); |
547 | enabled = true; | 547 | enabled = true; |
548 | off = -secs; | 548 | off = -secs; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | } | 551 | } |
552 | } | 552 | } |
553 | if ( enabled ) { | 553 | if ( enabled ) { |
554 | if ( alarmStart > QDateTime::currentDateTime() ) { | 554 | if ( alarmStart > start_dt ) { |
555 | *ok = true; | 555 | *ok = true; |
556 | * offset = off; | 556 | * offset = off; |
557 | return alarmStart; | 557 | return alarmStart; |
558 | } | 558 | } |
559 | } | 559 | } |
560 | *ok = false; | 560 | *ok = false; |
561 | return QDateTime (); | 561 | return QDateTime (); |
562 | 562 | ||
563 | } | 563 | } |
564 | 564 | ||
565 | void Todo::checkSetCompletedFalse() | 565 | void Todo::checkSetCompletedFalse() |
566 | { | 566 | { |
567 | if ( !hasRecurrenceID() ) { | 567 | if ( !hasRecurrenceID() ) { |
568 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 568 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
569 | } | 569 | } |
570 | // qDebug("Todo::checkSetCompletedFalse()"); | 570 | // qDebug("Todo::checkSetCompletedFalse()"); |
571 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 571 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
572 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | 572 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { |
573 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 573 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
574 | setCompleted( false ); | 574 | setCompleted( false ); |
575 | qDebug("Todo::checkSetCompletedFalse "); | 575 | qDebug("Todo::checkSetCompletedFalse "); |
576 | } | 576 | } |
577 | } | 577 | } |