Save the configuration parameters when the page is changed
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Jan 2009 14:17:40 +0000 (14:17 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Jan 2009 14:17:40 +0000 (14:17 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2227 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BModulePage.py

index 636b818886adaedad3249df52c5575f55ad3d1bd..9ee813ada3c922b630323fdd3d9f50867b0257c6 100644 (file)
@@ -56,7 +56,6 @@ class BModulePage(BWizardPage):
             checkBox.setChecked(modules[module]["enabled"])
     
     def _fillPropertyTable(self):
-        self.savePage()
         module = self._currentModule()
         configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"]
         configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration]
@@ -79,8 +78,10 @@ class BModulePage(BWizardPage):
                 comboBox = QComboBox()
                 self.pageContent.propertyTable.setCellWidget(index, 1, comboBox)
                 enum = self._projectInfoRetrieve("LISTS")[configurations[property]["informations"]["value_list"]]
-                for element in enum:
+                for index, element in enumerate(enum):
                     comboBox.addItem(element)
+                    if element == configurations[property]["value"]:
+                        comboBox.setCurrentIndex(index)
             else:
                 ## int, long or undefined type property
                 spinBox = QSpinBox()
@@ -99,11 +100,31 @@ class BModulePage(BWizardPage):
                     spinBox.setSuffix("L")
                 spinBox.setValue(int(configurations[property]["value"].replace("L", "")))
     
+    def _savePage(self, previousRow, previousColumn):
+        module = self._module(previousRow)
+        moduleConfigurations = self._projectInfoRetrieve("CONFIGURATIONS")[self._configurations(module)]
+        for index in range(self.pageContent.propertyTable.rowCount()):
+            parameter = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
+            if "type" not in moduleConfigurations[parameter]["informations"].keys() or moduleConfigurations[parameter]["informations"]["type"] == "int":
+                moduleConfigurations[parameter]["value"] = str(self.pageContent.propertyTable.cellWidget(index, 1).value())
+            elif moduleConfigurations[parameter]["informations"]["type"] == "enum":
+                moduleConfigurations[parameter]["value"] = unicode(self.pageContent.propertyTable.cellWidget(index, 1).currentText())
+            elif moduleConfigurations[parameter]["informations"]["type"] == "boolean":
+                if self.pageContent.propertyTable.cellWidget(index, 1).isChecked():
+                    moduleConfigurations[parameter]["value"] = "1"
+                else:
+                    moduleConfigurations[parameter]["value"] = "0"
+    
+    def _pageChanged(self, row, column, previousRow, previousColumn):
+        if previousRow != -1 and previousColumn != -1:
+            self._savePage(previousRow, previousColumn)
+        self._fillPropertyTable()
+    
     def _currentModule(self):
         return unicode(self.pageContent.moduleTable.item(self.pageContent.moduleTable.currentRow(), 1).text())
     
     def _currentModuleConfigurations(self):
-        return self._projectInfoRetrieve("MODULES")[self._currentModule()]["configuration"]
+        return self._configurations(self._currentModule())["configurations"]
     
     def _currentProperty(self):
         return qvariant_converter.getString(self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0).data(Qt.UserRole))
@@ -111,6 +132,12 @@ class BModulePage(BWizardPage):
     def _currentPropertyItem(self):
         return self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0)
     
+    def _module(self, row):
+        return unicode(self.pageContent.moduleTable.item(row, 1).text())
+    
+    def _configurations(self, module):
+        return self._projectInfoRetrieve("MODULES")[module]["configuration"]
+    
     def _resetPropertyDescription(self):
         for index in range(self.pageContent.propertyTable.rowCount()):
             propertyName = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
@@ -140,7 +167,7 @@ class BModulePage(BWizardPage):
         self.pageContent.propertyTable.setRowCount(0)
     
     def _connectSignals(self):
-        self.connect(self.pageContent.moduleTable, SIGNAL("itemSelectionChanged()"), self._fillPropertyTable)
+        self.connect(self.pageContent.moduleTable, SIGNAL("currentCellChanged(int, int, int, int)"), self._pageChanged)
         self.connect(self.pageContent.propertyTable, SIGNAL("itemSelectionChanged()"), self._showPropertyDescription)
 
     def _moduleSelectionChanged(self, index):
@@ -204,8 +231,4 @@ class BModulePage(BWizardPage):
                 unsatisfied |= set([module])
                 if dependency not in unsatisfied:
                     unsatisfied |= self.unselectDependencyCheck(module)
-        return unsatisfied
-    
-    def savePage(self):
-        for index in range(self.pageContent.propertyTable.rowCount()):
-            print qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
\ No newline at end of file
+        return unsatisfied
\ No newline at end of file