Fix issue with Delete key event on t3d mode causing exception (#1160). Additionally, work around the fact that every module that is removed also recalculates the fit, allowing for a faster response time when deleting multiple modules at a time. This is somewhat ugly as the removeModule function was originally based on the assumption of removing only one module. Should clean it up at some point.

This commit is contained in:
blitzmann
2017-05-13 00:21:26 -04:00
parent b4f063b07a
commit d4ce1ef3db
3 changed files with 46 additions and 15 deletions

View File

@@ -540,14 +540,26 @@ class Fit(object):
else:
return None
def removeModule(self, fitID, position):
pyfalog.debug("Removing module from position ({0}) for fit ID: {1}", position, fitID)
def removeModule(self, fitID, positions):
"""Removes modules based on a number of positions."""
pyfalog.debug("Removing module from position ({0}) for fit ID: {1}", positions, fitID)
fit = eos.db.getFit(fitID)
if fit.modules[position].isEmpty:
# Convert scalar value to list
if not isinstance(positions, list):
positions = [positions]
modulesChanged = False
for x in positions:
if not fit.modules[x].isEmpty:
fit.modules.toDummy(x)
modulesChanged=True
# if no modules have changes, report back None
if not modulesChanged:
return None
numSlots = len(fit.modules)
fit.modules.toDummy(position)
self.recalc(fit)
self.checkStates(fit, None)
fit.fill()