Add IP and included in backups columns (#735, #798)

This commit is contained in:
Marek Marczykowski-Górecki 2014-03-10 04:27:52 +01:00
parent 7053041a4d
commit 55a965e5bd
2 changed files with 91 additions and 3 deletions

View File

@ -117,6 +117,9 @@
<property name="rowCount">
<number>10</number>
</property>
<property name="columnCount">
<number>14</number>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
@ -224,6 +227,16 @@
<string>Internal</string>
</property>
</column>
<column>
<property name="text">
<string>IP</string>
</property>
</column>
<column>
<property name="text">
<string>Backups</string>
</property>
</column>
</widget>
</item>
</layout>
@ -264,6 +277,8 @@
<addaction name="action_mem_graph"/>
<addaction name="action_size_on_disk"/>
<addaction name="action_internal"/>
<addaction name="action_ip"/>
<addaction name="action_backups"/>
<addaction name="separator"/>
<addaction name="action_toolbar"/>
<addaction name="action_menubar"/>
@ -825,6 +840,28 @@
<string>Start VM for Window Tools installation</string>
</property>
</action>
<action name="action_ip">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>IP</string>
</property>
</action>
<action name="action_backups">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Include in backups</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>

View File

@ -661,6 +661,33 @@ class VmSizeOnDiskItem (QTableWidgetItem):
else:
return self.value < other.value
class VmIPItem(QTableWidgetItem):
def __init__(self, vm):
super(VmIPItem, self).__init__()
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
self.ip = vm.ip
if self.ip:
self.setText(self.ip)
else:
self.setText("n/a")
class VmIncludeInBackupsItem(QTableWidgetItem):
def __init__(self, vm):
super(VmIncludeInBackupsItem, self).__init__()
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
self.vm = vm
if self.vm.include_in_backups:
self.setText("Yes")
else:
self.setText("")
def __lt__(self, other):
if self.vm.include_in_backups == other.vm.include_in_backups:
return self.vm.qid < other.vm.qid
else:
return self.vm.include_in_backups < other.vm.include_in_backups
class VmRowInTable(object):
cpu_graph_hue = 210
@ -717,6 +744,13 @@ class VmRowInTable(object):
self.internal_widget = VmInternalItem(vm)
table.setItem(row_no, VmManagerWindow.columns_indices['Internal'], self.internal_widget)
self.ip_widget = VmIPItem(vm)
table.setItem(row_no, VmManagerWindow.columns_indices['IP'], self.ip_widget)
self.include_in_backups_widget = VmIncludeInBackupsItem(vm)
table.setItem(row_no, VmManagerWindow.columns_indices[
'Backups'], self.include_in_backups_widget)
def update(self, blk_visible = None, cpu_load = None, update_size_on_disk = False, rec_visible = None):
self.info_widget.update_vm_state(self.vm, blk_visible, rec_visible)
if cpu_load is not None:
@ -772,9 +806,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
"MEM": 8,
"MEM Graph": 9,
"Size": 10,
"Internal": 11,}
"Internal": 11,
"IP": 12,
"Backups": 13,
}
def __init__(self, parent=None):
super(VmManagerWindow, self).__init__()
@ -828,6 +863,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.columns_actions[ self.columns_indices["MEM Graph"] ] = self.action_mem_graph
self.columns_actions[ self.columns_indices["Size"] ] = self.action_size_on_disk
self.columns_actions[ self.columns_indices["Internal"] ] = self.action_internal
self.columns_actions[ self.columns_indices["IP"] ] = self\
.action_ip
self.columns_actions[ self.columns_indices["Backups"] ] = self\
.action_backups
self.visible_columns_count = len(self.columns_indices)
self.table.setColumnHidden( self.columns_indices["NetVM"], True)
@ -840,6 +879,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.action_size_on_disk.setChecked(False)
self.table.setColumnHidden( self.columns_indices["Internal"], True)
self.action_internal.setChecked(False)
self.table.setColumnHidden( self.columns_indices["IP"], True)
self.action_ip.setChecked(False)
self.table.setColumnHidden( self.columns_indices["Backups"], True)
self.action_backups.setChecked(False)
self.table.setColumnWidth(self.columns_indices["State"], 80)
self.table.setColumnWidth(self.columns_indices["Name"], 150)
@ -847,6 +890,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.table.setColumnWidth(self.columns_indices["Type"], 40)
self.table.setColumnWidth(self.columns_indices["Size"], 100)
self.table.setColumnWidth(self.columns_indices["Internal"], 60)
self.table.setColumnWidth(self.columns_indices["IP"], 100)
self.table.setColumnWidth(self.columns_indices["Backups"], 60)
self.table.horizontalHeader().setResizeMode(QHeaderView.Fixed)
@ -1833,6 +1878,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
def on_action_internal_toggled(self, checked):
self.showhide_column( self.columns_indices['Internal'], checked)
def on_action_ip_toggled(self, checked):
self.showhide_column( self.columns_indices['IP'], checked)
def on_action_backups_toggled(self, checked):
self.showhide_column( self.columns_indices['Backups'], checked)
def on_action_template_toggled(self, checked):
self.showhide_column( self.columns_indices['Template'], checked)