device_list.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, no_strict_reset_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.no_strict_reset_list = no_strict_reset_list
  28. self.setupUi(self)
  29. self.connect(
  30. self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply)
  31. self.connect(
  32. self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)
  33. self.ident_list = {}
  34. self.fill_device_list()
  35. def fill_device_list(self):
  36. self.device_list.clear()
  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).dev.ident
  40. self.device_list.addItem(text)
  41. self.ident_list[text] = ident
  42. if ident in self.no_strict_reset_list:
  43. self.device_list.setItemSelected(
  44. self.device_list.item(i), True)
  45. def reject(self):
  46. self.done(0)
  47. def save_and_apply(self):
  48. self.no_strict_reset_list.clear()
  49. self.no_strict_reset_list.extend([self.ident_list[item.text()] for item
  50. in self.device_list.selectedItems()])
  51. self.done(0)