Merge pull request #1230 from chrox/fix_1170

fix #1169 and #1170
This commit is contained in:
HW
2014-11-23 13:13:07 +01:00
2 changed files with 14 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ local FileChooser = Menu:extend{
strcoll = strcoll,
collate = "strcoll", -- or collate = "access",
reverse_collate = false,
path_pages = {}, -- store last browsed location(page) for each path
}
function FileChooser:init()
@@ -148,8 +149,14 @@ function FileChooser:genItemTableFromPath(path)
return item_table
end
function FileChooser:updateItems(select_number)
Menu.updateItems(self, select_number) -- call parent's updateItems()
self.path_pages[self.path] = self.page
end
function FileChooser:refreshPath()
self:swithItemTable(nil, self:genItemTableFromPath(self.path))
self.page = self.path_pages[self.path] or 1
self:swithItemTable(nil, self:genItemTableFromPath(self.path), -1)
end
function FileChooser:changeToPath(path)

View File

@@ -675,6 +675,12 @@ function Menu:swithItemTable(new_title, new_item_table, itemnumber)
self.page = math.ceil(itemnumber / self.perpage)
end
-- make sure current page is in right page range
local max_pages = math.ceil(#new_item_table / self.perpage)
if self.page > max_pages then
self.page = max_pages
end
self.item_table = new_item_table
self:updateItems(1)
end