diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 2ef807290..26e680b76 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -352,7 +352,7 @@ class FittingView(d.Display): cFit = service.Fit.getInstance() - if clone: + if clone and mod2.isEmpty: cFit.cloneModule(self.mainFrame.getActiveFit(), mod1.position, mod2.position) else: cFit.swapModules(self.mainFrame.getActiveFit(), mod1.position, mod2.position) diff --git a/service/fit.py b/service/fit.py index 2b71bb337..46aaeb6f4 100644 --- a/service/fit.py +++ b/service/fit.py @@ -395,8 +395,26 @@ class Fit(object): eos.db.commit() def cloneModule(self, fitID, src, dst): - #need implementation of module clone based on module positions (also make sure the dst is empty else do nothing) - pass + ''' + Clone a module from src to dst + + This will overwrite dst! Checking for empty module must be + done at a higher level + ''' + fit = eos.db.getFit(fitID) + # Gather modules + srcMod = fit.modules[src] + dstMod = fit.modules[dst] + + new = copy.deepcopy(srcMod) + + # remove empty mod + fit.modules.remove(dstMod) + + # insert copy + fit.modules.insert(dst, new) + + eos.db.commit() def addDrone(self, fitID, itemID): if fitID == None: