mirror of
				https://github.com/kepler155c/opus
				synced 2025-10-30 23:23:03 +00:00 
			
		
		
		
	on the fly grid table filtering in ui
This commit is contained in:
		| @@ -1463,7 +1463,14 @@ function UI.Grid:update() | |||||||
| 		end | 		end | ||||||
| 	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 | 	if order then | ||||||
| 		table.sort(self.sorted, function(a,b) | 		table.sort(self.sorted, function(a,b) | ||||||
| 			return order(self.values[a], self.values[b]) | 			return order(self.values[a], self.values[b]) | ||||||
| @@ -1545,6 +1552,12 @@ function UI.Grid:drawRows() | |||||||
| 	end | 	end | ||||||
| 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) | function UI.Grid:getRowTextColor(row, selected) | ||||||
| 	if selected then | 	if selected then | ||||||
| 		if self.focused then | 		if self.focused then | ||||||
| @@ -2359,9 +2372,7 @@ function UI.Wizard:eventHandler(event) | |||||||
| 	elseif event.type == 'previousView' then | 	elseif event.type == 'previousView' then | ||||||
| 		local currentView = Util.find(self.pages, 'enabled', true) | 		local currentView = Util.find(self.pages, 'enabled', true) | ||||||
| 		local nextView = Util.find(self.pages, 'index', currentView.index - 1) | 		local nextView = Util.find(self.pages, 'index', currentView.index - 1) | ||||||
| 		if self:isViewValid() then |  | ||||||
| 		currentView:emit({ type = 'enable_view', prev = nextView, current = currentView }) | 		currentView:emit({ type = 'enable_view', prev = nextView, current = currentView }) | ||||||
| 		end |  | ||||||
| 		return true | 		return true | ||||||
|  |  | ||||||
| 	elseif event.type == 'wizard_complete' then | 	elseif event.type == 'wizard_complete' then | ||||||
|   | |||||||
| @@ -356,6 +356,7 @@ function Util.readFile(fname) | |||||||
| end | end | ||||||
|  |  | ||||||
| function Util.writeFile(fname, data) | 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") | 	local file = io.open(fname, "w") | ||||||
| 	if not file then | 	if not file then | ||||||
| 		error('Unable to open ' .. fname, 2) | 		error('Unable to open ' .. fname, 2) | ||||||
| @@ -489,7 +490,7 @@ function Util.insertString(str, istr, pos) | |||||||
| end | end | ||||||
|  |  | ||||||
| function Util.split(str, pattern) | 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" | 	pattern = pattern or "(.-)\n" | ||||||
| 	local t = {} | 	local t = {} | ||||||
| 	local function helper(line) table.insert(t, line) return "" end | 	local function helper(line) table.insert(t, line) return "" end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 kepler155c@gmail.com
					kepler155c@gmail.com