| 15 | |
| 16 | |
| 17 | class ItemCompare(wx.Panel): |
| 18 | def __init__(self, parent, stuff, item, items, context=None): |
| 19 | # Start dealing with Price stuff to get that thread going |
| 20 | sPrice = ServicePrice.getInstance() |
| 21 | sPrice.getPrices(items, self.UpdateList, fetchTimeout=90) |
| 22 | |
| 23 | wx.Panel.__init__(self, parent) |
| 24 | self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) |
| 25 | mainSizer = wx.BoxSizer(wx.VERTICAL) |
| 26 | |
| 27 | self.paramList = AutoListCtrl(self, wx.ID_ANY, |
| 28 | style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER) |
| 29 | mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0) |
| 30 | self.SetSizer(mainSizer) |
| 31 | |
| 32 | self.toggleView = 1 |
| 33 | self.stuff = stuff |
| 34 | self.currentSort = None |
| 35 | self.sortReverse = False |
| 36 | self.item = item |
| 37 | self.items = sorted(items, key=defaultSort) |
| 38 | self.attrs = {} |
| 39 | self.HighlightOn = wx.Colour(255, 255, 0, wx.ALPHA_OPAQUE) |
| 40 | self.highlightedNames = [] |
| 41 | |
| 42 | # get a dict of attrName: attrInfo of all unique attributes across all items |
| 43 | for item in self.items: |
| 44 | for attr in list(item.attributes.keys()): |
| 45 | if item.attributes[attr].info.displayName: |
| 46 | self.attrs[attr] = item.attributes[attr].info |
| 47 | |
| 48 | # Process attributes for items and find ones that differ |
| 49 | for attr in list(self.attrs.keys()): |
| 50 | value = None |
| 51 | |
| 52 | for item in self.items: |
| 53 | # we can automatically break here if this item doesn't have the attribute, |
| 54 | # as that means at least one item did |
| 55 | if attr not in item.attributes: |
| 56 | break |
| 57 | |
| 58 | # this is the first attribute for the item set, set the initial value |
| 59 | if value is None: |
| 60 | value = item.attributes[attr].value |
| 61 | continue |
| 62 | |
| 63 | if attr not in item.attributes or item.attributes[attr].value != value: |
| 64 | break |
| 65 | else: |
| 66 | # attribute values were all the same, delete |
| 67 | del self.attrs[attr] |
| 68 | |
| 69 | self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, |
| 70 | wx.LI_HORIZONTAL) |
| 71 | mainSizer.Add(self.m_staticline, 0, wx.EXPAND) |
| 72 | bSizer = wx.BoxSizer(wx.HORIZONTAL) |
| 73 | |
| 74 | self.totalAttrsLabel = wx.StaticText(self, wx.ID_ANY, " ", wx.DefaultPosition, wx.DefaultSize, 0) |