From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- karm/plannerparser.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 karm/plannerparser.cpp (limited to 'karm/plannerparser.cpp') diff --git a/karm/plannerparser.cpp b/karm/plannerparser.cpp new file mode 100644 index 000000000..21e0c4f76 --- /dev/null +++ b/karm/plannerparser.cpp @@ -0,0 +1,100 @@ +// +// C++ Implementation: plannerparser +// +// Description: +/* + +this class is here to import tasks from a planner project file to karm. +the import shall not be limited to karm (kPlaTo sends greetings) +it imports planner's top-level-tasks on the same level-depth as current_item. +if there is no current_item, planner's top-level-tasks will become top-level-tasks in karm. +it imports as well the level-depth of each task, as its name, as its percent-complete. +test cases: + - deleting all tasks away, then import! + - having started with an empty ics, import! + - with current_item being a top-level-task, import! + - with current_item being a subtask, import! + + + Author: Thorsten Staerk , (C) 2004 + + Copyright: See COPYING file that comes with this distribution + + +*/ + +#include "plannerparser.h" + + + PlannerParser::PlannerParser(TaskView * tv) + // if there is a task one level above current_item, make it the father of all imported tasks. Set level accordingly. + // import as well if there a no task in the taskview as if there are. + // if there are, put the top-level tasks of planner on the same level as current_item. + // So you have the chance as well to have the planner tasks at top-level as at a whatever-so-deep sublevel. + { + kdDebug() << "entering constructor to import planner tasks" << endl; + _taskView=tv; + level=0; + if (_taskView->current_item()) if (_taskView->current_item()->parent()) + { + task = _taskView->current_item()->parent(); + level=1; + } + } + + bool PlannerParser::startDocument() + { + withInTasks=false; // becomes true as soon as parsing occurres + return true; + } + + bool PlannerParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& att ) + { + kdDebug() << "entering startElement" << endl; + QString taskName; + int taskComplete=0; + + // only s within are processed + if (qName == QString::fromLatin1("tasks")) withInTasks=true; + if ((qName == QString::fromLatin1("task")) && (withInTasks)) + { + + // find out name and percent-complete + for (int i=0; i0) + { + parentTask=task; + task = new Task(taskName, 0, 0, dl, parentTask); + task->setUid(_taskView->storage()->addTask(task, parentTask)); + } + else + { + task = new Task(taskName, 0, 0, dl, _taskView); + kdDebug() << "added" << taskName << endl; + task->setUid(_taskView->storage()->addTask(task, 0)); + } + + task->setPercentComplete(taskComplete, _taskView->storage()); + } + return true; + } + + bool PlannerParser::endElement( const QString&, const QString&, const QString& qName) + { + // only s within increased level, so only decrease for s within + if (withInTasks) + { + if (qName=="task") if (level-->=0) task=task->parent(); + if (qName=="tasks") withInTasks=false; + } + return true; + } + -- cgit v1.2.1