X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBBoardPage.py;h=80631b598f2c7cbd51b3b53348886661251da28e;hb=bb9ed2f778c62e37fe8dab83fcb6dc9a6928619f;hp=6b8dddfff2bcc84723cc27848afd27460c00d9a2;hpb=cc03eb93224f06debc7f426acd9374076e8be834;p=bertos.git diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 6b8dddff..80631b59 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -33,9 +33,14 @@ # Author: Lorenzo Berni # +from PyQt4.QtCore import * +from PyQt4.QtGui import * + from BWizardPage import BWizardPage -from const import * +import const +import qvariant_converter +from bertos_utils import presetList class BBoardPage(BWizardPage): """ @@ -44,5 +49,62 @@ class BBoardPage(BWizardPage): """ def __init__(self): - BWizardPage.__init__(self, UI_LOCATION + "/board_select.ui") + BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui") self.setTitle(self.tr("Select the board from the predefined ones")) + self._last_selected = None + + ## Overloaded QWizardPage methods ## + + def isComplete(self): + """ + Overload of the QWizardPage isComplete method. + """ + return False + + #### + + ## Overloaded BWizardPage methods ## + + def setupUi(self): + """ + Overload of the BWizardPage setupUi method. + """ + pass + + def connectSignals(self): + """ + Overload of the BWizardPage connectSignals method. + """ + self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged) + + def reloadData(self): + """ + Overload of the BWizardPage reloadData method. + """ + presets = presetList("/Users/duplo/Development/bertos") + self.setProjectInfo("PRESETS", presets) + self.populatePresetList() + + def populatePresetList(self): + presets = self.projectInfo("PRESETS") + for preset, info in presets.items(): + board_list = self.pageContent.boardList + item = QListWidgetItem(info["name"], board_list) + item.setData(Qt.UserRole, qvariant_converter.convertString(preset)) + if self._last_selected == preset: + self.pageContent.boardList.setCurrentItem(item) + if not self._last_selected and self.pageContent.boardList.count(): + self.pageContent.boardList.setCurrentRow(0) + + #### + + ## Slots ## + + def itemSelectionChanged(self): + preset_path = qvariant_converter.getString(self.pageContent.boardList.currentItem().data(Qt.UserRole)) + presets = self.projectInfo("PRESETS") + selected_preset = presets[preset_path] + self.pageContent.descriptionLabel.setText(selected_preset['description']) + self._last_selected = preset_path + + ####