Skip to content

Commit

Permalink
Restored add/remove/change events handling
Browse files Browse the repository at this point in the history
  • Loading branch information
donob4n committed Sep 18, 2019
1 parent 2f9b21f commit bdf1601
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def __init__(self, qubes_app):
QtCore.QAbstractTableModel.__init__(self)
self.qubes_app = qubes_app
self.info_list = []
self.info_by_id = {}
self.template = {}
self.klass_pixmap = {}
self.label_pixmap = {}
Expand Down Expand Up @@ -306,9 +307,9 @@ def fill_list(self):

row_no = 0
for vm in vms_list:
print(row_no)
progress.setValue(row_no)
self.info_list.append(VmInfo(vm))
self.info_by_id[vm.qid] = self.info_list[row_no]
row_no += 1

progress.setValue(row_no)
Expand Down Expand Up @@ -672,8 +673,8 @@ def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
self.update_size_on_disk = False
self.shutdown_monitor = {}

qubes_model = QubesTableModel(qubes_app)
self.table.setModel(qubes_model)
self.qubes_model = QubesTableModel(qubes_app)
self.table.setModel(self.qubes_model)
self.table.setItemDelegateForColumn(3, StateIconDelegate())
self.table.resizeColumnsToContents()

Expand Down Expand Up @@ -762,16 +763,39 @@ def check_updates(self):
pass

def on_domain_added(self, _submitter, _event, vm, **_kwargs):
pass
try:
domain = self.qubes_app.domains[vm]
self.qubes_model.info_by_id[domain.qid] = VmInfo(domain)
self.qubes_model.info_list.append(self.qubes_model.info_by_id[domain.qid])
self.qubes_model.layoutChanged.emit()
except (exc.QubesException, KeyError):
pass

def on_domain_removed(self, _submitter, _event, **kwargs):
pass
for qid, vm in self.qubes_model.info_by_id.items():
if vm.name == kwargs['vm']:
self.qubes_model.info_list.remove(self.qubes_model.info_by_id[qid])
del self.qubes_model.info_by_id[qid]
self.qubes_model.layoutChanged.emit()
return

def on_domain_status_changed(self, vm, _event, **_kwargs):
pass
try:
self.qubes_model.info_by_id[vm.qid].update()
self.qubes_model.layoutChanged.emit()
except exc.QubesPropertyAccessError:
return # the VM was deleted before its status could be updated
except KeyError: # adding the VM failed for some reason
self.on_domain_added(None, None, vm)

def on_domain_changed(self, vm, event, **_kwargs):
pass
if not vm: # change of global properties occured
return
try:
self.qubes_model.info_by_id[vm.qid].update(event=event)
self.qubes_model.layoutChanged.emit()
except exc.QubesPropertyAccessError:
return # the VM was deleted before its status could be updated

def load_manager_settings(self):
for col in self.columns_indices:
Expand Down

0 comments on commit bdf1601

Please sign in to comment.