Skip to content

Commit

Permalink
Added more columns to location browser.
Browse files Browse the repository at this point in the history
Table row indices now start with 1 (not all people are programmers).
  • Loading branch information
matzman666 committed Dec 19, 2015
1 parent ce2bcdf commit b51585f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
40 changes: 36 additions & 4 deletions widgets/locationbrowser/locationbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ 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:
if 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):
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion widgets/radio/radiowidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b51585f

Please sign in to comment.