Basic search functionality
This commit is contained in:
@@ -13,13 +13,15 @@ FitRemoved, EVT_FIT_REMOVED = wx.lib.newevent.NewEvent()
|
|||||||
Stage1Selected, EVT_SB_STAGE1_SEL = wx.lib.newevent.NewEvent()
|
Stage1Selected, EVT_SB_STAGE1_SEL = wx.lib.newevent.NewEvent()
|
||||||
Stage2Selected, EVT_SB_STAGE2_SEL = wx.lib.newevent.NewEvent()
|
Stage2Selected, EVT_SB_STAGE2_SEL = wx.lib.newevent.NewEvent()
|
||||||
Stage3Selected, EVT_SB_STAGE3_SEL = wx.lib.newevent.NewEvent()
|
Stage3Selected, EVT_SB_STAGE3_SEL = wx.lib.newevent.NewEvent()
|
||||||
|
SearchSelected, EVT_SB_SEARCH_SEL = wx.lib.newevent.NewEvent()
|
||||||
|
|
||||||
class ShipBrowser(wx.Panel):
|
class ShipBrowser(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
wx.Panel.__init__ (self, parent,style = 0 if 'wxGTK' in wx.PlatformInfo else wx.DOUBLE_BORDER)
|
wx.Panel.__init__ (self, parent,style = 0 if 'wxGTK' in wx.PlatformInfo else wx.DOUBLE_BORDER)
|
||||||
|
|
||||||
self._lastWidth = 0
|
self._lastWidth = 0
|
||||||
self._activeStage = 0
|
self._activeStage = 1
|
||||||
|
self._lastStage = 0
|
||||||
|
|
||||||
self._stage1Data = -1
|
self._stage1Data = -1
|
||||||
self._stage2Data = -1
|
self._stage2Data = -1
|
||||||
@@ -47,6 +49,7 @@ class ShipBrowser(wx.Panel):
|
|||||||
self.Bind(EVT_SB_STAGE2_SEL, self.stage2)
|
self.Bind(EVT_SB_STAGE2_SEL, self.stage2)
|
||||||
self.Bind(EVT_SB_STAGE1_SEL, self.stage1)
|
self.Bind(EVT_SB_STAGE1_SEL, self.stage1)
|
||||||
self.Bind(EVT_SB_STAGE3_SEL, self.stage3)
|
self.Bind(EVT_SB_STAGE3_SEL, self.stage3)
|
||||||
|
self.Bind(EVT_SB_SEARCH_SEL, self.searchStage)
|
||||||
|
|
||||||
self.stage1(None)
|
self.stage1(None)
|
||||||
|
|
||||||
@@ -63,6 +66,8 @@ class ShipBrowser(wx.Panel):
|
|||||||
pass
|
pass
|
||||||
def GetActiveStage(self):
|
def GetActiveStage(self):
|
||||||
return self._activeStage
|
return self._activeStage
|
||||||
|
def GetLastStage(self):
|
||||||
|
return self._lastStage
|
||||||
|
|
||||||
def GetStageData(self, stage):
|
def GetStageData(self, stage):
|
||||||
if stage == 1:
|
if stage == 1:
|
||||||
@@ -116,6 +121,7 @@ class ShipBrowser(wx.Panel):
|
|||||||
self.Show()
|
self.Show()
|
||||||
|
|
||||||
def stage3(self, event):
|
def stage3(self, event):
|
||||||
|
if self._activeStage != 4:
|
||||||
self._activeStage = 3
|
self._activeStage = 3
|
||||||
|
|
||||||
shipID = event.shipID
|
shipID = event.shipID
|
||||||
@@ -141,11 +147,17 @@ class ShipBrowser(wx.Panel):
|
|||||||
self.Show()
|
self.Show()
|
||||||
|
|
||||||
def searchStage(self, event):
|
def searchStage(self, event):
|
||||||
|
if self._activeStage != 4:
|
||||||
|
self._lastStage = self._activeStage
|
||||||
|
|
||||||
|
self._activeStage = 4
|
||||||
|
|
||||||
sMarket = service.Market.getInstance()
|
sMarket = service.Market.getInstance()
|
||||||
sFit = service.Market.getInstance()
|
sFit = service.Fit.getInstance()
|
||||||
query = event.text
|
query = event.text
|
||||||
|
|
||||||
self.lpane.RemoveAllChildren()
|
self.lpane.RemoveAllChildren()
|
||||||
|
if query:
|
||||||
shipList = sMarket.searchShips(query)
|
shipList = sMarket.searchShips(query)
|
||||||
fitList = sFit.searchFits(query)
|
fitList = sFit.searchFits(query)
|
||||||
|
|
||||||
@@ -178,6 +190,8 @@ class HeaderPane (wx.Panel):
|
|||||||
self.searchBmp = bitmapLoader.getBitmap("fsearch_small","icons")
|
self.searchBmp = bitmapLoader.getBitmap("fsearch_small","icons")
|
||||||
self.newBmp = bitmapLoader.getBitmap("fit_add_small","icons")
|
self.newBmp = bitmapLoader.getBitmap("fit_add_small","icons")
|
||||||
|
|
||||||
|
self.shipBrowser = self.Parent
|
||||||
|
|
||||||
self.toggleSearch = -1
|
self.toggleSearch = -1
|
||||||
self.recentSearches = []
|
self.recentSearches = []
|
||||||
self.menu = None
|
self.menu = None
|
||||||
@@ -269,9 +283,11 @@ class HeaderPane (wx.Panel):
|
|||||||
search = self.search.GetValue()
|
search = self.search.GetValue()
|
||||||
if len(search) < 3 and len(search) > 0:
|
if len(search) < 3 and len(search) > 0:
|
||||||
print "need more chars/clear search"
|
print "need more chars/clear search"
|
||||||
|
wx.PostEvent(self.shipBrowser,SearchSelected(text=None))
|
||||||
else:
|
else:
|
||||||
if search:
|
if search:
|
||||||
print "DO SEARCH ", search
|
print "DO SEARCH ", search
|
||||||
|
wx.PostEvent(self.shipBrowser,SearchSelected(text=search))
|
||||||
|
|
||||||
event.Skip()
|
event.Skip()
|
||||||
def OnMenu(self, event):
|
def OnMenu(self, event):
|
||||||
@@ -284,7 +300,10 @@ class HeaderPane (wx.Panel):
|
|||||||
def OnMenuSelected(self, event):
|
def OnMenuSelected(self, event):
|
||||||
item = self.menu.FindItemById(event.GetId())
|
item = self.menu.FindItemById(event.GetId())
|
||||||
text = item.GetText()
|
text = item.GetText()
|
||||||
|
|
||||||
print "menu sel do search:",text
|
print "menu sel do search:",text
|
||||||
|
if len(text)>2 :
|
||||||
|
wx.PostEvent(self.shipBrowser,SearchSelected(text=text))
|
||||||
self.editLostFocus()
|
self.editLostFocus()
|
||||||
|
|
||||||
def MakeMenu(self):
|
def MakeMenu(self):
|
||||||
@@ -336,8 +355,7 @@ class HeaderPane (wx.Panel):
|
|||||||
event.Skip()
|
event.Skip()
|
||||||
def doSearch(self, event):
|
def doSearch(self, event):
|
||||||
stxt = self.search.GetValue()
|
stxt = self.search.GetValue()
|
||||||
if stxt:
|
if len(stxt) > 3:
|
||||||
print "ENTER -> Search", stxt
|
|
||||||
self.editLostFocus()
|
self.editLostFocus()
|
||||||
|
|
||||||
def ToggleNewFitSB(self, toggle):
|
def ToggleNewFitSB(self, toggle):
|
||||||
@@ -449,6 +467,9 @@ class HeaderPane (wx.Panel):
|
|||||||
def OnBack(self,event):
|
def OnBack(self,event):
|
||||||
self.editLostFocus()
|
self.editLostFocus()
|
||||||
stage = self.Parent.GetActiveStage()
|
stage = self.Parent.GetActiveStage()
|
||||||
|
if stage == 4:
|
||||||
|
self.gotoStage(self.Parent.GetLastStage())
|
||||||
|
return
|
||||||
stage -=1
|
stage -=1
|
||||||
if stage <1:
|
if stage <1:
|
||||||
stage = 1
|
stage = 1
|
||||||
@@ -470,6 +491,8 @@ class HeaderPane (wx.Panel):
|
|||||||
shipID = self.Parent.GetStageData(stage)
|
shipID = self.Parent.GetStageData(stage)
|
||||||
if shipID != -1:
|
if shipID != -1:
|
||||||
wx.PostEvent(self.Parent,Stage3Selected(shipID=shipID))
|
wx.PostEvent(self.Parent,Stage3Selected(shipID=shipID))
|
||||||
|
else:
|
||||||
|
wx.PostEvent(self.Parent,Stage1Selected())
|
||||||
|
|
||||||
class ListPane (wx.ScrolledWindow):
|
class ListPane (wx.ScrolledWindow):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
|||||||
Reference in New Issue
Block a user