Remove fit from graph window when it gets deleted

This commit is contained in:
DarkPhoenix
2019-05-19 21:29:43 +03:00
parent 9c710285f2
commit 1ec78d9beb
6 changed files with 16 additions and 9 deletions

View File

@@ -25,7 +25,6 @@ import gui.display as d
import gui.fitCommands as cmd
import gui.globalEvents as GE
from gui.builtinContextMenus.commandFitAdd import AddCommandFit
from gui.builtinShipBrowser.events import EVT_FIT_REMOVED
from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
from gui.utils.staticHelpers import DragDropHelper
@@ -71,7 +70,7 @@ class CommandView(d.Display):
self.lastFitId = None
self.mainFrame.Bind(GE.FIT_CHANGED, AddCommandFit.fitChanged)
self.mainFrame.Bind(EVT_FIT_REMOVED, AddCommandFit.populateFits)
self.mainFrame.Bind(GE.FIT_REMOVED, AddCommandFit.populateFits)
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
self.Bind(wx.EVT_LEFT_DOWN, self.click)
self.Bind(wx.EVT_LEFT_DCLICK, self.onLeftDoubleClick)

View File

@@ -2,8 +2,7 @@
import wx.lib.newevent
FitRenamed, EVT_FIT_RENAMED = wx.lib.newevent.NewEvent()
FitSelected, EVT_FIT_SELECTED = wx.lib.newevent.NewEvent()
FitRemoved, EVT_FIT_REMOVED = wx.lib.newevent.NewEvent()
FitSelected, EVT_FIT_SELECTED = wx.lib.newevent.NewEvent()\
BoosterListUpdated, BOOSTER_LIST_UPDATED = wx.lib.newevent.NewEvent()

View File

@@ -10,6 +10,7 @@ import config
import gui.builtinShipBrowser.sfBrowserItem as SFItem
import gui.fitCommands as cmd
import gui.mainFrame
import gui.globalEvents as GE
import gui.utils.color as colorUtils
import gui.utils.draw as drawUtils
import gui.utils.fonts as fonts
@@ -17,7 +18,7 @@ from gui.bitmap_loader import BitmapLoader
from gui.builtinShipBrowser.events import EVT_FIT_RENAMED
from gui.builtinShipBrowser.pfBitmapFrame import PFBitmapFrame
from service.fit import Fit
from .events import BoosterListUpdated, FitRemoved, FitSelected, ImportSelected, SearchSelected, Stage3Selected
from .events import BoosterListUpdated, FitSelected, ImportSelected, SearchSelected, Stage3Selected
pyfalog = Logger(__name__)
@@ -379,9 +380,8 @@ class FitItem(SFItem.SFBrowserItem):
break
sFit.deleteFit(self.fitID)
# Notify other areas that a fit has been deleted
wx.PostEvent(self.mainFrame, FitRemoved(fitID=self.fitID))
wx.PostEvent(self.mainFrame, GE.FitRemoved(fitID=self.fitID))
# todo: would a simple RefreshList() work here instead of posting that a stage has been selected?
if self.shipBrowser.GetActiveStage() == 5:

View File

@@ -34,7 +34,7 @@ from eos.saveddata.module import Module, Rack
from eos.const import FittingSlot
from gui.bitmap_loader import BitmapLoader
from gui.builtinMarketBrowser.events import ITEM_SELECTED
from gui.builtinShipBrowser.events import EVT_FIT_REMOVED, EVT_FIT_RENAMED, EVT_FIT_SELECTED, FitSelected
from gui.builtinShipBrowser.events import EVT_FIT_RENAMED, EVT_FIT_SELECTED, FitSelected
from gui.builtinViewColumns.state import State
from gui.chrome_tabs import EVT_NOTEBOOK_PAGE_CHANGED
from gui.contextMenu import ContextMenu
@@ -148,7 +148,7 @@ class FittingView(d.Display):
self.parent = parent
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
self.mainFrame.Bind(EVT_FIT_RENAMED, self.fitRenamed)
self.mainFrame.Bind(EVT_FIT_REMOVED, self.fitRemoved)
self.mainFrame.Bind(GE.FIT_REMOVED, self.fitRemoved)
self.mainFrame.Bind(ITEM_SELECTED, self.appendItem)
self.font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)

View File

@@ -2,6 +2,7 @@
import wx.lib.newevent
FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent()
FitRemoved, FIT_REMOVED = wx.lib.newevent.NewEvent()
CharListUpdated, CHAR_LIST_UPDATED = wx.lib.newevent.NewEvent()
CharChanged, CHAR_CHANGED = wx.lib.newevent.NewEvent()

View File

@@ -165,6 +165,7 @@ class GraphFrame(wx.Frame):
self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
self.fitList.fitList.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
self.mainFrame.Bind(GE.FIT_CHANGED, self.OnFitChanged)
self.mainFrame.Bind(GE.FIT_REMOVED, self.OnFitRemoved)
self.Bind(wx.EVT_CLOSE, self.closeEvent)
self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent)
self.Bind(wx.EVT_CHOICE, self.graphChanged)
@@ -222,6 +223,12 @@ class GraphFrame(wx.Frame):
view.clearCache(key=event.fitID)
self.draw()
def OnFitRemoved(self, event):
event.Skip()
fit = next((f for f in self.fits if f.ID == event.fitID), None)
if fit is not None:
self.removeFits([fit])
def graphChanged(self, event):
self.select(self.graphSelection.GetSelection())
event.Skip()
@@ -230,6 +237,7 @@ class GraphFrame(wx.Frame):
from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED # Grr gons
self.fitList.fitList.Unbind(wx.EVT_LEFT_DCLICK, handler=self.OnLeftDClick)
self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.OnFitChanged)
self.mainFrame.Unbind(GE.FIT_REMOVED, handler=self.OnFitRemoved)
self.mainFrame.Unbind(EFFECTIVE_HP_TOGGLED, handler=self.OnEhpToggled)
self.Destroy()