From bc84c20cb235e4694bf0a2fe79f412e196d0c9b3 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 27 May 2019 15:35:14 +0300 Subject: [PATCH] Update database with actual contents before and after fill, also do it in UI commands --- gui/fitCommands/calc/booster/add.py | 16 +++------ gui/fitCommands/calc/booster/remove.py | 9 ++--- .../calc/booster/sideEffectToggleState.py | 2 -- gui/fitCommands/calc/booster/toggleStates.py | 2 -- gui/fitCommands/calc/cargo/add.py | 10 ++---- gui/fitCommands/calc/cargo/changeAmount.py | 2 -- gui/fitCommands/calc/cargo/remove.py | 10 ++---- gui/fitCommands/calc/commandFit/add.py | 7 ++-- gui/fitCommands/calc/commandFit/remove.py | 9 ++--- .../calc/commandFit/toggleStates.py | 2 -- gui/fitCommands/calc/drone/localAdd.py | 16 ++------- .../calc/drone/localChangeAmount.py | 8 +---- gui/fitCommands/calc/drone/localRemove.py | 10 +----- .../calc/drone/localToggleStates.py | 1 - gui/fitCommands/calc/drone/projectedAdd.py | 16 ++------- .../calc/drone/projectedChangeAmount.py | 5 --- .../calc/drone/projectedChangeState.py | 8 ++--- gui/fitCommands/calc/drone/projectedRemove.py | 10 ++---- .../calc/fighter/abilityToggleStates.py | 2 -- gui/fitCommands/calc/fighter/changeAmount.py | 3 -- gui/fitCommands/calc/fighter/localAdd.py | 12 ++----- gui/fitCommands/calc/fighter/localRemove.py | 9 ++--- .../calc/fighter/localToggleStates.py | 1 - gui/fitCommands/calc/fighter/projectedAdd.py | 12 ++----- .../calc/fighter/projectedChangeState.py | 9 ++--- .../calc/fighter/projectedRemove.py | 9 ++--- gui/fitCommands/calc/fitRename.py | 2 -- gui/fitCommands/calc/fitSystemSecurity.py | 2 -- gui/fitCommands/calc/implant/add.py | 17 +++------- .../calc/implant/changeLocation.py | 8 ++--- gui/fitCommands/calc/implant/remove.py | 9 ++--- gui/fitCommands/calc/implant/toggleStates.py | 2 -- gui/fitCommands/calc/itemRebase.py | 9 ++--- gui/fitCommands/calc/module/changeCharges.py | 9 ++--- gui/fitCommands/calc/module/changeSpool.py | 2 -- gui/fitCommands/calc/module/localAdd.py | 18 ++-------- .../calc/module/localChangeMutation.py | 9 ++--- .../calc/module/localChangeStates.py | 3 -- gui/fitCommands/calc/module/localClone.py | 5 +-- gui/fitCommands/calc/module/localRemove.py | 13 ++------ gui/fitCommands/calc/module/localReplace.py | 11 ++----- gui/fitCommands/calc/module/localSwap.py | 4 --- gui/fitCommands/calc/module/projectedAdd.py | 19 ++--------- .../calc/module/projectedChangeStates.py | 8 +---- .../calc/module/projectedRemove.py | 10 ++---- gui/fitCommands/calc/projectedFit/add.py | 17 ++-------- .../calc/projectedFit/changeAmount.py | 9 ++--- .../calc/projectedFit/changeState.py | 11 ++----- gui/fitCommands/calc/projectedFit/remove.py | 18 ++-------- gui/fitCommands/calc/shipModeChange.py | 2 -- gui/fitCommands/gui/booster/add.py | 5 +++ gui/fitCommands/gui/booster/changeMeta.py | 5 +++ gui/fitCommands/gui/booster/remove.py | 8 +++-- .../gui/booster/sideEffectToggleState.py | 5 +++ gui/fitCommands/gui/booster/toggleStates.py | 5 +++ gui/fitCommands/gui/cargo/add.py | 3 ++ gui/fitCommands/gui/cargo/changeAmount.py | 3 ++ gui/fitCommands/gui/cargo/changeMetas.py | 6 ++-- gui/fitCommands/gui/cargo/remove.py | 3 +- gui/fitCommands/gui/commandFit/add.py | 5 +++ gui/fitCommands/gui/commandFit/remove.py | 8 +++-- .../gui/commandFit/toggleStates.py | 5 +++ gui/fitCommands/gui/fitRename.py | 3 ++ gui/fitCommands/gui/fitRestrictionToggle.py | 8 +++-- gui/fitCommands/gui/fitSystemSecurity.py | 5 +++ gui/fitCommands/gui/implant/add.py | 10 +++--- gui/fitCommands/gui/implant/changeLocation.py | 5 +++ gui/fitCommands/gui/implant/changeMeta.py | 5 +++ gui/fitCommands/gui/implant/remove.py | 8 +++-- gui/fitCommands/gui/implant/setAdd.py | 8 +++-- gui/fitCommands/gui/implant/toggleStates.py | 5 +++ gui/fitCommands/gui/itemsRebase.py | 21 +++++------- gui/fitCommands/gui/localDrone/add.py | 5 +++ .../gui/localDrone/changeAmount.py | 5 +++ gui/fitCommands/gui/localDrone/changeMetas.py | 12 +++---- gui/fitCommands/gui/localDrone/clone.py | 5 +++ gui/fitCommands/gui/localDrone/remove.py | 9 ++--- gui/fitCommands/gui/localDrone/stackSplit.py | 12 +++---- gui/fitCommands/gui/localDrone/stacksMerge.py | 12 +++---- .../gui/localDrone/toggleStates.py | 5 +++ .../gui/localFighter/abilityToggleState.py | 5 +++ gui/fitCommands/gui/localFighter/add.py | 5 +++ .../gui/localFighter/changeAmount.py | 5 +++ .../gui/localFighter/changeMetas.py | 12 +++---- gui/fitCommands/gui/localFighter/remove.py | 8 +++-- .../gui/localFighter/toggleStates.py | 5 +++ gui/fitCommands/gui/localModule/add.py | 5 +++ .../gui/localModule/changeCharges.py | 5 +++ .../gui/localModule/changeMetas.py | 9 ++--- .../gui/localModule/changeMutation.py | 5 +++ .../gui/localModule/changeSpool.py | 5 +++ .../gui/localModule/changeStates.py | 5 +++ gui/fitCommands/gui/localModule/clone.py | 5 +++ gui/fitCommands/gui/localModule/fillAdd.py | 8 +++-- gui/fitCommands/gui/localModule/fillClone.py | 8 +++-- .../gui/localModule/mutatedConvert.py | 5 +++ .../gui/localModule/mutatedImport.py | 5 +++ .../gui/localModule/mutatedRevert.py | 5 +++ gui/fitCommands/gui/localModule/remove.py | 5 +++ gui/fitCommands/gui/localModule/replace.py | 9 ++--- gui/fitCommands/gui/localModule/swap.py | 3 ++ .../localModuleCargo/cargoToLocalModule.py | 33 ++++++++----------- .../localModuleCargo/localModuleToCargo.py | 33 ++++++++----------- gui/fitCommands/gui/projectedChangeStates.py | 18 +++++----- gui/fitCommands/gui/projectedDrone/add.py | 5 +++ .../gui/projectedDrone/changeAmount.py | 5 +++ .../gui/projectedDrone/changeMetas.py | 10 +++--- .../projectedFighter/abilityToggleState.py | 5 +++ gui/fitCommands/gui/projectedFighter/add.py | 5 +++ .../gui/projectedFighter/changeAmount.py | 5 +++ .../gui/projectedFighter/changeMetas.py | 10 +++--- gui/fitCommands/gui/projectedFit/add.py | 5 +++ .../gui/projectedFit/changeAmount.py | 5 +++ gui/fitCommands/gui/projectedModule/add.py | 5 +++ .../gui/projectedModule/changeCharges.py | 5 +++ .../gui/projectedModule/changeMetas.py | 10 +++--- .../gui/projectedModule/changeSpool.py | 5 +++ gui/fitCommands/gui/projectedRemove.py | 16 ++++----- gui/fitCommands/gui/shipModeChange.py | 9 +++-- 119 files changed, 441 insertions(+), 496 deletions(-) diff --git a/gui/fitCommands/calc/booster/add.py b/gui/fitCommands/calc/booster/add.py index aa0c89443..5b01afd08 100644 --- a/gui/fitCommands/calc/booster/add.py +++ b/gui/fitCommands/calc/booster/add.py @@ -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() diff --git a/gui/fitCommands/calc/booster/remove.py b/gui/fitCommands/calc/booster/remove.py index d05db275c..c01b18f18 100644 --- a/gui/fitCommands/calc/booster/remove.py +++ b/gui/fitCommands/calc/booster/remove.py @@ -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() diff --git a/gui/fitCommands/calc/booster/sideEffectToggleState.py b/gui/fitCommands/calc/booster/sideEffectToggleState.py index 29be8441d..9ecf1e178 100644 --- a/gui/fitCommands/calc/booster/sideEffectToggleState.py +++ b/gui/fitCommands/calc/booster/sideEffectToggleState.py @@ -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): diff --git a/gui/fitCommands/calc/booster/toggleStates.py b/gui/fitCommands/calc/booster/toggleStates.py index 36ebde67d..217602307 100644 --- a/gui/fitCommands/calc/booster/toggleStates.py +++ b/gui/fitCommands/calc/booster/toggleStates.py @@ -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): diff --git a/gui/fitCommands/calc/cargo/add.py b/gui/fitCommands/calc/cargo/add.py index 260451469..5a14ce2ad 100644 --- a/gui/fitCommands/calc/cargo/add.py +++ b/gui/fitCommands/calc/cargo/add.py @@ -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() diff --git a/gui/fitCommands/calc/cargo/changeAmount.py b/gui/fitCommands/calc/cargo/changeAmount.py index 7caa00f86..7fda7115b 100644 --- a/gui/fitCommands/calc/cargo/changeAmount.py +++ b/gui/fitCommands/calc/cargo/changeAmount.py @@ -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): diff --git a/gui/fitCommands/calc/cargo/remove.py b/gui/fitCommands/calc/cargo/remove.py index b27bf1194..e141e0835 100644 --- a/gui/fitCommands/calc/cargo/remove.py +++ b/gui/fitCommands/calc/cargo/remove.py @@ -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() diff --git a/gui/fitCommands/calc/commandFit/add.py b/gui/fitCommands/calc/commandFit/add.py index f366633d6..2929c5219 100644 --- a/gui/fitCommands/calc/commandFit/add.py +++ b/gui/fitCommands/calc/commandFit/add.py @@ -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() diff --git a/gui/fitCommands/calc/commandFit/remove.py b/gui/fitCommands/calc/commandFit/remove.py index e3a7fc457..5ddd56845 100644 --- a/gui/fitCommands/calc/commandFit/remove.py +++ b/gui/fitCommands/calc/commandFit/remove.py @@ -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() diff --git a/gui/fitCommands/calc/commandFit/toggleStates.py b/gui/fitCommands/calc/commandFit/toggleStates.py index 77d21a385..609aa9fd5 100644 --- a/gui/fitCommands/calc/commandFit/toggleStates.py +++ b/gui/fitCommands/calc/commandFit/toggleStates.py @@ -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): diff --git a/gui/fitCommands/calc/drone/localAdd.py b/gui/fitCommands/calc/drone/localAdd.py index c24db3af8..585916685 100644 --- a/gui/fitCommands/calc/drone/localAdd.py +++ b/gui/fitCommands/calc/drone/localAdd.py @@ -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() diff --git a/gui/fitCommands/calc/drone/localChangeAmount.py b/gui/fitCommands/calc/drone/localChangeAmount.py index f0836362a..2f1c84050 100644 --- a/gui/fitCommands/calc/drone/localChangeAmount.py +++ b/gui/fitCommands/calc/drone/localChangeAmount.py @@ -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 diff --git a/gui/fitCommands/calc/drone/localRemove.py b/gui/fitCommands/calc/drone/localRemove.py index 5425a934d..1ff26f4a3 100644 --- a/gui/fitCommands/calc/drone/localRemove.py +++ b/gui/fitCommands/calc/drone/localRemove.py @@ -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 diff --git a/gui/fitCommands/calc/drone/localToggleStates.py b/gui/fitCommands/calc/drone/localToggleStates.py index eccd98006..b014d6a8a 100644 --- a/gui/fitCommands/calc/drone/localToggleStates.py +++ b/gui/fitCommands/calc/drone/localToggleStates.py @@ -42,7 +42,6 @@ class CalcToggleLocalDroneStatesCommand(wx.Command): if drone.amountActive == 0: drone.amountActive = drone.amount - eos.db.commit() return True def Undo(self): diff --git a/gui/fitCommands/calc/drone/projectedAdd.py b/gui/fitCommands/calc/drone/projectedAdd.py index d54bc1447..ea68a7f07 100644 --- a/gui/fitCommands/calc/drone/projectedAdd.py +++ b/gui/fitCommands/calc/drone/projectedAdd.py @@ -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() diff --git a/gui/fitCommands/calc/drone/projectedChangeAmount.py b/gui/fitCommands/calc/drone/projectedChangeAmount.py index b7b24506d..0f47bb095 100644 --- a/gui/fitCommands/calc/drone/projectedChangeAmount.py +++ b/gui/fitCommands/calc/drone/projectedChangeAmount.py @@ -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 diff --git a/gui/fitCommands/calc/drone/projectedChangeState.py b/gui/fitCommands/calc/drone/projectedChangeState.py index 67433f0d8..1443a57df 100644 --- a/gui/fitCommands/calc/drone/projectedChangeState.py +++ b/gui/fitCommands/calc/drone/projectedChangeState.py @@ -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() diff --git a/gui/fitCommands/calc/drone/projectedRemove.py b/gui/fitCommands/calc/drone/projectedRemove.py index 091ddc0ee..fdc1f4705 100644 --- a/gui/fitCommands/calc/drone/projectedRemove.py +++ b/gui/fitCommands/calc/drone/projectedRemove.py @@ -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() diff --git a/gui/fitCommands/calc/fighter/abilityToggleStates.py b/gui/fitCommands/calc/fighter/abilityToggleStates.py index 2a7e52947..85203eaec 100644 --- a/gui/fitCommands/calc/fighter/abilityToggleStates.py +++ b/gui/fitCommands/calc/fighter/abilityToggleStates.py @@ -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): diff --git a/gui/fitCommands/calc/fighter/changeAmount.py b/gui/fitCommands/calc/fighter/changeAmount.py index 59047e654..0d481f7d8 100644 --- a/gui/fitCommands/calc/fighter/changeAmount.py +++ b/gui/fitCommands/calc/fighter/changeAmount.py @@ -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): diff --git a/gui/fitCommands/calc/fighter/localAdd.py b/gui/fitCommands/calc/fighter/localAdd.py index 39e2103d1..d5e305bc6 100644 --- a/gui/fitCommands/calc/fighter/localAdd.py +++ b/gui/fitCommands/calc/fighter/localAdd.py @@ -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 diff --git a/gui/fitCommands/calc/fighter/localRemove.py b/gui/fitCommands/calc/fighter/localRemove.py index c3c1a0c5d..923bb9801 100644 --- a/gui/fitCommands/calc/fighter/localRemove.py +++ b/gui/fitCommands/calc/fighter/localRemove.py @@ -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() diff --git a/gui/fitCommands/calc/fighter/localToggleStates.py b/gui/fitCommands/calc/fighter/localToggleStates.py index 57c7df996..599c8d702 100644 --- a/gui/fitCommands/calc/fighter/localToggleStates.py +++ b/gui/fitCommands/calc/fighter/localToggleStates.py @@ -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): diff --git a/gui/fitCommands/calc/fighter/projectedAdd.py b/gui/fitCommands/calc/fighter/projectedAdd.py index 714ed9143..7132f7a78 100644 --- a/gui/fitCommands/calc/fighter/projectedAdd.py +++ b/gui/fitCommands/calc/fighter/projectedAdd.py @@ -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() diff --git a/gui/fitCommands/calc/fighter/projectedChangeState.py b/gui/fitCommands/calc/fighter/projectedChangeState.py index 65765db6d..4a00946d5 100644 --- a/gui/fitCommands/calc/fighter/projectedChangeState.py +++ b/gui/fitCommands/calc/fighter/projectedChangeState.py @@ -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() diff --git a/gui/fitCommands/calc/fighter/projectedRemove.py b/gui/fitCommands/calc/fighter/projectedRemove.py index 1f34af8a0..ef27c0834 100644 --- a/gui/fitCommands/calc/fighter/projectedRemove.py +++ b/gui/fitCommands/calc/fighter/projectedRemove.py @@ -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() diff --git a/gui/fitCommands/calc/fitRename.py b/gui/fitCommands/calc/fitRename.py index edd4051d9..c620bf4ab 100644 --- a/gui/fitCommands/calc/fitRename.py +++ b/gui/fitCommands/calc/fitRename.py @@ -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): diff --git a/gui/fitCommands/calc/fitSystemSecurity.py b/gui/fitCommands/calc/fitSystemSecurity.py index d43918b38..30ccc39fc 100644 --- a/gui/fitCommands/calc/fitSystemSecurity.py +++ b/gui/fitCommands/calc/fitSystemSecurity.py @@ -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): diff --git a/gui/fitCommands/calc/implant/add.py b/gui/fitCommands/calc/implant/add.py index 5418ad7ad..99de50250 100644 --- a/gui/fitCommands/calc/implant/add.py +++ b/gui/fitCommands/calc/implant/add.py @@ -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() diff --git a/gui/fitCommands/calc/implant/changeLocation.py b/gui/fitCommands/calc/implant/changeLocation.py index b0e67d7d2..e8c16995c 100644 --- a/gui/fitCommands/calc/implant/changeLocation.py +++ b/gui/fitCommands/calc/implant/changeLocation.py @@ -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() diff --git a/gui/fitCommands/calc/implant/remove.py b/gui/fitCommands/calc/implant/remove.py index 508eab50d..e10148234 100644 --- a/gui/fitCommands/calc/implant/remove.py +++ b/gui/fitCommands/calc/implant/remove.py @@ -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() diff --git a/gui/fitCommands/calc/implant/toggleStates.py b/gui/fitCommands/calc/implant/toggleStates.py index 42df17d4b..26a80bed0 100644 --- a/gui/fitCommands/calc/implant/toggleStates.py +++ b/gui/fitCommands/calc/implant/toggleStates.py @@ -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): diff --git a/gui/fitCommands/calc/itemRebase.py b/gui/fitCommands/calc/itemRebase.py index b03b7e3c4..3bcbeccca 100644 --- a/gui/fitCommands/calc/itemRebase.py +++ b/gui/fitCommands/calc/itemRebase.py @@ -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() diff --git a/gui/fitCommands/calc/module/changeCharges.py b/gui/fitCommands/calc/module/changeCharges.py index 7bf720798..ae9278260 100644 --- a/gui/fitCommands/calc/module/changeCharges.py +++ b/gui/fitCommands/calc/module/changeCharges.py @@ -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) diff --git a/gui/fitCommands/calc/module/changeSpool.py b/gui/fitCommands/calc/module/changeSpool.py index c00aff37a..ce9351c3d 100644 --- a/gui/fitCommands/calc/module/changeSpool.py +++ b/gui/fitCommands/calc/module/changeSpool.py @@ -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): diff --git a/gui/fitCommands/calc/module/localAdd.py b/gui/fitCommands/calc/module/localAdd.py index 9aa34fcee..7bc29d8e1 100644 --- a/gui/fitCommands/calc/module/localAdd.py +++ b/gui/fitCommands/calc/module/localAdd.py @@ -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 diff --git a/gui/fitCommands/calc/module/localChangeMutation.py b/gui/fitCommands/calc/module/localChangeMutation.py index 32ce40759..cc23b2a4b 100644 --- a/gui/fitCommands/calc/module/localChangeMutation.py +++ b/gui/fitCommands/calc/module/localChangeMutation.py @@ -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() diff --git a/gui/fitCommands/calc/module/localChangeStates.py b/gui/fitCommands/calc/module/localChangeStates.py index 2ec469860..265616544 100644 --- a/gui/fitCommands/calc/module/localChangeStates.py +++ b/gui/fitCommands/calc/module/localChangeStates.py @@ -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 diff --git a/gui/fitCommands/calc/module/localClone.py b/gui/fitCommands/calc/module/localClone.py index 36d3334c0..d6c8a7bdc 100644 --- a/gui/fitCommands/calc/module/localClone.py +++ b/gui/fitCommands/calc/module/localClone.py @@ -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 diff --git a/gui/fitCommands/calc/module/localRemove.py b/gui/fitCommands/calc/module/localRemove.py index f477529cf..673f2c639 100644 --- a/gui/fitCommands/calc/module/localRemove.py +++ b/gui/fitCommands/calc/module/localRemove.py @@ -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 diff --git a/gui/fitCommands/calc/module/localReplace.py b/gui/fitCommands/calc/module/localReplace.py index fa485ae9f..676749aef 100644 --- a/gui/fitCommands/calc/module/localReplace.py +++ b/gui/fitCommands/calc/module/localReplace.py @@ -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 diff --git a/gui/fitCommands/calc/module/localSwap.py b/gui/fitCommands/calc/module/localSwap.py index 580e7fc48..1610399af 100644 --- a/gui/fitCommands/calc/module/localSwap.py +++ b/gui/fitCommands/calc/module/localSwap.py @@ -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 diff --git a/gui/fitCommands/calc/module/projectedAdd.py b/gui/fitCommands/calc/module/projectedAdd.py index 9d23e6a26..6465b6398 100644 --- a/gui/fitCommands/calc/module/projectedAdd.py +++ b/gui/fitCommands/calc/module/projectedAdd.py @@ -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 diff --git a/gui/fitCommands/calc/module/projectedChangeStates.py b/gui/fitCommands/calc/module/projectedChangeStates.py index 9a8f81830..8f742b1c1 100644 --- a/gui/fitCommands/calc/module/projectedChangeStates.py +++ b/gui/fitCommands/calc/module/projectedChangeStates.py @@ -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 diff --git a/gui/fitCommands/calc/module/projectedRemove.py b/gui/fitCommands/calc/module/projectedRemove.py index 8740d5101..a561f7f43 100644 --- a/gui/fitCommands/calc/module/projectedRemove.py +++ b/gui/fitCommands/calc/module/projectedRemove.py @@ -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 diff --git a/gui/fitCommands/calc/projectedFit/add.py b/gui/fitCommands/calc/projectedFit/add.py index 809018039..d77d32c0b 100644 --- a/gui/fitCommands/calc/projectedFit/add.py +++ b/gui/fitCommands/calc/projectedFit/add.py @@ -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 diff --git a/gui/fitCommands/calc/projectedFit/changeAmount.py b/gui/fitCommands/calc/projectedFit/changeAmount.py index 9ac721004..937bd98c9 100644 --- a/gui/fitCommands/calc/projectedFit/changeAmount.py +++ b/gui/fitCommands/calc/projectedFit/changeAmount.py @@ -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() diff --git a/gui/fitCommands/calc/projectedFit/changeState.py b/gui/fitCommands/calc/projectedFit/changeState.py index 8fb2f4671..b9311fb3b 100644 --- a/gui/fitCommands/calc/projectedFit/changeState.py +++ b/gui/fitCommands/calc/projectedFit/changeState.py @@ -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 diff --git a/gui/fitCommands/calc/projectedFit/remove.py b/gui/fitCommands/calc/projectedFit/remove.py index 73b05ec62..56194cb41 100644 --- a/gui/fitCommands/calc/projectedFit/remove.py +++ b/gui/fitCommands/calc/projectedFit/remove.py @@ -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 diff --git a/gui/fitCommands/calc/shipModeChange.py b/gui/fitCommands/calc/shipModeChange.py index 3aa284d29..5c180c103 100644 --- a/gui/fitCommands/calc/shipModeChange.py +++ b/gui/fitCommands/calc/shipModeChange.py @@ -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): diff --git a/gui/fitCommands/gui/booster/add.py b/gui/fitCommands/gui/booster/add.py index 9c8db0b00..50f3788f4 100644 --- a/gui/fitCommands/gui/booster/add.py +++ b/gui/fitCommands/gui/booster/add.py @@ -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 diff --git a/gui/fitCommands/gui/booster/changeMeta.py b/gui/fitCommands/gui/booster/changeMeta.py index 3167993ec..e69befba3 100644 --- a/gui/fitCommands/gui/booster/changeMeta.py +++ b/gui/fitCommands/gui/booster/changeMeta.py @@ -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 diff --git a/gui/fitCommands/gui/booster/remove.py b/gui/fitCommands/gui/booster/remove.py index 2732938c3..81e86b55f 100644 --- a/gui/fitCommands/gui/booster/remove.py +++ b/gui/fitCommands/gui/booster/remove.py @@ -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 diff --git a/gui/fitCommands/gui/booster/sideEffectToggleState.py b/gui/fitCommands/gui/booster/sideEffectToggleState.py index bffb6741c..f5048c778 100644 --- a/gui/fitCommands/gui/booster/sideEffectToggleState.py +++ b/gui/fitCommands/gui/booster/sideEffectToggleState.py @@ -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 diff --git a/gui/fitCommands/gui/booster/toggleStates.py b/gui/fitCommands/gui/booster/toggleStates.py index 8b2d6b469..e1b591906 100644 --- a/gui/fitCommands/gui/booster/toggleStates.py +++ b/gui/fitCommands/gui/booster/toggleStates.py @@ -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 diff --git a/gui/fitCommands/gui/cargo/add.py b/gui/fitCommands/gui/cargo/add.py index 0ac391391..77c725c7e 100644 --- a/gui/fitCommands/gui/cargo/add.py +++ b/gui/fitCommands/gui/cargo/add.py @@ -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 diff --git a/gui/fitCommands/gui/cargo/changeAmount.py b/gui/fitCommands/gui/cargo/changeAmount.py index b93fbb2f5..7fcc017c3 100644 --- a/gui/fitCommands/gui/cargo/changeAmount.py +++ b/gui/fitCommands/gui/cargo/changeAmount.py @@ -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 diff --git a/gui/fitCommands/gui/cargo/changeMetas.py b/gui/fitCommands/gui/cargo/changeMetas.py index 4daacdabc..eb457406a 100644 --- a/gui/fitCommands/gui/cargo/changeMetas.py +++ b/gui/fitCommands/gui/cargo/changeMetas.py @@ -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() diff --git a/gui/fitCommands/gui/cargo/remove.py b/gui/fitCommands/gui/cargo/remove.py index f80a537d5..b3f93d932 100644 --- a/gui/fitCommands/gui/cargo/remove.py +++ b/gui/fitCommands/gui/cargo/remove.py @@ -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() diff --git a/gui/fitCommands/gui/commandFit/add.py b/gui/fitCommands/gui/commandFit/add.py index 88d4b792d..0cb05cfc2 100644 --- a/gui/fitCommands/gui/commandFit/add.py +++ b/gui/fitCommands/gui/commandFit/add.py @@ -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 diff --git a/gui/fitCommands/gui/commandFit/remove.py b/gui/fitCommands/gui/commandFit/remove.py index 4fefc2985..60feeabe0 100644 --- a/gui/fitCommands/gui/commandFit/remove.py +++ b/gui/fitCommands/gui/commandFit/remove.py @@ -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 diff --git a/gui/fitCommands/gui/commandFit/toggleStates.py b/gui/fitCommands/gui/commandFit/toggleStates.py index 3cbc90330..f4409816c 100644 --- a/gui/fitCommands/gui/commandFit/toggleStates.py +++ b/gui/fitCommands/gui/commandFit/toggleStates.py @@ -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 diff --git a/gui/fitCommands/gui/fitRename.py b/gui/fitCommands/gui/fitRename.py index b8b118ad4..c3d0893f1 100644 --- a/gui/fitCommands/gui/fitRename.py +++ b/gui/fitCommands/gui/fitRename.py @@ -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 diff --git a/gui/fitCommands/gui/fitRestrictionToggle.py b/gui/fitCommands/gui/fitRestrictionToggle.py index b9b0d788f..43f791db5 100644 --- a/gui/fitCommands/gui/fitRestrictionToggle.py +++ b/gui/fitCommands/gui/fitRestrictionToggle.py @@ -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 diff --git a/gui/fitCommands/gui/fitSystemSecurity.py b/gui/fitCommands/gui/fitSystemSecurity.py index 5f17230a7..9173bed6d 100644 --- a/gui/fitCommands/gui/fitSystemSecurity.py +++ b/gui/fitCommands/gui/fitSystemSecurity.py @@ -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 diff --git a/gui/fitCommands/gui/implant/add.py b/gui/fitCommands/gui/implant/add.py index 9acfae7eb..81a3e279e 100644 --- a/gui/fitCommands/gui/implant/add.py +++ b/gui/fitCommands/gui/implant/add.py @@ -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 diff --git a/gui/fitCommands/gui/implant/changeLocation.py b/gui/fitCommands/gui/implant/changeLocation.py index e87471add..1c7c839a3 100644 --- a/gui/fitCommands/gui/implant/changeLocation.py +++ b/gui/fitCommands/gui/implant/changeLocation.py @@ -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 diff --git a/gui/fitCommands/gui/implant/changeMeta.py b/gui/fitCommands/gui/implant/changeMeta.py index 7d778343c..5964c7c3b 100644 --- a/gui/fitCommands/gui/implant/changeMeta.py +++ b/gui/fitCommands/gui/implant/changeMeta.py @@ -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 diff --git a/gui/fitCommands/gui/implant/remove.py b/gui/fitCommands/gui/implant/remove.py index cb4ebc4ee..26006cd7f 100644 --- a/gui/fitCommands/gui/implant/remove.py +++ b/gui/fitCommands/gui/implant/remove.py @@ -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 diff --git a/gui/fitCommands/gui/implant/setAdd.py b/gui/fitCommands/gui/implant/setAdd.py index 4e335deb2..23b8f484f 100644 --- a/gui/fitCommands/gui/implant/setAdd.py +++ b/gui/fitCommands/gui/implant/setAdd.py @@ -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 diff --git a/gui/fitCommands/gui/implant/toggleStates.py b/gui/fitCommands/gui/implant/toggleStates.py index 923415582..cad49710d 100644 --- a/gui/fitCommands/gui/implant/toggleStates.py +++ b/gui/fitCommands/gui/implant/toggleStates.py @@ -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 diff --git a/gui/fitCommands/gui/itemsRebase.py b/gui/fitCommands/gui/itemsRebase.py index 8be52a681..77daaec18 100644 --- a/gui/fitCommands/gui/itemsRebase.py +++ b/gui/fitCommands/gui/itemsRebase.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/add.py b/gui/fitCommands/gui/localDrone/add.py index 4a1607c76..33c29f74b 100644 --- a/gui/fitCommands/gui/localDrone/add.py +++ b/gui/fitCommands/gui/localDrone/add.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/changeAmount.py b/gui/fitCommands/gui/localDrone/changeAmount.py index 2834c8e95..196bed060 100644 --- a/gui/fitCommands/gui/localDrone/changeAmount.py +++ b/gui/fitCommands/gui/localDrone/changeAmount.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/changeMetas.py b/gui/fitCommands/gui/localDrone/changeMetas.py index 4fc06ca99..b77315065 100644 --- a/gui/fitCommands/gui/localDrone/changeMetas.py +++ b/gui/fitCommands/gui/localDrone/changeMetas.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/clone.py b/gui/fitCommands/gui/localDrone/clone.py index eb460ad51..c451acc56 100644 --- a/gui/fitCommands/gui/localDrone/clone.py +++ b/gui/fitCommands/gui/localDrone/clone.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/remove.py b/gui/fitCommands/gui/localDrone/remove.py index d30d002ed..dbf0b7130 100644 --- a/gui/fitCommands/gui/localDrone/remove.py +++ b/gui/fitCommands/gui/localDrone/remove.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/stackSplit.py b/gui/fitCommands/gui/localDrone/stackSplit.py index dd1a42893..7c9a44c0e 100644 --- a/gui/fitCommands/gui/localDrone/stackSplit.py +++ b/gui/fitCommands/gui/localDrone/stackSplit.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/stacksMerge.py b/gui/fitCommands/gui/localDrone/stacksMerge.py index ac25384e2..e6cd19289 100644 --- a/gui/fitCommands/gui/localDrone/stacksMerge.py +++ b/gui/fitCommands/gui/localDrone/stacksMerge.py @@ -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 diff --git a/gui/fitCommands/gui/localDrone/toggleStates.py b/gui/fitCommands/gui/localDrone/toggleStates.py index 4f5b595d0..affd1bda0 100644 --- a/gui/fitCommands/gui/localDrone/toggleStates.py +++ b/gui/fitCommands/gui/localDrone/toggleStates.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/abilityToggleState.py b/gui/fitCommands/gui/localFighter/abilityToggleState.py index 3c509a6ed..926752212 100644 --- a/gui/fitCommands/gui/localFighter/abilityToggleState.py +++ b/gui/fitCommands/gui/localFighter/abilityToggleState.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/add.py b/gui/fitCommands/gui/localFighter/add.py index 37cee084d..2e9d98680 100644 --- a/gui/fitCommands/gui/localFighter/add.py +++ b/gui/fitCommands/gui/localFighter/add.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/changeAmount.py b/gui/fitCommands/gui/localFighter/changeAmount.py index ed88fe469..9b535dd20 100644 --- a/gui/fitCommands/gui/localFighter/changeAmount.py +++ b/gui/fitCommands/gui/localFighter/changeAmount.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/changeMetas.py b/gui/fitCommands/gui/localFighter/changeMetas.py index b91030edc..1e5f95f50 100644 --- a/gui/fitCommands/gui/localFighter/changeMetas.py +++ b/gui/fitCommands/gui/localFighter/changeMetas.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/remove.py b/gui/fitCommands/gui/localFighter/remove.py index 0f47a8133..67f2889b9 100644 --- a/gui/fitCommands/gui/localFighter/remove.py +++ b/gui/fitCommands/gui/localFighter/remove.py @@ -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 diff --git a/gui/fitCommands/gui/localFighter/toggleStates.py b/gui/fitCommands/gui/localFighter/toggleStates.py index 0ef093ea8..3214d70aa 100644 --- a/gui/fitCommands/gui/localFighter/toggleStates.py +++ b/gui/fitCommands/gui/localFighter/toggleStates.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/add.py b/gui/fitCommands/gui/localModule/add.py index f40d16a64..821c0a59d 100644 --- a/gui/fitCommands/gui/localModule/add.py +++ b/gui/fitCommands/gui/localModule/add.py @@ -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) diff --git a/gui/fitCommands/gui/localModule/changeCharges.py b/gui/fitCommands/gui/localModule/changeCharges.py index 15b8f10a3..f22208f6f 100644 --- a/gui/fitCommands/gui/localModule/changeCharges.py +++ b/gui/fitCommands/gui/localModule/changeCharges.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/changeMetas.py b/gui/fitCommands/gui/localModule/changeMetas.py index 37cc613e0..5b5b0230e 100644 --- a/gui/fitCommands/gui/localModule/changeMetas.py +++ b/gui/fitCommands/gui/localModule/changeMetas.py @@ -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)) diff --git a/gui/fitCommands/gui/localModule/changeMutation.py b/gui/fitCommands/gui/localModule/changeMutation.py index 31aceab9b..7ffdf474f 100644 --- a/gui/fitCommands/gui/localModule/changeMutation.py +++ b/gui/fitCommands/gui/localModule/changeMutation.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/changeSpool.py b/gui/fitCommands/gui/localModule/changeSpool.py index 3bd4fac75..3dc90932b 100644 --- a/gui/fitCommands/gui/localModule/changeSpool.py +++ b/gui/fitCommands/gui/localModule/changeSpool.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/changeStates.py b/gui/fitCommands/gui/localModule/changeStates.py index 9eb400ecf..51fba410b 100644 --- a/gui/fitCommands/gui/localModule/changeStates.py +++ b/gui/fitCommands/gui/localModule/changeStates.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/clone.py b/gui/fitCommands/gui/localModule/clone.py index 970015d4b..06e88ddc4 100644 --- a/gui/fitCommands/gui/localModule/clone.py +++ b/gui/fitCommands/gui/localModule/clone.py @@ -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: diff --git a/gui/fitCommands/gui/localModule/fillAdd.py b/gui/fitCommands/gui/localModule/fillAdd.py index 8c875f25d..78280c1dc 100644 --- a/gui/fitCommands/gui/localModule/fillAdd.py +++ b/gui/fitCommands/gui/localModule/fillAdd.py @@ -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) diff --git a/gui/fitCommands/gui/localModule/fillClone.py b/gui/fitCommands/gui/localModule/fillClone.py index e42049714..c1953978f 100644 --- a/gui/fitCommands/gui/localModule/fillClone.py +++ b/gui/fitCommands/gui/localModule/fillClone.py @@ -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) diff --git a/gui/fitCommands/gui/localModule/mutatedConvert.py b/gui/fitCommands/gui/localModule/mutatedConvert.py index dd6680a11..e1bedd034 100644 --- a/gui/fitCommands/gui/localModule/mutatedConvert.py +++ b/gui/fitCommands/gui/localModule/mutatedConvert.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/mutatedImport.py b/gui/fitCommands/gui/localModule/mutatedImport.py index 091952dc5..4f1d279c4 100644 --- a/gui/fitCommands/gui/localModule/mutatedImport.py +++ b/gui/fitCommands/gui/localModule/mutatedImport.py @@ -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)) diff --git a/gui/fitCommands/gui/localModule/mutatedRevert.py b/gui/fitCommands/gui/localModule/mutatedRevert.py index 115e68e97..57a69c0d0 100644 --- a/gui/fitCommands/gui/localModule/mutatedRevert.py +++ b/gui/fitCommands/gui/localModule/mutatedRevert.py @@ -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 diff --git a/gui/fitCommands/gui/localModule/remove.py b/gui/fitCommands/gui/localModule/remove.py index b304a8617..197abfb38 100644 --- a/gui/fitCommands/gui/localModule/remove.py +++ b/gui/fitCommands/gui/localModule/remove.py @@ -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) diff --git a/gui/fitCommands/gui/localModule/replace.py b/gui/fitCommands/gui/localModule/replace.py index d006d89cb..350b1d181 100644 --- a/gui/fitCommands/gui/localModule/replace.py +++ b/gui/fitCommands/gui/localModule/replace.py @@ -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) diff --git a/gui/fitCommands/gui/localModule/swap.py b/gui/fitCommands/gui/localModule/swap.py index 382526b58..8dcf5dcc8 100644 --- a/gui/fitCommands/gui/localModule/swap.py +++ b/gui/fitCommands/gui/localModule/swap.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.module.localSwap import CalcSwapLocalModuleCommand @@ -20,10 +21,12 @@ class GuiSwapLocalModulesCommand(wx.Command): return False cmd = CalcSwapLocalModuleCommand(fitID=self.fitID, position1=self.position1, position2=self.position2) 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 diff --git a/gui/fitCommands/gui/localModuleCargo/cargoToLocalModule.py b/gui/fitCommands/gui/localModuleCargo/cargoToLocalModule.py index 99107199c..fa4a28245 100644 --- a/gui/fitCommands/gui/localModuleCargo/cargoToLocalModule.py +++ b/gui/fitCommands/gui/localModuleCargo/cargoToLocalModule.py @@ -47,18 +47,15 @@ class GuiCargoToLocalModuleCommand(wx.Command): if not self.copy: commands.append(CalcRemoveCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=newModChargeItemID, amount=newModChargeAmount), - commit=False)) + cargoInfo=CargoInfo(itemID=newModChargeItemID, amount=newModChargeAmount))) if newCargoChargeItemID is not None: commands.append(CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=newCargoChargeItemID, amount=newCargoChargeAmount), - commit=False)) + cargoInfo=CargoInfo(itemID=newCargoChargeItemID, amount=newCargoChargeAmount))) commands.append(CalcChangeModuleChargesCommand( fitID=self.fitID, projected=False, - chargeMap={self.dstModPosition: self.srcCargoItemID}, - commit=False)) + chargeMap={self.dstModPosition: self.srcCargoItemID})) success = self.internalHistory.submitBatch(*commands) # Moving/copying/replacing module elif srcCargo.item.isModule: @@ -83,20 +80,17 @@ class GuiCargoToLocalModuleCommand(wx.Command): if not self.copy: commands.append(CalcRemoveCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=self.srcCargoItemID, amount=1), - commit=False)) + cargoInfo=CargoInfo(itemID=self.srcCargoItemID, amount=1))) # Add item to cargo only if we copied/moved to non-empty slot if newCargoModItemID is not None: commands.append(CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=newCargoModItemID, amount=1), - commit=False)) + cargoInfo=CargoInfo(itemID=newCargoModItemID, amount=1))) cmdReplace = CalcReplaceLocalModuleCommand( fitID=self.fitID, position=self.dstModPosition, newModInfo=newModInfo, - unloadInvalidCharges=True, - commit=False) + unloadInvalidCharges=True) commands.append(cmdReplace) # Submit batch now because we need to have updated info on fit to keep going success = self.internalHistory.submitBatch(*commands) @@ -109,8 +103,7 @@ class GuiCargoToLocalModuleCommand(wx.Command): if cmdReplace.unloadedCharge and dstModChargeItemID is not None: cmdAddCargoCharge = CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=dstModChargeAmount), - commit=False) + cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=dstModChargeAmount)) success = self.internalHistory.submit(cmdAddCargoCharge) # If we did not unload charge and there still was a charge, see if amount differs and process it elif not cmdReplace.unloadedCharge and dstModChargeItemID is not None: @@ -119,16 +112,14 @@ class GuiCargoToLocalModuleCommand(wx.Command): if extraChargeAmount > 0: cmdRemoveCargoExtraCharge = CalcRemoveCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=extraChargeAmount), - commit=False) + cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=extraChargeAmount)) # Do not check if operation was successful or not, we're okay if we have no such # charges in cargo self.internalHistory.submit(cmdRemoveCargoExtraCharge) elif extraChargeAmount < 0: cmdAddCargoExtraCharge = CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=abs(extraChargeAmount)), - commit=False) + cargoInfo=CargoInfo(itemID=dstModChargeItemID, amount=abs(extraChargeAmount))) success = self.internalHistory.submit(cmdAddCargoExtraCharge) if success: # Store info to properly send events later @@ -138,9 +129,10 @@ class GuiCargoToLocalModuleCommand(wx.Command): self.internalHistory.undoAll() else: return False - eos.db.commit() + eos.db.flush() sFit.recalc(self.fitID) self.savedRemovedDummies = sFit.fill(self.fitID) + eos.db.commit() events = [] if self.removedModItemID is not None: events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.removedModItemID)) @@ -157,9 +149,10 @@ class GuiCargoToLocalModuleCommand(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 self.addedModItemID is not None: events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.addedModItemID)) diff --git a/gui/fitCommands/gui/localModuleCargo/localModuleToCargo.py b/gui/fitCommands/gui/localModuleCargo/localModuleToCargo.py index 4303d3025..bea380698 100644 --- a/gui/fitCommands/gui/localModuleCargo/localModuleToCargo.py +++ b/gui/fitCommands/gui/localModuleCargo/localModuleToCargo.py @@ -44,19 +44,16 @@ class GuiLocalModuleToCargoCommand(wx.Command): commands = [] commands.append(CalcRemoveCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=self.dstCargoItemID, amount=1), - commit=False)) + cargoInfo=CargoInfo(itemID=self.dstCargoItemID, amount=1))) commands.append(CalcAddCargoCommand( fitID=self.fitID, # We cannot put mutated items to cargo, so use unmutated item ID - cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1), - commit=False)) + cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1))) cmdReplace = CalcReplaceLocalModuleCommand( fitID=self.fitID, position=self.srcModPosition, newModInfo=newModInfo, - unloadInvalidCharges=True, - commit=False) + unloadInvalidCharges=True) commands.append(cmdReplace) # Submit batch now because we need to have updated info on fit to keep going success = self.internalHistory.submitBatch(*commands) @@ -67,8 +64,7 @@ class GuiLocalModuleToCargoCommand(wx.Command): if cmdReplace.unloadedCharge and srcModChargeItemID is not None: cmdAddCargoCharge = CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=srcModChargeAmount), - commit=False) + cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=srcModChargeAmount)) success = self.internalHistory.submit(cmdAddCargoCharge) # If we did not unload charge and there still was a charge, see if amount differs and process it elif not cmdReplace.unloadedCharge and srcModChargeItemID is not None: @@ -77,16 +73,14 @@ class GuiLocalModuleToCargoCommand(wx.Command): if extraChargeAmount > 0: cmdRemoveCargoExtraCharge = CalcRemoveCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=extraChargeAmount), - commit=False) + cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=extraChargeAmount)) # Do not check if operation was successful or not, we're okay if we have no such # charges in cargo self.internalHistory.submit(cmdRemoveCargoExtraCharge) elif extraChargeAmount < 0: cmdAddCargoExtraCharge = CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=abs(extraChargeAmount)), - commit=False) + cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=abs(extraChargeAmount))) success = self.internalHistory.submit(cmdAddCargoExtraCharge) if success: # Store info to properly send events later @@ -103,23 +97,21 @@ class GuiLocalModuleToCargoCommand(wx.Command): commands = [] commands.append(CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1), - commit=False)) + cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1))) if srcMod.chargeID is not None: commands.append(CalcAddCargoCommand( fitID=self.fitID, - cargoInfo=CargoInfo(itemID=srcMod.chargeID, amount=srcMod.numCharges), - commit=False)) + cargoInfo=CargoInfo(itemID=srcMod.chargeID, amount=srcMod.numCharges))) if not self.copy: commands.append(CalcRemoveLocalModulesCommand( fitID=self.fitID, - positions=[self.srcModPosition], - commit=False)) + positions=[self.srcModPosition])) success = self.internalHistory.submitBatch(*commands) - eos.db.commit() + eos.db.flush() sFit = Fit.getInstance() sFit.recalc(self.fitID) self.savedRemovedDummies = sFit.fill(self.fitID) + eos.db.commit() events = [] if self.removedModItemID is not None: events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.removedModItemID)) @@ -136,9 +128,10 @@ class GuiLocalModuleToCargoCommand(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 self.addedModItemID is not None: events.append(GE.FitChanged(fitID=self.fitID, action='moddel', typeID=self.addedModItemID)) diff --git a/gui/fitCommands/gui/projectedChangeStates.py b/gui/fitCommands/gui/projectedChangeStates.py index 7bace6554..fc22d9764 100644 --- a/gui/fitCommands/gui/projectedChangeStates.py +++ b/gui/fitCommands/gui/projectedChangeStates.py @@ -62,43 +62,41 @@ class GuiChangeProjectedItemStatesCommand(wx.Command): cmd = CalcChangeProjectedModuleStatesCommand( fitID=self.fitID, positions=self.pModPositions, - proposedState=self.proposedState, - commit=False) + proposedState=self.proposedState) results.append(self.internalHistory.submit(cmd)) for pDroneItemID in self.pDroneItemIDs: cmd = CalcChangeProjectedDroneStateCommand( fitID=self.fitID, itemID=pDroneItemID, - state=False if self.proposedState == 'inactive' else True, - commit=False) + state=False if self.proposedState == 'inactive' else True) results.append(self.internalHistory.submit(cmd)) for pFighterPosition in self.pFighterPositions: cmd = CalcChangeProjectedFighterStateCommand( fitID=self.fitID, position=pFighterPosition, - state=False if self.proposedState == 'inactive' else True, - commit=False) + state=False if self.proposedState == 'inactive' else True) results.append(self.internalHistory.submit(cmd)) for pFitID in self.pFitIDs: cmd = CalcChangeProjectedFitStateCommand( fitID=self.fitID, projectedFitID=pFitID, - state=False if self.proposedState == 'inactive' else True, - commit=False) + state=False if self.proposedState == 'inactive' else True) 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 diff --git a/gui/fitCommands/gui/projectedDrone/add.py b/gui/fitCommands/gui/projectedDrone/add.py index ee2ace5fa..822e31a4a 100644 --- a/gui/fitCommands/gui/projectedDrone/add.py +++ b/gui/fitCommands/gui/projectedDrone/add.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.drone.projectedAdd import CalcAddProjectedDroneCommand @@ -18,16 +19,20 @@ class GuiAddProjectedDroneCommand(wx.Command): def Do(self): cmd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=1, amountActive=1)) 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 diff --git a/gui/fitCommands/gui/projectedDrone/changeAmount.py b/gui/fitCommands/gui/projectedDrone/changeAmount.py index ef966f693..4314158a6 100644 --- a/gui/fitCommands/gui/projectedDrone/changeAmount.py +++ b/gui/fitCommands/gui/projectedDrone/changeAmount.py @@ -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.projectedChangeAmount import CalcChangeProjectedDroneAmountCommand @@ -25,16 +26,20 @@ class GuiChangeProjectedDroneAmountCommand(wx.Command): else: cmd = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=self.itemID, 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 diff --git a/gui/fitCommands/gui/projectedDrone/changeMetas.py b/gui/fitCommands/gui/projectedDrone/changeMetas.py index 286872be6..9fafef516 100644 --- a/gui/fitCommands/gui/projectedDrone/changeMetas.py +++ b/gui/fitCommands/gui/projectedDrone/changeMetas.py @@ -32,21 +32,23 @@ class GuiChangeProjectedDroneMetasCommand(wx.Command): continue info = DroneInfo.fromDrone(drone) info.itemID = self.newItemID - cmdRemove = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=itemID, amount=math.inf, commit=False) - cmdAdd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=info, commit=False) + cmdRemove = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=itemID, amount=math.inf) + cmdAdd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=info) 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 diff --git a/gui/fitCommands/gui/projectedFighter/abilityToggleState.py b/gui/fitCommands/gui/projectedFighter/abilityToggleState.py index d39548faf..63120cb00 100644 --- a/gui/fitCommands/gui/projectedFighter/abilityToggleState.py +++ b/gui/fitCommands/gui/projectedFighter/abilityToggleState.py @@ -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 GuiToggleProjectedFighterAbilityStateCommand(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 diff --git a/gui/fitCommands/gui/projectedFighter/add.py b/gui/fitCommands/gui/projectedFighter/add.py index a095e8197..769801ecc 100644 --- a/gui/fitCommands/gui/projectedFighter/add.py +++ b/gui/fitCommands/gui/projectedFighter/add.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.fighter.projectedAdd import CalcAddProjectedFighterCommand @@ -18,16 +19,20 @@ class GuiAddProjectedFighterCommand(wx.Command): def Do(self): cmd = CalcAddProjectedFighterCommand(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 diff --git a/gui/fitCommands/gui/projectedFighter/changeAmount.py b/gui/fitCommands/gui/projectedFighter/changeAmount.py index b62baa357..93e60237d 100644 --- a/gui/fitCommands/gui/projectedFighter/changeAmount.py +++ b/gui/fitCommands/gui/projectedFighter/changeAmount.py @@ -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 GuiChangeProjectedFighterAmountCommand(wx.Command): else: cmd = CalcRemoveProjectedFighterCommand(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 diff --git a/gui/fitCommands/gui/projectedFighter/changeMetas.py b/gui/fitCommands/gui/projectedFighter/changeMetas.py index cdc8464f7..bcce5cbe3 100644 --- a/gui/fitCommands/gui/projectedFighter/changeMetas.py +++ b/gui/fitCommands/gui/projectedFighter/changeMetas.py @@ -28,21 +28,23 @@ class GuiChangeProjectedFighterMetasCommand(wx.Command): continue info = FighterInfo.fromFighter(fighter) info.itemID = self.newItemID - cmdRemove = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=position, commit=False) - cmdAdd = CalcAddProjectedFighterCommand(fitID=self.fitID, fighterInfo=info, commit=False) + cmdRemove = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=position) + cmdAdd = CalcAddProjectedFighterCommand(fitID=self.fitID, fighterInfo=info) 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 diff --git a/gui/fitCommands/gui/projectedFit/add.py b/gui/fitCommands/gui/projectedFit/add.py index a6054fc35..e8f0af24e 100644 --- a/gui/fitCommands/gui/projectedFit/add.py +++ b/gui/fitCommands/gui/projectedFit/add.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.projectedFit.add import CalcAddProjectedFitCommand @@ -20,15 +21,19 @@ class GuiAddProjectedFitCommand(wx.Command): cmd = CalcAddProjectedFitCommand(fitID=self.fitID, projectedFitID=self.projectedFitID, amount=self.amount) success = self.internalHistory.submit(cmd) sFit = Fit.getInstance() + 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() sFit = Fit.getInstance() + 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 diff --git a/gui/fitCommands/gui/projectedFit/changeAmount.py b/gui/fitCommands/gui/projectedFit/changeAmount.py index 07a34d412..3bf167527 100644 --- a/gui/fitCommands/gui/projectedFit/changeAmount.py +++ b/gui/fitCommands/gui/projectedFit/changeAmount.py @@ -2,6 +2,7 @@ import math import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.projectedFit.changeAmount import CalcChangeProjectedFitAmountCommand @@ -25,16 +26,20 @@ class GuiChangeProjectedFitAmountCommand(wx.Command): else: cmd = CalcRemoveProjectedFitCommand(fitID=self.fitID, projectedFitID=self.projectedFitID, 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 diff --git a/gui/fitCommands/gui/projectedModule/add.py b/gui/fitCommands/gui/projectedModule/add.py index b7ae32174..da3f3346b 100644 --- a/gui/fitCommands/gui/projectedModule/add.py +++ b/gui/fitCommands/gui/projectedModule/add.py @@ -1,5 +1,6 @@ import wx +import eos.db import gui.mainFrame from gui import globalEvents as GE from gui.fitCommands.calc.module.projectedAdd import CalcAddProjectedModuleCommand @@ -18,16 +19,20 @@ class GuiAddProjectedModuleCommand(wx.Command): def Do(self): cmd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=ModuleInfo(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 diff --git a/gui/fitCommands/gui/projectedModule/changeCharges.py b/gui/fitCommands/gui/projectedModule/changeCharges.py index 7c2816365..1fde32910 100644 --- a/gui/fitCommands/gui/projectedModule/changeCharges.py +++ b/gui/fitCommands/gui/projectedModule/changeCharges.py @@ -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 GuiChangeProjectedModuleChargesCommand(wx.Command): def Do(self): cmd = CalcChangeModuleChargesCommand(fitID=self.fitID, projected=True, 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 diff --git a/gui/fitCommands/gui/projectedModule/changeMetas.py b/gui/fitCommands/gui/projectedModule/changeMetas.py index d85e80521..5550aacf7 100644 --- a/gui/fitCommands/gui/projectedModule/changeMetas.py +++ b/gui/fitCommands/gui/projectedModule/changeMetas.py @@ -28,21 +28,23 @@ class GuiChangeProjectedModuleMetasCommand(wx.Command): continue info = ModuleInfo.fromModule(module) info.itemID = self.newItemID - cmdRemove = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=position, commit=False) - cmdAdd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=info, commit=False) + cmdRemove = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=position) + cmdAdd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=info) 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 diff --git a/gui/fitCommands/gui/projectedModule/changeSpool.py b/gui/fitCommands/gui/projectedModule/changeSpool.py index 021a6e941..e03f7882a 100644 --- a/gui/fitCommands/gui/projectedModule/changeSpool.py +++ b/gui/fitCommands/gui/projectedModule/changeSpool.py @@ -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 GuiChangeProjectedModuleSpoolCommand(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 diff --git a/gui/fitCommands/gui/projectedRemove.py b/gui/fitCommands/gui/projectedRemove.py index 29f703987..3da1f8d1b 100644 --- a/gui/fitCommands/gui/projectedRemove.py +++ b/gui/fitCommands/gui/projectedRemove.py @@ -1,5 +1,3 @@ -import math - import wx import eos.db @@ -44,30 +42,32 @@ class GuiRemoveProjectedItemsCommand(wx.Command): def Do(self): results = [] for pModPosition in sorted(self.pModPositions, reverse=True): - cmd = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=pModPosition, commit=False) + cmd = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=pModPosition) results.append(self.internalHistory.submit(cmd)) for pDroneItemID in self.pDroneItemIDs: - cmd = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=pDroneItemID, amount=self.amount, commit=False) + cmd = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=pDroneItemID, amount=self.amount) results.append(self.internalHistory.submit(cmd)) for pFighterPosition in sorted(self.pFighterPositions, reverse=True): - cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=pFighterPosition, commit=False) + cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID, position=pFighterPosition) results.append(self.internalHistory.submit(cmd)) for pFitID in self.pFitIDs: - cmd = CalcRemoveProjectedFitCommand(fitID=self.fitID, projectedFitID=pFitID, amount=self.amount, commit=False) + cmd = CalcRemoveProjectedFitCommand(fitID=self.fitID, projectedFitID=pFitID, 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 diff --git a/gui/fitCommands/gui/shipModeChange.py b/gui/fitCommands/gui/shipModeChange.py index c407b2510..aa9072fbe 100644 --- a/gui/fitCommands/gui/shipModeChange.py +++ b/gui/fitCommands/gui/shipModeChange.py @@ -1,10 +1,11 @@ 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 from gui.fitCommands.calc.shipModeChange import CalcChangeShipModeCommand +from gui.fitCommands.helpers import InternalCommandHistory +from service.fit import Fit class GuiChangeShipModeCommand(wx.Command): @@ -18,16 +19,20 @@ class GuiChangeShipModeCommand(wx.Command): def Do(self): cmd = CalcChangeShipModeCommand(fitID=self.fitID, 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