4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
13 from BWizardPage import *
15 import qvariant_converter
17 class BCpuPage(BWizardPage):
20 BWizardPage.__init__(self, "cpu_select.ui")
21 self.setTitle(self.tr("Select the CPU"))
22 self._connectSignals()
25 def _populateCpuList(self):
26 self.pageContent.cpuList.clear()
27 self.pageContent.cpuList.setCurrentItem(None)
28 infos = bertos_utils.loadCpuInfos(self._projectInfoRetrieve("SOURCES_PATH"))
30 item = QListWidgetItem(cpu["CPU_NAME"])
31 # The CPU_DESC field in the cpu definition is a list of string, so we need to
32 # store it as a QStringList in a QVariant
33 item.setData(Qt.UserRole, QVariant(cpu))
34 self.pageContent.cpuList.addItem(item)
36 def _connectSignals(self):
37 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
39 def _selectItem(self, cpu):
40 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
41 if len(elements) == 1:
42 self.pageContent.cpuList.setCurrentItem(elements[0])
45 self.pageContent.descriptionLabel.setVisible(False)
46 self.pageContent.descriptionLabel.setText("")
49 self._populateCpuList()
50 cpuName = self._projectInfoRetrieve("CPU_NAME")
52 if not cpuName is None:
53 self._selectItem(cpuName)
54 self.emit(SIGNAL("completeChanged()"))
57 if self.pageContent.cpuList.currentRow() != -1:
58 self._projectInfoStore("CPU_INFOS", qvariant_converter.getStringDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole)))
64 description = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DESC"]
65 description = qvariant_converter.getStringList(description)
66 self.pageContent.descriptionLabel.setText("<br>".join(description))
67 self.pageContent.descriptionLabel.setVisible(True)
68 self.emit(SIGNAL("completeChanged()"))