ktimetracker
plannerparser.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "plannerparser.h"
00038
00039 #include "task.h"
00040 #include "taskview.h"
00041
00042 PlannerParser::PlannerParser(TaskView * tv)
00043
00044
00045
00046
00047 {
00048 kDebug() <<"entering constructor to import planner tasks";
00049 _taskView=tv;
00050 level=0;
00051 if (_taskView->currentItem()) if (_taskView->currentItem()->parent())
00052 {
00053 task = _taskView->currentItem()->parent();
00054 level=1;
00055 }
00056 }
00057
00058 bool PlannerParser::startDocument()
00059 {
00060 withInTasks=false;
00061 return true;
00062 }
00063
00064 bool PlannerParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& att )
00065 {
00066 kDebug() << "entering function";
00067 QString taskName;
00068 int taskComplete=0;
00069
00070
00071 if (qName == QString::fromLatin1("tasks")) withInTasks=true;
00072 if ((qName == QString::fromLatin1("task")) && (withInTasks))
00073 {
00074
00075
00076 for (int i=0; i<att.length(); i++)
00077 {
00078 if (att.qName(i) == QString::fromLatin1("name")) taskName=att.value(i);
00079 if (att.qName(i)==QString::fromLatin1("percent-complete")) taskComplete=att.value(i).toInt();
00080 }
00081
00082
00083
00084 DesktopList dl;
00085 if (level++>0)
00086 {
00087 parentTask=task;
00088 task = new Task(taskName, 0, 0, dl, parentTask);
00089 task->setUid(_taskView->storage()->addTask(task, parentTask));
00090 }
00091 else
00092 {
00093 task = new Task(taskName, 0, 0, dl, _taskView);
00094 kDebug() <<"added" << taskName;
00095 task->setUid(_taskView->storage()->addTask(task, 0));
00096 }
00097
00098 task->setPercentComplete(taskComplete, _taskView->storage());
00099 }
00100 return true;
00101 }
00102
00103 bool PlannerParser::endElement( const QString&, const QString&, const QString& qName)
00104 {
00105
00106 if (withInTasks)
00107 {
00108 if (qName=="task") if (level-->=0) task=task->parent();
00109 if (qName=="tasks") withInTasks=false;
00110 }
00111 return true;
00112 }
00113