Extend the controller with a getChildren method and use it to display marketgroup children

This commit is contained in:
cncfanatics
2010-08-15 19:52:40 +02:00
parent 378fcc0b51
commit 8d4fea3040
4 changed files with 46 additions and 14 deletions

View File

@@ -29,11 +29,26 @@ class Market():
return cls.instance
def getChildren(self, id):
"""
Get the children of the group or marketGroup with the passed id.
Returns a list, where each element is a tuple containing:
the id, the name, the icon, wether the group has more children.
"""
group = eos.db.getMarketGroup(id)
children = []
for child in group.children:
icon = child.icon.iconFile if child.icon else ""
children.append((child.ID, child.name, icon, not child.hasTypes))
return children
def getMarketRoot(self):
"""
Get the root of the market tree.
Returns a list, where each element is a tuple container: the ID, the name and the icon of the group
Returns a list, where each element is a tuple containing:
the ID, the name and the icon of the group
"""
marketGroups = (9, #Modules
@@ -42,14 +57,9 @@ class Market():
11, #Ammo
1112, #Subsystems
24) #Implants & Boosters
groups = (920, ) #Effect Beacons
root = []
for id in marketGroups:
mg = eos.db.getMarketGroup(id)
root.append((id, mg.name, mg.icon.iconFile))
for id in groups:
g = eos.db.getGroup(id)
root.append((id, g.name, g.icon.iconFile))
return root