4 # This file is part of slimqc.
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>
36 from PyQt4.QtCore import *
37 from PyQt4.QtGui import *
39 from BWizardPage import BWizardPage
41 from BCpuPage import BCpuPage
42 from BOutputPage import BOutputPage
45 import qvariant_converter
46 from bertos_utils import presetList
48 class BBoardPage(BWizardPage):
50 Initial page of the alternative route. Permit to select one of the
51 predefined projects for supported board.
55 BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui")
56 self.setTitle(self.tr("Select the board from the predefined ones"))
57 self._last_selected = None
59 ## Overloaded QWizardPage methods ##
63 Overload of the QWizardPage isComplete method.
65 return self.pageContent.boardList.currentItem() is not None
69 Overload of the QWizardPage nextId method.
71 # Stub of nextId logic
73 self.setProjectInfo("PRESET_ADVANCED_CONFIG", True)
74 return self.wizard().pageIndex(BCpuPage)
75 # Search for suitable toolchains. If there isn't one return
76 # BToolchainPage id (BToolchainPage should then route to BOutputPage
77 # instead of BModulePage).
79 # If a suitable toolchain is found the user has to be prompted
80 # directly to the BOutputPage
82 return self.wizard().pageIndex(BOutputPage)
86 ## Overloaded BWizardPage methods ##
90 Overload of the BWizardPage setupUi method.
94 def connectSignals(self):
96 Overload of the BWizardPage connectSignals method.
98 self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged)
100 def reloadData(self):
102 Overload of the BWizardPage reloadData method.
104 presets = presetList("/Users/duplo/Development/bertos")
105 self.setProjectInfo("PRESETS", presets)
106 self.populatePresetList()
108 def populatePresetList(self):
109 self.pageContent.boardList.clear()
110 presets = self.projectInfo("PRESETS")
111 for preset, info in presets.items():
112 board_list = self.pageContent.boardList
113 item = QListWidgetItem(info["PRESET_NAME"], board_list)
114 item.setData(Qt.UserRole, qvariant_converter.convertString(preset))
115 if self._last_selected == preset:
116 self.pageContent.boardList.setCurrentItem(item)
117 if not self._last_selected and self.pageContent.boardList.count():
118 self.pageContent.boardList.setCurrentRow(0)
124 def itemSelectionChanged(self):
125 preset_path = qvariant_converter.getString(self.pageContent.boardList.currentItem().data(Qt.UserRole))
126 presets = self.projectInfo("PRESETS")
127 selected_preset = presets[preset_path]
129 "Board: %s" %selected_preset["PRESET_NAME"],
130 "CPU: %s" %selected_preset["CPU_NAME"],
132 if selected_preset["PRESET_DESCRIPTION"]:
133 text_components.append("Description: %s" %selected_preset["PRESET_DESCRIPTION"])
134 text = "\n".join(text_components)
135 self.pageContent.descriptionLabel.setText(text)
136 self._last_selected = preset_path
137 self.emit(SIGNAL("completeChanged()"))
143 return self.pageContent.advancedCheckBox.isChecked()