From d935b195a2246fa24d35df7c6fc354ae628a6777 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 10 Jan 2013 15:51:33 +0100 Subject: Added attributes to nodes as well as messages for manipulating and transporting them. Switched debug interface to hugin. --- src/taskmanager.cc | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/taskmanager.cc') diff --git a/src/taskmanager.cc b/src/taskmanager.cc index 41c1c8d..7857d12 100644 --- a/src/taskmanager.cc +++ b/src/taskmanager.cc @@ -29,6 +29,8 @@ #include +#include "hugin.hpp" + // Global TaskManager object. TaskManager task_manager; @@ -46,7 +48,6 @@ static bool isProtected(taskid_t id) TaskManager::TaskManager() { idCount = FIRST_TASK_ID; - } TaskManager::~TaskManager() { @@ -54,7 +55,7 @@ TaskManager::~TaskManager() { void TaskManager::init(std::string filename) { - printf("Reading tasks from file: %s\n", filename.c_str()); + DEBUG(taskmgr, "Reading tasks from file: %s\n", filename.c_str()); file = filename; FILE *fp = fopen(file.c_str(), "r"); @@ -71,23 +72,24 @@ void TaskManager::init(std::string filename) // Create new basis config task_t t; - t.title = "root"; + + t.attributes["title"] = "root"; t.id = ROOT_ID; tree.insertAsChild(0, ROOT_ID, t); - t.title = "Finished"; + t.attributes["title"] = "Finished"; t.id = FINISHED_ID; tree.insertAsChild(ROOT_ID, FINISHED_ID, t); - t.title = "Backlog"; + t.attributes["title"] = "Backlog"; t.id = BACKLOG_ID; tree.insertAsChild(ROOT_ID, BACKLOG_ID, t); - t.title = "Lost+Found"; + t.attributes["title"] = "Lost+Found"; t.id = LOSTFOUND_ID; tree.insertAsChild(ROOT_ID, LOSTFOUND_ID, t); - t.title = "Projects"; + t.attributes["title"] = "Projects"; t.id = PROJECTS_ID; tree.insertAsChild(ROOT_ID, PROJECTS_ID, t); } @@ -144,7 +146,8 @@ TaskIdList TaskManager::removeTask(taskid_t id) return affectedTasks; } -TaskIdList TaskManager::updateTask(taskid_t id, task_t t) +TaskIdList TaskManager::updateTask(taskid_t id, const std::string &name, + const std::string &value) throw (std::exception) { if(isProtected(id)) return TaskIdList(); @@ -152,7 +155,7 @@ TaskIdList TaskManager::updateTask(taskid_t id, task_t t) TaskIdList affectedTasks; try { - affectedTasks = tree.updateData(id, t); + affectedTasks = tree.updateData(id, name, value); } catch (std::exception& e) { throw e; @@ -169,7 +172,7 @@ TaskIdList TaskManager::createTask(taskid_t parentid, taskid_t *pid) task_t t; taskid_t id = *pid;//createId(); - t.title = ""; + t.attributes["title"] = ""; t.id = id; if(pid) *pid = id; @@ -235,7 +238,7 @@ task_t create_task(std::string title, std::string desc) { task_t t; t.parent_id = current_id_count(); - t.title = title; + t.attributes["title"] = title; t.desc = desc; t.id = id_count; id_count++; @@ -271,8 +274,8 @@ bool save_tasklist_to_file(TaskList list, std::string file) { // printf("Flushing task %d\n", t.id); r |= fprintf(fp, " \n", t.id, t.parent_id); - r |= fprintf(fp, " %s\n", xml_encode(t.title).c_str()); - r |= fprintf(fp, " %s\n", xml_encode(t.desc).c_str()); + r |= fprintf(fp, " %s\n", xml_encode(t.attributes["title"]).c_str()); + r |= fprintf(fp, " %s\n", xml_encode(t.attributes["description"]).c_str()); r |= fprintf(fp, " )\n"); if(!r) { -- cgit v1.2.3