- Promoted filtering code to the Command base class.
- Added filtering short-circuit.
This commit is contained in:
Paul Beckingham 2011-06-19 10:25:53 -04:00
parent db17536266
commit 7762ee2f9e
14 changed files with 79 additions and 173 deletions

View file

@ -28,7 +28,6 @@
#include <sstream>
#include <stdlib.h>
#include <Context.h>
#include <Expression.h>
#include <ViewText.h>
#include <Date.h>
#include <main.h>
@ -59,15 +58,9 @@ int CmdTimesheet::execute (std::string& output)
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
// Apply filter.
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);
filter (tasks, filtered);
// Just do this once.
int width = context.getWidth ();
@ -118,6 +111,7 @@ int CmdTimesheet::execute (std::string& output)
completed.add (Column::factory ("string.right", "Due"));
completed.add (Column::factory ("string", "Description"));
std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task)
{
// If task completed within range.