forked from M-Labs/artiq
gui: regenerate argument setter when modified from repository
This commit is contained in:
parent
585bb236f8
commit
42010fcd4b
|
@ -12,7 +12,8 @@ from artiq.gui.scan import ScanController
|
||||||
|
|
||||||
|
|
||||||
class _ExplistModel(DictSyncModel):
|
class _ExplistModel(DictSyncModel):
|
||||||
def __init__(self, parent, init):
|
def __init__(self, explorer, parent, init):
|
||||||
|
self.explorer = explorer
|
||||||
DictSyncModel.__init__(self,
|
DictSyncModel.__init__(self,
|
||||||
["Experiment"],
|
["Experiment"],
|
||||||
parent, init)
|
parent, init)
|
||||||
|
@ -23,6 +24,11 @@ class _ExplistModel(DictSyncModel):
|
||||||
def convert(self, k, v, column):
|
def convert(self, k, v, column):
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
def __setitem__(self, k, v):
|
||||||
|
DictSyncModel.__setitem__(self, k, v)
|
||||||
|
if k == self.explorer.selected_key:
|
||||||
|
self.explorer.update_selection(k, k)
|
||||||
|
|
||||||
|
|
||||||
class _FreeValueEntry(QtGui.QLineEdit):
|
class _FreeValueEntry(QtGui.QLineEdit):
|
||||||
def __init__(self, procdesc):
|
def __init__(self, procdesc):
|
||||||
|
@ -166,7 +172,8 @@ class ExplorerDock(dockarea.Dock):
|
||||||
self.splitter.addWidget(grid)
|
self.splitter.addWidget(grid)
|
||||||
|
|
||||||
self.el = QtGui.QListView()
|
self.el = QtGui.QListView()
|
||||||
self.el.selectionChanged = self.update_argsetter
|
self.el.selectionChanged = self._selection_changed
|
||||||
|
self.selected_key = None
|
||||||
grid.addWidget(self.el, 0, 0, colspan=4)
|
grid.addWidget(self.el, 0, 0, colspan=4)
|
||||||
|
|
||||||
self.datetime = QtGui.QDateTimeEdit()
|
self.datetime = QtGui.QDateTimeEdit()
|
||||||
|
@ -200,28 +207,35 @@ class ExplorerDock(dockarea.Dock):
|
||||||
self.splitter.setSizes([grid.minimumSizeHint().width(), 1000])
|
self.splitter.setSizes([grid.minimumSizeHint().width(), 1000])
|
||||||
self.state = dict()
|
self.state = dict()
|
||||||
|
|
||||||
def update_argsetter(self, selected, deselected):
|
def update_selection(self, selected, deselected):
|
||||||
deselected = deselected.indexes()
|
|
||||||
if deselected:
|
if deselected:
|
||||||
row = deselected[0].row()
|
self.state[deselected] = self.argsetter.get_argument_values(False)
|
||||||
key = self.explist_model.row_to_key[row]
|
|
||||||
self.state[key] = self.argsetter.get_argument_values(False)
|
|
||||||
|
|
||||||
selected = selected.indexes()
|
|
||||||
if selected:
|
if selected:
|
||||||
row = selected[0].row()
|
expinfo = self.explist_model.backing_store[selected]
|
||||||
key = self.explist_model.row_to_key[row]
|
|
||||||
expinfo = self.explist_model.backing_store[key]
|
|
||||||
arguments = expinfo["arguments"]
|
arguments = expinfo["arguments"]
|
||||||
sizes = self.splitter.sizes()
|
sizes = self.splitter.sizes()
|
||||||
self.argsetter.deleteLater()
|
self.argsetter.deleteLater()
|
||||||
self.argsetter = _ArgumentSetter(self.dialog_parent, arguments)
|
self.argsetter = _ArgumentSetter(self.dialog_parent, arguments)
|
||||||
if key in self.state:
|
if selected in self.state:
|
||||||
arguments = self.state[key]
|
arguments = self.state[selected]
|
||||||
if arguments is not None:
|
if arguments is not None:
|
||||||
self.argsetter.set_argument_values(arguments, True)
|
self.argsetter.set_argument_values(arguments, True)
|
||||||
self.splitter.insertWidget(1, self.argsetter)
|
self.splitter.insertWidget(1, self.argsetter)
|
||||||
self.splitter.setSizes(sizes)
|
self.splitter.setSizes(sizes)
|
||||||
|
self.selected_key = selected
|
||||||
|
|
||||||
|
def _sel_to_key(self, selection):
|
||||||
|
selection = selection.indexes()
|
||||||
|
if selection:
|
||||||
|
row = selection[0].row()
|
||||||
|
return self.explist_model.row_to_key[row]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _selection_changed(self, selected, deselected):
|
||||||
|
self.update_selection(self._sel_to_key(selected),
|
||||||
|
self._sel_to_key(deselected))
|
||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
idx = self.el.selectedIndexes()
|
idx = self.el.selectedIndexes()
|
||||||
|
@ -248,7 +262,7 @@ class ExplorerDock(dockarea.Dock):
|
||||||
yield from self.explist_subscriber.close()
|
yield from self.explist_subscriber.close()
|
||||||
|
|
||||||
def init_explist_model(self, init):
|
def init_explist_model(self, init):
|
||||||
self.explist_model = _ExplistModel(self.el, init)
|
self.explist_model = _ExplistModel(self, self.el, init)
|
||||||
self.el.setModel(self.explist_model)
|
self.el.setModel(self.explist_model)
|
||||||
return self.explist_model
|
return self.explist_model
|
||||||
|
|
||||||
|
@ -266,11 +280,8 @@ class ExplorerDock(dockarea.Dock):
|
||||||
self.status_bar.showMessage("Submitted RID {}".format(rid))
|
self.status_bar.showMessage("Submitted RID {}".format(rid))
|
||||||
|
|
||||||
def submit_clicked(self):
|
def submit_clicked(self):
|
||||||
idx = self.el.selectedIndexes()
|
if self.selected_key is not None:
|
||||||
if idx:
|
expinfo = self.explist_model.backing_store[self.selected_key]
|
||||||
row = idx[0].row()
|
|
||||||
key = self.explist_model.row_to_key[row]
|
|
||||||
expinfo = self.explist_model.backing_store[key]
|
|
||||||
if self.datetime_en.isChecked():
|
if self.datetime_en.isChecked():
|
||||||
due_date = self.datetime.dateTime().toMSecsSinceEpoch()/1000
|
due_date = self.datetime.dateTime().toMSecsSinceEpoch()/1000
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue