X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBModulePage.py;h=5fd3abc8c074e676cf59a925b58fb8b15c815aef;hb=9f78ac29bdc537afaab5dba3239b6631bdf2a740;hp=b124df9c94e9e19e94ab9b3b6e2e0fb33537b628;hpb=5456306fbbfcc4940fcfdf9cb9ac42ba7d643eb0;p=bertos.git diff --git a/wizard/BModulePage.py b/wizard/BModulePage.py index b124df9c..5fd3abc8 100644 --- a/wizard/BModulePage.py +++ b/wizard/BModulePage.py @@ -27,9 +27,11 @@ class BModulePage(BWizardPage): self._connectSignals() def reloadData(self): + QApplication.instance().setOverrideCursor(Qt.WaitCursor) self._setupUi() self._loadModuleData() self._fillModuleTree() + QApplication.instance().restoreOverrideCursor() def _setupButtonGroup(self): self._button_group = QButtonGroup() @@ -37,14 +39,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 +61,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 +83,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 @@ -110,14 +125,18 @@ class BModulePage(BWizardPage): def _insertComboBox(self, index, value, value_list): ## enum property - combo_box = QComboBox() - self.pageContent.propertyTable.setCellWidget(index, 1, combo_box) - enum = self._projectInfoRetrieve("LISTS")[value_list] - for i, element in enumerate(enum): - combo_box.addItem(element) - if element == value: - combo_box.setCurrentIndex(i) - self._control_group.addControl(index, combo_box) + try: + enum = self._projectInfoRetrieve("LISTS")[value_list] + combo_box = QComboBox() + self.pageContent.propertyTable.setCellWidget(index, 1, combo_box) + for i, element in enumerate(enum): + combo_box.addItem(element) + if element == value: + combo_box.setCurrentIndex(i) + self._control_group.addControl(index, combo_box) + except KeyError: + self._exceptionOccurred(self.tr("Define list \"%1\" not found. Check definition files.").arg(value_list)) + self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(value)) def _insertSpinBox(self, index, value, informations): ## int, long or undefined type property