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()
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")
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)
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
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