forked from M-Labs/artiq
1
0
Fork 0

dashboard: simplify dataset editing code

This commit is contained in:
Sebastien Bourdeauducq 2016-07-03 12:23:56 +08:00
parent 77f60a3e63
commit dd349b0701
1 changed files with 3 additions and 5 deletions

View File

@ -13,12 +13,11 @@ logger = logging.getLogger(__name__)
class Editor(QtWidgets.QDialog): class Editor(QtWidgets.QDialog):
def __init__(self, parent, dataset_ctl, key, value, persist): def __init__(self, parent, dataset_ctl, key, value):
QtWidgets.QDialog.__init__(self, parent=parent) QtWidgets.QDialog.__init__(self, parent=parent)
self.dataset_ctl = dataset_ctl self.dataset_ctl = dataset_ctl
self.key = key self.key = key
self.initial_type = type(value) self.initial_type = type(value)
self.persist = persist
self.setWindowTitle("Edit dataset") self.setWindowTitle("Edit dataset")
grid = QtWidgets.QGridLayout() grid = QtWidgets.QGridLayout()
@ -39,8 +38,7 @@ class Editor(QtWidgets.QDialog):
def accept(self): def accept(self):
value = self.initial_type(self.get_edit_widget_value()) value = self.initial_type(self.get_edit_widget_value())
asyncio.ensure_future(self.dataset_ctl.set( asyncio.ensure_future(self.dataset_ctl.set(self.key, value))
self.key, value, self.persist))
QtWidgets.QDialog.accept(self) QtWidgets.QDialog.accept(self)
def get_edit_widget(self, initial_value): def get_edit_widget(self, initial_value):
@ -165,7 +163,7 @@ class DatasetsDock(QtWidgets.QDockWidget):
logger.error("Cannot edit dataset %s: " logger.error("Cannot edit dataset %s: "
"type %s is not supported", key, t) "type %s is not supported", key, t)
return return
dialog_cls(self, self.dataset_ctl, key, value, persist).open() dialog_cls(self, self.dataset_ctl, key, value).open()
def delete_clicked(self): def delete_clicked(self):
idx = self.table.selectedIndexes() idx = self.table.selectedIndexes()