Added the ability to remove charges and projected items using the itemRemove built in context menu. In this commit I fixed a minor bug in the projected view that caused the right clicked item not to be SHOWN as selected until after the context menu had been spawned and closed. I also removed all parent references from the ContextMenu class and sub classes. I am instead using the fit service to do all the work of removing the items in the itemRemove class.
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
from gui.contextMenu import ContextMenu
|
|
from gui.itemStats import ItemStatsDialog
|
|
import gui.mainFrame
|
|
import service
|
|
|
|
class MarketJump(ContextMenu):
|
|
def __init__(self):
|
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
|
|
|
def display(self, srcContext, selection):
|
|
validContexts = ("marketItemMisc", "fittingModule", "fittingCharge", "droneItem", "implantItem",
|
|
"boosterItem", "projectedModule", "projectedDrone", "projectedCharge")
|
|
if not srcContext in validContexts:
|
|
return False
|
|
sMkt = service.Market.getInstance()
|
|
if selection is None or len(selection) < 1:
|
|
return False
|
|
item = getattr(selection[0], "item", selection[0])
|
|
doit = not selection[0].isEmpty if srcContext == "fittingModule" else True \
|
|
and sMkt.getMarketGroupByItem(item) is not None
|
|
return doit
|
|
|
|
def getText(self, itmContext, selection):
|
|
return "{0} Market Group".format(itmContext if itmContext is not None else "Item")
|
|
|
|
def activate(self, fullContext, selection, i):
|
|
srcContext = fullContext[0]
|
|
if srcContext in ("fittingModule", "droneItem", "implantItem", "boosterItem", "projectedModule", "projectedDrone"):
|
|
item = selection[0].item
|
|
elif srcContext in ("fittingCharge", "projectedCharge"):
|
|
item = selection[0].charge
|
|
else:
|
|
item = selection[0]
|
|
|
|
self.mainFrame.notebookBrowsers.SetSelection(0)
|
|
self.mainFrame.marketBrowser.jump(item)
|
|
|
|
MarketJump.register()
|