From 051720a279b39ccbe880212c3a1f691d7ee5c38a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 16 Jun 2009 22:55:05 -0400 Subject: [PATCH] Enhancement - annotate - Implemented annotation command. --- src/Context.cpp | 2 -- src/command.cpp | 30 +++++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 925c6416e..6898c7aec 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -192,9 +192,7 @@ std::string Context::dispatch () else if (cmd.command == "" && task.getId ()) { out = handleModify (); } */ else if (cmd.command == "append") { out = handleAppend (); } -/* else if (cmd.command == "annotate") { out = handleAnnotate (); } -*/ else if (cmd.command == "done") { out = handleDone (); } else if (cmd.command == "undo") { out = handleUndo (); } else if (cmd.command == "delete") { out = handleDelete (); } diff --git a/src/command.cpp b/src/command.cpp index ab4053fad..2f1a47672 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1041,31 +1041,35 @@ std::string handleColor () //////////////////////////////////////////////////////////////////////////////// std::string handleAnnotate () { -/* - if (task.getDescription () == "") + if (!context.task.has ("description")) throw std::string ("Cannot apply a blank annotation."); -*/ std::stringstream out; -/* - std::vector all; - tdb.pendingT (all); - filterSequence (all, task); - foreach (t, all) + std::vector tasks; + context.tdb.lock (context.config.get ("locking", true)); + context.tdb.loadPending (tasks, context.filter); + + // Filter sequence. + context.filter.applySequence (tasks, context.sequence); + + foreach (task, tasks) { - t->addAnnotation (task.getDescription ()); - tdb.modifyT (*t); + task->addAnnotation (context.task.get ("description")); + context.tdb.update (*task); if (context.config.get ("echo.command", true)) out << "Annotated " - << t->getId () + << task->id << " with '" - << t->getDescription () + << task->get ("description") << "'" << std::endl; } -*/ + + context.tdb.commit (); + context.tdb.unlock (); + return out.str (); }