From b51585fddb6a791e94962c7904c6a1021c78f905 Mon Sep 17 00:00:00 2001 From: matzman666 Date: Sat, 19 Dec 2015 23:15:20 +0100 Subject: [PATCH] Added more columns to location browser. Table row indices now start with 1 (not all people are programmers). --- widgets/locationbrowser/locationbrowser.py | 40 +++++++++++++++++++--- widgets/radio/radiowidget.py | 2 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/widgets/locationbrowser/locationbrowser.py b/widgets/locationbrowser/locationbrowser.py index 72e8b54..745af71 100644 --- a/widgets/locationbrowser/locationbrowser.py +++ b/widgets/locationbrowser/locationbrowser.py @@ -38,7 +38,7 @@ def rowCount(self, parent = QtCore.QModelIndex()): return 0 def columnCount(self, parent = QtCore.QModelIndex()): - return 3 + return 8 def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole): if orientation == QtCore.Qt.Horizontal: @@ -46,9 +46,19 @@ def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole): if section == 0: return 'Name' elif section == 1: - return 'Discovered' + return 'Type' elif section == 2: + return 'Discovered' + elif section == 3: return 'Cleared' + elif section == 4: + return 'Owned' + elif section == 5: + return 'Population' + elif section == 6: + return 'Happiness' + elif section == 7: + return 'Visible' return None def data(self, index, role = QtCore.Qt.DisplayRole): @@ -59,17 +69,39 @@ def _data(self, location, column, role = QtCore.Qt.DisplayRole): if column == 0: return location.child('Name').value() elif column == 1: + return location.child('type').value() + elif column == 2: discovered = location.child('Discovered') if discovered: return discovered.value() else: return '-' - elif column == 2: + elif column == 3: cleared = location.child('ClearedStatus') if cleared: return cleared.value() else: return '-' + elif column == 4: + owned = location.child('WorkshopOwned') + if owned: + return owned.value() + else: + return '-' + elif column == 5: + pop = location.child('WorkshopPopulation') + if pop: + return pop.value() + else: + return '-' + elif column == 6: + hap = location.child('WorkshopHappinessPct') + if hap: + return hap.value() + else: + return '-' + elif column == 7: + return location.child('Visible').value() return None def getPipValue(self, row): @@ -111,7 +143,7 @@ def filterAcceptsRow(self, source_row, source_parent): def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole): if orientation == QtCore.Qt.Vertical: if role == QtCore.Qt.DisplayRole: - return section + return section + 1 else: return super().headerData(section, orientation, role) diff --git a/widgets/radio/radiowidget.py b/widgets/radio/radiowidget.py index c74f9e2..df25ed1 100644 --- a/widgets/radio/radiowidget.py +++ b/widgets/radio/radiowidget.py @@ -99,7 +99,7 @@ def sort(self, column, order = QtCore.Qt.AscendingOrder): def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole): if orientation == QtCore.Qt.Vertical: if role == QtCore.Qt.DisplayRole: - return section + return section + 1 else: return super().headerData(section, orientation, role)