added support for multiple tooltip filters

This commit is contained in:
Manuel Simon Hirsig
2016-02-02 23:03:02 +01:00
parent 710b36f3f0
commit 9cf2cb0324
+7 -5
View File
@@ -291,23 +291,25 @@ function m.validator(filter)
then then
return return
end end
local TRUE, FALSE = 1, 0
if filter.tooltip then if filter.tooltip then
local stack = {} local stack = {}
for i=getn(filter.tooltip),1,-1 do for i=getn(filter.tooltip),1,-1 do
local op = strupper(filter.tooltip[i]) local op = strupper(filter.tooltip[i])
if op == 'AND' then if op == 'AND' then
tinsert(stack, tremove(stack) and tremove(stack)) tinsert(stack, tremove(stack) * tremove(stack))
elseif op == 'OR' then elseif op == 'OR' then
tinsert(stack, tremove(stack) or tremove(stack)) tinsert(stack, max(1, tremove(stack) + tremove(stack)))
elseif op == 'NOT' then elseif op == 'NOT' then
tinsert(stack, not tremove(stack)) tinsert(stack, mod(tremove(stack), 2))
elseif op ~= 'TT' then elseif op ~= 'TT' then
tinsert(stack, Aux.util.any(record.tooltip, function(entry) tinsert(stack, Aux.util.any(record.tooltip, function(entry)
return strfind(strupper(entry[1].text or ''), strupper(op), 1, true) or strfind(strupper(entry[2].text or ''), strupper(op), 1, true) return strfind(strupper(entry[1].text or ''), strupper(op), 1, true) or strfind(strupper(entry[2].text or ''), strupper(op), 1, true)
end)) end) and TRUE or FALSE)
end end
end end
return tremove(stack) return Aux.util.all(stack, function(x) return x == TRUE end)
end end
return true return true
end end