gui/datasets: tree view

This commit is contained in:
Sebastien Bourdeauducq 2015-11-17 19:46:17 +08:00
parent 107d8f0ffa
commit 9c5db288a5
1 changed files with 8 additions and 12 deletions

View File

@ -8,7 +8,7 @@ from pyqtgraph import dockarea
from pyqtgraph import LayoutWidget from pyqtgraph import LayoutWidget
from artiq.tools import short_format from artiq.tools import short_format
from artiq.gui.models import DictSyncModel from artiq.gui.models import DictSyncTreeSepModel
from artiq.gui.displays import * from artiq.gui.displays import *
try: try:
@ -20,17 +20,14 @@ except AttributeError:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class Model(DictSyncModel): class Model(DictSyncTreeSepModel):
def __init__(self, init): def __init__(self, init):
DictSyncModel.__init__(self, ["Dataset", "Persistent", "Value"], init) DictSyncTreeSepModel.__init__(self, ".",
["Dataset", "Persistent", "Value"],
def sort_key(self, k, v): init)
return k
def convert(self, k, v, column): def convert(self, k, v, column):
if column == 0: if column == 1:
return k
elif column == 1:
return "Y" if v[0] else "N" return "Y" if v[0] else "N"
elif column == 2: elif column == 2:
return short_format(v[1]) return short_format(v[1])
@ -58,10 +55,9 @@ class DatasetsDock(dockarea.Dock):
self.search.editingFinished.connect(self._search_datasets) self.search.editingFinished.connect(self._search_datasets)
grid.addWidget(self.search, 0, 0) grid.addWidget(self.search, 0, 0)
self.table = QtGui.QTableView() self.table = QtGui.QTreeView()
self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
self.table.horizontalHeader().setResizeMode( self.table.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
QtGui.QHeaderView.ResizeToContents)
grid.addWidget(self.table, 1, 0) grid.addWidget(self.table, 1, 0)
self.table_model = Model(dict()) self.table_model = Model(dict())