summaryrefslogtreecommitdiff
path: root/src/taskmanager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/taskmanager.cc')
-rw-r--r--src/taskmanager.cc29
1 files changed, 16 insertions, 13 deletions
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 <stdio.h>
+#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, " <task id=\"%d\" parent_id=\"%d\">\n", t.id, t.parent_id);
- r |= fprintf(fp, " <title>%s</title>\n", xml_encode(t.title).c_str());
- r |= fprintf(fp, " <desc>%s</desc>\n", xml_encode(t.desc).c_str());
+ r |= fprintf(fp, " <title>%s</title>\n", xml_encode(t.attributes["title"]).c_str());
+ r |= fprintf(fp, " <desc>%s</desc>\n", xml_encode(t.attributes["description"]).c_str());
r |= fprintf(fp, " </task>)\n");
if(!r) {