Retrieve module data only if it isn't already loaded, and remember the module selections
[bertos.git] / wizard / BModulePage.py
index b124df9c94e9e19e94ab9b3b6e2e0fb33537b628..5f17d88181a6001be60a8d3b51928440d4f9e361 100644 (file)
@@ -37,14 +37,18 @@ class BModulePage(BWizardPage):
         self.connect(self._button_group, SIGNAL("buttonClicked(int)"), self._moduleSelectionChanged)
     
     def _loadModuleData(self):
-        try:
-            bertos_utils.loadModuleData(self._project())
-        except ModuleDefineException, e:
-            self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
-        except EnumDefineException, e:
-            self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
-        except ConfigurationDefineException, e:
-            self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
+        ## Load the module data only if it isn't already loaded
+        if self._projectInfoRetrieve("MODULES") == None \
+                and self._projectInfoRetrieve("LISTS") == None \
+                and self._projectInfoRetrieve("CONFIGURATIONS") == None:
+            try:
+                bertos_utils.loadModuleData(self._project())
+            except ModuleDefineException, e:
+                self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
+            except EnumDefineException, e:
+                self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
+            except ConfigurationDefineException, e:
+                self._exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
     
     def _fillModuleTree(self):
         modules = self._projectInfoRetrieve("MODULES")
@@ -55,11 +59,15 @@ class BModulePage(BWizardPage):
             if information["category"] not in categories.keys():
                 categories[information["category"]] = []
             categories[information["category"]].append(module)
-        for category, modules in categories.items():
+        for category, module_list in categories.items():
             item = QTreeWidgetItem(QStringList([category]))
-            for module in modules:
+            for module in module_list:
+                enabled = modules[module]["enabled"]
                 module_item = QTreeWidgetItem(item, QStringList([module]))
-                module_item.setCheckState(0, Qt.Unchecked)
+                if enabled:
+                    module_item.setCheckState(0, Qt.Checked)
+                else:
+                    module_item.setCheckState(0, Qt.Unchecked)
             self.pageContent.moduleTree.addTopLevelItem(item)
         self.pageContent.moduleTree.sortItems(0, Qt.AscendingOrder)
         
@@ -73,30 +81,35 @@ class BModulePage(BWizardPage):
             self.pageContent.moduleLabel.setText(module_description)
             self.pageContent.moduleLabel.setVisible(True)
             self.pageContent.propertyTable.clear()
-            configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration]
-            param_list = sorted(configurations["paramlist"])
             self.pageContent.propertyTable.setRowCount(0)
-            index = 0
-            for i, property in param_list:
-                if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "autoenabled":
-                    ## Doesn't show the hidden fields
-                    pass
-                else:
-                    ## Set the row count to the current index + 1
-                    self.pageContent.propertyTable.setRowCount(index + 1)
-                    item = QTableWidgetItem(configurations[property]["brief"])
-                    item.setData(Qt.UserRole, qvariant_converter.convertString(property))
-                    self.pageContent.propertyTable.setItem(index, 0, item)
-                    if "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "boolean":
-                        self._insertCheckBox(index, configurations[property]["value"])
-                    elif "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "enum":
-                        self._insertComboBox(index, configurations[property]["value"], configurations[property]["informations"]["value_list"])
-                    elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "int":
-                        self._insertSpinBox(index, configurations[property]["value"], configurations[property]["informations"])
+            if configuration != "":
+                configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration]
+                param_list = sorted(configurations["paramlist"])
+                index = 0
+                for i, property in param_list:
+                    if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "autoenabled":
+                        ## Doesn't show the hidden fields
+                        pass
                     else:
-                        # Not defined type, rendered as a text field
-                        self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(configurations[property]["value"]))
-                    index += 1
+                        ## Set the row count to the current index + 1
+                        self.pageContent.propertyTable.setRowCount(index + 1)
+                        item = QTableWidgetItem(configurations[property]["brief"])
+                        item.setData(Qt.UserRole, qvariant_converter.convertString(property))
+                        self.pageContent.propertyTable.setItem(index, 0, item)
+                        if "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "boolean":
+                            self._insertCheckBox(index, configurations[property]["value"])
+                        elif "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "enum":
+                            self._insertComboBox(index, configurations[property]["value"], configurations[property]["informations"]["value_list"])
+                        elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "int":
+                            self._insertSpinBox(index, configurations[property]["value"], configurations[property]["informations"])
+                        else:
+                            # Not defined type, rendered as a text field
+                            self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(configurations[property]["value"]))
+                        index += 1
+            if self.pageContent.propertyTable.rowCount() == 0:
+                module_label = self.pageContent.moduleLabel.text()
+                module_label += "\n\nNo configuration needed."
+                self.pageContent.moduleLabel.setText(module_label)
     
     def _insertCheckBox(self, index, value):
         ## boolean property