Enhancement - delete sequences

- Implemented sequences for delete command
- Renamed T::inSequence to T::sequenceContains, which makes the code
  read more naturally.
This commit is contained in:
Paul Beckingham
2009-05-05 02:14:43 -04:00
parent fb674a5626
commit b67b27f5cd
4 changed files with 10 additions and 13 deletions

View File

@@ -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) foreach (seq, mSequence)
if (*seq == id) if (*seq == id)

View File

@@ -84,7 +84,7 @@ public:
void getAnnotations (std::map <time_t, std::string>&) const; void getAnnotations (std::map <time_t, std::string>&) const;
void setAnnotations (const std::map <time_t, std::string>&); void setAnnotations (const std::map <time_t, std::string>&);
void addAnnotation (const std::string&); void addAnnotation (const std::string&);
bool inSequence (int) const; bool sequenceContains (int) const;
const std::string compose () const; const std::string compose () const;
const std::string composeCSV (); const std::string composeCSV ();

View File

@@ -439,13 +439,13 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
if (!conf.get (std::string ("confirmation"), false) || confirm ("Permanently delete task?")) std::vector <T> all;
tdb.allPendingT (all);
foreach (t, all)
{ {
std::vector <T> all; if (t->getId () == task.getId () || task.sequenceContains (t->getId ()))
tdb.allPendingT (all);
foreach (t, all)
{ {
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 // Check for the more complex case of a recurring task. If this is a
// recurring task, get confirmation to delete them all. // recurring task, get confirmation to delete them all.
@@ -494,13 +494,11 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
<< t->getDescription () << t->getDescription ()
<< std::endl; << 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 (); return out.str ();
} }

View File

@@ -271,8 +271,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
{ {
T refTask (tasks[i]); T refTask (tasks[i]);
if (refTask.getId () == task.getId () || if (refTask.getId () == task.getId () || task.sequenceContains (refTask.getId ()))
task.inSequence (refTask.getId ()))
{ {
++count; ++count;