Enhancements - filters

- The project attribute is now automatically filtered with
    project.startswith:<value>
  to provide leftmost matching (ie subprojects).
- Unmodifiable attributes (uuid, start ...) are now prevented from
  being updated if the command is designated as a "write" command.
This commit is contained in:
Paul Beckingham 2009-06-16 10:42:53 -04:00
parent 5691ed0588
commit 97d732e5f7
2 changed files with 42 additions and 30 deletions

View file

@ -494,7 +494,7 @@ void Context::constructFilter ()
{
foreach (att, task)
{
// TODO this doesn't work.
// Words are found in the description using the .has modifier.
if (att->first == "description")
{
std::vector <std::string> words;
@ -502,19 +502,27 @@ void Context::constructFilter ()
foreach (word, words)
{
filter.push_back (Att ("description", "has", *word));
std::cout << "Context::constructFilter " << att->first << "=" << *word << std::endl;
std::cout << "# auto filter: " << att->first << ".has:" << *word << "" << std::endl;
}
}
// Projects are matched left-most.
else if (att->first == "project")
{
filter.push_back (Att ("project", "startswith", att->second.value ()));
std::cout << "# auto filter: " << att->first << ".startswith:" << att->second.value () << "" << std::endl;
}
// TODO Don't create a uuid for every task?
// Every task has a unique uuid by default, and it shouldn't be included.
// The mechanism for filtering on tags is +/-<tag>, not tags:foo which
// means that there can only be one tag, "foo".
else if (att->first != "uuid" &&
att->first != "tags")
att->first != "tags" &&
att->first != "project")
{
filter.push_back (att->second);
std::cout << "Context::constructFilter " << att->first << "=" << att->second.value () << std::endl;
std::cout << "# auto filter: " << att->first << ":" << att->second.value () << "" << std::endl;
}
}
@ -524,14 +532,14 @@ void Context::constructFilter ()
foreach (tag, tagAdditions)
{
filter.push_back (Att ("tags", "has", *tag));
std::cout << "Context::constructFilter tags=+" << *tag << std::endl;
std::cout << "# auto filter: +" << *tag << "" << std::endl;
}
// TODO Include tagRemovals.
// Include tagRemovals.
foreach (tag, tagRemovals)
{
filter.push_back (Att ("tags", "hasnt", *tag));
std::cout << "Context::constructFilter tags=-" << *tag << std::endl;
std::cout << "# auto filter: -" << *tag << "" << std::endl;
}
}