From 9c5db288a530abccc714993de5c4f2dd9f66e0b7 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 17 Nov 2015 19:46:17 +0800 Subject: [PATCH] gui/datasets: tree view --- artiq/gui/datasets.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/artiq/gui/datasets.py b/artiq/gui/datasets.py index de4d505ee..d06bf26ef 100644 --- a/artiq/gui/datasets.py +++ b/artiq/gui/datasets.py @@ -8,7 +8,7 @@ from pyqtgraph import dockarea from pyqtgraph import LayoutWidget from artiq.tools import short_format -from artiq.gui.models import DictSyncModel +from artiq.gui.models import DictSyncTreeSepModel from artiq.gui.displays import * try: @@ -20,17 +20,14 @@ except AttributeError: logger = logging.getLogger(__name__) -class Model(DictSyncModel): +class Model(DictSyncTreeSepModel): def __init__(self, init): - DictSyncModel.__init__(self, ["Dataset", "Persistent", "Value"], init) - - def sort_key(self, k, v): - return k + DictSyncTreeSepModel.__init__(self, ".", + ["Dataset", "Persistent", "Value"], + init) def convert(self, k, v, column): - if column == 0: - return k - elif column == 1: + if column == 1: return "Y" if v[0] else "N" elif column == 2: return short_format(v[1]) @@ -58,10 +55,9 @@ class DatasetsDock(dockarea.Dock): self.search.editingFinished.connect(self._search_datasets) grid.addWidget(self.search, 0, 0) - self.table = QtGui.QTableView() + self.table = QtGui.QTreeView() self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) - self.table.horizontalHeader().setResizeMode( - QtGui.QHeaderView.ResizeToContents) + self.table.header().setResizeMode(QtGui.QHeaderView.ResizeToContents) grid.addWidget(self.table, 1, 0) self.table_model = Model(dict())