From cd8a243f5c16621eac9e2d1533238a72b22e16cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 23 Jan 2018 20:28:19 +0100 Subject: [PATCH] Fixes to resizing in Qube Manager Change column resize mode to interactive and stretch last column, so there's no useless space on the right. Also minor fix to sorting last_timestamp column, for more readability and also to fix a rare bug. --- qubesmanager/qube_manager.py | 5 ++++- qubesmanager/table_widgets.py | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 9cb6ef1..1a23e7f 100755 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -291,7 +291,10 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.table.setColumnWidth(self.columns_indices["Backups"], 60) self.table.setColumnWidth(self.columns_indices["Last backup"], 90) - self.table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Fixed) + self.table.horizontalHeader().setResizeMode( + QtGui.QHeaderView.Interactive) + self.table.horizontalHeader().setStretchLastSection(True) + self.table.sortItems(self.columns_indices[self.sort_by_column], self.sort_order) diff --git a/qubesmanager/table_widgets.py b/qubesmanager/table_widgets.py index efa3fe6..1a426de 100644 --- a/qubesmanager/table_widgets.py +++ b/qubesmanager/table_widgets.py @@ -505,7 +505,9 @@ class VmLastBackupItem(QtGui.QTableWidgetItem): self.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.vm = vm - if getattr(self.vm, 'backup_timestamp', None): + self.backup_timestamp = getattr(self.vm, 'backup_timestamp', None) + + if self.backup_timestamp: self.setText( str(datetime.datetime.fromtimestamp(self.vm.backup_timestamp))) else: @@ -516,10 +518,10 @@ class VmLastBackupItem(QtGui.QTableWidgetItem): return True elif other.vm.qid == 0: return False - elif self.vm.backup_timestamp == other.vm.backup_timestamp: + elif self.backup_timestamp == other.backup_timestamp: return self.vm.name < other.vm.name - elif not self.vm.backup_timestamp: + elif not self.backup_timestamp: return False - elif not other.vm.backup_timestamp: + elif not other.backup_timestamp: return True - return self.vm.backup_timestamp < other.vm.backup_timestamp + return self.backup_timestamp < other.backup_timestamp