summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/taskmanager.cc2
-rw-r--r--src/tasktree.cc17
-rw-r--r--src/tasktree.h2
3 files changed, 21 insertions, 0 deletions
diff --git a/src/taskmanager.cc b/src/taskmanager.cc
index 590c5b8..838fd23 100644
--- a/src/taskmanager.cc
+++ b/src/taskmanager.cc
@@ -54,6 +54,8 @@ TaskManager::TaskManager() {
t.title = "Projects";
tree.insertAsChild(ROOT_ID, PROJECTS_ID, t);
+
+ tree.toStdOut();
}
TaskManager::~TaskManager() {
diff --git a/src/tasktree.cc b/src/tasktree.cc
index e44efee..6e36974 100644
--- a/src/tasktree.cc
+++ b/src/tasktree.cc
@@ -182,6 +182,23 @@ void TaskTree::insertChild(node_t* parent, node_t* child) {
child->parent = parent;
}
+static void printNode(node_t* node, std::string prefix) {
+ if(!node) return;
+ task_t t = node->data;
+ printf("%s/%u - %s\n", prefix.c_str(), t.id, t.title.c_str());
+ char buf[4096];
+ sprintf(buf, "%s/%u - %s", prefix.c_str(), t.id, t.title.c_str());
+
+ NodeList::iterator it;
+ for(it = node->children.begin(); it != node->children.end(); it++) {
+ node_t* child = *it;
+ printNode(child, buf);
+ }
+}
+
+void TaskTree::toStdOut() {
+ printNode(root, "/");
+}
#ifdef TEST_TASKTREE
diff --git a/src/tasktree.h b/src/tasktree.h
index 9a3a45f..6623b0f 100644
--- a/src/tasktree.h
+++ b/src/tasktree.h
@@ -58,6 +58,8 @@ public:
TaskIdList ancestorList(taskid_t id) throw (std::exception);
+ void toStdOut();
+
private:
node_t* createNode(taskid_t id);
void insertChild(node_t* parent, node_t* child);