X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=wizard%2FBBoardPage.py;h=4553da77d2f67c92a72d4db5c374c4bc14ad118e;hb=f884c67ed85598875ef683987323fd6085e01e14;hp=80631b598f2c7cbd51b3b53348886661251da28e;hpb=bb9ed2f778c62e37fe8dab83fcb6dc9a6928619f;p=bertos.git diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 80631b59..4553da77 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 # -# This file is part of slimqc. +# This file is part of bertos. # # Bertos is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,11 +33,17 @@ # Author: Lorenzo Berni # +import os + from PyQt4.QtCore import * from PyQt4.QtGui import * from BWizardPage import BWizardPage +from BCpuPage import BCpuPage +from BOutputPage import BOutputPage +from BRoutePage import BRoutePage + import const import qvariant_converter from bertos_utils import presetList @@ -61,6 +67,12 @@ class BBoardPage(BWizardPage): """ return False + def nextId(self): + """ + Overload of the QWizardPage nextId method. + """ + return self.wizard().pageIndex(BRoutePage) + #### ## Overloaded BWizardPage methods ## @@ -75,36 +87,41 @@ class BBoardPage(BWizardPage): """ Overload of the BWizardPage connectSignals method. """ - self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged) + pass 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) + self._fillPresetTree() #### ## 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 #### + + def _fillPresetTree(self): + self.pageContent.boardTree.clear() + 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]) + item.setIcon(0, QIcon(self._getNodeIcon(obj))) + children_dict = obj['children'] + for child in children_dict: + self._createPresetNode(item, child) + + def _getNodeIcon(self, obj): + icon_file = os.path.join(obj['info']['path'], const.PREDEFINED_BOARD_ICON_FILE) + if os.path.exists(icon_file): + return icon_file + elif obj['children']: + return const.PREDEFINED_BOARD_DEFAULT_DIR_ICON + else: + return const.PREDEFINED_BOARD_DEFAULT_PROJECT_ICON