From beea88e5feb6f14b4912c6aa4878c39a7632977c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 17 Jan 2016 22:46:24 +0100 Subject: Use a separate field for the completed status Add a new field that indicates whether a todo item is completed or not instead of encoding completed todo items by negative priorities. Signed-off-by: Lukas Fleischer --- src/ui-todo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ui-todo.c') diff --git a/src/ui-todo.c b/src/ui-todo.c index 86592c1..2a03844 100644 --- a/src/ui-todo.c +++ b/src/ui-todo.c @@ -60,7 +60,7 @@ void ui_todo_add(void) status_mesg(mesg_id, ""); ch = wgetch(win[KEY].p); } - todo_add(todo_input, ch - '0', NULL); + todo_add(todo_input, ch - '0', 0, NULL); ui_todo_load_items(); io_set_modified(); } @@ -163,14 +163,14 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) int j; if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW) { - while (i && todo->id < 0) { + while (i && todo->completed) { i = i->next; if (i) todo = LLIST_TS_GET_DATA(i); } } - mark[0] = todo->id > 0 ? '0' + todo->id : 'X'; + mark[0] = todo->completed ? 'X' : '0' + todo->id; mark[1] = todo->note ? '>' : '.'; hilt = hilt && (wins_slctd() == TOD); @@ -217,7 +217,8 @@ void ui_todo_load_items(void) /* TODO: Optimize this by keeping the list size in a variable. */ LLIST_FOREACH(&todolist, i) { struct todo *todo = LLIST_TS_GET_DATA(i); - if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW && todo->id < 0) + if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW && + todo->completed) continue; n++; } @@ -263,7 +264,7 @@ void ui_todo_chg_priority(int diff) else if (id > 9) id = 9; - item_new = todo_add(item->mesg, id, item->note); + item_new = todo_add(item->mesg, id, item->completed, item->note); todo_delete(item); io_set_modified(); listbox_set_sel(&lb_todo, todo_get_position(item_new)); -- cgit v1.2.3-54-g00ecf