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; }
KCal::Todo *IncidenceConverter::convertFromTask(ngwt__Task *task) { if(!task) return 0; KCal::Todo *todo = new KCal::Todo(); if(!convertFromCalendarItem(task, todo)) { delete todo; return 0; } if(task->startDate) { todo->setHasStartDate(true); todo->setDtStart(stringToQDateTime(task->startDate)); } if(task->dueDate) { todo->setHasDueDate(true); todo->setDtDue(stringToQDateTime(task->dueDate)); } if(task->taskPriority) { QString priority = stringToQString(task->taskPriority); // FIXME: Store priority string somewhere int p = priority.toInt(); if(p == 0) p = 3; todo->setPriority(p); } if(task->completed) todo->setCompleted(*task->completed); todo->setLocation(i18n("Novell GroupWise does not support locations for to-dos.")); return todo; }