| 52 | |
| 53 | # @todo: Was copied form another class and modified. Look through entire file, refine |
| 54 | class CargoView(d.Display): |
| 55 | DEFAULT_COLS = ["Base Icon", |
| 56 | "Base Name", |
| 57 | "attr:volume", |
| 58 | "Price"] |
| 59 | |
| 60 | def __init__(self, parent): |
| 61 | d.Display.__init__(self, parent, style=wx.BORDER_NONE) |
| 62 | |
| 63 | self.lastFitId = None |
| 64 | |
| 65 | self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) |
| 66 | self.mainFrame.Bind(ITEM_SELECTED, self.addItem) |
| 67 | self.Bind(wx.EVT_LEFT_DCLICK, self.onLeftDoubleClick) |
| 68 | self.Bind(wx.EVT_KEY_UP, self.kbEvent) |
| 69 | |
| 70 | self.SetDropTarget(CargoViewDrop(self.handleListDrag)) |
| 71 | self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) |
| 72 | |
| 73 | self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) |
| 74 | |
| 75 | def addItem(self, event): |
| 76 | item = Market.getInstance().getItem(event.itemID, eager='group') |
| 77 | if item is None or not (item.isCharge or item.isCommodity): |
| 78 | event.Skip() |
| 79 | return |
| 80 | |
| 81 | fitID = self.mainFrame.getActiveFit() |
| 82 | fit = Fit.getInstance().getFit(fitID) |
| 83 | |
| 84 | if not fit: |
| 85 | event.Skip() |
| 86 | return |
| 87 | modifiers = wx.GetMouseState().GetModifiers() |
| 88 | amount = 1 |
| 89 | if modifiers == wx.MOD_CONTROL: |
| 90 | amount = 10 |
| 91 | elif modifiers == wx.MOD_ALT: |
| 92 | amount = 100 |
| 93 | elif modifiers == wx.MOD_CONTROL | wx.MOD_ALT: |
| 94 | amount = 1000 |
| 95 | self.mainFrame.command.Submit(cmd.GuiAddCargoCommand( |
| 96 | fitID=fitID, itemID=item.ID, amount=amount)) |
| 97 | self.mainFrame.additionsPane.select('Cargo') |
| 98 | event.Skip() |
| 99 | |
| 100 | def handleListDrag(self, x, y, data): |
| 101 | """ |
| 102 | Handles dragging of items from various pyfa displays which support it |
| 103 | |
| 104 | data is list with two indices: |
| 105 | data[0] is hard-coded str of originating source |
| 106 | data[1] is typeID or index of data we want to manipulate |
| 107 | """ |
| 108 | |
| 109 | if data[0] == "fitting": |
| 110 | self.swapModule(x, y, int(data[1])) |
| 111 | elif data[0] == "market": |