Enhancement - en passant "done"

- When marking task(s) as done, it is now possible to modify them
  at the same time.
This commit is contained in:
Paul Beckingham 2009-05-08 00:25:30 -04:00
parent b23bad9a5b
commit 5cf33105a3
3 changed files with 45 additions and 15 deletions

View file

@ -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 <T> all;
tdb.allPendingT (all);
std::vector <T> 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 ();
}