mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 02:17:21 +02:00
Filter
- Improved ::pendingOnly algorithm.
This commit is contained in:
parent
ff9b8217e2
commit
fd518e3fce
1 changed files with 29 additions and 22 deletions
|
@ -207,12 +207,12 @@ bool Filter::pendingOnly ()
|
||||||
// - no 'or'
|
// - no 'or'
|
||||||
int countStatus = 0;
|
int countStatus = 0;
|
||||||
int countPending = 0;
|
int countPending = 0;
|
||||||
|
int countWaiting = 0;
|
||||||
|
int countRecurring = 0;
|
||||||
int countId = 0;
|
int countId = 0;
|
||||||
int countOr = 0;
|
int countOr = 0;
|
||||||
int countXor = 0;
|
int countXor = 0;
|
||||||
|
int countNot = 0;
|
||||||
// TODO Use an int index, and ensure that 'status', '==' and 'pending/waiting'
|
|
||||||
// are consecutive.
|
|
||||||
|
|
||||||
std::vector <A>::iterator a;
|
std::vector <A>::iterator a;
|
||||||
for (a = context.cli._args.begin (); a != context.cli._args.end (); ++a)
|
for (a = context.cli._args.begin (); a != context.cli._args.end (); ++a)
|
||||||
|
@ -222,24 +222,31 @@ bool Filter::pendingOnly ()
|
||||||
if (a->hasTag ("ID")) ++countId;
|
if (a->hasTag ("ID")) ++countId;
|
||||||
if (a->hasTag ("OP") && a->attribute ("raw") == "or") ++countOr;
|
if (a->hasTag ("OP") && a->attribute ("raw") == "or") ++countOr;
|
||||||
if (a->hasTag ("OP") && a->attribute ("raw") == "xor") ++countXor;
|
if (a->hasTag ("OP") && a->attribute ("raw") == "xor") ++countXor;
|
||||||
|
if (a->hasTag ("OP") && a->attribute ("raw") == "not") ++countNot;
|
||||||
if (a->hasTag ("ATTRIBUTE") && a->attribute ("name") == "status") ++countStatus;
|
if (a->hasTag ("ATTRIBUTE") && a->attribute ("name") == "status") ++countStatus;
|
||||||
if ( a->attribute ("raw") == "pending") ++countPending;
|
if ( a->attribute ("raw") == "pending") ++countPending;
|
||||||
|
if ( a->attribute ("raw") == "waiting") ++countWaiting;
|
||||||
|
if ( a->attribute ("raw") == "recurring") ++countRecurring;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use of 'or' or 'xor' means the potential for alternation.
|
if (countOr || countXor || countNot)
|
||||||
if (countOr || countXor)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the filter does not contain id or status terms, read both files.
|
if (countStatus)
|
||||||
if (countId == 0 && countStatus == 0)
|
{
|
||||||
return false;
|
if (!countPending && !countWaiting && !countRecurring)
|
||||||
|
|
||||||
// Only one 'status == pending' is allowed.
|
|
||||||
if (countStatus != 1 || countPending != 1)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countId)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue