diff --git a/ChangeLog b/ChangeLog index 1a32805b1..cfe687e81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,7 +14,10 @@ part of the description, despite what they otherwise might mean. + Removed support for the obsolete task file format 1 (never released). + Fixed bug that allowed blank annotations to be added (thanks to Bruce - Dillahunty), + Dillahunty). + + Supports negative tag filters, so that (task list +foo -bar) now filters + tasks that have the "foo" tag, but do not have the "bar" tag (thanks to + Chris Pride). ------ old releases ------------------------------ diff --git a/html/filter.html b/html/filter.html index d3f111573..7bb5a11a3 100644 --- a/html/filter.html +++ b/html/filter.html @@ -76,6 +76,13 @@

Lists only tasks with the "shopping" tag.

+ +
% task list +shopping -gift
+ +

+ Lists tasks that have the "shopping" tag, but do not have the + "gift" tag. +


diff --git a/html/task.html b/html/task.html index a8aa521f1..922edc11c 100644 --- a/html/task.html +++ b/html/task.html @@ -144,7 +144,10 @@ part of the description, despite what they otherwise might mean.
  • Removed support for the obsolete task file format 1 (never released).
  • Fixed bug that allowed blank annotations to be added (thanks to Bruce - Dillahunty), + Dillahunty). +
  • Supports negative tag filters, so that (task list +foo -bar) now filters + tasks that have the "foo" tag, but do not have the "bar" tag (thanks to + Chris Pride).

    diff --git a/src/report.cpp b/src/report.cpp index f9105f394..0a77cc7d1 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -108,6 +108,9 @@ void filter (std::vector& all, T& task) std::vector tagList; task.getTags (tagList); + std::vector removeTagList; + task.getRemoveTags (removeTagList); + // Get all the attributes to match against. std::map attrList; task.getAttributes (attrList); @@ -180,7 +183,15 @@ void filter (std::vector& 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); + } } } } diff --git a/src/tests/filter.t b/src/tests/filter.t index 5fd4e918b..64ec1314c 100755 --- a/src/tests/filter.t +++ b/src/tests/filter.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 108; +use Test::More tests => 129; # Create the rc file. if (open my $fh, '>', 'filter.rc') @@ -110,6 +110,33 @@ like ($output, qr/five/, 'g5'); unlike ($output, qr/six/, 'g6'); unlike ($output, qr/seven/, 'g7'); +$output = qx{../task rc:filter.rc list -tag}; +unlike ($output, qr/one/, 'g1'); +like ($output, qr/two/, 'g2'); +like ($output, qr/three/, 'g3'); +like ($output, qr/four/, 'g4'); +unlike ($output, qr/five/, 'g5'); +like ($output, qr/six/, 'g6'); +like ($output, qr/seven/, 'g7'); + +$output = qx{../task rc:filter.rc list -missing}; +like ($output, qr/one/, 'g1'); +like ($output, qr/two/, 'g2'); +like ($output, qr/three/, 'g3'); +like ($output, qr/four/, 'g4'); +like ($output, qr/five/, 'g5'); +like ($output, qr/six/, 'g6'); +like ($output, qr/seven/, 'g7'); + +$output = qx{../task rc:filter.rc list +tag -tag}; +unlike ($output, qr/one/, 'g1'); +unlike ($output, qr/two/, 'g2'); +unlike ($output, qr/three/, 'g3'); +unlike ($output, qr/four/, 'g4'); +unlike ($output, qr/five/, 'g5'); +unlike ($output, qr/six/, 'g6'); +unlike ($output, qr/seven/, 'g7'); + $output = qx{../task rc:filter.rc list project:A priority:H}; like ($output, qr/one/, 'h1'); like ($output, qr/two/, 'h2');