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)
if (*seq == id)

View file

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

View file

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

View file

@ -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;