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/ical.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/ical.c') diff --git a/src/ical.c b/src/ical.c index 93952ec..dfb5dd7 100644 --- a/src/ical.c +++ b/src/ical.c @@ -266,14 +266,11 @@ static void ical_export_todo(FILE * stream, int export_uid) LLIST_FOREACH(&todolist, i) { struct todo *todo = LLIST_TS_GET_DATA(i); - int priority = todo->id; fputs("BEGIN:VTODO\n", stream); - if (todo->id < 0) { + if (todo->completed) fprintf(stream, "STATUS:COMPLETED\n"); - priority = -priority; - } - fprintf(stream, "PRIORITY:%d\n", priority); + fprintf(stream, "PRIORITY:%d\n", todo->id); fprintf(stream, "SUMMARY:%s\n", todo->mesg); if (export_uid) { @@ -327,9 +324,10 @@ static void ical_log(FILE * log, ical_types_e type, unsigned lineno, fprintf(log, "%s [%d]: %s\n", typestr[type], lineno, msg); } -static void ical_store_todo(int priority, char *mesg, char *note, int list) +static void ical_store_todo(int priority, int completed, char *mesg, + char *note, int list) { - struct todo *todo = todo_add(mesg, priority, note); + struct todo *todo = todo_add(mesg, priority, completed, note); if (list) { char *hash = todo_hash(todo); printf("%s\n", hash); @@ -1081,16 +1079,14 @@ ical_read_todo(FILE * fdi, FILE * log, int list, unsigned *notodos, if (starts_with_ci(buf, "END:VTODO")) { if (!vtodo.has_priority) vtodo.priority = LOWEST; - if (vtodo.completed) - vtodo.priority = -vtodo.priority; if (!vtodo.mesg) { ical_log(log, ICAL_VTODO, ITEMLINE, _("could not retrieve item summary.")); goto cleanup; } - ical_store_todo(vtodo.priority, vtodo.mesg, - vtodo.note, list); + ical_store_todo(vtodo.priority, vtodo.completed, + vtodo.mesg, vtodo.note, list); (*notodos)++; return; } -- cgit v1.2.3-54-g00ecf