FileChooser: collates: smooth percentage to 2 decimal points for sorting for all percent collates

re #11592
reviewable/pr11592/r4
hasezoey 2 months ago
parent 8470d1f4f8
commit 40ad03a214
No known key found for this signature in database
GPG Key ID: 9F8C99E834CC54FB

@ -158,7 +158,7 @@ local FileChooser = Menu:extend{
return function(a, b)
if a.opened == b.opened then
if a.opened then
return a.percent_finished < b.percent_finished
return a.sort_percent < b.sort_percent
end
return ffiUtil.strcoll(a.text, b.text)
end
@ -172,7 +172,11 @@ local FileChooser = Menu:extend{
local doc_settings = DocSettings:open(item.path)
percent_finished = doc_settings:readSetting("percent_finished")
end
item.percent_finished = percent_finished or 0
percent_finished = percent_finished or 0
-- smooth 2 decimal points (0.00) instead of 16 decimal points
item.sort_percent = util.round_decimal(percent_finished, 2)
item.percent_finished = percent_finished
end,
mandatory_func = function(item)
return item.opened and string.format("%d %%", 100 * item.percent_finished) or ""
@ -186,7 +190,7 @@ local FileChooser = Menu:extend{
return function(a, b)
if a.opened == b.opened then
if a.opened then
return a.percent_finished < b.percent_finished
return a.sort_percent < b.sort_percent
end
return ffiUtil.strcoll(a.text, b.text)
end
@ -200,7 +204,11 @@ local FileChooser = Menu:extend{
local doc_settings = DocSettings:open(item.path)
percent_finished = doc_settings:readSetting("percent_finished")
end
item.percent_finished = percent_finished or 0
percent_finished = percent_finished or 0
-- smooth 2 decimal points (0.00) instead of 16 decimal points
item.sort_percent = util.round_decimal(percent_finished, 2)
item.percent_finished = percent_finished
end,
mandatory_func = function(item)
return item.opened and string.format("%d %%", 100 * item.percent_finished) or ""
@ -245,7 +253,7 @@ local FileChooser = Menu:extend{
percent_finished = doc_settings:readSetting("percent_finished")
end
-- smooth 2 decimal points (0.00) instead of 16 decimal numbers
-- smooth 2 decimal points (0.00) instead of 16 decimal points
item.sort_percent = sort_percent or util.round_decimal(percent_finished or -1, 2)
item.percent_finished = percent_finished or 0
end,

Loading…
Cancel
Save