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
42 import qvariant_converter
43 from bertos_utils import presetList
45 class BBoardPage(BWizardPage):
47 Initial page of the alternative route. Permit to select one of the
48 predefined projects for supported board.
52 BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui")
53 self.setTitle(self.tr("Select the board from the predefined ones"))
54 self._last_selected = None
56 ## Overloaded QWizardPage methods ##
60 Overload of the QWizardPage isComplete method.
66 ## Overloaded BWizardPage methods ##
70 Overload of the BWizardPage setupUi method.
74 def connectSignals(self):
76 Overload of the BWizardPage connectSignals method.
78 self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged)
82 Overload of the BWizardPage reloadData method.
84 presets = presetList("/Users/duplo/Development/bertos")
85 self.setProjectInfo("PRESETS", presets)
86 self.populatePresetList()
88 def populatePresetList(self):
89 presets = self.projectInfo("PRESETS")
90 for preset, info in presets.items():
91 board_list = self.pageContent.boardList
92 item = QListWidgetItem(info["name"], board_list)
93 item.setData(Qt.UserRole, qvariant_converter.convertString(preset))
94 if self._last_selected == preset:
95 self.pageContent.boardList.setCurrentItem(item)
96 if not self._last_selected and self.pageContent.boardList.count():
97 self.pageContent.boardList.setCurrentRow(0)
103 def itemSelectionChanged(self):
104 preset_path = qvariant_converter.getString(self.pageContent.boardList.currentItem().data(Qt.UserRole))
105 presets = self.projectInfo("PRESETS")
106 selected_preset = presets[preset_path]
107 self.pageContent.descriptionLabel.setText(selected_preset['description'])
108 self._last_selected = preset_path