QString timetrackerstorage::setTaskParent(Task* task, Task* parent) { kDebug(5970) << "Entering function"; QString err; KCalCore::Todo::Ptr todo = d->mCalendar->todo( task->uid() ); if ( !parent ) { todo->setRelatedTo( QString() ); } else { todo->setRelatedTo( parent->uid() ); } kDebug(5970) << "Leaving function"; return err; }
QString timetrackerstorage::addTask(const Task* task, const Task* parent) { kDebug(5970) << "Entering function"; KCalCore::Todo::Ptr todo; QString uid; if ( !d->mCalendar ) { kDebug(5970) << "mCalendar is not set"; return uid; } todo = KCalCore::Todo::Ptr( new KCalCore::Todo() ); if ( d->mCalendar->addTodo( todo ) ) { task->asTodo( todo ); if (parent) todo->setRelatedTo( parent->uid() ); uid = todo->uid(); } else { // Most likely a lock could not be pulled, although there are other // possiblities (like a really confused resource manager). uid.clear();; } return uid; }
QString timetrackerstorage::writeTaskAsTodo(Task* task, QStack<KCalCore::Todo::Ptr>& parents) { kDebug(5970) << "Entering function"; QString err; KCalCore::Todo::Ptr todo = d->mCalendar->todo(task->uid()); task->asTodo(todo); // FIXME ? if ( !todo ) { kDebug(5970) << "Could not get todo from calendar"; return "Could not get todo from calendar"; } task->asTodo(todo); if ( !parents.isEmpty() ) todo->setRelatedTo( parents.top() ? parents.top()->uid() : QString() ); parents.push( todo ); for ( int i = 0; i < task->childCount(); ++i ) { Task *nextTask = static_cast< Task* >( task->child( i ) ); err = writeTaskAsTodo( nextTask, parents ); } parents.pop(); return err; }