Sorting State olumn takes on/off state into consideration.
This commit is contained in:
parent
58e30b6875
commit
8ccd74d3b1
@ -150,9 +150,24 @@ class VmStatusIcon(QLabel):
|
|||||||
|
|
||||||
class VmInfoWidget (QWidget):
|
class VmInfoWidget (QWidget):
|
||||||
|
|
||||||
|
class VmInfoItem (QTableWidgetItem):
|
||||||
|
def __init__(self, upd_info_item, vm):
|
||||||
|
super(VmInfoWidget.VmInfoItem, self).__init__()
|
||||||
|
self.upd_info_item = upd_info_item
|
||||||
|
self.vm = vm
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
self_val = 1 if self.vm.is_running() else 0
|
||||||
|
other_val = 1 if other.vm.is_running() else 0
|
||||||
|
|
||||||
|
self_val += self.upd_info_item.value
|
||||||
|
other_val += other.upd_info_item.value
|
||||||
|
|
||||||
|
return (self_val) < (other_val)
|
||||||
|
|
||||||
def __init__(self, vm, parent = None):
|
def __init__(self, vm, parent = None):
|
||||||
super (VmInfoWidget, self).__init__(parent)
|
super (VmInfoWidget, self).__init__(parent)
|
||||||
|
self.vm = vm
|
||||||
layout = QHBoxLayout ()
|
layout = QHBoxLayout ()
|
||||||
|
|
||||||
self.on_icon = VmStatusIcon(vm)
|
self.on_icon = VmStatusIcon(vm)
|
||||||
@ -169,7 +184,7 @@ class VmInfoWidget (QWidget):
|
|||||||
|
|
||||||
self.blk_icon.setVisible(False)
|
self.blk_icon.setVisible(False)
|
||||||
|
|
||||||
self.tableItem = self.upd_info.tableItem
|
self.tableItem = self.VmInfoItem(self.upd_info.tableItem, vm)
|
||||||
|
|
||||||
def update_vm_state(self, vm, blk_visible):
|
def update_vm_state(self, vm, blk_visible):
|
||||||
self.on_icon.update()
|
self.on_icon.update()
|
||||||
@ -342,20 +357,21 @@ class VmUpdateInfoWidget(QWidget):
|
|||||||
class VmUpdateInfoItem (QTableWidgetItem):
|
class VmUpdateInfoItem (QTableWidgetItem):
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
super(VmUpdateInfoWidget.VmUpdateInfoItem, self).__init__()
|
super(VmUpdateInfoWidget.VmUpdateInfoItem, self).__init__()
|
||||||
self.value = value
|
self.value = 0
|
||||||
|
self.set_value(value)
|
||||||
|
|
||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
self.value = value
|
if value == "outdated":
|
||||||
|
self.value = 30
|
||||||
def __lt__(self, other):
|
elif value == "update":
|
||||||
if self.value == "outdated":
|
self.value = 20
|
||||||
return other.value == "outdated"
|
elif value == "ok":
|
||||||
elif self.value == "update":
|
self.value = 10
|
||||||
return other.value == "outdated" or other.value == "update"
|
|
||||||
elif self.value == "ok":
|
|
||||||
return other.value == "outdated" or other.value == "update" or other.value == "ok"
|
|
||||||
else:
|
else:
|
||||||
return True
|
self.value = 0
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
return self.value < other.value
|
||||||
|
|
||||||
def __init__(self, vm, show_text=True, parent = None):
|
def __init__(self, vm, show_text=True, parent = None):
|
||||||
super (VmUpdateInfoWidget, self).__init__(parent)
|
super (VmUpdateInfoWidget, self).__init__(parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user