MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / swapItems

Method swapItems

gui/builtinViews/fittingView.py:507–538  ·  view source on GitHub ↗

Swap two modules in fitting window

(self, x, y, srcIdx)

Source from the content-addressed store, hash-verified

505 copy=wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL))
506
507 def swapItems(self, x, y, srcIdx):
508 """Swap two modules in fitting window"""
509 sFit = Fit.getInstance()
510 fit = sFit.getFit(self.activeFitID)
511
512 dstRow, _ = self.HitTest((x, y))
513
514 if dstRow != -1 and dstRow not in self.blanks:
515 try:
516 mod1 = fit.modules[srcIdx]
517 mod2 = self.mods[dstRow]
518 except IndexError:
519 return
520 if not isinstance(mod2, Module):
521 return
522 # can't swap modules to different racks
523 if mod1.slot != mod2.slot:
524 return
525 if mod2 not in fit.modules:
526 pyfalog.error("Missing module position for: {0}", str(getattr(mod2, "ID", "Unknown")))
527 return
528 mod2Position = fit.modules.index(mod2)
529 mstate = wx.GetMouseState()
530 if mstate.GetModifiers() == wx.MOD_CONTROL | wx.MOD_ALT:
531 self.mainFrame.command.Submit(cmd.GuiFillWithClonedLocalModulesCommand(
532 fitID=self.activeFitID, position=srcIdx))
533 elif mstate.GetModifiers() == wx.MOD_CONTROL and mod2.isEmpty:
534 self.mainFrame.command.Submit(cmd.GuiCloneLocalModuleCommand(
535 fitID=self.activeFitID, srcPosition=srcIdx, dstPosition=mod2Position))
536 elif mstate.GetModifiers() == wx.MOD_NONE:
537 self.mainFrame.command.Submit(cmd.GuiSwapLocalModulesCommand(
538 fitID=self.activeFitID, position1=srcIdx, position2=mod2Position))
539
540 def generateMods(self):
541 """

Callers 1

handleListDragMethod · 0.95

Calls 3

getFitMethod · 0.80
getInstanceMethod · 0.45
HitTestMethod · 0.45

Tested by

no test coverage detected