Skip to content

Commit 03ed80f

Browse files
committed
Fix virtual device removal
1 parent 112c323 commit 03ed80f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

blacs/plugins/virtual_device/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class Menu(object):
168168
VD_TREE_COL_DELETE = 3
169169
VD_TREE_ROLE_IS_DUMMY_ROW = Qt.UserRole + 1
170170
VD_TREE_ROLE_DO_INVERTED = Qt.UserRole + 2
171+
VD_TREE_ROLE_IS_VIRTUAL_DEVICE = Qt.UserRole + 3
171172

172173
def _get_root_parent(item):
173174
while item.parent() is not None:
@@ -339,6 +340,7 @@ def on_virtual_devices_item_changed(self, item):
339340

340341
new_device_item = QStandardItem(new_vd_name)
341342
remove_item = QStandardItem()
343+
remove_item.setData(True, self.VD_TREE_ROLE_IS_VIRTUAL_DEVICE)
342344
remove_item.setIcon(QIcon(':qtutils/fugue/minus'))
343345
remove_item.setEditable(False)
344346
remove_item.setToolTip('Remove this virtual device')
@@ -364,6 +366,8 @@ def on_treeView_virtual_devices_clicked(self, index):
364366
elif item.column() == self.VD_TREE_COL_DN:
365367
if index.row() < item.parent().rowCount()-1:
366368
item.parent().insertRow(index.row()+1, item.parent().takeRow(index.row()))
369+
elif item.data(self.VD_TREE_ROLE_IS_VIRTUAL_DEVICE) and item.column() == self.VD_TREE_COL_DELETE:
370+
self.virtual_device_model.removeRows(index.row(), 1)
367371
elif item.column() == self.VD_TREE_COL_DELETE:
368372
item.parent().removeRow(index.row())
369373

@@ -372,7 +376,12 @@ def on_edit_virtual_devices(self, *args, **kwargs):
372376
# This happens here so that the tree is up to date
373377
for vd_name, vd in self.BLACS['plugins'][module].get_save_virtual_devices().items():
374378
device_item = QStandardItem(vd_name)
375-
self.virtual_device_model.appendRow([device_item])
379+
remove_item = QStandardItem()
380+
remove_item.setData(True, self.VD_TREE_ROLE_IS_VIRTUAL_DEVICE)
381+
remove_item.setIcon(QIcon(':qtutils/fugue/minus'))
382+
remove_item.setEditable(False)
383+
remove_item.setToolTip('Remove this virtual device')
384+
self.virtual_device_model.appendRow([device_item, None, None, remove_item])
376385

377386
analog_outputs = QStandardItem('Analog Outputs')
378387
device_item.appendRow(analog_outputs)

0 commit comments

Comments
 (0)