diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-17 22:46:24 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-18 18:08:34 +0100 |
commit | beea88e5feb6f14b4912c6aa4878c39a7632977c (patch) | |
tree | 6559c7090a687a4b96319b9bc1539050f913f27a /src/ical.c | |
parent | 1a4bf2b0a2a54393c401522611f85c2637d1de88 (diff) | |
download | calcurse-beea88e5feb6f14b4912c6aa4878c39a7632977c.zip |
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src/ical.c')
-rw-r--r-- | src/ical.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -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; } |