Add a stub of the code that will fill all the fields of the board selection Wizard...
[bertos.git] / wizard / BBoardPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # This file is part of slimqc.
5 #
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.
10 #
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.
15 #
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
19 #
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.
28 #
29 # Copyright 2010 Develer S.r.l. (http://www.develer.com/)
30 #
31 # $Id$
32 #
33 # Author: Lorenzo Berni <duplo@develer.com>
34 #
35
36 from PyQt4.QtCore import *
37 from PyQt4.QtGui import *
38
39 from BWizardPage import BWizardPage
40
41 import const
42 import qvariant_converter
43 from bertos_utils import presetList
44
45 class BBoardPage(BWizardPage):
46     """
47     Initial page of the alternative route. Permit to select one of the
48     predefined projects for supported board.
49     """
50     
51     def __init__(self):
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
55
56     ## Overloaded QWizardPage methods ##
57
58     def isComplete(self):
59         """
60         Overload of the QWizardPage isComplete method.
61         """
62         return False
63
64     ####
65
66     ## Overloaded BWizardPage methods ##
67
68     def setupUi(self):
69         """
70         Overload of the BWizardPage setupUi method.
71         """
72         pass
73
74     def connectSignals(self):
75         """
76         Overload of the BWizardPage connectSignals method.
77         """
78         self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged)
79
80     def reloadData(self):
81         """
82         Overload of the BWizardPage reloadData method.
83         """
84         presets = presetList("/Users/duplo/Development/bertos")
85         self.setProjectInfo("PRESETS", presets)
86         self.populatePresetList()
87
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)
98
99     ####
100
101     ## Slots ##
102
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
109
110     ####