Change projected fits behavior - now addition adds 1 fit in any case (even if fit is already projected), and removal via double-click works like with drones

This commit is contained in:
DarkPhoenix
2019-04-21 21:22:57 +03:00
parent 72fc560241
commit 031cb6fcfb
9 changed files with 58 additions and 27 deletions

View File

@@ -10,12 +10,14 @@ pyfalog = Logger(__name__)
class CalcRemoveProjectedFitCommand(wx.Command):
def __init__(self, fitID, projectedFitID):
def __init__(self, fitID, projectedFitID, amount):
wx.Command.__init__(self, True, 'Add Projected Fit')
self.fitID = fitID
self.projectedFitID = projectedFitID
self.amount = amount
self.savedState = None
self.savedAmount = None
self.changeAmountCommand = None
def Do(self):
pyfalog.debug('Doing removal of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID))
@@ -34,15 +36,28 @@ class CalcRemoveProjectedFitCommand(wx.Command):
self.savedState = projectionInfo.active
self.savedAmount = projectionInfo.amount
if projectedFit.ID not in fit.projectedFitDict:
pyfalog.warning('Unable to find projected fit in projected dict')
return False
del fit.projectedFitDict[projectedFit.ID]
eos.db.commit()
return True
remainingAmount = projectionInfo.amount - self.amount
# Change amount if more than 0 remaining, remove otherwise
if remainingAmount > 0:
from .changeAmount import CalcChangeProjectedFitAmountCommand
self.changeAmountCommand = CalcChangeProjectedFitAmountCommand(
fitID=self.fitID, projectedFitID=self.projectedFitID, amount=remainingAmount)
return self.changeAmountCommand.Do()
else:
self.changeAmountCommand = None
if projectedFit.ID not in fit.projectedFitDict:
pyfalog.warning('Unable to find projected fit in projected dict')
return False
del fit.projectedFitDict[projectedFit.ID]
eos.db.commit()
return True
def Undo(self):
pyfalog.debug('Undoing removal of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID))
if self.changeAmountCommand is not None:
return self.changeAmountCommand.Undo()
from .add import CalcAddProjectedFitCommand
cmd = CalcAddProjectedFitCommand(
fitID=self.fitID,