Implement a set of modifications to allow attributeDisplay to directly

query attributes, this is always slower then using the normal method
except for the marketBrowser.
This commit is contained in:
cncfanatics
2010-12-06 09:47:30 +01:00
parent a5e0059a4f
commit 570c5a9a0c
5 changed files with 40 additions and 8 deletions

2
eos

Submodule eos updated: 219a162271...c000423ee9

View File

@@ -54,15 +54,32 @@ class AttributeDisplay(ViewColumn):
self.columnText = info.displayName if info.displayName != "" else info.name
self.mask |= wx.LIST_MASK_IMAGE
if params["direct"]:
self.direct = True
self.view = fittingView
originalRefresh = fittingView.refresh
sMarket = service.Market.getInstance()
#Hack into our master view and add a callback for ourselves to know when to query
def refresh(stuff):
self.directInfo = sMarket.directRequest(stuff, info.ID) if stuff is not None else None
originalRefresh(stuff)
fittingView.refresh = refresh
def getText(self, mod):
if hasattr(mod, "item"):
attr = mod.getModifiedItemAttr(self.info.name)
else:
attr = mod.getAttribute(self.info.name)
if attr:
if self.direct:
info = self.directInfo
attr = info.get(mod.ID, "") if info else ""
else:
attr = mod.getAttribute(self.info.name)
if isinstance(attr, (float, int)):
return (formatAmount(attr, 3, 0, 3))
else:
return ""
return attr if attr is not None else ""
def getImageId(self, mod):
return -1
@@ -71,6 +88,7 @@ class AttributeDisplay(ViewColumn):
def getParameters():
return (("attribute", str, None),
("displayName", bool, False),
("showIcon", bool, True))
("showIcon", bool, True),
("direct", bool, True))
AttributeDisplay.register()

View File

@@ -46,8 +46,9 @@ class Display(wx.ListCtrl):
for x, param in enumerate(paramList):
name, type, defaultValue = param
value = params[x] if len(params) > x else defaultValue
if type == bool:
value = bool(value) if value != "False" else False
value = value if value != "" else defaultValue
if type == bool and isinstance(value, basestring):
value = bool(value) if value.lower() != "false" and value != "0" else False
paramDict[name] = value
col = colClass(self, paramDict)
else:

View File

@@ -199,7 +199,9 @@ class MarketTree(wx.TreeCtrl):
class ItemView(d.Display):
DEFAULT_COLS = ["Base Icon",
"Base Name"]
"Base Name",
"attr:power,,,True",
"attr:cpu,,,True"]
def __init__(self, parent, marketBrowser):
d.Display.__init__(self, parent)

View File

@@ -25,6 +25,8 @@ import threading
from sqlalchemy.orm.exc import NoResultFound
import Queue
import traceback
import sqlalchemy.sql
import sqlalchemy.orm
class ShipBrowserWorkerThread(threading.Thread):
def run(self):
@@ -334,3 +336,12 @@ class Market():
eos.db.commit()
self.priceWorkerThread.trigger(requests, cb)
def directRequest(self, items, attrID):
itemIDs = map(lambda i: i.ID, items)
info = {}
for ID, val in eos.db.directAttributeRequest(itemIDs, attrID):
info[ID] = val
return info