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 self.pageContent.cpuList.setCurrentItem(None)
27 infos = bertos_utils.loadCpuInfos(self._projectInfoRetrieve("SOURCES_PATH"))
29 item = QListWidgetItem(cpu["CPU_NAME"])
30 # The CPU_DESC field in the cpu definition is a list of string, so we need to
31 # store it as a QStringList in a QVariant
32 item.setData(Qt.UserRole, QVariant(cpu))
33 self.pageContent.cpuList.addItem(item)
35 def _connectSignals(self):
36 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
38 def _selectItem(self, cpu):
39 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
40 if len(elements) == 1:
41 self.pageContent.cpuList.setCurrentItem(elements[0])
44 self.pageContent.descriptionLabel.setVisible(False)
45 self.pageContent.descriptionLabel.setText("")
48 self._populateCpuList()
49 cpuName = self._projectInfoRetrieve("CPU_NAME")
51 if not cpuName is None:
52 self._selectItem(cpuName)
53 self.emit(SIGNAL("completeChanged()"))
56 if self.pageContent.cpuList.currentRow() != -1:
57 self._projectInfoStore("CPU_INFOS", self.pageContent.cpuList.currentItem().data(Qt.UserRole).toMap())
63 description = self.pageContent.cpuList.currentItem().data(Qt.UserRole).toMap()
64 # I don't like to use QString as key in the dict, but the QVariant.toMap() return a dict<QString,QVariant>
65 description = description[QString("CPU_DESC")].toStringList()
66 # We need to convert the list of QString in a list of unicode
67 description = [unicode(line) for line in description]
68 self.pageContent.descriptionLabel.setText("<br>".join(description))
69 self.pageContent.descriptionLabel.setVisible(True)
70 self.emit(SIGNAL("completeChanged()"))