summaryrefslogtreecommitdiffstats
path: root/karm/plannerparser.h
blob: 6a7ff028143f9d45f064c3194b79ca2532896316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// C++ Interface: plannerparser
//
// Description:
//
//
// Author: Thorsten Staerk <Thorsten@Staerk.de>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef PLANNERPARSER_H
#define PLANNERPARSER_H

/**
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
*/

#include <tqxml.h>
#include <klocale.h>
#include "taskview.h"
#include "task.h"
#include "karmstorage.h"
#include "kapplication.h"

class PlannerParser : public QXmlDefaultHandler
{
public:

  /**  Stores the active TaskView in this parser. Returns error code (not always, hopefully)  */
  PlannerParser(TaskView * tv);

  /** given by the framework from qxml. Called when parsing the xml-document starts.          */
  bool startDocument();

  /** given by the framework from qxml. Called when the reader occurs an open tag (e.g. \<b\> ) */
  bool startElement( const TQString&, const TQString&, const TQString& qName, const TQXmlAttributes& att );

  /** given by the framework from qxml. Called when the reader occurs a closed tag (e.g. \</b\> )*/
  bool endElement( const TQString&, const TQString&, const TQString& qName);

private:
  bool withInTasks;     // within <tasks> ?
  TaskView *_taskView;
  Task *task;
  Task *parentTask;
  int level;            // level=1: task is top-level-task
};


#endif