search interface upgrade, search history

This commit is contained in:
Manuel Simon Hirsig
2016-07-12 02:32:01 +02:00
parent 885cdce515
commit adaf8bef1e
7 changed files with 95 additions and 124 deletions
+2 -3
View File
@@ -655,7 +655,7 @@ local methods = {
ChatFrameEditBox:Insert(this.row.data.record.hyperlink) ChatFrameEditBox:Insert(this.row.data.record.hyperlink)
elseif Aux.unmodified() and button == 'RightButton' then -- TODO not when alt (how?) elseif Aux.unmodified() and button == 'RightButton' then -- TODO not when alt (how?)
Aux.tab_group:set_tab(1) Aux.tab_group:set_tab(1)
Aux.search_frame.start_search(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact') Aux.search_frame.execute('search', strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
else else
local selection = this.rt:GetSelection() local selection = this.rt:GetSelection()
if not selection or selection.record ~= this.row.data.record then if not selection or selection.record ~= this.row.data.record then
@@ -854,9 +854,8 @@ local methods = {
-- General Results Table Methods -- General Results Table Methods
-- ============================================================================ -- ============================================================================
Clear = function(rt) Reset = function(rt)
Aux.util.wipe(rt.expanded) Aux.util.wipe(rt.expanded)
Aux.util.wipe(rt.records)
rt:UpdateRowInfo() rt:UpdateRowInfo()
rt:UpdateRows() rt:UpdateRows()
rt:SetSelectedRecord() rt:SetSelectedRecord()
+1 -2
View File
@@ -1,8 +1,7 @@
function Aux.auctions_frame.create_frames(private, public) function Aux.auctions_frame.create_frames(private, public)
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:SetSort(1,2,3,4,5,6,7,8) private.listing:SetSort(1,2,3,4,5,6,7,8)
private.listing:Clear() private.listing:Reset()
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
private.cancel_button:Click() private.cancel_button:Click()
+1 -2
View File
@@ -1,8 +1,7 @@
function Aux.bids_frame.create_frames(private, public) function Aux.bids_frame.create_frames(private, public)
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:SetSort(1,2,3,4,5,6,7,8) private.listing:SetSort(1,2,3,4,5,6,7,8)
private.listing:Clear() private.listing:Reset()
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
if button == 'LeftButton' and private.buyout_button:IsEnabled() then if button == 'LeftButton' and private.buyout_button:IsEnabled() then
+2 -2
View File
@@ -344,7 +344,7 @@ function Aux.SetItemRef(...)
local item_info = Aux.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3])) local item_info = Aux.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3]))
if item_info then if item_info then
Aux.search_frame.set_filter(item_info.name..'/exact') Aux.search_frame.set_filter(item_info.name..'/exact')
Aux.search_frame.start_search() Aux.search_frame.execute('search')
return return
end end
end end
@@ -361,7 +361,7 @@ function Aux.UseContainerItem(...)
local item_info = Aux.info.container_item(bag, slot) local item_info = Aux.info.container_item(bag, slot)
item_info = item_info and Aux.info.item(item_info.item_id) item_info = item_info and Aux.info.item(item_info.item_id)
if item_info then if item_info then
Aux.search_frame.start_search(strlower(item_info.name)..'/exact') Aux.search_frame.execute('search', strlower(item_info.name)..'/exact')
end end
return return
end end
+1 -1
View File
@@ -41,7 +41,7 @@ function Aux.post_frame.create_frames(private, public)
private.set_item(this.item_record) private.set_item(this.item_record)
elseif arg1 == 'RightButton' then elseif arg1 == 'RightButton' then
Aux.tab_group:set_tab(1) Aux.tab_group:set_tab(1)
Aux.search_frame.start_search(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact') Aux.search_frame.execute('search', strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
end end
end, end,
function() function()
+51 -55
View File
@@ -207,30 +207,17 @@ function public.on_load()
private.update_tab(private.SAVED) private.update_tab(private.SAVED)
end end
function private.stop_search() function public.execute(mode, filter_string)
Aux.scan.abort(search_scan_id)
end
function private.discard_search_continuation()
private:current_search().continuation = nil
private.resume_button:Hide()
private.search_button:Show()
end
function public.start_search(filter_string, resume)
if resume and not private:current_search().continuation then
return
end
local queries = private:current_search().continuation
Aux.scan.abort(search_scan_id)
private.discard_search_continuation()
if filter_string then if filter_string then
private.search_box:SetText(filter_string) private.search_box:SetText(filter_string)
end end
if not resume then local queries
if mode == 'search' or mode == 'refresh' then
if mode == 'refresh' then
private.search_box:SetText(private.current_search().filter_string)
end
local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText()) local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText())
if not filters then if not filters then
return return
@@ -243,37 +230,40 @@ function public.start_search(filter_string, resume)
} }
end) end)
tinsert(aux_recent_searches, 1, { if mode == 'search' then
filter_string = private.search_box:GetText(), tinsert(aux_recent_searches, 1, {
prettified = Aux.util.join(Aux.util.map(filters, function(filter) return filter.prettified end), ';'), filter_string = private.search_box:GetText(),
}) prettified = Aux.util.join(Aux.util.map(filters, function(filter) return filter.prettified end), ';'),
while getn(aux_recent_searches) > 50 do })
tremove(aux_recent_searches) while getn(aux_recent_searches) > 50 do
tremove(aux_recent_searches)
end
private.update_search_listings()
private.new_search()
end end
private.update_search_listings() elseif mode == 'resume' then
queries = private.current_search().continuation
Aux.scan.abort(search_scan_id)
private.current_search().continuation = nil
private.resume_button:Disable()
private.results_listing:SetSelectedRecord()
end end
private.update_tab(private.RESULTS) private.update_tab(private.RESULTS)
private.stop_button:Show()
private.resume_button:Hide()
private.search_button:Hide()
if resume then
private.results_listing:SetSelectedRecord(nil)
else
private.new_search()
end
local search = private.current_search()
local current_query, current_page local current_query, current_page
search_scan_id = Aux.scan.start{ search_scan_id = Aux.scan.start{
type = 'list', type = 'list',
queries = queries, queries = queries,
on_scan_start = function() on_scan_start = function()
private.status_bar:update_status(0,0) private.status_bar:update_status(0,0)
if resume then if mode == 'search' then
private.status_bar:set_text('Resuming scan...')
else
private.status_bar:set_text('Scanning auctions...') private.status_bar:set_text('Scanning auctions...')
elseif mode == 'refresh' then
private.status_bar:set_text('Rescanning auctions...')
elseif mode == 'resume' then
private.status_bar:set_text('Resuming scan...')
end end
end, end,
on_page_loaded = function(page, total_pages) on_page_loaded = function(page, total_pages)
@@ -288,9 +278,9 @@ function public.start_search(filter_string, resume)
current_query = query_index current_query = query_index
end, end,
on_auction = function(auction_record) on_auction = function(auction_record)
if getn(private:current_search().records) < 1000 then if getn(search.records) < 1000 then
tinsert(private:current_search().records, auction_record) tinsert(search.records, auction_record)
if getn(private:current_search().records) == 1000 then if getn(search.records) == 1000 then
StaticPopup_Show('AUX_SEARCH_TABLE_FULL') StaticPopup_Show('AUX_SEARCH_TABLE_FULL')
end end
end end
@@ -299,10 +289,7 @@ function public.start_search(filter_string, resume)
private.status_bar:update_status(100, 100) private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning') private.status_bar:set_text('Done Scanning')
private.stop_button:Hide() if private.current_search() == search and AuxSearchFrameResults:IsVisible() and getn(search.records) == 0 then
private.search_button:Show()
if getn(private:current_search().records) == 0 and AuxSearchFrameResults:IsVisible() then
private.update_tab(private.SAVED) private.update_tab(private.SAVED)
end end
end, end,
@@ -310,19 +297,16 @@ function public.start_search(filter_string, resume)
private.status_bar:update_status(100, 100) private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning') private.status_bar:set_text('Done Scanning')
private.stop_button:Hide()
if not resume then
private.search_button:Hide()
end
private.resume_button:Show()
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
if queries[1].blizzard_query then if queries[1].blizzard_query then
queries[1].blizzard_query.first_page = (current_page and (queries[1].blizzard_query.first_page or 0) + current_page or queries[1].blizzard_query.first_page) queries[1].blizzard_query.first_page = (current_page and (queries[1].blizzard_query.first_page or 0) + current_page or queries[1].blizzard_query.first_page)
end end
private:current_search().continuation = queries search.continuation = queries
if private.current_search() == search then
private.resume_button:Enable()
end
end, end,
} }
end end
@@ -432,7 +416,9 @@ do
end end
function private.update_search() function private.update_search()
Aux.scan.abort(search_scan_id)
private.search_box:SetText(searches[search_index].filter_string) private.search_box:SetText(searches[search_index].filter_string)
private.results_listing:Reset()
private.results_listing:SetDatabase(searches[search_index].records) private.results_listing:SetDatabase(searches[search_index].records)
if search_index == 1 or search_index == 0 then if search_index == 1 or search_index == 0 then
private.previous_button:Disable() private.previous_button:Disable()
@@ -440,9 +426,19 @@ do
private.previous_button:Enable() private.previous_button:Enable()
end end
if search_index == getn(searches) or search_index == 0 then if search_index == getn(searches) or search_index == 0 then
private.next_button:Disable() private.next_button:Hide()
private.search_box:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
else else
private.next_button:Enable() private.next_button:Show()
private.search_box:SetPoint('LEFT', private.next_button, 'RIGHT', 4, 0)
end
if search_index > 0 then
private.refresh_button:Enable()
end
if searches[search_index].continuation then
private.resume_button:Enable()
else
private.resume_button:Disable()
end end
end end
+37 -59
View File
@@ -1,50 +1,7 @@
function Aux.search_frame.create_frames(private, public) function Aux.search_frame.create_frames(private, public)
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPRIGHT', -75, -8)
btn:SetWidth(60)
btn:SetHeight(25)
btn:SetText('Search')
btn:SetScript('OnClick', public.start_search)
private.search_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPRIGHT', -75, -8)
btn:SetWidth(60)
btn:SetHeight(25)
btn:SetText('Cont.')
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
private.search_box:ClearFocus()
if arg1 == 'RightButton' then
private.discard_search_continuation()
else
public.start_search(nil, true)
end
end)
btn:Hide()
private.resume_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPRIGHT', -75, -8)
btn:SetWidth(60)
btn:SetHeight(25)
btn:SetText('Stop')
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
private.stop_search()
if arg1 == 'RightButton' then
private.discard_search_continuation()
end
end)
btn:Hide()
private.stop_button = btn
end
do do
local btn = Aux.gui.button(AuxSearchFrame, 26) local btn = Aux.gui.button(AuxSearchFrame, 26)
btn:SetPoint('TOPRIGHT', -40, -8) btn:SetPoint('TOPLEFT', 5, -8)
btn:SetWidth(30) btn:SetWidth(30)
btn:SetHeight(25) btn:SetHeight(25)
btn:SetText('<') btn:SetText('<')
@@ -53,21 +10,43 @@ function Aux.search_frame.create_frames(private, public)
end end
do do
local btn = Aux.gui.button(AuxSearchFrame, 26) local btn = Aux.gui.button(AuxSearchFrame, 26)
btn:SetPoint('TOPRIGHT', -5, -8) btn:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
btn:SetWidth(30) btn:SetWidth(30)
btn:SetHeight(25) btn:SetHeight(25)
btn:SetText('>') btn:SetText('>')
btn:SetScript('OnClick', private.next_search) btn:SetScript('OnClick', private.next_search)
private.next_button = btn private.next_button = btn
end end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPRIGHT', -5, -8)
btn:SetWidth(69)
btn:SetHeight(25)
btn:SetText('Resume')
btn:SetScript('OnClick', function()
private.search_box:ClearFocus()
public.execute('resume')
end)
private.resume_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('RIGHT', private.resume_button, 'LEFT', -4, 0)
btn:SetWidth(72)
btn:SetHeight(25)
btn:SetText('Refresh')
btn:SetScript('OnClick', function()
public.execute('refresh')
end)
btn:Disable()
private.refresh_button = btn
end
do do
local editbox = Aux.gui.editbox(AuxSearchFrame) local editbox = Aux.gui.editbox(AuxSearchFrame)
editbox:SetMaxLetters(nil) editbox:SetMaxLetters(nil)
editbox:EnableMouse(1) editbox:EnableMouse(1)
editbox.complete = Aux.completion.complete editbox.complete = Aux.completion.complete
editbox:SetPoint('TOPLEFT', 5, -8) editbox:SetPoint('RIGHT', private.refresh_button, 'LEFT', -4, 0)
editbox:SetPoint('RIGHT', private.search_button, 'LEFT', -4, 0)
editbox:SetWidth(400)
editbox:SetHeight(25) editbox:SetHeight(25)
editbox:SetScript('OnChar', function() editbox:SetScript('OnChar', function()
this:complete() this:complete()
@@ -78,12 +57,12 @@ function Aux.search_frame.create_frames(private, public)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:HighlightText(0, 0) this:HighlightText(0, 0)
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
editbox:SetScript('OnReceiveDrag', function() editbox:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id) local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
if item_info then if item_info then
public.start_search(strlower(item_info.name)..'/exact') public.execute('search', strlower(item_info.name)..'/exact')
end end
ClearCursor() ClearCursor()
end) end)
@@ -184,7 +163,7 @@ function Aux.search_frame.create_frames(private, public)
private.search_box:SetText('') private.search_box:SetText('')
private.add_filter() private.add_filter()
private.clear_form() private.clear_form()
public.start_search() public.execute('search')
end) end)
local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16) local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16)
@@ -226,7 +205,7 @@ function Aux.search_frame.create_frames(private, public)
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -257,7 +236,7 @@ function Aux.search_frame.create_frames(private, public)
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -278,7 +257,7 @@ function Aux.search_frame.create_frames(private, public)
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0) label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
@@ -365,7 +344,7 @@ function Aux.search_frame.create_frames(private, public)
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -387,7 +366,7 @@ function Aux.search_frame.create_frames(private, public)
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
this:ClearFocus() this:ClearFocus()
public.start_search() public.execute('search')
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0) label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
@@ -583,9 +562,8 @@ function Aux.search_frame.create_frames(private, public)
end end
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:SetSort(1,2,3,4,5,6,7,8,9) private.results_listing:SetSort(1,2,3,4,5,6,7,8,9)
private.results_listing:Clear() private.results_listing:Reset()
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
if button == 'LeftButton' and private.buyout_button:IsEnabled() then if button == 'LeftButton' and private.buyout_button:IsEnabled() then
@@ -628,7 +606,7 @@ function Aux.search_frame.create_frames(private, public)
end end
elseif button == 'LeftButton' then elseif button == 'LeftButton' then
private.search_box:SetText(data.search.filter_string) private.search_box:SetText(data.search.filter_string)
public.start_search() public.execute('search')
elseif button == 'RightButton' then elseif button == 'RightButton' then
if st == private.recent_searches_listing then if st == private.recent_searches_listing then
tinsert(aux_favorite_searches, 1, data.search) tinsert(aux_favorite_searches, 1, data.search)