• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

ktimetracker

  • sources
  • kde-4.12
  • kdepim
  • ktimetracker
plannerparser.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 by Thorsten Staerk <dev@staerk.de>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the
16  * Free Software Foundation, Inc.
17  * 51 Franklin Street, Fifth Floor
18  * Boston, MA 02110-1301 USA.
19  *
20  */
21 
22 /*
23 
24 this class is here to import tasks from a planner project file to ktimetracker.
25 the import shall not be limited to ktimetracker (kPlaTo sends greetings)
26 it imports planner's top-level-tasks on the same level-depth as currentItem.
27 if there is no currentItem, planner's top-level-tasks will become top-level-tasks in ktimetracker.
28 it imports as well the level-depth of each task, as its name, as its percent-complete.
29 test cases:
30  - deleting all tasks away, then import!
31  - having started with an empty ics, import!
32  - with currentItem being a top-level-task, import!
33  - with currentItem being a subtask, import!
34 */
35 
36 #include "plannerparser.h"
37 
38 #include "task.h"
39 #include "taskview.h"
40 
41 #include <KDebug>
42 
43 PlannerParser::PlannerParser(TaskView * tv)
44 // if there is a task one level above currentItem, make it the father of all imported tasks. Set level accordingly.
45 // import as well if there a no task in the taskview as if there are.
46 // if there are, put the top-level tasks of planner on the same level as currentItem.
47 // So you have the chance as well to have the planner tasks at top-level as at a whatever-so-deep sublevel.
48 {
49  kDebug() <<"entering constructor to import planner tasks";
50  _taskView=tv;
51  level=0;
52  if (_taskView->currentItem()) if (_taskView->currentItem()->parent())
53  {
54  task = _taskView->currentItem()->parent();
55  level=1;
56  }
57 }
58 
59 bool PlannerParser::startDocument()
60 {
61  withInTasks=false; // becomes true as soon as parsing occurres <tasks>
62  return true;
63 }
64 
65 bool PlannerParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& att )
66 {
67  kDebug() << "entering function";
68  QString taskName;
69  int taskComplete=0;
70 
71  // only <task>s within <tasks> are processed
72  if (qName == QString::fromLatin1("tasks")) withInTasks=true;
73  if ((qName == QString::fromLatin1("task")) && (withInTasks))
74  {
75  // find out name and percent-complete
76  for (int i=0; i<att.length(); ++i)
77  {
78  if (att.qName(i) == QString::fromLatin1("name")) taskName=att.value(i);
79  if (att.qName(i)==QString::fromLatin1("percent-complete")) taskComplete=att.value(i).toInt();
80  }
81 
82  // at the moment, task is still the old task or the old father task (if an endElement occurred) or not existing (if the
83  // new task is a top-level-task). Make task the parenttask, if existing.
84  DesktopList dl;
85  if (level++>0)
86  {
87  parentTask=task;
88  task = new Task(taskName, QString(), 0, 0, dl, parentTask);
89  task->setUid(_taskView->storage()->addTask(task, parentTask));
90  }
91  else
92  {
93  task = new Task(taskName, QString(), 0, 0, dl, _taskView);
94  kDebug() <<"added" << taskName;
95  task->setUid(_taskView->storage()->addTask(task, 0));
96  }
97  task->setPercentComplete(taskComplete, _taskView->storage());
98  }
99  return true;
100 }
101 
102 bool PlannerParser::endElement( const QString&, const QString&, const QString& qName)
103 {
104  // only <task>s within <tasks> increased level, so only decrease for <task>s within <tasks>
105  if (withInTasks)
106  {
107  if (qName=="task") if (level-->=0) task=task->parent();
108  if (qName=="tasks") withInTasks=false;
109  }
110  return true;
111 }
112 
Task::setPercentComplete
void setPercentComplete(const int percent, timetrackerstorage *storage)
Update percent complete for this task.
Definition: task.cpp:238
PlannerParser::endElement
bool endElement(const QString &, const QString &, const QString &qName)
given by the framework from qxml.
Definition: plannerparser.cpp:102
PlannerParser::PlannerParser
PlannerParser(TaskView *tv)
Stores the active TaskView in this parser.
Definition: plannerparser.cpp:43
taskview.h
TaskView::storage
timetrackerstorage * storage()
Returns a pointer to storage object.
Definition: taskview.cpp:387
DesktopList
QVector< int > DesktopList
Definition: desktoplist.h:28
task.h
Task::setUid
void setUid(const QString &uid)
Set unique id for the task.
Definition: task.cpp:203
PlannerParser::startDocument
bool startDocument()
given by the framework from qxml.
Definition: plannerparser.cpp:59
Task::parent
Task * parent() const
return parent Task or null in case of TaskView.
Definition: task.h:71
timetrackerstorage::addTask
QString addTask(const Task *task, const Task *parent=0)
Add this task from iCalendar file.
Definition: timetrackerstorage.cpp:442
PlannerParser::startElement
bool startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &att)
given by the framework from qxml.
Definition: plannerparser.cpp:65
TaskView
Container and interface for the tasks.
Definition: taskview.h:50
Task
A class representing a task.
Definition: task.h:54
plannerparser.h
TaskView::currentItem
Task * currentItem() const
Return the current item in the view, cast to a Task pointer.
Definition: taskview.cpp:399
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal