mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 14:36:44 +02:00
Filter
- Added domSource, and a context Task so that Eval can access attributes. Doesn't work.
This commit is contained in:
parent
e924468de6
commit
899e65714a
1 changed files with 25 additions and 2 deletions
|
@ -35,6 +35,23 @@
|
|||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Const iterator that can be derefenced into a Task by domSource.
|
||||
static std::vector <Task>::const_iterator contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static bool domSource (const std::string& identifier, Variant& value)
|
||||
{
|
||||
std::string stringValue = context.dom.get (identifier, *contextTask);
|
||||
if (stringValue != identifier)
|
||||
{
|
||||
value = Variant (stringValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Filter::Filter ()
|
||||
: _startCount (0)
|
||||
|
@ -72,7 +89,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
|
|||
|
||||
Eval eval;
|
||||
eval.addSource (namedDates);
|
||||
// TODO Need DOM source.
|
||||
eval.addSource (domSource);
|
||||
eval.compileExpression (filterExpr);
|
||||
|
||||
std::vector <Task>::const_iterator task;
|
||||
|
@ -82,6 +99,8 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
|
|||
if (oldFilter)
|
||||
output.push_back (*task);
|
||||
|
||||
contextTask = task;
|
||||
|
||||
Variant var;
|
||||
eval.evaluateCompiledExpression (var);
|
||||
|
||||
|
@ -122,7 +141,7 @@ void Filter::subset (std::vector <Task>& output)
|
|||
|
||||
Eval eval;
|
||||
eval.addSource (namedDates);
|
||||
// TODO Need DOM source.
|
||||
eval.addSource (domSource);
|
||||
eval.compileExpression (filterExpr);
|
||||
|
||||
output.clear ();
|
||||
|
@ -134,6 +153,8 @@ void Filter::subset (std::vector <Task>& output)
|
|||
if (oldFilter)
|
||||
output.push_back (*task);
|
||||
|
||||
contextTask = task;
|
||||
|
||||
Variant var;
|
||||
eval.evaluateCompiledExpression (var);
|
||||
|
||||
|
@ -153,6 +174,8 @@ void Filter::subset (std::vector <Task>& output)
|
|||
if (oldFilter)
|
||||
output.push_back (*task);
|
||||
|
||||
contextTask = task;
|
||||
|
||||
Variant var;
|
||||
eval.evaluateCompiledExpression (var);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue