@ -4,6 +4,7 @@ local datetime = require("datetime")
local Device = require ( " device " )
local Device = require ( " device " )
local DocSettings = require ( " docsettings " )
local DocSettings = require ( " docsettings " )
local DocumentRegistry = require ( " document/documentregistry " )
local DocumentRegistry = require ( " document/documentregistry " )
local filemanagerutil = require ( " apps/filemanager/filemanagerutil " )
local Menu = require ( " ui/widget/menu " )
local Menu = require ( " ui/widget/menu " )
local OpenWithDialog = require ( " ui/widget/openwithdialog " )
local OpenWithDialog = require ( " ui/widget/openwithdialog " )
local UIManager = require ( " ui/uimanager " )
local UIManager = require ( " ui/uimanager " )
@ -24,6 +25,7 @@ local FileChooser = Menu:extend{
show_hidden = false , -- set to true to show folders/files starting with "."
show_hidden = false , -- set to true to show folders/files starting with "."
file_filter = nil , -- function defined in the caller, returns true for files to be shown
file_filter = nil , -- function defined in the caller, returns true for files to be shown
show_unsupported = false , -- set to true to ignore file_filter
show_unsupported = false , -- set to true to ignore file_filter
show_finished = true , -- show all books
-- NOTE: Input is *always* a relative entry name
-- NOTE: Input is *always* a relative entry name
exclude_dirs = { -- const
exclude_dirs = { -- const
-- KOReader / Kindle
-- KOReader / Kindle
@ -88,11 +90,13 @@ function FileChooser:show_dir(dirname)
return true
return true
end
end
function FileChooser : show_file ( filename )
function FileChooser : show_file ( filename , fullpath )
for _ , pattern in ipairs ( self.exclude_files ) do
for _ , pattern in ipairs ( self.exclude_files ) do
if filename : match ( pattern ) then return false end
if filename : match ( pattern ) then return false end
end
end
return self.show_unsupported or self.file_filter == nil or self.file_filter ( filename )
if not self.show_unsupported and self.file_filter ~= nil and not self.file_filter ( filename ) then return false end
if not self.show_finished and fullpath ~= nil and filemanagerutil.getStatus ( fullpath ) == " complete " then return false end
return true
end
end
function FileChooser : init ( )
function FileChooser : init ( )
@ -123,7 +127,7 @@ function FileChooser:getList(path, collate)
end
end
-- Always ignore macOS resource forks.
-- Always ignore macOS resource forks.
elseif attributes.mode == " file " and not util.stringStartsWith ( f , " ._ " ) then
elseif attributes.mode == " file " and not util.stringStartsWith ( f , " ._ " ) then
if self : show_file ( f ) then
if self : show_file ( f , filename ) then
if collate then -- when collate == nil count only to display in folder mandatory
if collate then -- when collate == nil count only to display in folder mandatory
item = self : getListItem ( f , filename , attributes , collate )
item = self : getListItem ( f , filename , attributes , collate )
end
end
@ -450,6 +454,11 @@ function FileChooser:changePageToPath(path)
end
end
end
end
function FileChooser : toggleFinishedBooks ( )
self.show_finished = not self.show_finished
self : refreshPath ( )
end
function FileChooser : toggleHiddenFiles ( )
function FileChooser : toggleHiddenFiles ( )
self.show_hidden = not self.show_hidden
self.show_hidden = not self.show_hidden
self : refreshPath ( )
self : refreshPath ( )