Devices tab.

This commit is contained in:
Agnieszka Kostrzewa 2012-03-13 20:06:41 +01:00
parent f155ef5780
commit b9e361d468
2 changed files with 49 additions and 4 deletions

View File

@ -102,8 +102,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.deleteRuleButton.clicked.connect(self.delete_rule_button_pressed)
####### devices tab
self.dev_list = MultiSelectWidget(self)
self.devices_layout.addWidget(self.dev_list)
self.__init_devices_tab__()
####### apps tab
if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
@ -147,6 +146,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
ret = self.__apply_basic_tab__()
self.__apply_advanced_tab__()
self.__apply_devices_tab__()
if len(ret) > 0 :
thread_monitor.set_error_msg('\n'.join(ret))
@ -395,6 +395,51 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.vm.kernel = kernel
self.anything_changed = True
######## devices tab
def __init_devices_tab__(self):
self.dev_list = MultiSelectWidget(self)
self.devices_layout.addWidget(self.dev_list)
devs = []
lspci = subprocess.Popen(["lspci",], stdout = subprocess.PIPE)
for dev in lspci.stdout:
devs.append( (dev.rstrip(), dev.split(' ')[0]) )
class DevListWidgetItem(QListWidgetItem):
def __init__(self, name, slot, parent = None):
super(DevListWidgetItem, self).__init__(name, parent)
self.slot = slot
for d in devs:
if d[1] in self.vm.pcidevs:
self.dev_list.selected_list.addItem( DevListWidgetItem(d[0], d[1]))
else:
self.dev_list.available_list.addItem( DevListWidgetItem(d[0], d[1]))
def __apply_devices_tab__(self):
sth_changed = False
added = []
for i in range(self.dev_list.selected_list.count()):
item = self.dev_list.selected_list.item(i)
if item.slot not in self.vm.pcidevs:
added.append(item)
if self.dev_list.selected_list.count() - len(added) < len(self.vm.pcidevs): #sth removed
sth_changed = True;
elif len(added) > 0:
sth_changed = True;
if sth_changed == True:
pcidevs = []
for i in range(self.dev_list.selected_list.count()):
slot = self.dev_list.selected_list.item(i).slot
pcidevs.append(slot)
self.vm.pcidevs = pcidevs
self.anything_changed = True
######### firewall tab related
def set_fw_model(self, model):

View File

@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -721,7 +721,7 @@
</widget>
<widget class="QWidget" name="devices_tab">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<attribute name="title">
<string>Devices</string>