Update database with actual contents before and after fill, also do it in UI commands
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,12 +9,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddBoosterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, boosterInfo, position=None, commit=True):
|
||||
def __init__(self, fitID, boosterInfo, position=None):
|
||||
wx.Command.__init__(self, True, 'Add Booster')
|
||||
self.fitID = fitID
|
||||
self.newBoosterInfo = boosterInfo
|
||||
self.newPosition = position
|
||||
self.commit = commit
|
||||
self.oldBoosterInfo = None
|
||||
self.oldPosition = None
|
||||
|
||||
@@ -40,8 +38,7 @@ class CalcAddBoosterCommand(wx.Command):
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
boosterInfo=self.oldBoosterInfo,
|
||||
position=self.oldPosition,
|
||||
commit=self.commit)
|
||||
position=self.oldPosition)
|
||||
cmd.Do()
|
||||
return False
|
||||
else:
|
||||
@@ -51,21 +48,18 @@ class CalcAddBoosterCommand(wx.Command):
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
boosterInfo=self.oldBoosterInfo,
|
||||
position=self.oldPosition,
|
||||
commit=self.commit)
|
||||
position=self.oldPosition)
|
||||
cmd.Do()
|
||||
return False
|
||||
self.newPosition = fit.boosters.index(newBooster)
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undo addition of booster {} to fit {}'.format(self.newBoosterInfo, self.fitID))
|
||||
if self.oldBoosterInfo is not None and self.oldPosition is not None:
|
||||
cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=self.oldBoosterInfo, position=self.oldPosition, commit=self.commit)
|
||||
cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=self.oldBoosterInfo, position=self.oldPosition)
|
||||
return cmd.Do()
|
||||
from .remove import CalcRemoveBoosterCommand
|
||||
cmd = CalcRemoveBoosterCommand(fitID=self.fitID, position=self.newPosition, commit=self.commit)
|
||||
cmd = CalcRemoveBoosterCommand(fitID=self.fitID, position=self.newPosition)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import BoosterInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,11 +10,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveBoosterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, commit=True):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, 'Remove Booster')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
self.savedBoosterInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -24,8 +22,6 @@ class CalcRemoveBoosterCommand(wx.Command):
|
||||
booster = fit.boosters[self.position]
|
||||
self.savedBoosterInfo = BoosterInfo.fromBooster(booster)
|
||||
fit.boosters.remove(booster)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -34,6 +30,5 @@ class CalcRemoveBoosterCommand(wx.Command):
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
boosterInfo=self.savedBoosterInfo,
|
||||
position=self.position,
|
||||
commit=self.commit)
|
||||
position=self.position)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -28,7 +27,6 @@ class CalcToggleBoosterSideEffectStateCommand(wx.Command):
|
||||
return False
|
||||
self.savedState = sideEffect.active
|
||||
sideEffect.active = not sideEffect.active if self.forceState is None else self.forceState
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -41,7 +40,6 @@ class CalcToggleBoosterStatesCommand(wx.Command):
|
||||
booster = fit.boosters[position]
|
||||
if not booster.active:
|
||||
booster.active = True
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,11 +9,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddCargoCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, cargoInfo, commit=True):
|
||||
def __init__(self, fitID, cargoInfo):
|
||||
wx.Command.__init__(self, True, 'Add Cargo')
|
||||
self.fitID = fitID
|
||||
self.cargoInfo = cargoInfo
|
||||
self.commit = commit
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing addition of cargo {} to fit {}'.format(self.cargoInfo, self.fitID))
|
||||
@@ -27,15 +25,11 @@ class CalcAddCargoCommand(wx.Command):
|
||||
fit.cargo.append(cargo)
|
||||
if cargo not in fit.cargo:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undoing addition of cargo {} to fit {}'.format(self.cargoInfo, self.fitID))
|
||||
from .remove import CalcRemoveCargoCommand
|
||||
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=self.cargoInfo, commit=self.commit)
|
||||
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=self.cargoInfo)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import CargoInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -28,7 +27,6 @@ class CalcChangeCargoAmountCommand(wx.Command):
|
||||
if self.cargoInfo.amount == self.savedCargoInfo.amount:
|
||||
return False
|
||||
cargo.amount = self.cargoInfo.amount
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import wx
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import CargoInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -12,11 +10,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveCargoCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, cargoInfo, commit=True):
|
||||
def __init__(self, fitID, cargoInfo):
|
||||
wx.Command.__init__(self, True, 'Remove Cargo')
|
||||
self.fitID = fitID
|
||||
self.cargoInfo = cargoInfo
|
||||
self.commit = commit
|
||||
self.savedRemovedAmount = None
|
||||
|
||||
def Do(self):
|
||||
@@ -29,8 +26,6 @@ class CalcRemoveCargoCommand(wx.Command):
|
||||
cargo.amount -= self.savedRemovedAmount
|
||||
if cargo.amount <= 0:
|
||||
fit.cargo.remove(cargo)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -38,6 +33,5 @@ class CalcRemoveCargoCommand(wx.Command):
|
||||
from .add import CalcAddCargoCommand
|
||||
cmd = CalcAddCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=self.cargoInfo.itemID, amount=self.savedRemovedAmount),
|
||||
commit=self.commit)
|
||||
cargoInfo=CargoInfo(itemID=self.cargoInfo.itemID, amount=self.savedRemovedAmount))
|
||||
return cmd.Do()
|
||||
|
||||
@@ -10,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddCommandCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, commandFitID, state=None, commit=True):
|
||||
def __init__(self, fitID, commandFitID, state=None):
|
||||
wx.Command.__init__(self, True, 'Add Command Fit')
|
||||
self.fitID = fitID
|
||||
self.commandFitID = commandFitID
|
||||
self.state = state
|
||||
self.commit = commit
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing addition of command fit {} for fit {}'.format(self.commandFitID, self.fitID))
|
||||
@@ -47,8 +46,6 @@ class CalcAddCommandCommand(wx.Command):
|
||||
return False
|
||||
fitCommandInfo.active = self.state
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -59,5 +56,5 @@ class CalcAddCommandCommand(wx.Command):
|
||||
if commandFit is None:
|
||||
return True
|
||||
from .remove import CalcRemoveCommandFitCommand
|
||||
cmd = CalcRemoveCommandFitCommand(fitID=self.fitID, commandFitID=self.commandFitID, commit=self.commit)
|
||||
cmd = CalcRemoveCommandFitCommand(fitID=self.fitID, commandFitID=self.commandFitID)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,11 +9,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveCommandFitCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, commandFitID, commit=True):
|
||||
def __init__(self, fitID, commandFitID):
|
||||
wx.Command.__init__(self, True, 'Remove Command Fit')
|
||||
self.fitID = fitID
|
||||
self.commandFitID = commandFitID
|
||||
self.commit = commit
|
||||
self.savedState = None
|
||||
|
||||
def Do(self):
|
||||
@@ -36,8 +34,6 @@ class CalcRemoveCommandFitCommand(wx.Command):
|
||||
pyfalog.warning('Unable to find commanding fit in command dict')
|
||||
return False
|
||||
del fit.commandFitDict[commandFit.ID]
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -46,6 +42,5 @@ class CalcRemoveCommandFitCommand(wx.Command):
|
||||
cmd = CalcAddCommandCommand(
|
||||
fitID=self.fitID,
|
||||
commandFitID=self.commandFitID,
|
||||
state=self.savedState,
|
||||
commit=self.commit)
|
||||
state=self.savedState)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -60,7 +59,6 @@ class CalcToggleCommandFitStatesCommand(wx.Command):
|
||||
# Bail if we cannot calculate which state to take
|
||||
else:
|
||||
return False
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import wx
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo, droneStackLimit
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
@@ -13,13 +11,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddLocalDroneCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, droneInfo, forceNewStack=False, ignoreRestrictions=False, commit=True):
|
||||
def __init__(self, fitID, droneInfo, forceNewStack=False, ignoreRestrictions=False):
|
||||
wx.Command.__init__(self, True, 'Add Local Drone')
|
||||
self.fitID = fitID
|
||||
self.droneInfo = droneInfo
|
||||
self.forceNewStack = forceNewStack
|
||||
self.ignoreRestrictions = ignoreRestrictions
|
||||
self.commit = commit
|
||||
self.savedDroneInfo = None
|
||||
self.savedPosition = None
|
||||
|
||||
@@ -39,8 +36,6 @@ class CalcAddLocalDroneCommand(wx.Command):
|
||||
self.savedDroneInfo = DroneInfo.fromDrone(drone)
|
||||
self.savedPosition = fit.drones.index(drone)
|
||||
drone.amount += self.droneInfo.amount
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Do new stack otherwise
|
||||
drone = self.droneInfo.toDrone()
|
||||
@@ -52,11 +47,7 @@ class CalcAddLocalDroneCommand(wx.Command):
|
||||
fit.drones.append(drone)
|
||||
if drone not in fit.drones:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
self.savedPosition = fit.drones.index(drone)
|
||||
return True
|
||||
|
||||
@@ -67,13 +58,10 @@ class CalcAddLocalDroneCommand(wx.Command):
|
||||
drone = fit.drones[self.savedPosition]
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
from .localRemove import CalcRemoveLocalDroneCommand
|
||||
cmd = CalcRemoveLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.savedPosition,
|
||||
amount=self.droneInfo.amount,
|
||||
commit=self.commit)
|
||||
amount=self.droneInfo.amount)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeLocalDroneAmountCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, amount, commit=True):
|
||||
def __init__(self, fitID, position, amount):
|
||||
wx.Command.__init__(self, True, 'Change Local Drone Amount')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.amount = amount
|
||||
self.commit = commit
|
||||
self.savedDroneInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -31,8 +29,6 @@ class CalcChangeLocalDroneAmountCommand(wx.Command):
|
||||
difference = self.amount - self.savedDroneInfo.amount
|
||||
drone.amount = self.amount
|
||||
drone.amountActive = max(min(drone.amountActive + difference, drone.amount), 0)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -42,7 +38,5 @@ class CalcChangeLocalDroneAmountCommand(wx.Command):
|
||||
drone = fit.drones[self.position]
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveLocalDroneCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, amount, commit=True):
|
||||
def __init__(self, fitID, position, amount):
|
||||
wx.Command.__init__(self, True, 'Remove Local Drone')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.amountToRemove = amount
|
||||
self.commit = commit
|
||||
self.savedDroneInfo = None
|
||||
self.removedStack = None
|
||||
|
||||
@@ -36,8 +34,6 @@ class CalcRemoveLocalDroneCommand(wx.Command):
|
||||
else:
|
||||
self.removedStack = False
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -50,13 +46,9 @@ class CalcRemoveLocalDroneCommand(wx.Command):
|
||||
fit.drones.insert(self.position, drone)
|
||||
if drone not in fit.drones:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
else:
|
||||
drone = fit.drones[self.position]
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -42,7 +42,6 @@ class CalcToggleLocalDroneStatesCommand(wx.Command):
|
||||
if drone.amountActive == 0:
|
||||
drone.amountActive = drone.amount
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import math
|
||||
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -13,11 +11,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddProjectedDroneCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, droneInfo, commit=True):
|
||||
def __init__(self, fitID, droneInfo):
|
||||
wx.Command.__init__(self, True, 'Add Projected Drone')
|
||||
self.fitID = fitID
|
||||
self.droneInfo = droneInfo
|
||||
self.commit = commit
|
||||
self.savedDroneInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -32,8 +29,6 @@ class CalcAddProjectedDroneCommand(wx.Command):
|
||||
drone.amount += self.droneInfo.amount
|
||||
if drone.amountActive > 0:
|
||||
drone.amountActive += self.droneInfo.amount
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Making new stack
|
||||
drone = self.droneInfo.toDrone()
|
||||
@@ -45,11 +40,7 @@ class CalcAddProjectedDroneCommand(wx.Command):
|
||||
fit.projectedDrones.append(drone)
|
||||
if drone not in fit.projectedDrones:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -63,14 +54,11 @@ class CalcAddProjectedDroneCommand(wx.Command):
|
||||
return False
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Removing previously added stack
|
||||
from .projectedRemove import CalcRemoveProjectedDroneCommand
|
||||
cmd = CalcRemoveProjectedDroneCommand(
|
||||
fitID=self.fitID,
|
||||
itemID=self.droneInfo.itemID,
|
||||
amount=math.inf,
|
||||
commit=self.commit)
|
||||
amount=math.inf)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import math
|
||||
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -35,7 +32,6 @@ class CalcChangeProjectedDroneAmountCommand(wx.Command):
|
||||
difference = self.amount - self.savedDroneInfo.amount
|
||||
drone.amount = self.amount
|
||||
drone.amountActive = max(min(drone.amountActive + difference, drone.amount), 0)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -48,6 +44,5 @@ class CalcChangeProjectedDroneAmountCommand(wx.Command):
|
||||
return False
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
eos.db.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -10,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeProjectedDroneStateCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID, state, commit=True):
|
||||
def __init__(self, fitID, itemID, state):
|
||||
wx.Command.__init__(self, True, 'Change Projected Drone State')
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.state = state
|
||||
self.commit = commit
|
||||
self.savedState = None
|
||||
|
||||
def Do(self):
|
||||
@@ -39,8 +38,6 @@ class CalcChangeProjectedDroneStateCommand(wx.Command):
|
||||
else:
|
||||
drone.amountActive = 0
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -48,6 +45,5 @@ class CalcChangeProjectedDroneStateCommand(wx.Command):
|
||||
cmd = CalcChangeProjectedDroneStateCommand(
|
||||
fitID=self.fitID,
|
||||
itemID=self.itemID,
|
||||
state=self.savedState,
|
||||
commit=self.commit)
|
||||
state=self.savedState)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import DroneInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveProjectedDroneCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID, amount, commit=True):
|
||||
def __init__(self, fitID, itemID, amount):
|
||||
wx.Command.__init__(self, True, 'Remove Projected Drone')
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.amountToRemove = amount
|
||||
self.commit = commit
|
||||
self.savedDroneInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -34,8 +32,6 @@ class CalcRemoveProjectedDroneCommand(wx.Command):
|
||||
else:
|
||||
if drone.amountActive > 0:
|
||||
drone.amountActive = min(drone.amountActive, drone.amount)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -46,10 +42,8 @@ class CalcRemoveProjectedDroneCommand(wx.Command):
|
||||
if drone is not None:
|
||||
drone.amount = self.savedDroneInfo.amount
|
||||
drone.amountActive = self.savedDroneInfo.amountActive
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Make new stack
|
||||
from .projectedAdd import CalcAddProjectedDroneCommand
|
||||
cmd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=self.savedDroneInfo, commit=self.commit)
|
||||
cmd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=self.savedDroneInfo)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -72,7 +71,6 @@ class CalcToggleFighterAbilityStatesCommand(wx.Command):
|
||||
if not ability.active:
|
||||
changes = True
|
||||
ability.active = True
|
||||
eos.db.commit()
|
||||
return changes
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -28,11 +27,9 @@ class CalcChangeFighterAmountCommand(wx.Command):
|
||||
self.savedAmount = fighter.amount
|
||||
if self.amount == -1:
|
||||
fighter.amount = self.amount
|
||||
eos.db.commit()
|
||||
return True
|
||||
else:
|
||||
fighter.amount = max(min(self.amount, fighter.fighterSquadronMaxSize), 0)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,13 +9,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddLocalFighterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, fighterInfo, position=None, ignoreRestrictions=False, commit=True):
|
||||
def __init__(self, fitID, fighterInfo, position=None, ignoreRestrictions=False):
|
||||
wx.Command.__init__(self, True, 'Add Fighter')
|
||||
self.fitID = fitID
|
||||
self.fighterInfo = fighterInfo
|
||||
self.position = position
|
||||
self.ignoreRestrictions = ignoreRestrictions
|
||||
self.commit = commit
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing addition of fighter {} to fit {}'.format(self.fighterInfo, self.fitID))
|
||||
@@ -43,24 +41,18 @@ class CalcAddLocalFighterCommand(wx.Command):
|
||||
fit.fighters.append(fighter)
|
||||
if fighter not in fit.fighters:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
self.position = fit.fighters.index(fighter)
|
||||
else:
|
||||
fit.fighters.insert(self.position, fighter)
|
||||
if fighter not in fit.fighters:
|
||||
pyfalog.warning('Failed to insert to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undoing addition of fighter {} to fit {}'.format(self.fighterInfo, self.fitID))
|
||||
from .localRemove import CalcRemoveLocalFighterCommand
|
||||
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position, commit=self.commit)
|
||||
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
|
||||
cmd.Do()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import FighterInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,11 +10,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveLocalFighterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, commit=True):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, 'Remove Fighter')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
self.savedFighterInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -24,8 +22,6 @@ class CalcRemoveLocalFighterCommand(wx.Command):
|
||||
fighter = fit.fighters[self.position]
|
||||
self.savedFighterInfo = FighterInfo.fromFighter(fighter)
|
||||
fit.fighters.remove(fighter)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -35,6 +31,5 @@ class CalcRemoveLocalFighterCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
fighterInfo=self.savedFighterInfo,
|
||||
position=self.position,
|
||||
ignoreRestrictions=True,
|
||||
commit=self.commit)
|
||||
ignoreRestrictions=True)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -42,7 +42,6 @@ class CalcToggleLocalFighterStatesCommand(wx.Command):
|
||||
fighter = fit.fighters[position]
|
||||
if not fighter.active:
|
||||
fighter.active = True
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,12 +9,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddProjectedFighterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, fighterInfo, position=None, commit=True):
|
||||
def __init__(self, fitID, fighterInfo, position=None):
|
||||
wx.Command.__init__(self, True, 'Add Projected Fighter')
|
||||
self.fitID = fitID
|
||||
self.fighterInfo = fighterInfo
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing addition of projected fighter {} onto: {}'.format(self.fighterInfo, self.fitID))
|
||||
@@ -26,22 +24,16 @@ class CalcAddProjectedFighterCommand(wx.Command):
|
||||
if self.position is not None:
|
||||
fit.projectedFighters.insert(self.position, fighter)
|
||||
if fighter not in fit.projectedFighters:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
else:
|
||||
fit.projectedFighters.append(fighter)
|
||||
if fighter not in fit.projectedFighters:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
self.position = fit.projectedFighters.index(fighter)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undoing addition of projected fighter {} onto: {}'.format(self.fighterInfo, self.fitID))
|
||||
from .projectedRemove import CalcRemoveProjectedFighterCommand
|
||||
cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=self.position, commit=self.commit)
|
||||
cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=self.position)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,12 +9,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeProjectedFighterStateCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, state, commit=True):
|
||||
def __init__(self, fitID, position, state):
|
||||
wx.Command.__init__(self, True, 'Change Projected Fighter State')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.state = state
|
||||
self.commit = commit
|
||||
self.savedState = None
|
||||
|
||||
def Do(self):
|
||||
@@ -31,8 +29,6 @@ class CalcChangeProjectedFighterStateCommand(wx.Command):
|
||||
|
||||
fighter.active = self.state
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -41,6 +37,5 @@ class CalcChangeProjectedFighterStateCommand(wx.Command):
|
||||
cmd = CalcChangeProjectedFighterStateCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.position,
|
||||
state=self.savedState,
|
||||
commit=self.commit)
|
||||
state=self.savedState)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import FighterInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,11 +10,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveProjectedFighterCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, commit=True):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, 'Add Projected Fighter')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
self.savedFighterInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -24,8 +22,6 @@ class CalcRemoveProjectedFighterCommand(wx.Command):
|
||||
fighter = fit.projectedFighters[self.position]
|
||||
self.savedFighterInfo = FighterInfo.fromFighter(fighter)
|
||||
fit.projectedFighters.remove(fighter)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -34,6 +30,5 @@ class CalcRemoveProjectedFighterCommand(wx.Command):
|
||||
cmd = CalcAddProjectedFighterCommand(
|
||||
fitID=self.fitID,
|
||||
fighterInfo=self.savedFighterInfo,
|
||||
position=self.position,
|
||||
commit=self.commit)
|
||||
position=self.position)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -23,7 +22,6 @@ class CalcFitRenameCommand(wx.Command):
|
||||
return False
|
||||
self.savedName = fit.name
|
||||
fit.name = self.name
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -25,7 +24,6 @@ class CalcChangeFitSystemSecurityCommand(wx.Command):
|
||||
return False
|
||||
self.savedSecStatus = fit.systemSecurity
|
||||
fit.systemSecurity = self.secStatus
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,12 +9,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddImplantCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, implantInfo, position=None, commit=True):
|
||||
def __init__(self, fitID, implantInfo, position=None):
|
||||
wx.Command.__init__(self, True, 'Add Implant')
|
||||
self.fitID = fitID
|
||||
self.newImplantInfo = implantInfo
|
||||
self.newPosition = position
|
||||
self.commit = commit
|
||||
self.oldImplantInfo = None
|
||||
self.oldPosition = None
|
||||
|
||||
@@ -40,8 +38,7 @@ class CalcAddImplantCommand(wx.Command):
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
implantInfo=self.oldImplantInfo,
|
||||
position=self.oldPosition,
|
||||
commit=self.commit)
|
||||
position=self.oldPosition)
|
||||
cmd.Do()
|
||||
return False
|
||||
else:
|
||||
@@ -51,13 +48,10 @@ class CalcAddImplantCommand(wx.Command):
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
implantInfo=self.oldImplantInfo,
|
||||
position=self.oldPosition,
|
||||
commit=self.commit)
|
||||
position=self.oldPosition)
|
||||
cmd.Do()
|
||||
return False
|
||||
self.newPosition = fit.implants.index(newImplant)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -66,9 +60,8 @@ class CalcAddImplantCommand(wx.Command):
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
implantInfo=self.oldImplantInfo,
|
||||
position=self.oldPosition,
|
||||
commit=self.commit)
|
||||
position=self.oldPosition)
|
||||
return cmd.Do()
|
||||
from .remove import CalcRemoveImplantCommand
|
||||
cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=self.newPosition, commit=self.commit)
|
||||
cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=self.newPosition)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,11 +9,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeImplantLocationCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, source, commit=True):
|
||||
def __init__(self, fitID, source):
|
||||
wx.Command.__init__(self, True, 'Change Implant Location')
|
||||
self.fitID = fitID
|
||||
self.source = source
|
||||
self.commit = commit
|
||||
self.savedSource = None
|
||||
|
||||
def Do(self):
|
||||
@@ -24,10 +22,8 @@ class CalcChangeImplantLocationCommand(wx.Command):
|
||||
if self.source == self.savedSource:
|
||||
return False
|
||||
fit.implantSource = self.source
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.savedSource, commit=self.commit)
|
||||
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.savedSource)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import ImplantInfo
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,11 +10,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveImplantCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, commit=True):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, 'Remove Implant')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
self.savedImplantInfo = None
|
||||
|
||||
def Do(self):
|
||||
@@ -24,8 +22,6 @@ class CalcRemoveImplantCommand(wx.Command):
|
||||
implant = fit.implants[self.position]
|
||||
self.savedImplantInfo = ImplantInfo.fromImplant(implant)
|
||||
fit.implants.remove(implant)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -34,6 +30,5 @@ class CalcRemoveImplantCommand(wx.Command):
|
||||
cmd = CalcAddImplantCommand(
|
||||
fitID=self.fitID,
|
||||
implantInfo=self.savedImplantInfo,
|
||||
position=self.position,
|
||||
commit=self.commit)
|
||||
position=self.position)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -41,7 +40,6 @@ class CalcToggleImplantStatesCommand(wx.Command):
|
||||
implant = fit.implants[position]
|
||||
if not implant.active:
|
||||
implant.active = True
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
|
||||
@@ -11,13 +10,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRebaseItemCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, containerName, position, itemID, commit=True):
|
||||
def __init__(self, fitID, containerName, position, itemID):
|
||||
wx.Command.__init__(self, True, 'Rebase Item')
|
||||
self.fitID = fitID
|
||||
self.containerName = containerName
|
||||
self.position = position
|
||||
self.itemID = itemID
|
||||
self.commit = commit
|
||||
self.savedItemID = None
|
||||
|
||||
def Do(self):
|
||||
@@ -33,8 +31,6 @@ class CalcRebaseItemCommand(wx.Command):
|
||||
pyfalog.warning('Unable to fetch new item')
|
||||
return False
|
||||
obj.rebase(newItem)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -43,6 +39,5 @@ class CalcRebaseItemCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
containerName=self.containerName,
|
||||
position=self.position,
|
||||
itemID=self.savedItemID,
|
||||
commit=self.commit)
|
||||
itemID=self.savedItemID)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
@@ -12,13 +11,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeModuleChargesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, projected, chargeMap, ignoreRestriction=False, commit=True):
|
||||
def __init__(self, fitID, projected, chargeMap, ignoreRestriction=False):
|
||||
wx.Command.__init__(self, True, 'Change Module Charges')
|
||||
self.fitID = fitID
|
||||
self.projected = projected
|
||||
self.chargeMap = chargeMap
|
||||
self.ignoreRestriction = ignoreRestriction
|
||||
self.commit = commit
|
||||
self.savedChargeMap = None
|
||||
self.savedStateCheckChanges = None
|
||||
|
||||
@@ -52,8 +50,6 @@ class CalcChangeModuleChargesCommand(wx.Command):
|
||||
return False
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -62,8 +58,7 @@ class CalcChangeModuleChargesCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
projected=self.projected,
|
||||
chargeMap=self.savedChargeMap,
|
||||
ignoreRestriction=True,
|
||||
commit=self.commit)
|
||||
ignoreRestriction=True)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -34,7 +33,6 @@ class CalcChangeModuleSpoolCommand(wx.Command):
|
||||
return False
|
||||
mod.spoolType = self.spoolType
|
||||
mod.spoolAmount = self.spoolAmount
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -11,11 +11,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddLocalModuleCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, newModInfo, commit=True):
|
||||
def __init__(self, fitID, newModInfo):
|
||||
wx.Command.__init__(self, True, 'Add Module')
|
||||
self.fitID = fitID
|
||||
self.newModInfo = newModInfo
|
||||
self.commit = commit
|
||||
self.savedPosition = None
|
||||
self.subsystemCmd = None
|
||||
self.savedStateCheckChanges = None
|
||||
@@ -39,8 +38,7 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
self.subsystemCmd = CalcReplaceLocalModuleCommand(
|
||||
fitID=self.fitID,
|
||||
position=fit.modules.index(oldMod),
|
||||
newModInfo=self.newModInfo,
|
||||
commit=False)
|
||||
newModInfo=self.newModInfo)
|
||||
if not self.subsystemCmd.Do():
|
||||
return False
|
||||
# Need to flush because checkStates sometimes relies on module->fit
|
||||
@@ -48,8 +46,6 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
if not newMod.fits(fit):
|
||||
pyfalog.warning('Module does not fit')
|
||||
@@ -57,8 +53,6 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
fit.modules.append(newMod)
|
||||
if newMod not in fit.modules:
|
||||
pyfalog.warning('Failed to append to list')
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
self.savedPosition = fit.modules.index(newMod)
|
||||
# Need to flush because checkStates sometimes relies on module->fit
|
||||
@@ -66,8 +60,6 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -77,16 +69,12 @@ class CalcAddLocalModuleCommand(wx.Command):
|
||||
if not self.subsystemCmd.Undo():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
if self.savedPosition is None:
|
||||
return False
|
||||
from .localRemove import CalcRemoveLocalModulesCommand
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition], commit=False)
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition])
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,13 +9,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeLocalModuleMutationCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, mutation, oldMutation=None, commit=True):
|
||||
def __init__(self, fitID, position, mutation, oldMutation=None):
|
||||
wx.Command.__init__(self, True, 'Change Local Module Mutation')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.mutation = mutation
|
||||
self.savedMutation = oldMutation
|
||||
self.commit = commit
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing changing of local module mutation at position {} to {} for fit ID {}'.format(
|
||||
@@ -41,8 +39,6 @@ class CalcChangeLocalModuleMutationCommand(wx.Command):
|
||||
if mutator.value != self.mutation[mutator.attrID]:
|
||||
mutator.value = self.mutation[mutator.attrID]
|
||||
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -51,6 +47,5 @@ class CalcChangeLocalModuleMutationCommand(wx.Command):
|
||||
cmd = CalcChangeLocalModuleMutationCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.position,
|
||||
mutation=self.savedMutation,
|
||||
commit=self.commit)
|
||||
mutation=self.savedMutation)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.saveddata.module import Module
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
@@ -51,7 +50,6 @@ class CalcChangeLocalModuleStatesCommand(wx.Command):
|
||||
return False
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, mainMod)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -62,5 +60,4 @@ class CalcChangeLocalModuleStatesCommand(wx.Command):
|
||||
pyfalog.debug('Reverting {} to state {} for fit ID {}'.format(mod, state, self.fitID))
|
||||
mod.state = state
|
||||
restoreCheckedStates(fit, self.savedStateCheckChanges, ignoreModPoss=self.savedStates)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -33,22 +33,19 @@ class CalcCloneLocalModuleCommand(wx.Command):
|
||||
fit.modules.replace(self.dstPosition, copyMod)
|
||||
if copyMod not in fit.modules:
|
||||
pyfalog.warning('Failed to replace module')
|
||||
eos.db.commit()
|
||||
return False
|
||||
# Need to flush because checkStates sometimes relies on module->fit
|
||||
# relationship via .owner attribute, which is handled by SQLAlchemy
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, copyMod)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undoing cloning of local module from position {} to position {} for fit ID {}'.format(self.srcPosition, self.dstPosition, self.fitID))
|
||||
from .localRemove import CalcRemoveLocalModulesCommand
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.dstPosition], commit=False)
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.dstPosition])
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -12,11 +12,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveLocalModulesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, positions, commit=True):
|
||||
def __init__(self, fitID, positions):
|
||||
wx.Command.__init__(self, True, 'Remove Module')
|
||||
self.fitID = fitID
|
||||
self.positions = positions
|
||||
self.commit = commit
|
||||
self.savedSubInfos = None
|
||||
self.savedModInfos = None
|
||||
self.savedStateCheckChanges = None
|
||||
@@ -45,8 +44,6 @@ class CalcRemoveLocalModulesCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
# If no modules were removed, report that command was not completed
|
||||
return True
|
||||
|
||||
@@ -63,8 +60,7 @@ class CalcRemoveLocalModulesCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
newModInfo=modInfo,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
results.append(cmd.Do())
|
||||
sFit.recalc(fit)
|
||||
for position, modInfo in self.savedModInfos.items():
|
||||
@@ -72,12 +68,9 @@ class CalcRemoveLocalModulesCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
newModInfo=modInfo,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
results.append(cmd.Do())
|
||||
if not any(results):
|
||||
return False
|
||||
restoreCheckedStates(fit, self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -11,7 +11,7 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, newModInfo, unloadInvalidCharges=False, ignoreRestrictions=False, commit=True):
|
||||
def __init__(self, fitID, position, newModInfo, unloadInvalidCharges=False, ignoreRestrictions=False):
|
||||
wx.Command.__init__(self, True, 'Replace Module')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
@@ -19,7 +19,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
self.oldModInfo = None
|
||||
self.unloadInvalidCharges = unloadInvalidCharges
|
||||
self.ignoreRestrictions = ignoreRestrictions
|
||||
self.commit = commit
|
||||
self.savedStateCheckChanges = None
|
||||
self.unloadedCharge = None
|
||||
|
||||
@@ -62,8 +61,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -73,12 +70,10 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
# Remove if there was no module
|
||||
if self.oldModInfo is None:
|
||||
from .localRemove import CalcRemoveLocalModulesCommand
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.position], commit=False)
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.position])
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(fit, self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Replace if there was
|
||||
oldMod = self.oldModInfo.toModule()
|
||||
@@ -91,6 +86,4 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
||||
self.Do()
|
||||
return False
|
||||
restoreCheckedStates(fit, self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -36,14 +35,11 @@ class CalcSwapLocalModuleCommand(wx.Command):
|
||||
if len(fit.modules) <= position2 or fit.modules[position2] is not mod1:
|
||||
fit.modules.replace(position1, mod1)
|
||||
fit.modules.replace(position2, mod2)
|
||||
eos.db.commit()
|
||||
return False
|
||||
fit.modules.replace(position1, mod2)
|
||||
if len(fit.modules) <= position1 or fit.modules[position1] is not mod2:
|
||||
fit.modules.free(position2)
|
||||
fit.modules.replace(position1, mod1)
|
||||
fit.modules.replace(position2, mod2)
|
||||
eos.db.commit()
|
||||
return False
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -12,13 +12,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddProjectedModuleCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, modInfo, position=None, ignoreRestrictions=False, commit=True):
|
||||
def __init__(self, fitID, modInfo, position=None, ignoreRestrictions=False):
|
||||
wx.Command.__init__(self, True)
|
||||
self.fitID = fitID
|
||||
self.newModInfo = modInfo
|
||||
self.newPosition = position
|
||||
self.ignoreRestrictions = ignoreRestrictions
|
||||
self.commit = commit
|
||||
self.oldModInfo = None
|
||||
self.oldPosition = None
|
||||
self.savedStateCheckChanges = None
|
||||
@@ -40,14 +39,10 @@ class CalcAddProjectedModuleCommand(wx.Command):
|
||||
if self.newPosition is not None:
|
||||
fit.projectedModules.insert(self.newPosition, newMod)
|
||||
if newMod not in fit.projectedModules:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
else:
|
||||
fit.projectedModules.append(newMod)
|
||||
if newMod not in fit.projectedModules:
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return False
|
||||
self.newPosition = fit.projectedModules.index(newMod)
|
||||
|
||||
@@ -56,8 +51,6 @@ class CalcAddProjectedModuleCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -67,22 +60,16 @@ class CalcAddProjectedModuleCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
modInfo=self.oldModInfo,
|
||||
position=self.oldPosition,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
from .projectedRemove import CalcRemoveProjectedModuleCommand
|
||||
cmd = CalcRemoveProjectedModuleCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.newPosition,
|
||||
commit=False)
|
||||
position=self.newPosition)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.const import FittingModuleState
|
||||
from eos.saveddata.module import Module
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
@@ -19,12 +18,11 @@ STATE_MAP = {
|
||||
|
||||
class CalcChangeProjectedModuleStatesCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, positions, proposedState, commit=True):
|
||||
def __init__(self, fitID, positions, proposedState):
|
||||
wx.Command.__init__(self, True, 'Change Projected Module States')
|
||||
self.fitID = fitID
|
||||
self.positions = positions
|
||||
self.proposedState = STATE_MAP[proposedState]
|
||||
self.commit = commit
|
||||
self.savedStates = {}
|
||||
self.savedStateCheckChanges = None
|
||||
|
||||
@@ -47,8 +45,6 @@ class CalcChangeProjectedModuleStatesCommand(wx.Command):
|
||||
return False
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -60,6 +56,4 @@ class CalcChangeProjectedModuleStatesCommand(wx.Command):
|
||||
pyfalog.debug('Reverting projected {} to state {} for fit ID {}'.format(mod, state, self.fitID))
|
||||
mod.state = state
|
||||
restoreCheckedStates(fit, self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -11,11 +11,10 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveProjectedModuleCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, commit=True):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True)
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.commit = commit
|
||||
self.savedModInfo = None
|
||||
self.savedStateCheckChanges = None
|
||||
|
||||
@@ -32,8 +31,6 @@ class CalcRemoveProjectedModuleCommand(wx.Command):
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -43,11 +40,8 @@ class CalcRemoveProjectedModuleCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
modInfo=self.savedModInfo,
|
||||
position=self.position,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -11,13 +11,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcAddProjectedFitCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, projectedFitID, amount, state=None, commit=True):
|
||||
def __init__(self, fitID, projectedFitID, amount, state=None):
|
||||
wx.Command.__init__(self, True, 'Add Projected Fit')
|
||||
self.fitID = fitID
|
||||
self.projectedFitID = projectedFitID
|
||||
self.amount = amount
|
||||
self.state = state
|
||||
self.commit = commit
|
||||
self.changeAmountCommand = None
|
||||
self.savedStateCheckChanges = None
|
||||
|
||||
@@ -40,14 +39,11 @@ class CalcAddProjectedFitCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
amount=self.amount,
|
||||
relative=True,
|
||||
commit=False)
|
||||
relative=True)
|
||||
if not self.changeAmountCommand.Do():
|
||||
return False
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
else:
|
||||
self.changeAmountCommand = None
|
||||
@@ -70,8 +66,6 @@ class CalcAddProjectedFitCommand(wx.Command):
|
||||
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -80,8 +74,6 @@ class CalcAddProjectedFitCommand(wx.Command):
|
||||
if not self.changeAmountCommand.Undo():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
# Can't find the projected fit, it must have been deleted. Just skip, as deleted fit
|
||||
# means that someone else just did exactly what we wanted to do
|
||||
@@ -91,11 +83,8 @@ class CalcAddProjectedFitCommand(wx.Command):
|
||||
cmd = CalcRemoveProjectedFitCommand(
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
amount=self.amount,
|
||||
commit=False)
|
||||
amount=self.amount)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -10,13 +9,12 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeProjectedFitAmountCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, projectedFitID, amount, relative=False, commit=True):
|
||||
def __init__(self, fitID, projectedFitID, amount, relative=False):
|
||||
wx.Command.__init__(self, True, 'Change Projected Fit Amount')
|
||||
self.fitID = fitID
|
||||
self.projectedFitID = projectedFitID
|
||||
self.amount = amount
|
||||
self.relative = relative
|
||||
self.commit = commit
|
||||
self.savedAmount = None
|
||||
|
||||
def Do(self):
|
||||
@@ -40,8 +38,6 @@ class CalcChangeProjectedFitAmountCommand(wx.Command):
|
||||
if confinedAmount == self.savedAmount:
|
||||
return False
|
||||
projectionInfo.amount = confinedAmount
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -49,6 +45,5 @@ class CalcChangeProjectedFitAmountCommand(wx.Command):
|
||||
cmd = CalcChangeProjectedFitAmountCommand(
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
amount=self.savedAmount,
|
||||
commit=self.commit)
|
||||
amount=self.savedAmount)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcChangeProjectedFitStateCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, projectedFitID, state, commit=True):
|
||||
def __init__(self, fitID, projectedFitID, state):
|
||||
wx.Command.__init__(self, True, 'Change Projected Fit State')
|
||||
self.fitID = fitID
|
||||
self.projectedFitID = projectedFitID
|
||||
self.state = state
|
||||
self.commit = commit
|
||||
self.savedState = None
|
||||
self.savedStateCheckChanges = None
|
||||
|
||||
@@ -43,8 +41,6 @@ class CalcChangeProjectedFitStateCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -53,11 +49,8 @@ class CalcChangeProjectedFitStateCommand(wx.Command):
|
||||
cmd = CalcChangeProjectedFitStateCommand(
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
state=self.savedState,
|
||||
commit=False)
|
||||
state=self.savedState)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from gui.fitCommands.helpers import restoreCheckedStates
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -11,12 +10,11 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class CalcRemoveProjectedFitCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, projectedFitID, amount, commit=True):
|
||||
def __init__(self, fitID, projectedFitID, amount):
|
||||
wx.Command.__init__(self, True, 'Add Projected Fit')
|
||||
self.fitID = fitID
|
||||
self.projectedFitID = projectedFitID
|
||||
self.amount = amount
|
||||
self.commit = commit
|
||||
self.savedState = None
|
||||
self.savedAmount = None
|
||||
self.changeAmountCommand = None
|
||||
@@ -48,14 +46,11 @@ class CalcRemoveProjectedFitCommand(wx.Command):
|
||||
self.changeAmountCommand = CalcChangeProjectedFitAmountCommand(
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
amount=remainingAmount,
|
||||
commit=False)
|
||||
amount=remainingAmount)
|
||||
if not self.changeAmountCommand.Do():
|
||||
return False
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
else:
|
||||
self.changeAmountCommand = None
|
||||
@@ -65,8 +60,6 @@ class CalcRemoveProjectedFitCommand(wx.Command):
|
||||
del fit.projectedFitDict[projectedFit.ID]
|
||||
sFit.recalc(fit)
|
||||
self.savedStateCheckChanges = sFit.checkStates(fit, None)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
@@ -75,19 +68,14 @@ class CalcRemoveProjectedFitCommand(wx.Command):
|
||||
if not self.changeAmountCommand.Undo():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
from .add import CalcAddProjectedFitCommand
|
||||
cmd = CalcAddProjectedFitCommand(
|
||||
fitID=self.fitID,
|
||||
projectedFitID=self.projectedFitID,
|
||||
amount=self.savedAmount,
|
||||
state=self.savedState,
|
||||
commit=False)
|
||||
state=self.savedState)
|
||||
if not cmd.Do():
|
||||
return False
|
||||
restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
|
||||
if self.commit:
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from eos.saveddata.mode import Mode
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
@@ -25,7 +24,6 @@ class CalcChangeShipModeCommand(wx.Command):
|
||||
item = Market.getInstance().getItem(self.itemID)
|
||||
mode = Mode(item)
|
||||
fit.mode = mode
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.booster.add import CalcAddBoosterCommand
|
||||
@@ -18,16 +19,20 @@ class GuiAddBoosterCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=BoosterInfo(itemID=self.itemID))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.booster.add import CalcAddBoosterCommand
|
||||
@@ -26,15 +27,19 @@ class GuiChangeBoosterMetaCommand(wx.Command):
|
||||
info.itemID = self.newItemID
|
||||
cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=info)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -19,21 +19,23 @@ class GuiRemoveBoostersCommand(wx.Command):
|
||||
def Do(self):
|
||||
results = []
|
||||
for position in sorted(self.positions, reverse=True):
|
||||
cmd = CalcRemoveBoosterCommand(fitID=self.fitID, position=position, commit=False)
|
||||
cmd = CalcRemoveBoosterCommand(fitID=self.fitID, position=position)
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.booster.sideEffectToggleState import CalcToggleBoosterSideEffectStateCommand
|
||||
@@ -19,16 +20,20 @@ class GuiToggleBoosterSideEffectStateCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcToggleBoosterSideEffectStateCommand(fitID=self.fitID, position=self.position, effectID=self.effectID)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.booster.toggleStates import CalcToggleBoosterStatesCommand
|
||||
@@ -19,16 +20,20 @@ class GuiToggleBoosterStatesCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcToggleBoosterStatesCommand(fitID=self.fitID, mainPosition=self.mainPosition, positions=self.positions)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.cargo.add import CalcAddCargoCommand
|
||||
@@ -18,10 +19,12 @@ class GuiAddCargoCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -2,6 +2,7 @@ import math
|
||||
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.cargo.changeAmount import CalcChangeCargoAmountCommand
|
||||
@@ -24,10 +25,12 @@ class GuiChangeCargoAmountCommand(wx.Command):
|
||||
else:
|
||||
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -32,12 +32,10 @@ class GuiChangeCargoMetasCommand(wx.Command):
|
||||
amount = cargo.amount
|
||||
cmdRemove = CalcRemoveCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=itemID, amount=math.inf),
|
||||
commit=False)
|
||||
cargoInfo=CargoInfo(itemID=itemID, amount=math.inf))
|
||||
cmdAdd = CalcAddCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=self.newItemID, amount=amount),
|
||||
commit=False)
|
||||
cargoInfo=CargoInfo(itemID=self.newItemID, amount=amount))
|
||||
results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
|
||||
@@ -22,8 +22,7 @@ class GuiRemoveCargosCommand(wx.Command):
|
||||
for itemID in self.itemIDs:
|
||||
cmd = CalcRemoveCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=itemID, amount=math.inf),
|
||||
commit=False)
|
||||
cargoInfo=CargoInfo(itemID=itemID, amount=math.inf))
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.commandFit.add import CalcAddCommandCommand
|
||||
@@ -18,16 +19,20 @@ class GuiAddCommandFitCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -19,21 +19,23 @@ class GuiRemoveCommandFitsCommand(wx.Command):
|
||||
def Do(self):
|
||||
results = []
|
||||
for commandFitID in self.commandFitIDs:
|
||||
cmd = CalcRemoveCommandFitCommand(fitID=self.fitID, commandFitID=commandFitID, commit=False)
|
||||
cmd = CalcRemoveCommandFitCommand(fitID=self.fitID, commandFitID=commandFitID)
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.commandFit.toggleStates import CalcToggleCommandFitStatesCommand
|
||||
@@ -22,16 +23,20 @@ class GuiToggleCommandFitStatesCommand(wx.Command):
|
||||
mainCommandFitID=self.mainCommandFitID,
|
||||
commandFitIDs=self.commandFitIDs)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui.builtinShipBrowser.events import FitRenamed
|
||||
from gui.fitCommands.calc.fitRename import CalcFitRenameCommand
|
||||
@@ -17,10 +18,12 @@ class GuiRenameFitCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcFitRenameCommand(fitID=self.fitID, name=self.name)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), FitRenamed(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), FitRenamed(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -25,14 +25,15 @@ class GuiToggleFittingRestrictionsCommand(wx.Command):
|
||||
results = []
|
||||
for position, mod in sorted(enumerate(fit.modules), key=lambda i: i[0], reverse=True):
|
||||
if not mod.isEmpty and not mod.fits(fit, hardpointLimit=False):
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[position], commit=False)
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[position])
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
if len(results) > 0:
|
||||
success = any(results)
|
||||
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -41,8 +42,9 @@ class GuiToggleFittingRestrictionsCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
fit.ignoreRestrictions = not fit.ignoreRestrictions
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.helpers import InternalCommandHistory
|
||||
@@ -18,14 +19,18 @@ class GuiChangeFitSystemSecurityCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcChangeFitSystemSecurityCommand(fitID=self.fitID, secStatus=self.secStatus)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -22,27 +22,29 @@ class GuiAddImplantCommand(wx.Command):
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.fitID)
|
||||
if fit.implantSource != ImplantLocation.FIT:
|
||||
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT, commit=False)
|
||||
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT)
|
||||
successSource = self.internalHistory.submit(cmd)
|
||||
else:
|
||||
successSource = False
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID), commit=False)
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID))
|
||||
successImplant = self.internalHistory.submit(cmd)
|
||||
# Acceptable behavior when we already have passed implant and just switch source, or
|
||||
# when we have source and add implant, but not if we do not change anything
|
||||
success = successSource or successImplant
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.implant.changeLocation import CalcChangeImplantLocationCommand
|
||||
@@ -18,16 +19,20 @@ class GuiChangeImplantLocationCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.source)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.implant.add import CalcAddImplantCommand
|
||||
@@ -26,15 +27,19 @@ class GuiChangeImplantMetaCommand(wx.Command):
|
||||
info.itemID = self.newItemID
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=info)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -19,21 +19,23 @@ class GuiRemoveImplantsCommand(wx.Command):
|
||||
def Do(self):
|
||||
results = []
|
||||
for position in sorted(self.positions, reverse=True):
|
||||
cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=position, commit=False)
|
||||
cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=position)
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -19,21 +19,23 @@ class GuiAddImplantSetCommand(wx.Command):
|
||||
def Do(self):
|
||||
results = []
|
||||
for itemID in self.itemIDs:
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=itemID), commit=False)
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=itemID))
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
# Some might fail, as we already might have these implants
|
||||
return any(results)
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.implant.toggleStates import CalcToggleImplantStatesCommand
|
||||
@@ -19,16 +20,20 @@ class GuiToggleImplantStatesCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcToggleImplantStatesCommand(fitID=self.fitID, mainPosition=self.mainPosition, positions=self.positions)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -28,15 +28,13 @@ class GuiRebaseItemsCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
containerName='modules',
|
||||
position=fit.modules.index(mod),
|
||||
itemID=self.rebaseMap[mod.itemID],
|
||||
commit=False)
|
||||
itemID=self.rebaseMap[mod.itemID])
|
||||
self.internalHistory.submit(cmd)
|
||||
if mod.chargeID in self.rebaseMap:
|
||||
cmd = CalcChangeModuleChargesCommand(
|
||||
fitID=self.fitID,
|
||||
projected=False,
|
||||
chargeMap={fit.modules.index(mod): self.rebaseMap[mod.chargeID]},
|
||||
commit=False)
|
||||
chargeMap={fit.modules.index(mod): self.rebaseMap[mod.chargeID]})
|
||||
self.internalHistory.submit(cmd)
|
||||
for containerName in ('drones', 'fighters', 'implants', 'boosters'):
|
||||
container = getattr(fit, containerName)
|
||||
@@ -46,8 +44,7 @@ class GuiRebaseItemsCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
containerName=containerName,
|
||||
position=container.index(obj),
|
||||
itemID=self.rebaseMap[obj.itemID],
|
||||
commit=False)
|
||||
itemID=self.rebaseMap[obj.itemID])
|
||||
self.internalHistory.submit(cmd)
|
||||
# Need to process cargo separately as we want to merge items when needed,
|
||||
# e.g. FN iron and CN iron into single stack of CN iron
|
||||
@@ -56,24 +53,24 @@ class GuiRebaseItemsCommand(wx.Command):
|
||||
amount = cargo.amount
|
||||
cmdRemove = CalcRemoveCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=cargo.itemID, amount=amount),
|
||||
commit=False)
|
||||
cargoInfo=CargoInfo(itemID=cargo.itemID, amount=amount))
|
||||
cmdAdd = CalcAddCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=self.rebaseMap[cargo.itemID], amount=amount),
|
||||
commit=False)
|
||||
cargoInfo=CargoInfo(itemID=self.rebaseMap[cargo.itemID], amount=amount))
|
||||
self.internalHistory.submitBatch(cmdRemove, cmdAdd)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(fit)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return len(self.internalHistory) > 0
|
||||
|
||||
def Undo(self):
|
||||
sFit = Fit.getInstance()
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.drone.localAdd import CalcAddLocalDroneCommand
|
||||
@@ -19,16 +20,20 @@ class GuiAddLocalDroneCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=self.amount, amountActive=0))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -2,6 +2,7 @@ import math
|
||||
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.drone.localChangeAmount import CalcChangeLocalDroneAmountCommand
|
||||
@@ -25,16 +26,20 @@ class GuiChangeLocalDroneAmountCommand(wx.Command):
|
||||
else:
|
||||
cmd = CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=math.inf)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -33,27 +33,27 @@ class GuiChangeLocalDroneMetasCommand(wx.Command):
|
||||
cmdRemove = CalcRemoveLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
amount=math.inf,
|
||||
commit=False)
|
||||
amount=math.inf)
|
||||
cmdAdd = CalcAddLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
droneInfo=info,
|
||||
forceNewStack=True,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.drone.localAdd import CalcAddLocalDroneCommand
|
||||
@@ -25,15 +26,19 @@ class GuiCloneLocalDroneCommand(wx.Command):
|
||||
info = DroneInfo.fromDrone(drone)
|
||||
cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=info, forceNewStack=True)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -23,22 +23,23 @@ class GuiRemoveLocalDronesCommand(wx.Command):
|
||||
cmd = CalcRemoveLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
amount=self.amount,
|
||||
commit=False)
|
||||
amount=self.amount)
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -31,26 +31,26 @@ class GuiSplitLocalDroneStackCommand(wx.Command):
|
||||
commands.append(CalcRemoveLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.position,
|
||||
amount=self.amount,
|
||||
commit=False))
|
||||
amount=self.amount))
|
||||
commands.append(CalcAddLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
droneInfo=info,
|
||||
forceNewStack=True,
|
||||
ignoreRestrictions=True,
|
||||
commit=False))
|
||||
ignoreRestrictions=True))
|
||||
success = self.internalHistory.submitBatch(*commands)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -32,25 +32,25 @@ class GuiMergeLocalDroneStacksCommand(wx.Command):
|
||||
commands.append(CalcChangeLocalDroneAmountCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.dstPosition,
|
||||
amount=dstDrone.amount + srcAmount,
|
||||
commit=False))
|
||||
amount=dstDrone.amount + srcAmount))
|
||||
commands.append(CalcRemoveLocalDroneCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.srcPosition,
|
||||
amount=srcAmount,
|
||||
commit=False))
|
||||
amount=srcAmount))
|
||||
success = self.internalHistory.submitBatch(*commands)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.drone.localToggleStates import CalcToggleLocalDroneStatesCommand
|
||||
@@ -22,16 +23,20 @@ class GuiToggleLocalDroneStatesCommand(wx.Command):
|
||||
mainPosition=self.mainPosition,
|
||||
positions=self.positions)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.fighter.abilityToggleStates import CalcToggleFighterAbilityStatesCommand
|
||||
@@ -25,16 +26,20 @@ class GuiToggleLocalFighterAbilityStateCommand(wx.Command):
|
||||
positions=self.positions,
|
||||
effectID=self.effectID)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.fighter.localAdd import CalcAddLocalFighterCommand
|
||||
@@ -18,16 +19,20 @@ class GuiAddLocalFighterCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=FighterInfo(itemID=self.itemID))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.fighter.changeAmount import CalcChangeFighterAmountCommand
|
||||
@@ -23,16 +24,20 @@ class GuiChangeLocalFighterAmountCommand(wx.Command):
|
||||
else:
|
||||
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -30,26 +30,26 @@ class GuiChangeLocalFighterMetasCommand(wx.Command):
|
||||
info.itemID = self.newItemID
|
||||
cmdRemove = CalcRemoveLocalFighterCommand(
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
commit=False)
|
||||
position=position)
|
||||
cmdAdd = CalcAddLocalFighterCommand(
|
||||
fitID=self.fitID,
|
||||
fighterInfo=info,
|
||||
ignoreRestrictions=True,
|
||||
commit=False)
|
||||
ignoreRestrictions=True)
|
||||
results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -19,21 +19,23 @@ class GuiRemoveLocalFightersCommand(wx.Command):
|
||||
def Do(self):
|
||||
results = []
|
||||
for position in sorted(self.positions, reverse=True):
|
||||
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=position, commit=False)
|
||||
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=position)
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.fighter.localToggleStates import CalcToggleLocalFighterStatesCommand
|
||||
@@ -22,16 +23,20 @@ class GuiToggleLocalFighterStatesCommand(wx.Command):
|
||||
mainPosition=self.mainPosition,
|
||||
positions=self.positions)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localAdd import CalcAddLocalModuleCommand
|
||||
@@ -19,9 +20,11 @@ class GuiAddLocalModuleCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=ModuleInfo(itemID=self.itemID))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.itemID)
|
||||
@@ -34,8 +37,10 @@ class GuiAddLocalModuleCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.itemID)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.changeCharges import CalcChangeModuleChargesCommand
|
||||
@@ -19,16 +20,20 @@ class GuiChangeLocalModuleChargesCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcChangeModuleChargesCommand(fitID=self.fitID, projected=False, chargeMap={p: self.chargeItemID for p in self.positions})
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -37,15 +37,15 @@ class GuiChangeLocalModuleMetasCommand(wx.Command):
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
newModInfo=info,
|
||||
unloadInvalidCharges=True,
|
||||
commit=False)
|
||||
unloadInvalidCharges=True)
|
||||
commands.append(cmd)
|
||||
if not commands:
|
||||
return False
|
||||
success = self.internalHistory.submitBatch(*commands)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
events = []
|
||||
if success and self.replacedItemIDs:
|
||||
events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.replacedItemIDs))
|
||||
@@ -62,9 +62,10 @@ class GuiChangeLocalModuleMetasCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
events = []
|
||||
if success:
|
||||
events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.newItemID))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localChangeMutation import CalcChangeLocalModuleMutationCommand
|
||||
@@ -24,16 +25,20 @@ class GuiChangeLocalModuleMutationCommand(wx.Command):
|
||||
mutation=self.mutation,
|
||||
oldMutation=self.oldMutation)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.changeSpool import CalcChangeModuleSpoolCommand
|
||||
@@ -25,16 +26,20 @@ class GuiChangeLocalModuleSpoolCommand(wx.Command):
|
||||
spoolType=self.spoolType,
|
||||
spoolAmount=self.spoolAmount)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localChangeStates import CalcChangeLocalModuleStatesCommand
|
||||
@@ -25,9 +26,11 @@ class GuiChangeLocalModuleStatesCommand(wx.Command):
|
||||
positions=self.positions,
|
||||
click=self.click)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -36,7 +39,9 @@ class GuiChangeLocalModuleStatesCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localClone import CalcCloneLocalModuleCommand
|
||||
@@ -24,9 +25,11 @@ class GuiCloneLocalModuleCommand(wx.Command):
|
||||
sFit = Fit.getInstance()
|
||||
cmd = CalcCloneLocalModuleCommand(fitID=self.fitID, srcPosition=self.srcPosition, dstPosition=self.dstPosition)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
fit = sFit.getFit(self.fitID)
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
self.savedItemID = fit.modules[self.srcPosition].itemID
|
||||
if success and self.savedItemID is not None:
|
||||
event = GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.savedItemID)
|
||||
@@ -40,8 +43,10 @@ class GuiCloneLocalModuleCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
if success and self.savedItemID is not None:
|
||||
event = GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.savedItemID)
|
||||
else:
|
||||
|
||||
@@ -21,14 +21,15 @@ class GuiFillWithNewLocalModulesCommand(wx.Command):
|
||||
info = ModuleInfo(itemID=self.itemID)
|
||||
added_modules = 0
|
||||
while True:
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info, commit=False)
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info)
|
||||
if not self.internalHistory.submit(cmd):
|
||||
break
|
||||
added_modules += 1
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
success = added_modules > 0
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
@@ -42,9 +43,10 @@ class GuiFillWithNewLocalModulesCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.itemID)
|
||||
|
||||
@@ -26,13 +26,14 @@ class GuiFillWithClonedLocalModulesCommand(wx.Command):
|
||||
info = ModuleInfo.fromModule(mod)
|
||||
added_modules = 0
|
||||
while True:
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info, commit=False)
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info)
|
||||
if not self.internalHistory.submit(cmd):
|
||||
break
|
||||
added_modules += 1
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
success = added_modules > 0
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
@@ -46,9 +47,10 @@ class GuiFillWithClonedLocalModulesCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.savedItemID)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localReplace import CalcReplaceLocalModuleCommand
|
||||
@@ -38,15 +39,19 @@ class GuiConvertMutatedLocalModuleCommand(wx.Command):
|
||||
spoolType=mod.spoolType,
|
||||
spoolAmount=mod.spoolAmount))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localAdd import CalcAddLocalModuleCommand
|
||||
@@ -23,9 +24,11 @@ class GuiImportLocalMutatedModuleCommand(wx.Command):
|
||||
def Do(self):
|
||||
cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=self.newModInfo)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.newModInfo.itemID))
|
||||
@@ -36,8 +39,10 @@ class GuiImportLocalMutatedModuleCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.newModInfo.itemID))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localReplace import CalcReplaceLocalModuleCommand
|
||||
@@ -33,15 +34,19 @@ class GuiRevertMutatedLocalModuleCommand(wx.Command):
|
||||
spoolType=mod.spoolType,
|
||||
spoolAmount=mod.spoolAmount))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.module.localRemove import CalcRemoveLocalModulesCommand
|
||||
@@ -23,8 +24,10 @@ class GuiRemoveLocalModuleCommand(wx.Command):
|
||||
self.savedTypeIDs = {m.itemID for m in fit.modules if not m.isEmpty}
|
||||
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=self.positions)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.savedTypeIDs)
|
||||
@@ -37,8 +40,10 @@ class GuiRemoveLocalModuleCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.savedTypeIDs)
|
||||
|
||||
@@ -24,14 +24,14 @@ class GuiReplaceLocalModuleCommand(wx.Command):
|
||||
cmd = CalcReplaceLocalModuleCommand(
|
||||
fitID=self.fitID,
|
||||
position=position,
|
||||
newModInfo=ModuleInfo(itemID=self.itemID),
|
||||
commit=False)
|
||||
newModInfo=ModuleInfo(itemID=self.itemID))
|
||||
results.append(self.internalHistory.submit(cmd))
|
||||
success = any(results)
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
self.savedRemovedDummies = sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='modadd', typeID=self.itemID)
|
||||
@@ -44,9 +44,10 @@ class GuiReplaceLocalModuleCommand(wx.Command):
|
||||
fit = sFit.getFit(self.fitID)
|
||||
restoreRemovedDummies(fit, self.savedRemovedDummies)
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
eos.db.flush()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(
|
||||
gui.mainFrame.MainFrame.getInstance(),
|
||||
GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.itemID)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user