From 5cf33105a3fd6f04f5131ac54d58ef667c187814 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 8 May 2009 00:25:30 -0400 Subject: [PATCH] Enhancement - en passant "done" - When marking task(s) as done, it is now possible to modify them at the same time. --- src/TDB.cpp | 1 + src/command.cpp | 55 +++++++++++++++++++++++++++++++++++-------------- src/task.cpp | 4 ++++ 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/TDB.cpp b/src/TDB.cpp index bf565fa33..3c203f999 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -280,6 +280,7 @@ bool TDB::completeT (const T& t) for (it = all.begin (); it != all.end (); ++it) if (task.getId () == it->getId ()) { + *it = t; it->setStatus (T::completed); char endTime[16]; diff --git a/src/command.cpp b/src/command.cpp index de48bb40e..04abee49d 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -570,32 +570,57 @@ std::string handleStop (TDB& tdb, T& task, Config& conf) //////////////////////////////////////////////////////////////////////////////// std::string handleDone (TDB& tdb, T& task, Config& conf) { + int count = 0; std::stringstream out; - std::vector all; tdb.allPendingT (all); + std::vector filtered = all; filterSequence (filtered, task); - - foreach (t, filtered) + foreach (seq, filtered) { - t->setStatus (T::completed); - if (!tdb.completeT (*t)) - throw std::string ("Could not mark task as completed."); + if (seq->getStatus () == T::pending) + { + // Apply deltas. + deltaDescription (*seq, task); + deltaTags (*seq, task); + deltaAttributes (*seq, task); + deltaSubstitutions (*seq, task); - // Now update mask in parent. - if (conf.get ("echo.command", true)) - out << "Completed " - << t->getId () + seq->setStatus (T::completed); + if (!tdb.completeT (*seq)) + throw std::string ("Could not mark task as completed."); + + if (conf.get ("echo.command", true)) + out << "Completed " + << seq->getId () + << " '" + << seq->getDescription () + << "'" + << std::endl; + + updateRecurrenceMask (tdb, all, *seq); + nag (tdb, *seq, conf); + + ++count; + } + else + out << "Task " + << seq->getId () << " '" - << t->getDescription () - << "'" + << seq->getDescription () + << "' is not pending" << std::endl; - - updateRecurrenceMask (tdb, all, *t); - nag (tdb, task, conf); } + if (conf.get ("echo.command", true)) + out << "Marked " + << count + << " task" + << (count == 1 ? "" : "s") + << " as done" + << std::endl; + return out.str (); } diff --git a/src/task.cpp b/src/task.cpp index 49026df94..cd7a18066 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -220,6 +220,10 @@ static std::string shortUsage (Config& conf) << "full tutorial. New releases containing fixes and enhancements are " << "made frequently." << std::endl + << std::endl + << "Join in the discussion of task, present and future, at " + << "http://groups.google.com/group/taskprogram" + << std::endl << std::endl; return out.str ();