- configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"]
- configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration]
- self.pageContent.propertyTable.clear()
- self.pageContent.propertyTable.setRowCount(len(configurations))
- for index, property in enumerate(configurations):
- item = QTableWidgetItem(property)
- 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":
- ## boolean property
- checkBox = QCheckBox()
- self.pageContent.propertyTable.setCellWidget(index, 1, checkBox)
- if configurations[property]["value"] == "1":
- checkBox.setChecked(True)
- else:
- checkBox.setChecked(False)
- elif "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "enum":
- ## enum property
- comboBox = QComboBox()
- self.pageContent.propertyTable.setCellWidget(index, 1, comboBox)
- enum = self._projectInfoRetrieve("LISTS")[configurations[property]["informations"]["value_list"]]
- 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()
- self.pageContent.propertyTable.setCellWidget(index, 1, spinBox)
- if "min" in configurations[property]["informations"].keys():
- minimum = int(configurations[property]["informations"]["min"])
- else:
- minimum = -32768
- spinBox.setMinimum(minimum)
- if "max" in configurations[property]["informations"].keys():
- maximum = int(configurations[property]["informations"]["max"])
- else:
- maximum = 32767
- spinBox.setMaximum(maximum)
- if "long" in configurations[property]["informations"].keys() and configurations[property]["informations"]["long"] == "True":
- 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"
+ if module is not None:
+ self._control_group.clear()
+ configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"]
+ module_description = self._projectInfoRetrieve("MODULES")[module]["description"]
+ self.pageContent.moduleLabel.setText(module_description)
+ self.pageContent.moduleLabel.setVisible(True)
+ self.pageContent.propertyTable.clear()
+ self.pageContent.propertyTable.setRowCount(0)
+ 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:
+ ## 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
+ 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):
+ ## enum property
+ 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))