aboutsummaryrefslogtreecommitdiffstats
path: root/src/ical.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-17 22:46:24 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:08:34 +0100
commitbeea88e5feb6f14b4912c6aa4878c39a7632977c (patch)
tree6559c7090a687a4b96319b9bc1539050f913f27a /src/ical.c
parent1a4bf2b0a2a54393c401522611f85c2637d1de88 (diff)
downloadcalcurse-beea88e5feb6f14b4912c6aa4878c39a7632977c.tar.gz
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.c18
1 files changed, 7 insertions, 11 deletions
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;
}