Make command-related commands and their invokations more reliable
This commit is contained in:
@@ -99,14 +99,17 @@ class CommandView(d.Display):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
row = self.GetFirstSelected()
|
||||
if row != -1:
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(fitID, self.get(row).ID))
|
||||
commandFit = self.get(row)
|
||||
if commandFit is not None:
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(
|
||||
fitID=fitID, commandFitID=commandFit.ID))
|
||||
|
||||
def handleDrag(self, type, fitID):
|
||||
# Those are drags coming from pyfa sources, NOT builtin wx drags
|
||||
if type == "fit":
|
||||
activeFit = self.mainFrame.getActiveFit()
|
||||
if activeFit:
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=activeFit, commandFitID=fitID))
|
||||
|
||||
def startDrag(self, event):
|
||||
row = event.GetIndex()
|
||||
|
||||
@@ -98,7 +98,7 @@ class AddCommandFit(ContextMenu):
|
||||
return
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID, fit.ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=fitID, commandFitID=fit.ID))
|
||||
|
||||
|
||||
AddCommandFit.populateFits(None)
|
||||
|
||||
@@ -185,13 +185,13 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
if activeFit:
|
||||
sFit = Fit.getInstance()
|
||||
projectedFit = sFit.getFit(self.fitID)
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddProjectedCommand(activeFit, projectedFit.ID, 'fit')):
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddProjectedFitCommand(fitID=activeFit, projectedFitID=projectedFit.ID)):
|
||||
self.mainFrame.additionsPane.select("Projected")
|
||||
|
||||
def OnAddCommandFit(self, event):
|
||||
activeFit = self.mainFrame.getActiveFit()
|
||||
if activeFit:
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, self.fitID)):
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=activeFit, commandFitID=self.fitID)):
|
||||
self.mainFrame.additionsPane.select("Command")
|
||||
|
||||
def OnMouseCaptureLost(self, event):
|
||||
|
||||
@@ -30,7 +30,9 @@ class CalcAddCommandCommand(wx.Command):
|
||||
if commandFit in fit.commandFits:
|
||||
pyfalog.debug('Command fit had been applied already')
|
||||
return False
|
||||
|
||||
if commandFit.ID in fit.commandFitDict:
|
||||
pyfalog.debug('Commanding fit is in command dict already')
|
||||
return False
|
||||
fit.commandFitDict[commandFit.ID] = commandFit
|
||||
# This bit is required, see issue #83
|
||||
eos.db.saveddata_session.flush()
|
||||
|
||||
@@ -30,8 +30,10 @@ class CalcRemoveCommandCommand(wx.Command):
|
||||
if commandInfo is None:
|
||||
pyfalog.warning('Fit command info is not available')
|
||||
return False
|
||||
|
||||
self.savedState = commandInfo.active
|
||||
if commandFit.ID not in fit.commandFitDict:
|
||||
pyfalog.warning('Unable to find commanding fit in command dict')
|
||||
return False
|
||||
del fit.commandFitDict[commandFit.ID]
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user