FileChooser: re-add file sort by "last date read" (#10682)

Revert bits from eb299c30.
This commit is contained in:
Glen Sawyer
2023-07-12 14:33:14 -06:00
committed by GitHub
parent d0e705a582
commit 73c4f09a88
2 changed files with 8 additions and 1 deletions

View File

@@ -844,6 +844,7 @@ function FileManagerMenu:getSortingMenuTable()
local collates = {
{ _("name"), "strcoll" },
{ _("name (natural sorting)"), "natural" },
{ _("last read date"), "access" },
{ _("date modified"), "date" },
{ _("size"), "size" },
{ _("type"), "type" },

View File

@@ -193,6 +193,10 @@ function FileChooser:getSortingFunction(collate, reverse_collate)
sorting = function(a, b)
return natsort(a.text, b.text)
end
elseif collate == "access" then
sorting = function(a, b)
return a.attr.access > b.attr.access
end
elseif collate == "date" then
sorting = function(a, b)
return a.attr.modification > b.attr.modification
@@ -340,7 +344,9 @@ function FileChooser:getMenuItemMandatory(item, collate)
local text
if collate then -- file
-- display the sorting parameter in mandatory
if collate == "date" then
if collate == "access" then
text = datetime.secondsToDateTime(item.attr.access)
elseif collate == "date" then
text = datetime.secondsToDateTime(item.attr.modification)
elseif collate == "percent_unopened_first" or collate == "percent_unopened_last" then
text = item.opened and string.format("%d %%", 100 * item.percent_finished) or ""