4 # This file is part of bertos.
6 # Bertos is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # As a special exception, you may use this file as part of a free software
21 # library without restriction. Specifically, if other files instantiate
22 # templates or use macros or inline functions from this file, or you compile
23 # this file and link it with other files to produce an executable, this
24 # file does not by itself cause the resulting executable to be covered by
25 # the GNU General Public License. This exception does not however
26 # invalidate any other reasons why the executable file might be covered by
27 # the GNU General Public License.
29 # Copyright 2010 Develer S.r.l. (http://www.develer.com/)
33 # Author: Lorenzo Berni <duplo@develer.com>
38 from PyQt4.QtCore import *
39 from PyQt4.QtGui import *
41 from BWizardPage import BWizardPage
43 from BCpuPage import BCpuPage
44 from BOutputPage import BOutputPage
45 from BRoutePage import BRoutePage
48 import qvariant_converter
49 from bertos_utils import presetList
51 class BBoardPage(BWizardPage):
53 Initial page of the alternative route. Permit to select one of the
54 predefined projects for supported board.
58 BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui")
59 self.setTitle(self.tr("Select the board from the predefined ones"))
60 self._last_selected = None
62 ## Overloaded QWizardPage methods ##
66 Overload of the QWizardPage isComplete method.
72 Overload of the QWizardPage nextId method.
74 return self.wizard().pageIndex(BRoutePage)
78 ## Overloaded BWizardPage methods ##
82 Overload of the BWizardPage setupUi method.
86 def connectSignals(self):
88 Overload of the BWizardPage connectSignals method.
94 Overload of the BWizardPage reloadData method.
96 self._fillPresetTree()
105 def _fillPresetTree(self):
106 self.pageContent.boardTree.clear()
107 self.project.loadProjectPresets()
108 preset_tree = self.project.info("PRESET_TREE")
109 for obj in preset_tree['children']:
110 self._createPresetNode(self.pageContent.boardTree, obj)
112 def _createPresetNode(self, parent, obj):
113 item_name = obj['info'].get('name', obj['info']['filename'])
114 item = QTreeWidgetItem(parent, [item_name])
115 item.setIcon(0, QIcon(self._getNodeIcon(obj)))
116 children_dict = obj['children']
117 for child in children_dict:
118 self._createPresetNode(item, child)
120 def _getNodeIcon(self, obj):
121 icon_file = os.path.join(obj['info']['path'], const.PREDEFINED_BOARD_ICON_FILE)
122 if os.path.exists(icon_file):
124 elif obj['children']:
125 return const.PREDEFINED_BOARD_DEFAULT_DIR_ICON
127 return const.PREDEFINED_BOARD_DEFAULT_PROJECT_ICON