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

ktimetracker

plannerparser.cpp

Go to the documentation of this file.
00001 /*
00002  *     Copyright (C) 2004 by Thorsten Staerk <dev@staerk.de>
00003  *                   2007 the ktimetracker developers
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License along
00016  *   with this program; if not, write to the
00017  *      Free Software Foundation, Inc.
00018  *      51 Franklin Street, Fifth Floor
00019  *      Boston, MA  02110-1301  USA.
00020  *
00021  */
00022 
00023 /*
00024 
00025 this class is here to import tasks from a planner project file to karm.
00026 the import shall not be limited to karm (kPlaTo sends greetings)
00027 it imports planner's top-level-tasks on the same level-depth as currentItem.
00028 if there is no currentItem, planner's top-level-tasks will become top-level-tasks in karm.
00029 it imports as well the level-depth of each task, as its name, as its percent-complete.
00030 test cases:
00031  - deleting all tasks away, then import!
00032  - having started with an empty ics, import!
00033  - with currentItem being a top-level-task, import!
00034  - with currentItem being a subtask, import!
00035 */
00036 
00037 #include "plannerparser.h"
00038 
00039 #include "task.h"
00040 #include "taskview.h"
00041 
00042   PlannerParser::PlannerParser(TaskView * tv)
00043   // if there is a task one level above currentItem, make it the father of all imported tasks. Set level accordingly.
00044   // import as well if there a no task in the taskview as if there are.
00045   // if there are, put the top-level tasks of planner on the same level as currentItem.
00046   // So you have the chance as well to have the planner tasks at top-level as at a whatever-so-deep sublevel.
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; // becomes true as soon as parsing occurres <tasks>
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     // only <task>s within <tasks> are processed
00071     if (qName == QString::fromLatin1("tasks")) withInTasks=true;
00072     if ((qName == QString::fromLatin1("task")) && (withInTasks))
00073     {
00074     
00075       // find out name and percent-complete
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       // at the moment, task is still the old task or the old father task (if an endElement occurred) or not existing (if the
00083       // new task is a top-level-task). Make task the parenttask, if existing.
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     // only <task>s within <tasks> increased level, so only decrease for <task>s within <tasks>
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 

ktimetracker

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal