Make sure implant/booster/projected view gets in sync with current fit (clear its content if there is no active fitting), also , make sure the first item is visible/all selected items deselected in case we switch to other fit

This commit is contained in:
HomeWorld
2010-12-11 14:16:57 +02:00
parent 8660e36bad
commit 22ecdba471
4 changed files with 63 additions and 1 deletions

View File

@@ -32,6 +32,9 @@ class BoosterView(d.Display):
def __init__(self, parent):
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
self.lastFitId = None
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
@@ -42,10 +45,29 @@ class BoosterView(d.Display):
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
def fitChanged(self, event):
#Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
event.Skip()
return
cFit = service.Fit.getInstance()
fit = cFit.getFit(event.fitID)
stuff = fit.boosters if fit is not None else None
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)
if item != -1:
self.EnsureVisible(item)
self.deselectItems()
self.populate(stuff)
self.refresh(stuff)
event.Skip()