device_list.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/python3
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License along
  16. # with this program; if not, see <http://www.gnu.org/licenses/>.
  17. #
  18. #
  19. from . import ui_devicelist # pylint: disable=no-name-in-module
  20. from PyQt4 import QtGui, QtCore # pylint: disable=import-error
  21. class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtGui.QDialog):
  22. def __init__(self, vm, qapp, dev_list, parent=None):
  23. super(PCIDeviceListWindow, self).__init__(parent)
  24. self.vm = vm
  25. self.qapp = qapp
  26. self.dev_list = dev_list
  27. self.setupUi(self)
  28. self.connect(
  29. self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply)
  30. self.connect(
  31. self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)
  32. self.fill_device_list()
  33. def fill_device_list(self):
  34. self.device_list.clear()
  35. pci_devices = [ass.ident.replace('_', ':')
  36. for ass in self.vm.devices['pci'].assignments()]
  37. for i in range(self.dev_list.selected_list.count()):
  38. text = self.dev_list.selected_list.item(i).text()
  39. ident = self.dev_list.selected_list.item(i).ident
  40. if ident in pci_devices:
  41. self.device_list.addItem(text)
  42. def reject(self):
  43. self.done(0)
  44. def save_and_apply(self):
  45. self.done(0)
  46. def show(self):
  47. super(PCIDeviceListWindow, self).show()
  48. self.fill_device_list()