Add attribute columns to the fittingView
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from controller.market import Market
|
||||
from controller.fit import Fit
|
||||
from controller.attribute import Attribute
|
||||
|
||||
33
controller/attribute.py
Normal file
33
controller/attribute.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#===============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import eos.db
|
||||
|
||||
class Attribute():
|
||||
instance = None
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
if cls.instance is None:
|
||||
cls.instance = Attribute()
|
||||
|
||||
return cls.instance
|
||||
|
||||
def getAttributeInfo(self, attributeName):
|
||||
info = eos.db.getAttributeInfo(attributeName)
|
||||
return info
|
||||
@@ -1,4 +1,4 @@
|
||||
__all__ = ["moduleState", "moduleNameOrSlot"]
|
||||
__all__ = ["moduleState", "moduleNameOrSlot", "attributeDisplay"]
|
||||
|
||||
columns = {}
|
||||
def registerColumn(column):
|
||||
|
||||
56
gui/builtinViewColumns/attributeDisplay.py
Normal file
56
gui/builtinViewColumns/attributeDisplay.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#===============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
from gui import builtinViewColumns
|
||||
from gui.viewColumn import ViewColumn
|
||||
from gui import bitmapLoader
|
||||
import controller
|
||||
|
||||
class AttributeDisplay(ViewColumn):
|
||||
name = "Attribute Display"
|
||||
def __init__(self, fittingView, params):
|
||||
ViewColumn.__init__(self, fittingView)
|
||||
cAttribute = controller.Attribute.getInstance()
|
||||
info = cAttribute.getAttributeInfo(params["attribute"])
|
||||
self.info = info
|
||||
if params["showIcon"]:
|
||||
iconFile = info.icon.iconFile if info.icon else None
|
||||
if iconFile:
|
||||
bitmap = bitmapLoader.getBitmap(iconFile, "pack")
|
||||
self.imageId = fittingView.imageList.Add(bitmap)
|
||||
else:
|
||||
self.imageId = -1
|
||||
else:
|
||||
self.imageId = -1
|
||||
|
||||
if params["displayName"] or self.imageId == -1:
|
||||
self.columnText = info.displayName if info.displayName != "" else info.name
|
||||
|
||||
def getText(self, mod):
|
||||
return "%.2f" % mod.getModifiedItemAttr(self.info.name)
|
||||
|
||||
def getImageId(self, mod):
|
||||
return -1
|
||||
|
||||
def getParameters(self):
|
||||
return (("attribute", str, None),
|
||||
("displayName", bool, False),
|
||||
("showIcon", bool, True))
|
||||
|
||||
builtinViewColumns.registerColumn(AttributeDisplay)
|
||||
@@ -18,12 +18,14 @@
|
||||
#===============================================================================
|
||||
|
||||
import wx
|
||||
|
||||
import sys
|
||||
import gui.builtinViewColumns
|
||||
from gui.builtinViewColumns import *
|
||||
|
||||
class FittingView(wx.ListCtrl):
|
||||
DEFAULT_COLS = ["Module state", "Module name/slot"]
|
||||
DEFAULT_ATTR_COLS = ["power", "cpu", "capacitorNeed", "maxRange", "trackingSpeed"]
|
||||
|
||||
def __init__(self, parent):
|
||||
listStyle = wx.LC_REPORT | wx.BORDER_NONE
|
||||
wx.ListCtrl.__init__(self, parent, wx.ID_ANY, style=listStyle)
|
||||
@@ -34,19 +36,33 @@ class FittingView(wx.ListCtrl):
|
||||
self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.resizeChecker)
|
||||
self.Bind(wx.EVT_LIST_COL_CLICK, self.dragCheck)
|
||||
self.Bind(wx.EVT_LIST_COL_END_DRAG, self.dragCheck)
|
||||
|
||||
i = 0
|
||||
for colName in FittingView.DEFAULT_COLS:
|
||||
col = gui.builtinViewColumns.getColumn(colName)(self, None)
|
||||
self.activeColumns.append(col)
|
||||
|
||||
info = wx.ListItem()
|
||||
info.m_mask = col.mask
|
||||
info.m_image = col.imageId
|
||||
info.m_text = col.columnText
|
||||
self.InsertColumnInfo(i, info)
|
||||
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER if col.size is wx.LIST_AUTOSIZE else col.size)
|
||||
self.addColumn(i, col)
|
||||
i += 1
|
||||
|
||||
for attrName in FittingView.DEFAULT_ATTR_COLS:
|
||||
params = {"showIcon": True,
|
||||
"displayName": False,
|
||||
"attribute": attrName}
|
||||
|
||||
col = gui.builtinViewColumns.getColumn("Attribute Display")(self, params)
|
||||
self.addColumn(i, col)
|
||||
i += 1
|
||||
|
||||
self.imageListBase = self.imageList.ImageCount
|
||||
|
||||
def addColumn(self, i, col):
|
||||
self.activeColumns.append(col)
|
||||
info = wx.ListItem()
|
||||
info.m_mask = col.mask
|
||||
info.m_image = col.imageId
|
||||
info.m_text = col.columnText
|
||||
self.InsertColumnInfo(i, info)
|
||||
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER if col.size is wx.LIST_AUTOSIZE else col.size)
|
||||
|
||||
def resizeChecker(self, event):
|
||||
if self.activeColumns[event.Column].resizable is False:
|
||||
event.Veto()
|
||||
|
||||
@@ -179,7 +179,6 @@ class MarketBrowser(wx.Panel):
|
||||
iconId = self.addItemViewImage(iconFile)
|
||||
index = self.itemView.InsertImageStringItem(sys.maxint, name, iconId)
|
||||
idNameMap[id] = name
|
||||
width, _ = self.itemView.GetTextExtent(name)
|
||||
|
||||
self.itemView.SetItemData(index, id)
|
||||
|
||||
|
||||
BIN
icons/pg_small.png
Normal file
BIN
icons/pg_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 570 B |
Reference in New Issue
Block a user