+ def loadModuleData(self):
+ """
+ Loads the module data.
+ """
+ # Do not load the module data again when the Wizard is in editing mode
+ # or when it's working on a preset.
+ if not self.project.edit and not self.project.from_preset:
+ # Load the module data every time so that if the user changed the cpu
+ # the right configurations are picked up.
+ try:
+ self.project.loadModuleData()
+ 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):
+ """
+ Fills the module tree with the module entries separated in categories.
+ """
+ self.pageContent.moduleTree.clear()
+ modules = self.projectInfo("MODULES")
+ if not modules:
+ return
+ categories = {}
+ for module, information in modules.items():
+ if information["category"] not in categories:
+ categories[information["category"]] = []
+ categories[information["category"]].append(module)
+ for category, module_list in categories.items():
+ item = QTreeWidgetItem(QStringList([category]))
+ for module in module_list:
+ enabled = modules[module]["enabled"]
+ module_item = QTreeWidgetItem(item, QStringList([module]))
+ try:
+ supported = bertos_utils.isSupported(self.project, module=module)
+ except SupportedException, e:
+ self.exceptionOccurred(self.tr("Error evaluating \"%1\" for module %2").arg(e.support_string).arg(module))
+ supported = True
+ if not supported:
+ module_item.setForeground(0, QBrush(QColor(Qt.red)))
+ 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)
+ self.fillPropertyTable()
+
+ def insertCheckBox(self, index, value):
+ """
+ Inserts in the table at index a checkbox for a boolean property setted
+ to value.
+ """
+ check_box = QCheckBox()
+ self.pageContent.propertyTable.setCellWidget(index, 1, check_box)
+ if value == "1":
+ check_box.setChecked(True)
+ else:
+ check_box.setChecked(False)
+ self._control_group.addControl(index, check_box)
+
+ def insertComboBox(self, index, value, value_list):
+ """
+ Inserts in the table at index a combobox for an enum property setted
+ to value.
+ """
+ try:
+ enum = self.projectInfo("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):
+ """
+ Inserts in the table at index a spinbox for an int, a long or an unsigned
+ long property setted to value.
+ """
+ # int, long or undefined type property
+ spin_box = None
+ if bertos_utils.isLong(informations) or bertos_utils.isUnsignedLong(informations):
+ spin_box = QDoubleSpinBox()
+ spin_box.setDecimals(0)
+ else:
+ spin_box = QSpinBox()
+ self.pageContent.propertyTable.setCellWidget(index, 1, spin_box)
+ minimum = -32768
+ maximum = 32767
+ suff = ""
+ if bertos_utils.isLong(informations):
+ minimum = -2147483648
+ maximum = 2147483647
+ suff = "L"
+ elif bertos_utils.isUnsigned(informations):
+ minimum = 0
+ maximum = 65535
+ suff = "U"
+ elif bertos_utils.isUnsignedLong(informations):
+ minimum = 0
+ maximum = 4294967295
+ suff = "UL"
+ if "min" in informations:
+ minimum = int(informations["min"])
+ if "max" in informations:
+ maximum = int(informations["max"])
+ spin_box.setRange(minimum, maximum)
+ spin_box.setSuffix(suff)
+ spin_box.setValue(int(value.replace("L", "").replace("U", "")))
+ self._control_group.addControl(index, spin_box)
+
+
+ def insertLineEdit(self, index, value, informations):
+ """
+ Inserts in the table at index a line edit for hexadecimal property
+ setted to value.
+ """
+ edit_box = QLineEdit()
+ edit_validator = QRegExpValidator(QRegExp(r"^0x[0-9A-Fa-f]+$"), edit_box)
+ edit_box.setValidator(edit_validator)
+ self.pageContent.propertyTable.setCellWidget(index, 1, edit_box)
+ edit_box.setText(value)
+ self._control_group.addControl(index, edit_box)
+
+ def currentModule(self):
+ """
+ Retuns the current module name.
+ """
+ current_module = self.pageContent.moduleTree.currentItem()
+ # return only the child items
+ if current_module and current_module.parent():
+ return unicode(current_module.text(0))