1 import QtConfigurator.Forms 2 import XSLForms.Prepare 3 import factory 4 import qtui 5 import os 6 7 class Configurator(QtConfigurator.Forms.Configurator): 8 9 resource_dir = os.path.join(os.path.split(__file__)[0], "Resources") 10 ui_filename = os.path.join(resource_dir, "config.ui") 11 ui_hard_disks_filename = os.path.join(resource_dir, "config_hard_disks.ui") 12 ui_memory_units_filename = os.path.join(resource_dir, "config_memory_units.ui") 13 ui_storage_units_filename = os.path.join(resource_dir, "config_storage_units.ui") 14 15 def __init__(self, *args, **kw): 16 QtConfigurator.Forms.Configurator.__init__(self, *args, **kw) 17 self.factory = factory.Factory(self.ui_filename) 18 XSLForms.Prepare.ensure_qt_fragment(self.ui_filename, self.ui_hard_disks_filename, "hard_disks") 19 XSLForms.Prepare.ensure_qt_fragment(self.ui_filename, self.ui_memory_units_filename, "memory_units") 20 XSLForms.Prepare.ensure_qt_fragment(self.ui_filename, self.ui_storage_units_filename, "storage_units") 21 22 def baseSystemChanged(self): 23 print self.base_system.currentItem() 24 25 def addHardDisk(self): 26 hard_disks = qtui.QWidgetFactory.create(self.ui_hard_disks_filename) 27 tab_pages = hard_disks.child("tab pages") 28 tab = tab_pages.child("tab") 29 self.hard_disks.addTab(tab, hard_disks.tabLabel(tab)) 30 self.factory.connect(tab, self) 31 32 def addMemoryUnit(self): 33 memory_units = qtui.QWidgetFactory.create(self.ui_memory_units_filename) 34 tab_pages = memory_units.child("tab pages") 35 tab = tab_pages.child("tab") 36 self.memory_units.addTab(tab, memory_units.tabLabel(tab)) 37 self.factory.connect(tab, self) 38 39 def addStorageUnit(self): 40 storage_units = qtui.QWidgetFactory.create(self.ui_storage_units_filename) 41 tab_pages = storage_units.child("tab pages") 42 tab = tab_pages.child("tab") 43 self.storage_units.addTab(tab, storage_units.tabLabel(tab)) 44 self.factory.connect(tab, self) 45 46 def removeHardDisk(self): 47 page = self.hard_disks.currentPage() 48 self.hard_disks.removePage(page) 49 page.deleteLater() 50 51 def removeMemoryUnit(self): 52 page = self.memory_units.currentPage() 53 self.memory_units.removePage(page) 54 page.deleteLater() 55 56 def removeStorageUnit(self): 57 page = self.storage_units.currentPage() 58 self.storage_units.removePage(page) 59 page.deleteLater() 60 61 def updateConfig(self): 62 print "configuration.updateConfig(): Not implemented yet" 63 64 def exportConfig(self): 65 print "configuration.exportConfig(): Not implemented yet" 66 67 # vim: tabstop=4 expandtab shiftwidth=4