diff options
-rw-r--r-- | src/taskmanager.cc | 2 | ||||
-rw-r--r-- | src/tasktree.cc | 7 | ||||
-rw-r--r-- | src/tasktree.h | 4 | ||||
-rw-r--r-- | src/xmlparser.cc | 8 |
4 files changed, 16 insertions, 5 deletions
diff --git a/src/taskmanager.cc b/src/taskmanager.cc index 1ca0b63..0d15eb6 100644 --- a/src/taskmanager.cc +++ b/src/taskmanager.cc @@ -95,7 +95,7 @@ task_t TaskManager::task(taskid_t t) { } taskid_t TaskManager::createId() { - return idCount++; + return tree.createId(); } TaskIdListPair TaskManager::moveTask(taskid_t id, taskid_t to) diff --git a/src/tasktree.cc b/src/tasktree.cc index ee181eb..e2e2bf6 100644 --- a/src/tasktree.cc +++ b/src/tasktree.cc @@ -70,12 +70,17 @@ static void concatTaskIdLists(TaskIdList& pre, TaskIdList& post) { TaskTree::TaskTree() { root = NULL; + nextid = 10; } TaskTree::~TaskTree() { // cleanup tree } +taskid_t TaskTree::createId() { + return nextid++; +} + static taskid_t rootid = -1; TaskIdList TaskTree::insertAsChild(taskid_t parentid, taskid_t id, task_t data) @@ -329,7 +334,7 @@ std::string TaskTree::toXML() std::string xml; xml += "<?xml version='1.0' encoding='UTF-8'?>\n"; - xml += "<tasktree>\n"; + xml += "<tasktree nextid=\""+id2str(nextid)+"\">\n"; xml += root->toXML(" "); xml += "</tasktree>"; diff --git a/src/tasktree.h b/src/tasktree.h index d5e215f..15d9c44 100644 --- a/src/tasktree.h +++ b/src/tasktree.h @@ -56,6 +56,8 @@ public: TaskTree(); ~TaskTree(); + taskid_t createId(); + TaskIdList insertAsChild(taskid_t parentid, taskid_t id, task_t data) throw (std::exception); TaskIdList remove(taskid_t id) throw (std::exception); // TaskIdList move(taskid_t id, taskid_t newParentId) throw (std::exception); @@ -72,6 +74,8 @@ public: void fromXML(std::string xml); private: + taskid_t nextid; + node_t* createNode(taskid_t id); void insertChild(node_t* parent, node_t* child); diff --git a/src/xmlparser.cc b/src/xmlparser.cc index 112ea00..a362f95 100644 --- a/src/xmlparser.cc +++ b/src/xmlparser.cc @@ -31,8 +31,6 @@ #include "xml_encode_decode.h" -#define NOID 0xffffffff - XmlParser::XmlParser(TaskTree *t) : tree(t) { } @@ -48,6 +46,10 @@ void XmlParser::characterData(const std::string &data) void XmlParser::startTag(std::string name, attributes_t &attr) { + if(name == "tasktree") { + tree->nextid = atoi(xml_decode(attr["nextid"]).c_str()); + } + if(name == "task") { taskid_t id = atoi(xml_decode(attr["id"]).c_str()); @@ -74,7 +76,7 @@ void XmlParser::endTag(std::string name) parents.pop(); } - if (name == "title") { + if(name == "title") { node->data.title = cdata; } } |