From 5b5c9b2bb732c521e573180c06f1fad343a00a84 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Fri, 13 May 2016 15:27:23 +0200 Subject: [PATCH] browser: pass mods to applets (closes #434) --- artiq/browser/datasets.py | 2 +- artiq/browser/experiments.py | 8 ++++++-- artiq/gui/models.py | 8 +++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/artiq/browser/datasets.py b/artiq/browser/datasets.py index 8059fd599..33bb44ca3 100644 --- a/artiq/browser/datasets.py +++ b/artiq/browser/datasets.py @@ -36,7 +36,7 @@ class DatasetsDock(QtWidgets.QDockWidget): QtWidgets.QAbstractItemView.SingleSelection) grid.addWidget(self.table, 1, 0) - self.table_model = Model(dict()) + self.set_model(Model(dict())) datasets_sub.add_setmodel_callback(self.set_model) def _search_datasets(self): diff --git a/artiq/browser/experiments.py b/artiq/browser/experiments.py index e6a4db792..ebe64ef6d 100644 --- a/artiq/browser/experiments.py +++ b/artiq/browser/experiments.py @@ -332,6 +332,10 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow): class LocalDatasetDB: + def __init__(self, datasets_sub): + self.datasets_sub = datasets_sub + datasets_sub.add_setmodel_callback(self.init) + def init(self, data): self._data = data @@ -339,6 +343,7 @@ class LocalDatasetDB: return self._data.backing_store[key][1] def update(self, mod): + self.datasets_sub.update(mod) process_mod(self._data, mod) @@ -351,8 +356,7 @@ class ExperimentsArea(QtWidgets.QMdiArea): self.open_experiments = [] - self._ddb = LocalDatasetDB() - datasets_sub.add_setmodel_callback(self._ddb.init) + self._ddb = LocalDatasetDB(datasets_sub) self.worker_handlers = { "get_device_db": lambda: None, diff --git a/artiq/gui/models.py b/artiq/gui/models.py index 3bc47470a..df4750509 100644 --- a/artiq/gui/models.py +++ b/artiq/gui/models.py @@ -32,12 +32,14 @@ class LocalModelManager(ModelManager): ModelManager.__init__(self, model_factory) self.notify_cbs = [] - def init(self, struct): - self._create_model(struct) - mod = {"action": "init", "struct": struct} + def update(self, mod): for notify_cb in self.notify_cbs: notify_cb(mod) + def init(self, struct): + self._create_model(struct) + self.update({"action": "init", "struct": struct}) + class _SyncSubstruct: def __init__(self, update_cb, ref):