mirror of
https://github.com/kepler155c/opus
synced 2025-01-11 16:20:26 +00:00
on the fly grid table filtering in ui
This commit is contained in:
parent
b564b1e9be
commit
9484153f38
@ -1463,7 +1463,14 @@ function UI.Grid:update()
|
||||
end
|
||||
end
|
||||
|
||||
self.sorted = Util.keys(self.values)
|
||||
self.sorted = { }
|
||||
for k,v in pairs(self.values) do
|
||||
if self:isRowValid(k, v) then
|
||||
table.insert(self.sorted, k)
|
||||
end
|
||||
end
|
||||
|
||||
--self.sorted = Util.keys(self.values)
|
||||
if order then
|
||||
table.sort(self.sorted, function(a,b)
|
||||
return order(self.values[a], self.values[b])
|
||||
@ -1545,6 +1552,12 @@ function UI.Grid:drawRows()
|
||||
end
|
||||
end
|
||||
|
||||
-- Non-intuitive: update must be called if the table was specified
|
||||
-- in the shortcut definition (as this callback was not yet overridden)
|
||||
function UI.Grid:isRowValid(--[[ key, value ]])
|
||||
return true
|
||||
end
|
||||
|
||||
function UI.Grid:getRowTextColor(row, selected)
|
||||
if selected then
|
||||
if self.focused then
|
||||
@ -2359,9 +2372,7 @@ function UI.Wizard:eventHandler(event)
|
||||
elseif event.type == 'previousView' then
|
||||
local currentView = Util.find(self.pages, 'enabled', true)
|
||||
local nextView = Util.find(self.pages, 'index', currentView.index - 1)
|
||||
if self:isViewValid() then
|
||||
currentView:emit({ type = 'enable_view', prev = nextView, current = currentView })
|
||||
end
|
||||
currentView:emit({ type = 'enable_view', prev = nextView, current = currentView })
|
||||
return true
|
||||
|
||||
elseif event.type == 'wizard_complete' then
|
||||
|
@ -356,6 +356,7 @@ function Util.readFile(fname)
|
||||
end
|
||||
|
||||
function Util.writeFile(fname, data)
|
||||
if not fname or not data then error('Util.writeFile: invalid parameters', 2) end
|
||||
local file = io.open(fname, "w")
|
||||
if not file then
|
||||
error('Unable to open ' .. fname, 2)
|
||||
@ -489,7 +490,7 @@ function Util.insertString(str, istr, pos)
|
||||
end
|
||||
|
||||
function Util.split(str, pattern)
|
||||
if not str then error('Util:split: invalid parameters', 2) end
|
||||
if not str then error('Util.split: Invalid parameters', 2) end
|
||||
pattern = pattern or "(.-)\n"
|
||||
local t = {}
|
||||
local function helper(line) table.insert(t, line) return "" end
|
||||
|
Loading…
Reference in New Issue
Block a user