Example #1
0
KCal::Todo*
ICalReport::generateTODO(Task* task, ResourceList& resourceList)
{
    KCal::Todo *todo = new KCal::Todo();

    QDateTime dt;

    /* Start-Time of the task */
    dt.setTime_t(task->getStart(scenarios[0]), Qt::UTC);
    todo->setDtStart(dt);
    if (!task->isMilestone())
        todo->setHasDueDate(true);

    /* Due-Time of the todo -> plan End  */
    dt.setTime_t(task->getEnd(scenarios[0]) + 1, Qt::UTC);
    todo->setDtDue(dt);
    todo->setHasStartDate(true);

    // Make sure that the time is not ignored.
    todo->setFloats(false);

    /* Description and summary -> project ID */
    todo->setDescription(task->getNote());
    todo->setSummary(task->getName());

    /* ICal defines priorities between 1..9 where 1 is the highest. TaskJuggler
     * uses Priority 1 - 1000, 1000 being the highest. So we have to map the
     * priorities. */
    todo->setPriority(1 + ((1000 - task->getPriority()) / 100));

    todo->setPercentComplete
        (static_cast<int>(task->getCalcedCompletionDegree(scenarios[0])));

    /* Resources */
    ResourceListIterator rli = task->getBookedResourcesIterator(scenarios[0]);
    for (; *rli != 0; ++rli)
        // We only include resources that have not been filtered out.
        if (resourceList.find(*rli))
            todo->addAttendee(new KCal::Attendee
                              ((*rli)->getName(), "", false,
                               KCal::Attendee::NeedsAction,
                               KCal::Attendee::ReqParticipant,
                               (*rli)->getId()));

    return todo;
}