1.1 --- a/examples/Common/QtConfigurator/__init__.py Tue Oct 25 14:52:22 2005 +0000
1.2 +++ b/examples/Common/QtConfigurator/__init__.py Tue Oct 25 14:53:13 2005 +0000
1.3 @@ -18,9 +18,12 @@
1.4 }
1.5
1.6 widget_resources = {
1.7 - "hard-disks" : ("config_hard_disks.ui", "hard_disks"),
1.8 - "memory-units" : ("config_memory_units.ui", "memory_units"),
1.9 - "storage-units" : ("config_storage_units.ui", "storage_units")
1.10 + "hard-disk" : ("config_hard_disk.ui", "hard_disk"),
1.11 + "memory-unit" : ("config_memory_unit.ui", "memory_unit"),
1.12 + "storage-unit" : ("config_storage_unit.ui", "storage_unit")
1.13 + #"hard-disks" : ("config_hard_disks.ui", "hard_disks"),
1.14 + #"memory-units" : ("config_memory_units.ui", "memory_units"),
1.15 + #"storage-units" : ("config_storage_units.ui", "storage_units")
1.16 }
1.17
1.18 document_resources = {
1.19 @@ -66,12 +69,12 @@
1.20 filename = self.template_resources[template_identifier]
1.21 return os.path.abspath(os.path.join(self.resource_dir, filename))
1.22
1.23 - def prepare_widget(self, template_identifier, widget_identifier):
1.24 + def prepare_widget(self, template_identifier, widget_identifier, parent=None):
1.25 template_path = self.prepare_template(template_identifier)
1.26 fragment_name, widget_name = self.widget_resources[widget_identifier]
1.27 fragment_path = os.path.abspath(os.path.join(self.resource_dir, fragment_name))
1.28 XSLForms.Prepare.ensure_qt_fragment(template_path, fragment_path, widget_name)
1.29 - return qtui.QWidgetFactory.create(fragment_path)
1.30 + return qtui.QWidgetFactory.create(fragment_path, None, parent)
1.31
1.32 # Initialisation.
1.33
1.34 @@ -128,12 +131,15 @@
1.35 self.refresh(current_text)
1.36
1.37 def addHardDisk(self):
1.38 - print self.sender()
1.39 - hard_disks = self.prepare_widget("configuration", "hard-disks")
1.40 - tab_pages = hard_disks.child("tab pages")
1.41 - tab = tab_pages.child("tab")
1.42 - self.hard_disks.addTab(tab, hard_disks.tabLabel(tab))
1.43 - self.factory.connect(tab, self)
1.44 + #hard_disks = self.prepare_widget("configuration", "hard-disks")
1.45 + #tab_pages = hard_disks.child("tab pages")
1.46 + #tab = tab_pages.child("tab")
1.47 + #self.hard_disks.addTab(tab, hard_disks.tabLabel(tab))
1.48 + #self.factory.connect(tab, self)
1.49 + hard_disk = self.prepare_widget("configuration", "hard-disk", self.hard_disks)
1.50 + self.hard_disks.layout().add(hard_disk)
1.51 + hard_disk.show()
1.52 + self.factory.connect(hard_disk, self)
1.53
1.54 # Perform the consistency check.
1.55 # NOTE: This is not as efficient as it could be since the general check
1.56 @@ -141,11 +147,15 @@
1.57 self.refresh()
1.58
1.59 def addMemoryUnit(self):
1.60 - memory_units = self.prepare_widget("configuration", "memory-units")
1.61 - tab_pages = memory_units.child("tab pages")
1.62 - tab = tab_pages.child("tab")
1.63 - self.memory_units.addTab(tab, memory_units.tabLabel(tab))
1.64 - self.factory.connect(tab, self)
1.65 + #memory_units = self.prepare_widget("configuration", "memory-units")
1.66 + #tab_pages = memory_units.child("tab pages")
1.67 + #tab = tab_pages.child("tab")
1.68 + #self.memory_units.addTab(tab, memory_units.tabLabel(tab))
1.69 + #self.factory.connect(tab, self)
1.70 + memory_unit = self.prepare_widget("configuration", "memory-unit", self.memory_units)
1.71 + self.memory_units.layout().add(memory_unit)
1.72 + memory_unit.show()
1.73 + self.factory.connect(memory_unit, self)
1.74
1.75 # Perform the consistency check.
1.76 # NOTE: This is not as efficient as it could be since the general check
1.77 @@ -153,11 +163,15 @@
1.78 self.refresh()
1.79
1.80 def addStorageUnit(self):
1.81 - storage_units = self.prepare_widget("configuration", "storage-units")
1.82 - tab_pages = storage_units.child("tab pages")
1.83 - tab = tab_pages.child("tab")
1.84 - self.storage_units.addTab(tab, storage_units.tabLabel(tab))
1.85 - self.factory.connect(tab, self)
1.86 + #storage_units = self.prepare_widget("configuration", "storage-units")
1.87 + #tab_pages = storage_units.child("tab pages")
1.88 + #tab = tab_pages.child("tab")
1.89 + #self.storage_units.addTab(tab, storage_units.tabLabel(tab))
1.90 + #self.factory.connect(tab, self)
1.91 + storage_unit = self.prepare_widget("configuration", "storage-unit", self.storage_units)
1.92 + self.storage_units.layout().add(storage_unit)
1.93 + storage_unit.show()
1.94 + self.factory.connect(storage_unit, self)
1.95
1.96 # Perform the consistency check.
1.97 # NOTE: This is not as efficient as it could be since the general check
1.98 @@ -165,19 +179,31 @@
1.99 self.refresh()
1.100
1.101 def removeHardDisk(self):
1.102 - page = self.hard_disks.currentPage()
1.103 - self.hard_disks.removePage(page)
1.104 - page.deleteLater()
1.105 + #page = self.hard_disks.currentPage()
1.106 + #self.hard_disks.removePage(page)
1.107 + #page.deleteLater()
1.108 + remove_hard_disk = self.sender()
1.109 + hard_disk = remove_hard_disk.parent()
1.110 + self.hard_disks.layout().remove(hard_disk)
1.111 + hard_disk.deleteLater()
1.112
1.113 def removeMemoryUnit(self):
1.114 - page = self.memory_units.currentPage()
1.115 - self.memory_units.removePage(page)
1.116 - page.deleteLater()
1.117 + #page = self.memory_units.currentPage()
1.118 + #self.memory_units.removePage(page)
1.119 + #page.deleteLater()
1.120 + remove_memory_unit = self.sender()
1.121 + memory_unit = remove_memory_unit.parent()
1.122 + self.memory_units.layout().remove(memory_unit)
1.123 + memory_unit.deleteLater()
1.124
1.125 def removeStorageUnit(self):
1.126 - page = self.storage_units.currentPage()
1.127 - self.storage_units.removePage(page)
1.128 - page.deleteLater()
1.129 + #page = self.storage_units.currentPage()
1.130 + #self.storage_units.removePage(page)
1.131 + #page.deleteLater()
1.132 + remove_storage_unit = self.sender()
1.133 + storage_unit = remove_storage_unit.parent()
1.134 + self.storage_units.layout().remove(storage_unit)
1.135 + storage_unit.deleteLater()
1.136
1.137 def updateConfig(self):
1.138 self.refresh()