From b67b27f5cdd1bdaf673df0a532a2c1e1ac0a5a7e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 5 May 2009 02:14:43 -0400 Subject: [PATCH] Enhancement - delete sequences - Implemented sequences for delete command - Renamed T::inSequence to T::sequenceContains, which makes the code read more naturally. --- src/T.cpp | 2 +- src/T.h | 2 +- src/command.cpp | 16 +++++++--------- src/report.cpp | 3 +-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/T.cpp b/src/T.cpp index b589ba628..ac4943e86 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -290,7 +290,7 @@ void T::addAnnotation (const std::string& description) } //////////////////////////////////////////////////////////////////////////////// -bool T::inSequence (int id) const +bool T::sequenceContains (int id) const { foreach (seq, mSequence) if (*seq == id) diff --git a/src/T.h b/src/T.h index 23a219fb9..29537053f 100644 --- a/src/T.h +++ b/src/T.h @@ -84,7 +84,7 @@ public: void getAnnotations (std::map &) const; void setAnnotations (const std::map &); void addAnnotation (const std::string&); - bool inSequence (int) const; + bool sequenceContains (int) const; const std::string compose () const; const std::string composeCSV (); diff --git a/src/command.cpp b/src/command.cpp index 968763656..d04953734 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -439,13 +439,13 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf) { std::stringstream out; - if (!conf.get (std::string ("confirmation"), false) || confirm ("Permanently delete task?")) + std::vector all; + tdb.allPendingT (all); + foreach (t, all) { - std::vector all; - tdb.allPendingT (all); - foreach (t, all) + if (t->getId () == task.getId () || task.sequenceContains (t->getId ())) { - if (t->getId () == task.getId ()) + if (!conf.get (std::string ("confirmation"), false) || confirm ("Permanently delete task?")) { // Check for the more complex case of a recurring task. If this is a // recurring task, get confirmation to delete them all. @@ -494,13 +494,11 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf) << t->getDescription () << std::endl; } - - break; // No point continuing the loop. } + else + out << "Task not deleted." << std::endl; } } - else - out << "Task not deleted." << std::endl; return out.str (); } diff --git a/src/report.cpp b/src/report.cpp index e389190e7..540a603fb 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -271,8 +271,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf) { T refTask (tasks[i]); - if (refTask.getId () == task.getId () || - task.inSequence (refTask.getId ())) + if (refTask.getId () == task.getId () || task.sequenceContains (refTask.getId ())) { ++count;