X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBBoardPage.py;h=5d83fda38ddab5a030171e445baee875e5f2b597;hb=f0c8799f695c20bda1134592ac357620af6cc9fd;hp=2bf90ff38843d975dc3263722b01a9387ba9dc52;hpb=1b91fae6ef2c8d756d1f3a1ab812ddb92e650c01;p=bertos.git diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 2bf90ff3..5d83fda3 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -33,6 +33,8 @@ # Author: Lorenzo Berni # +import os + from PyQt4.QtCore import * from PyQt4.QtGui import * @@ -55,7 +57,6 @@ class BBoardPage(BWizardPage): def __init__(self): 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 ## @@ -65,11 +66,11 @@ class BBoardPage(BWizardPage): """ return False - def nextId(self): - """ - Overload of the QWizardPage nextId method. - """ - return self.wizard().pageIndex(BRoutePage) + # def nextId(self): + # """ + # Overload of the QWizardPage nextId method. + # """ + # return self.wizard().pageIndex(BRoutePage) #### @@ -85,13 +86,17 @@ class BBoardPage(BWizardPage): """ Overload of the BWizardPage connectSignals method. """ - pass def reloadData(self): """ Overload of the BWizardPage reloadData method. """ - self._fillPresetTree() + preset_list = self.projectInfo("PRESET_TREE") + preset_list = preset_list["children"] + def _cmp(x, y): + return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) + preset_list = sorted(preset_list, _cmp) + self.setItems(preset_list) #### @@ -100,15 +105,7 @@ class BBoardPage(BWizardPage): #### - def _fillPresetTree(self): - self.project.loadProjectPresets() - preset_tree = self.project.info("PRESET_TREE") - for obj in preset_tree['children']: - self._createPresetNode(self.pageContent.boardTree, obj) - - def _createPresetNode(self, parent, obj): - item_name = obj['info'].get('name', obj['info']['filename']) - item = QTreeWidgetItem(parent, [item_name]) - children_dict = obj['children'] - for child in children_dict: - self._createPresetNode(item, child) + def setItems(self, preset_list): + self.pageContent.boardList.clear() + for item in preset_list: + self.pageContent.boardList.addItem(item["info"].get("name", item["info"]["filename"])) \ No newline at end of file