summaryrefslogtreecommitdiff
path: root/src/task_proto.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2012-03-10 14:56:34 +0100
committerJonas Suhr Christensen <jsc@umbraculum.org>2012-03-10 14:56:34 +0100
commit39396a2660150770c3fd14aac8b4be0dcbae8497 (patch)
treeec1604a37725de1dfafade10bb4cb24d89e6322c /src/task_proto.cc
parent0f00f525e5c4da9f5a96cd35c3cdad50f84b51d9 (diff)
Added new task hierarchy based protocol.
Drag and drop works somehow - maybe some weirdness in html5 drag and drop.
Diffstat (limited to 'src/task_proto.cc')
-rw-r--r--src/task_proto.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/task_proto.cc b/src/task_proto.cc
index 4bcc3a8..717ca3e 100644
--- a/src/task_proto.cc
+++ b/src/task_proto.cc
@@ -184,9 +184,11 @@ int callback_lws_task(struct libwebsocket_context * context,
case cmd::add: {
printf("Handling add cmd\n");
+// task_t t = create_task(m.add.title, m.add.desc,
+// m.add.x, m.add.y);
task_t t = create_task(m.add.title, m.add.desc,
- m.add.x, m.add.y);
- tasklist.push_back(t);
+ m.add.parent_id);
+ tasklist.push_back(t);
// buf_len = sprintf(buf, "add %d %s %s %d %d;",
// t.id, t.title.c_str(), t.desc.c_str(),
// t.x, t.y);
@@ -202,6 +204,7 @@ int callback_lws_task(struct libwebsocket_context * context,
printf("Delete\n");
printf("Deleting task with id %d\n", m.del.id);
+ // todo: delete all children recursively
task_t del_task;
bool id_found = false;
TaskList::iterator it;
@@ -228,21 +231,22 @@ int callback_lws_task(struct libwebsocket_context * context,
case cmd::move: {
printf("Move\n");
- printf("Moving task with id %d to (%d,%d)\n", m.move.id, m.move.x, m.move.y);
+ printf("Moving task with id %d to %d\n", m.move.id, m.move.parent_id);
bool id_found = false;
TaskList::iterator it;
- int x = m.move.x / 300 * 300;
+// int x = m.move.x / 300 * 300;
task_t moved_task;
for(it = tasklist.begin(); it != tasklist.end(); it++) {
task_t &t = *it;
if(t.id == m.move.id) {
id_found = true;
- t.x = x;
- t.y = m.move.y;
- moved_task = t;
+// t.x = x;
+// t.y = m.move.y;
+ t.parent_id = m.move.parent_id;
+ moved_task = t;
break;
}
}