- Added filtering to the calendar command.
This commit is contained in:
Paul Beckingham 2011-06-13 23:03:50 -04:00
parent ded55c360b
commit 087cf7e5ed
3 changed files with 19 additions and 10 deletions

View file

@ -39,6 +39,7 @@
# Tracked Features, sorted by ID. # Tracked Features, sorted by ID.
+ Added feature #330, which supports the 'inverse' color attribute. + Added feature #330, which supports the 'inverse' color attribute.
+ Added feature #479, which enables filtering for the 'calendar' command.
+ Added feature #523 & #659, adding 'status' as a reportable field (thanks to + Added feature #523 & #659, adding 'status' as a reportable field (thanks to
Peter De Poorter and Bryce Harrington). Peter De Poorter and Bryce Harrington).
+ Added feature #545, #610, #611, #646, which support complex aliases. + Added feature #545, #610, #611, #646, which support complex aliases.

1
NEWS
View file

@ -20,6 +20,7 @@ New Features in taskwarrior 2.0.0
- JSON is the new default export format. - JSON is the new default export format.
- New 'reports' command that lists reports and their descriptions. - New 'reports' command that lists reports and their descriptions.
- New complex aliases. - New complex aliases.
- Filtering now available on most read-only commands.
Please refer to the ChangeLog file for full details. There are too many to Please refer to the ChangeLog file for full details. There are too many to
list here. list here.

View file

@ -29,6 +29,7 @@
#include <iomanip> #include <iomanip>
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <Expression.h>
#include <ViewText.h> #include <ViewText.h>
#include <text.h> #include <text.h>
#include <util.h> #include <util.h>
@ -52,7 +53,6 @@ int CmdCalendar::execute (std::string& output)
{ {
int rc = 0; int rc = 0;
/*
// Each month requires 28 text columns width. See how many will actually // Each month requires 28 text columns width. See how many will actually
// fit. But if a preference is specified, and it fits, use it. // fit. But if a preference is specified, and it fits, use it.
int width = context.getWidth (); int width = context.getWidth ();
@ -72,6 +72,16 @@ int CmdCalendar::execute (std::string& output)
context.tdb.commit (); context.tdb.commit ();
context.tdb.unlock (); context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
Date today; Date today;
bool getpendingdate = false; bool getpendingdate = false;
int monthsToDisplay = 1; int monthsToDisplay = 1;
@ -115,6 +125,7 @@ int CmdCalendar::execute (std::string& output)
int argMonth = 0; int argMonth = 0;
int argYear = 0; int argYear = 0;
bool argWholeYear = false; bool argWholeYear = false;
/*
std::vector <std::string> args = context.args.list (); std::vector <std::string> args = context.args.list ();
std::vector <std::string>::iterator arg; std::vector <std::string>::iterator arg;
for (arg = args.begin (); arg != args.end (); ++arg) for (arg = args.begin (); arg != args.end (); ++arg)
@ -154,6 +165,7 @@ int CmdCalendar::execute (std::string& output)
else else
throw std::string ("Could not recognize argument '") + *arg + "'."; throw std::string ("Could not recognize argument '") + *arg + "'.";
} }
*/
// Supported combinations: // Supported combinations:
// //
@ -180,11 +192,11 @@ int CmdCalendar::execute (std::string& output)
// Now begin the data subset and rendering. // Now begin the data subset and rendering.
int countDueDates = 0; int countDueDates = 0;
if (getpendingdate == true) { if (getpendingdate == true)
{
// Find the oldest pending due date. // Find the oldest pending due date.
Date oldest (12,31,2037); Date oldest (12,31,2037);
std::vector <Task>::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task)
for (task = tasks.begin (); task != tasks.end (); ++task)
{ {
if (task->getStatus () == Task::pending) if (task->getStatus () == Task::pending)
{ {
@ -277,7 +289,7 @@ int CmdCalendar::execute (std::string& output)
out << "\n" out << "\n"
<< optionalBlankLine () << optionalBlankLine ()
<< renderMonths (mFrom, yFrom, today, tasks, monthsPerLine) << renderMonths (mFrom, yFrom, today, filtered, monthsPerLine)
<< "\n"; << "\n";
mFrom += monthsPerLine; mFrom += monthsPerLine;
@ -350,10 +362,6 @@ int CmdCalendar::execute (std::string& output)
// Display all due task in the report colorized not only the imminet ones // Display all due task in the report colorized not only the imminet ones
context.config.set ("due", 0); context.config.set ("due", 0);
context.args.clear ();
context.filter.clear ();
context.sequence.clear ();
std::string output; std::string output;
context.commands[report]->execute (output); context.commands[report]->execute (output);
out << output; out << output;
@ -402,7 +410,6 @@ int CmdCalendar::execute (std::string& output)
} }
output = out.str (); output = out.str ();
*/
return rc; return rc;
} }