Patch - Support tag exclusion filtering

- Now supports "-tag" in filters to filter out tasks that do not
  have the specified tag (thanks to Chris Pride).
- Added unit tests to prevent regression.
- Updated the filter docs to include examples.
This commit is contained in:
Paul Beckingham 2009-05-28 11:30:30 -04:00
parent 0fcaf85652
commit 7aace1b3db
5 changed files with 55 additions and 4 deletions

View file

@ -108,6 +108,9 @@ void filter (std::vector<T>& all, T& task)
std::vector <std::string> tagList;
task.getTags (tagList);
std::vector <std::string> removeTagList;
task.getRemoveTags (removeTagList);
// Get all the attributes to match against.
std::map <std::string, std::string> attrList;
task.getAttributes (attrList);
@ -180,7 +183,15 @@ void filter (std::vector<T>& all, T& task)
++matches;
if (matches == tagList.size ())
filtered.push_back (refTask);
{
matches = 0;
for (unsigned int t = 0; t < removeTagList.size (); ++t)
if (refTask.hasTag (removeTagList[t]))
++matches;
if (matches == 0)
filtered.push_back (refTask);
}
}
}
}