From: duplo Date: Fri, 23 Jan 2009 13:57:08 +0000 (+0000) Subject: Rewrite the BModulePage class X-Git-Tag: 2.1.0~468 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=ca3c4f9c1ed38c12eacadafe3b8f87608a6ff8c8;p=bertos.git Rewrite the BModulePage class git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2214 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BModulePage.py b/wizard/BModulePage.py index deefec6d..9c26fcbe 100644 --- a/wizard/BModulePage.py +++ b/wizard/BModulePage.py @@ -25,21 +25,84 @@ class BModulePage(BWizardPage): self._connectSignals() def reloadData(self): + self._setupButtonGroup() self._loadModuleData() + self._fillModuleTable() + + def _setupButtonGroup(self): + self._buttonGroup = QButtonGroup() + self._buttonGroup.setExclusive(False) def _loadModuleData(self): modules = bertos_utils.loadModuleInfosDict(self._projectInfoRetrieve("SOURCES_PATH")) lists = bertos_utils.loadDefineListsDict(self._projectInfoRetrieve("SOURCES_PATH")) configurations = {} for module, informations in modules.items(): - configurations.update(bertos_utils.loadConfigurationInfos(self._projectInfoRetrieve("SOURCES_PATH") + "/" + informations["configuration"])) - print "modules", modules - print "lists", lists - print "configurations", configurations + configurations[informations["configuration"]] = bertos_utils.loadConfigurationInfos(self._projectInfoRetrieve("SOURCES_PATH") + + "/" + informations["configuration"]) + self._projectInfoStore("MODULES", modules) + self._projectInfoStore("LISTS", lists) + self._projectInfoStore("CONFIGURATIONS", configurations) + + def _fillModuleTable(self): + modules = self._projectInfoRetrieve("MODULES") + self.pageContent.moduleTable.setRowCount(len(modules)) + for index, module in enumerate(modules): + self.pageContent.moduleTable.setItem(index, 1, QTableWidgetItem(module)) + checkBox = QCheckBox() + self._buttonGroup.addButton(checkBox, index) + self.pageContent.moduleTable.setCellWidget(index, 0, checkBox) + + def _fillPropertyTable(self): + module = unicode(self.pageContent.moduleTable.item(self.pageContent.moduleTable.currentRow(), 1).text()) + configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"] + configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration] + self.pageContent.propertyTable.clear() + self.pageContent.propertyTable.setRowCount(len(configurations)) + for index, parameter in enumerate(configurations): + self.pageContent.propertyTable.setItem(index, 0, QTableWidgetItem(parameter)) + if "type" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["type"] == "boolean": + ## boolean parameter + checkBox = QCheckBox() + self.pageContent.propertyTable.setCellWidget(index, 1, checkBox) + if configurations[parameter]["value"] == "1": + checkBox.setChecked(True) + else: + checkBox.setChecked(False) + elif "type" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["type"] == "enum": + ## enum parameter + comboBox = QComboBox() + self.pageContent.propertyTable.setCellWidget(index, 1, comboBox) + enum = self._projectInfoRetrieve("LISTS")[configurations[parameter]["informations"]["value_list"]] + for element in enum: + comboBox.addItem(element) + else: + ## int, long or undefined type parameter + spinBox = QSpinBox() + self.pageContent.propertyTable.setCellWidget(index, 1, spinBox) + if "min" in configurations[parameter]["informations"].keys(): + minimum = int(configurations[parameter]["informations"]["min"]) + else: + minimum = -32768 + spinBox.setMinimum(minimum) + if "max" in configurations[parameter]["informations"].keys(): + maximum = int(configurations[parameter]["infomations"]["max"]) + else: + maximum = 32767 + spinBox.setMaximum(maximum) + if "long" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["long"] == "True": + spinBox.setSuffix("L") + spinBox.setValue(int(configurations[parameter]["value"].replace("L", ""))) def _setupUi(self): - self.pageContent.moduleList.setSortingEnabled(True) - self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) + self.pageContent.moduleTable.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) + self.pageContent.moduleTable.horizontalHeader().setStretchLastSection(True) + self.pageContent.moduleTable.horizontalHeader().setVisible(False) + self.pageContent.moduleTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) + self.pageContent.moduleTable.verticalHeader().setVisible(False) + self.pageContent.moduleTable.setColumnCount(2) + self.pageContent.moduleTable.setRowCount(0) + self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.Stretch) self.pageContent.propertyTable.horizontalHeader().setVisible(False) self.pageContent.propertyTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.pageContent.propertyTable.verticalHeader().setVisible(False) @@ -47,4 +110,4 @@ class BModulePage(BWizardPage): self.pageContent.propertyTable.setRowCount(0) def _connectSignals(self): - pass \ No newline at end of file + self.connect(self.pageContent.moduleTable, SIGNAL("itemSelectionChanged()"), self._fillPropertyTable) \ No newline at end of file diff --git a/wizard/module_select.ui b/wizard/module_select.ui index a6400fee..d9b8486e 100644 --- a/wizard/module_select.ui +++ b/wizard/module_select.ui @@ -20,19 +20,25 @@ - - - - 0 - 0 - - + - 120 + 150 16777215 + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false +