4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
13 from BWizardPage import *
16 class BCpuPage(BWizardPage):
19 BWizardPage.__init__(self, "cpu_select.ui")
20 self.setTitle(self.tr("Select the CPU"))
21 self._connectSignals()
24 def _populateCpuList(self):
25 self.pageContent.cpuList.clear()
26 infos = bertos_utils.loadCpuInfos(self._projectInfoRetrieve("SOURCES_PATH"))
28 item = QListWidgetItem(cpu["CPU_NAME"])
29 # The CPU_DESC field in the cpu definition is a list of string, so we need to
30 # store it as a QStringList in a QVariant
31 item.setData(Qt.UserRole, QVariant(QStringList(cpu["CPU_DESC"])))
32 self.pageContent.cpuList.addItem(item)
34 def _connectSignals(self):
35 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
37 def _selectItem(self, cpu):
38 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
39 if len(elements) == 1:
40 self.pageContent.cpuList.setCurrentItem(elements[0])
43 self.pageContent.descriptionLabel.setVisible(False)
46 self._populateCpuList()
47 cpuName = self._projectInfoRetrieve("CPU_NAME")
48 if not cpuName is None:
49 self._selectItem(cpuName)
52 if self.pageContent.cpuList.currentRow() != -1:
53 self._projectInfoStore("CPU_NAME", self.pageContent.cpuList.currentItem().text())
59 description = self.pageContent.cpuList.currentItem().data(Qt.UserRole).toStringList()
60 # We need to convert the list of QString in a list of unicode
61 description = [unicode(line) for line in description]
62 self.pageContent.descriptionLabel.setText("<br>".join(description))
63 self.pageContent.descriptionLabel.setVisible(True)
64 self.emit(SIGNAL("completeChanged()"))