Add a "hide completed" view to the todo panel

Add a second view to the todo panel that hides all completed items.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer
2016-01-17 20:04:25 +01:00
parent 2857bac971
commit 1a4bf2b0a2
5 changed files with 84 additions and 15 deletions

View File

@@ -43,10 +43,23 @@
llist_t todolist;
/* Returns a structure containing the selected item. */
struct todo *todo_get_item(int item_number)
static int todo_is_uncompleted(struct todo *todo, void *cbdata)
{
return LLIST_GET_DATA(LLIST_NTH(&todolist, item_number));
return todo->id >= 0;
}
/* Returns a structure containing the selected item. */
struct todo *todo_get_item(int item_number, int skip_completed)
{
llist_item_t *i;
if (skip_completed)
i = LLIST_FIND_NTH(&todolist, item_number, NULL,
todo_is_uncompleted);
else
i = LLIST_NTH(&todolist, item_number);
return LLIST_GET_DATA(i);
}
static int todo_cmp_id(struct todo *a, struct todo *b)