diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-09-27 20:01:41 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-09-27 20:01:41 +0300 |
commit | afca431f3c8a8975cce2ebe59ae42e7f7b021a09 (patch) | |
tree | c22c6c691c260834072586ee923e98209e80150e /mesongui.py | |
parent | 59ef84102bed43123555d44019520de318308839 (diff) | |
download | meson-afca431f3c8a8975cce2ebe59ae42e7f7b021a09.zip meson-afca431f3c8a8975cce2ebe59ae42e7f7b021a09.tar.gz meson-afca431f3c8a8975cce2ebe59ae42e7f7b021a09.tar.bz2 |
Display headers in tree views.
Diffstat (limited to 'mesongui.py')
-rwxr-xr-x | mesongui.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/mesongui.py b/mesongui.py index 52f2fab..72f6fd4 100755 --- a/mesongui.py +++ b/mesongui.py @@ -17,7 +17,7 @@ import sys, os, pickle import build, coredata from PyQt5 import uic -from PyQt5.QtWidgets import QApplication, QMainWindow +from PyQt5.QtWidgets import QApplication, QMainWindow, QHeaderView from PyQt5.QtCore import QAbstractItemModel, QModelIndex, QVariant import PyQt5.QtCore @@ -46,10 +46,30 @@ class PathModel(QAbstractItemModel): return 2 def headerData(self, section, orientation, role): + if role != PyQt5.QtCore.Qt.DisplayRole: + return QVariant() if section == 1: return QVariant('Path') return QVariant('Type') + def index(self, row, column, parent): + return self.createIndex(row, column) + + def index(self, row, column, parent): + return self.createIndex(row, column) + + def data(self, index, role): + if role != PyQt5.QtCore.Qt.DisplayRole: + return QVariant() + row = index.row() + column = index.column() + if column == 0: + return self.names[row] + return getattr(self.coredata, self.attr_name[row]) + + def parent(self, index): + return QModelIndex() + def setData(self, index, value, role): if role != PyQt5.QtCore.Qt.EditRole: return False @@ -89,8 +109,10 @@ class TargetModel(QAbstractItemModel): return 3 def headerData(self, section, orientation, role): + if role != PyQt5.QtCore.Qt.DisplayRole: + return QVariant() if section == 2: - return QVariant('Number of source files') + return QVariant('Source files') if section == 1: return QVariant('Type') return QVariant('Name') @@ -104,7 +126,7 @@ class TargetModel(QAbstractItemModel): def index(self, row, column, parent): return self.createIndex(row, column) - + def parent(self, index): return QModelIndex() @@ -126,7 +148,13 @@ class MesonGui(): self.target_model = TargetModel(self.build) self.fill_data() self.ui.path_view.setModel(self.path_model) + hv = QHeaderView(1) + hv.setModel(self.path_model) + self.ui.path_view.setHeader(hv) self.ui.target_view.setModel(self.target_model) + hv = QHeaderView(1) + hv.setModel(self.target_model) + self.ui.target_view.setHeader(hv) def fill_data(self): self.ui.project_label.setText('Hack project') |