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)
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)
def fillPropertyTable(self): """ Slot called when the user selects a module from the module tree. Fills the property table using the configuration parameters defined in the source tree. """ module = self.currentModule() if 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 self._control_group.clear() configuration = self.projectInfo( "MODULES")[module]["configuration"] module_description = self.projectInfo( "MODULES")[module]["description"] self.pageContent.moduleLabel.setText(module_description) self.pageContent.moduleLabel.setVisible(True) if not supported: self.pageContent.warningLabel.setVisible(True) selected_cpu = self.projectInfo("CPU_NAME") self.pageContent.warningLabel.setText( self.tr( "<font color='#FF0000'>Warning: the selected module, \ is not completely supported by the %1.</font>").arg( selected_cpu)) else: self.pageContent.warningLabel.setVisible(False) self.pageContent.propertyTable.clear() self.pageContent.propertyTable.setRowCount(0) if configuration != "": configurations = self.projectInfo( "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 continue try: param_supported = bertos_utils.isSupported( self.project, property_id=(configuration, property)) except SupportedException, e: self.exceptionOccurred( self.tr("Error evaluating \"%1\" for parameter %2" ).arg(e.support_string).arg(property)) param_supported = True if not param_supported: # Doesn't show the unsupported parameters continue # Set the row count to the current index + 1 self.pageContent.propertyTable.setRowCount(index + 1) item = QTableWidgetItem(configurations[property]["brief"]) item.setFlags(item.flags() & ~Qt.ItemIsSelectable) tooltip = property description = configurations[property].get( "description", None) if description: tooltip = tooltip + ": " + description item.setToolTip(tooltip) item.setData(Qt.UserRole, qvariant_converter.convertString(property)) self.pageContent.propertyTable.setItem(index, 0, item) if "type" in configurations[property][ "informations"] and configurations[property][ "informations"]["type"] == "boolean": self.insertCheckBox(index, configurations[property]["value"]) elif "type" in configurations[property][ "informations"] 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"]) elif "type" in configurations[property][ "informations"] and configurations[property][ "informations"]["type"] == "hex": self.insertLineEdit( 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
def fillPropertyTable(self): """ Slot called when the user selects a module from the module tree. Fills the property table using the configuration parameters defined in the source tree. """ module = self.currentModule() if 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 self._control_group.clear() configuration = self.projectInfo("MODULES")[module]["configuration"] module_description = self.projectInfo("MODULES")[module]["description"] self.pageContent.moduleLabel.setText(module_description) self.pageContent.moduleLabel.setVisible(True) if not supported: self.pageContent.warningLabel.setVisible(True) selected_cpu = self.projectInfo("CPU_NAME") self.pageContent.warningLabel.setText(self.tr("<font color='#FF0000'>Warning: the selected module, \ is not completely supported by the %1.</font>").arg(selected_cpu)) else: self.pageContent.warningLabel.setVisible(False) self.pageContent.propertyTable.clear() self.pageContent.propertyTable.setRowCount(0) if configuration != "": configurations = self.projectInfo("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 continue try: param_supported = bertos_utils.isSupported(self.project, property_id=(configuration, property)) except SupportedException, e: self.exceptionOccurred(self.tr("Error evaluating \"%1\" for parameter %2").arg(e.support_string).arg(property)) param_supported = True if not param_supported: # Doesn't show the unsupported parameters continue # Set the row count to the current index + 1 self.pageContent.propertyTable.setRowCount(index + 1) item = QTableWidgetItem(configurations[property]["brief"]) item.setFlags(item.flags() & ~Qt.ItemIsSelectable) tooltip = property description = configurations[property].get("description", None) if description: tooltip = tooltip + ": " + description item.setToolTip(tooltip) item.setData(Qt.UserRole, qvariant_converter.convertString(property)) self.pageContent.propertyTable.setItem(index, 0, item) if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "boolean": self.insertCheckBox(index, configurations[property]["value"]) elif "type" in configurations[property]["informations"] 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