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

Method spawnMenu

gui/builtinViews/fittingView.py:635–684  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

633 pyfalog.error("Caught dead object")
634
635 def spawnMenu(self, event):
636 clickedPos = self.getRowByAbs(event.Position)
637 self.ensureSelection(clickedPos)
638
639 if self.activeFitID is None or self.getColumn(self.screenToClientFixed(event.Position)) == self.getColIndex(State):
640 return
641
642 selection = []
643 for mod in self.getSelectedMods():
644 # Test if this is a mode, which is a special snowflake of a Module
645 if isinstance(mod, Mode):
646 selection.append(mod)
647 elif not mod.isEmpty:
648 selection.append(mod)
649
650 fit = Fit.getInstance().getFit(self.activeFitID)
651 mainMod = None
652 if clickedPos != -1:
653 try:
654 mod = self.mods[clickedPos]
655 except IndexError:
656 pass
657 else:
658 if mod is not None and (mod in fit.modules or mod is fit.mode):
659 mainMod = mod
660
661 sMkt = Market.getInstance()
662 contexts = []
663 if isinstance(mainMod, Module) and not mainMod.isEmpty:
664 srcContext = "fittingModule"
665 itemContext = sMkt.getCategoryByItem(mainMod.item).displayName
666 fullContext = (srcContext, itemContext)
667 if srcContext not in tuple(fCtx[0] for fCtx in contexts):
668 contexts.append(fullContext)
669 if mainMod.charge is not None:
670 srcContext = "fittingCharge"
671 itemContext = sMkt.getCategoryByItem(mainMod.charge).displayName
672 fullContext = (srcContext, itemContext)
673 if srcContext not in tuple(fCtxt[0] for fCtxt in contexts):
674 contexts.append(fullContext)
675 elif isinstance(mainMod, Mode):
676 srcContext = "fittingMode"
677 itemContext = _t("Tactical Mode")
678 fullContext = (srcContext, itemContext)
679 if srcContext not in tuple(fCtx[0] for fCtx in contexts):
680 contexts.append(fullContext)
681 contexts.append(("fittingShip", _t("Ship") if not fit.isStructure else _t("Citadel")))
682
683 menu = ContextMenu.getMenu(self, mainMod, selection, *contexts)
684 self.PopupMenu(menu)
685
686 def click(self, event):
687 """

Callers

nothing calls this directly

Calls 12

getSelectedModsMethod · 0.95
getRowByAbsMethod · 0.80
ensureSelectionMethod · 0.80
screenToClientFixedMethod · 0.80
getColIndexMethod · 0.80
getFitMethod · 0.80
getCategoryByItemMethod · 0.80
getMenuMethod · 0.80
_tFunction · 0.50
getColumnMethod · 0.45
appendMethod · 0.45
getInstanceMethod · 0.45

Tested by

no test coverage detected