improved sorting and resume bugfix
This commit is contained in:
+34
-44
@@ -581,8 +581,8 @@ local methods = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local descending = false
|
local descending = false
|
||||||
if rt.sortInfo.columnIndex == this.columnIndex then
|
if getn(rt.sorts) > 0 and rt.sorts[1].index == this.columnIndex then
|
||||||
descending = not rt.sortInfo.descending
|
descending = not rt.sorts[1].descending
|
||||||
end
|
end
|
||||||
rt:SetSort((descending and -1 or 1) * this.columnIndex)
|
rt:SetSort((descending and -1 or 1) * this.columnIndex)
|
||||||
end,
|
end,
|
||||||
@@ -685,7 +685,7 @@ local methods = {
|
|||||||
UpdateRowInfo = function(self)
|
UpdateRowInfo = function(self)
|
||||||
Aux.util.wipe(self.rowInfo)
|
Aux.util.wipe(self.rowInfo)
|
||||||
self.rowInfo.numDisplayRows = 0
|
self.rowInfo.numDisplayRows = 0
|
||||||
self.sortInfo.isSorted = nil
|
self.isSorted = nil
|
||||||
self:SetSelectedRecord(nil, true)
|
self:SetSelectedRecord(nil, true)
|
||||||
|
|
||||||
sort(self.records, function(a, b) return Aux.sort.multi_lt(a.search_signature, b.search_signature, tostring(a), tostring(b)) end)
|
sort(self.records, function(a, b) return Aux.sort.multi_lt(a.search_signature, b.search_signature, tostring(a), tostring(b)) end)
|
||||||
@@ -738,10 +738,14 @@ local methods = {
|
|||||||
tex:SetTexCoord(0.017, 1, 0.083, 0.909)
|
tex:SetTexCoord(0.017, 1, 0.083, 0.909)
|
||||||
tex:SetAlpha(0.5)
|
tex:SetAlpha(0.5)
|
||||||
end
|
end
|
||||||
if self.sortInfo.descending then
|
|
||||||
self.headCells[self.sortInfo.columnIndex]:GetNormalTexture():SetTexture(0.8, 0.6, 1, 0.8)
|
if getn(self.sorts) > 0 then
|
||||||
else
|
local last_sort = self.sorts[1]
|
||||||
self.headCells[self.sortInfo.columnIndex]:GetNormalTexture():SetTexture(0.6, 0.8, 1, 0.8)
|
if last_sort.descending then
|
||||||
|
self.headCells[last_sort.index]:GetNormalTexture():SetTexture(0.8, 0.6, 1, 0.8)
|
||||||
|
else
|
||||||
|
self.headCells[last_sort.index]:GetNormalTexture():SetTexture(0.6, 0.8, 1, 0.8)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
FauxScrollFrame_Update(self.scrollFrame, self.rowInfo.numDisplayRows, getn(self.rows), self.ROW_HEIGHT)
|
FauxScrollFrame_Update(self.scrollFrame, self.rowInfo.numDisplayRows, getn(self.rows), self.ROW_HEIGHT)
|
||||||
@@ -752,7 +756,7 @@ local methods = {
|
|||||||
FauxScrollFrame_SetOffset(self.scrollFrame, maxOffset)
|
FauxScrollFrame_SetOffset(self.scrollFrame, maxOffset)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.sortInfo.isSorted then
|
if not self.isSorted then
|
||||||
local function sort_helper(a, b)
|
local function sort_helper(a, b)
|
||||||
|
|
||||||
local record_a, record_b
|
local record_a, record_b
|
||||||
@@ -764,42 +768,24 @@ local methods = {
|
|||||||
record_b = b.record
|
record_b = b.record
|
||||||
end
|
end
|
||||||
|
|
||||||
local ordering = self.config[self.sortInfo.columnIndex].cmp and self.config[self.sortInfo.columnIndex].cmp(record_a, record_b, self.sortInfo.descending) or Aux.sort.EQ
|
for _, sort in self.sorts do
|
||||||
|
local ordering = self.config[sort.index].cmp and self.config[sort.index].cmp(record_a, record_b, sort.descending) or Aux.sort.EQ
|
||||||
|
|
||||||
if ordering == Aux.sort.EQ then
|
if ordering == Aux.sort.LT then
|
||||||
-- if sortKey == 'percent' then
|
return true
|
||||||
-- -- sort by buyout
|
elseif ordering == Aux.sort.GT then
|
||||||
-- sortKey = aux_price_per_unit and 'unit_buyout_price' or 'buyout_price'
|
return false
|
||||||
-- local result = SortHelperFunc(a, b, sortKey)
|
end
|
||||||
-- if result ~= nil then
|
|
||||||
-- return result
|
|
||||||
-- end
|
|
||||||
-- elseif sortKey == 'buyout_price' or sortKey == 'unit_buyout_price' then
|
|
||||||
-- -- sort by bid
|
|
||||||
-- sortKey = aux_price_per_unit and 'unit_bid_price' or 'bid_price'
|
|
||||||
-- local result = SortHelperFunc(a, b, sortKey)
|
|
||||||
-- if result ~= nil then
|
|
||||||
-- return result
|
|
||||||
-- end
|
|
||||||
-- elseif hadSortKey then
|
|
||||||
-- -- this was called recursively, so just return nil
|
|
||||||
-- return
|
|
||||||
-- else
|
|
||||||
-- -- sort by percent
|
|
||||||
-- return SortHelperFunc(a, b, 'percent')
|
|
||||||
-- end
|
|
||||||
-- as a last resort compare search signatures to ensure a total order
|
|
||||||
return tostring(record_a) < tostring(record_b)
|
|
||||||
else
|
|
||||||
return ordering == Aux.sort.LT
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return tostring(a) < tostring(b)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, info in ipairs(self.rowInfo) do
|
for i, info in ipairs(self.rowInfo) do
|
||||||
sort(info.children, sort_helper)
|
sort(info.children, sort_helper)
|
||||||
end
|
end
|
||||||
sort(self.rowInfo, sort_helper)
|
sort(self.rowInfo, sort_helper)
|
||||||
self.sortInfo.isSorted = true
|
self.isSorted = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update all the rows
|
-- update all the rows
|
||||||
@@ -943,14 +929,18 @@ local methods = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
SetSort = function(self, sortIndex)
|
SetSort = function(self, ...)
|
||||||
if sortIndex then
|
for k=1,arg.n do
|
||||||
if sortIndex == self.sortInfo.index then return end
|
for i, sort in self.sorts do
|
||||||
self.sortInfo.descending = sortIndex < 0
|
if sort.index == abs(arg[k]) then
|
||||||
self.sortInfo.columnIndex = abs(sortIndex)
|
tremove(self.sorts, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tinsert(self.sorts, 1, { index = abs(arg[k]), descending = arg[k] < 0 })
|
||||||
end
|
end
|
||||||
self.sortInfo.isSorted = nil
|
|
||||||
self.sortInfo.index = sortIndex
|
self.isSorted = nil
|
||||||
self:UpdateRows()
|
self:UpdateRows()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -1013,7 +1003,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
|||||||
rt.scrollDisabled = nil
|
rt.scrollDisabled = nil
|
||||||
rt.expanded = {}
|
rt.expanded = {}
|
||||||
rt.handlers = {}
|
rt.handlers = {}
|
||||||
rt.sortInfo = {}
|
rt.sorts = {}
|
||||||
rt.records = {}
|
rt.records = {}
|
||||||
rt.rowInfo = { numDisplayRows=0 }
|
rt.rowInfo = { numDisplayRows=0 }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ local auction_records
|
|||||||
function public.on_load()
|
function public.on_load()
|
||||||
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
|
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
|
||||||
private.listing:Show()
|
private.listing:Show()
|
||||||
private.listing:SetSort(8)
|
private.listing:SetSort(1,2,3,4,5,6,7,8)
|
||||||
private.listing:Clear()
|
private.listing:Clear()
|
||||||
private.listing:SetHandler('OnCellClick', function(cell, button)
|
private.listing:SetHandler('OnCellClick', function(cell, button)
|
||||||
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record and private.cancel_button:IsEnabled() then
|
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record and private.cancel_button:IsEnabled() then
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ local auction_records
|
|||||||
function public.on_load()
|
function public.on_load()
|
||||||
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
|
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
|
||||||
private.listing:Show()
|
private.listing:Show()
|
||||||
private.listing:SetSort(8)
|
private.listing:SetSort(1,2,3,4,5,6,7,8)
|
||||||
private.listing:Clear()
|
private.listing:Clear()
|
||||||
private.listing:SetHandler('OnCellClick', function(cell, button)
|
private.listing:SetHandler('OnCellClick', function(cell, button)
|
||||||
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
|
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
|
||||||
|
|||||||
+4
-2
@@ -711,7 +711,7 @@ function public.on_load()
|
|||||||
|
|
||||||
private.results_listing = Aux.auction_listing.CreateAuctionResultsTable(AuxSearchFrameResults, Aux.auction_listing.search_config)
|
private.results_listing = Aux.auction_listing.CreateAuctionResultsTable(AuxSearchFrameResults, Aux.auction_listing.search_config)
|
||||||
private.results_listing:Show()
|
private.results_listing:Show()
|
||||||
private.results_listing:SetSort(9)
|
private.results_listing:SetSort(1,2,3,4,5,6,7,8,9)
|
||||||
private.results_listing:Clear()
|
private.results_listing:Clear()
|
||||||
private.results_listing:SetHandler('OnCellClick', function(cell, button)
|
private.results_listing:SetHandler('OnCellClick', function(cell, button)
|
||||||
if IsAltKeyDown() and private.results_listing:GetSelection().record == cell.row.data.record then
|
if IsAltKeyDown() and private.results_listing:GetSelection().record == cell.row.data.record then
|
||||||
@@ -913,7 +913,9 @@ function public.start_search(filter_string, resume)
|
|||||||
for i=1,(current_query or 1)-1 do
|
for i=1,(current_query or 1)-1 do
|
||||||
tremove(queries, 1)
|
tremove(queries, 1)
|
||||||
end
|
end
|
||||||
queries[1].start_page = (current_page and current_page + 1 or queries[1].start_page)
|
if queries[1].blizzard_query then
|
||||||
|
queries[1].blizzard_query.start_page = (current_page and current_page + 1 or queries[1].start_page)
|
||||||
|
end
|
||||||
aborted_search = queries
|
aborted_search = queries
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user