Merge remote-tracking branch 'origin/pr/275'
* origin/pr/275: Replace '2' with Qt.Checked Rename 'Include in backups' to 'Backup' flags() rewrite Fix empty lines Include in backups changed to 'CheckStateRole'
This commit is contained in:
commit
7f257b1c8e
@ -359,7 +359,7 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
"Disk Usage",
|
"Disk Usage",
|
||||||
"Internal",
|
"Internal",
|
||||||
"IP",
|
"IP",
|
||||||
"Include in backups",
|
"Backup",
|
||||||
"Last backup",
|
"Last backup",
|
||||||
"Default DispVM",
|
"Default DispVM",
|
||||||
"Is DVM Template",
|
"Is DVM Template",
|
||||||
@ -404,8 +404,6 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
return "Yes" if vm.internal else ""
|
return "Yes" if vm.internal else ""
|
||||||
if col_name == "IP":
|
if col_name == "IP":
|
||||||
return vm.ip
|
return vm.ip
|
||||||
if col_name == "Include in backups":
|
|
||||||
return "Yes" if vm.inc_backup else ""
|
|
||||||
if col_name == "Last backup":
|
if col_name == "Last backup":
|
||||||
return vm.last_backup
|
return vm.last_backup
|
||||||
if col_name == "Default DispVM":
|
if col_name == "Default DispVM":
|
||||||
@ -428,7 +426,6 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
return self.klass_pixmap[vm.klass]
|
return self.klass_pixmap[vm.klass]
|
||||||
except exc.QubesDaemonAccessError:
|
except exc.QubesDaemonAccessError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if col_name == "Label":
|
if col_name == "Label":
|
||||||
try:
|
try:
|
||||||
return self.label_pixmap[vm.icon]
|
return self.label_pixmap[vm.icon]
|
||||||
@ -436,23 +433,22 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
icon = QIcon.fromTheme(vm.icon)
|
icon = QIcon.fromTheme(vm.icon)
|
||||||
self.label_pixmap[vm.icon] = icon.pixmap(icon_size)
|
self.label_pixmap[vm.icon] = icon.pixmap(icon_size)
|
||||||
return self.label_pixmap[vm.icon]
|
return self.label_pixmap[vm.icon]
|
||||||
|
if role == Qt.CheckStateRole:
|
||||||
|
if col_name == "Backup":
|
||||||
|
return Qt.Checked if vm.inc_backup else Qt.Unchecked
|
||||||
if role == Qt.FontRole:
|
if role == Qt.FontRole:
|
||||||
if col_name == "Template":
|
if col_name == "Template":
|
||||||
if vm.template is None:
|
if vm.template is None:
|
||||||
font = QFont()
|
font = QFont()
|
||||||
font.setItalic(True)
|
font.setItalic(True)
|
||||||
return font
|
return font
|
||||||
|
|
||||||
if role == Qt.ForegroundRole:
|
if role == Qt.ForegroundRole:
|
||||||
if col_name == "Template":
|
if col_name == "Template":
|
||||||
if vm.template is None:
|
if vm.template is None:
|
||||||
return QColor("gray")
|
return QColor("gray")
|
||||||
|
|
||||||
# Used for get VM Object
|
# Used for get VM Object
|
||||||
if role == Qt.UserRole:
|
if role == Qt.UserRole:
|
||||||
return vm
|
return vm
|
||||||
|
|
||||||
# Used for sorting
|
# Used for sorting
|
||||||
if role == Qt.UserRole + 1:
|
if role == Qt.UserRole + 1:
|
||||||
if vm.klass == 'AdminVM':
|
if vm.klass == 'AdminVM':
|
||||||
@ -465,7 +461,6 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
return str(vm.state)
|
return str(vm.state)
|
||||||
if col_name == "Disk Usage":
|
if col_name == "Disk Usage":
|
||||||
return vm.disk_float
|
return vm.disk_float
|
||||||
|
|
||||||
return self.data(index, Qt.DisplayRole)
|
return self.data(index, Qt.DisplayRole)
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
@ -476,6 +471,27 @@ class QubesTableModel(QAbstractTableModel):
|
|||||||
return self.columns_indices[col]
|
return self.columns_indices[col]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def setData(self, index, value, role=Qt.EditRole):
|
||||||
|
if not index.isValid():
|
||||||
|
return False
|
||||||
|
|
||||||
|
if role == Qt.CheckStateRole:
|
||||||
|
col_name = self.columns_indices[index.column()]
|
||||||
|
if col_name == "Backup":
|
||||||
|
vm = self.qubes_cache.get_vm(index.row())
|
||||||
|
vm.vm.include_in_backups = (value == Qt.Checked)
|
||||||
|
vm.inc_backup = (value == Qt.Checked)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def flags(self, index):
|
||||||
|
if not index.isValid():
|
||||||
|
return False
|
||||||
|
|
||||||
|
def_flags = QAbstractTableModel.flags(self, index)
|
||||||
|
if self.columns_indices[index.column()] == "Backup":
|
||||||
|
return def_flags | Qt.ItemIsUserCheckable
|
||||||
|
return def_flags
|
||||||
|
|
||||||
vm_shutdown_timeout = 20000 # in msec
|
vm_shutdown_timeout = 20000 # in msec
|
||||||
vm_restart_check_timeout = 1000 # in msec
|
vm_restart_check_timeout = 1000 # in msec
|
||||||
|
Loading…
Reference in New Issue
Block a user