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
19 class BCpuPage(BWizardPage):
21 Page of the wizard that permits to choose the cpu from the supported ones.
25 BWizardPage.__init__(self, UI_LOCATION + "/cpu_select.ui")
26 self.setTitle(self.tr("Select the CPU"))
28 ## Overloaded QWizardPage methods ##
32 Overload of the QWizardPage isComplete method.
34 if self.pageContent.cpuList.currentRow() != -1:
35 infos = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))
36 for key, value in infos.items():
37 if type(CPU_DEF[key]) == list:
38 infos[key] = qvariant_converter.getStringList(value)
39 if type(CPU_DEF[key]) == str or type(CPU_DEF) == unicode:
40 infos[key] = qvariant_converter.getString(value)
41 self.setProjectInfo("CPU_INFOS", infos)
42 self.setProjectInfo("CPU_NAME", unicode(self.pageContent.cpuList.currentItem().text()))
49 ## Overloaded BWizardPage methods ##
53 Overload of the BWizardPage setupUi method.
55 self.pageContent.cpuList.setSortingEnabled(True)
56 self.pageContent.descriptionLabel.setVisible(False)
57 self.pageContent.descriptionLabel.setText("")
59 def connectSignals(self):
61 Overload of the BWizardPage connectSignals method.
63 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
67 Overload of the BWizardPage reloadData method.
69 QApplication.instance().setOverrideCursor(Qt.WaitCursor)
70 bertos_utils.loadSourceTree(self.project())
71 self.populateCpuList()
72 cpu_name = self.projectInfo("CPU_NAME")
74 if not cpu_name is None:
75 self.selectItem(cpu_name)
76 QApplication.instance().restoreOverrideCursor()
77 self.emit(SIGNAL("completeChanged()"))
85 Slot called when the user select an entry from the cpu list.
87 description = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DESC"]
88 description = qvariant_converter.getStringList(description)
89 self.pageContent.descriptionLabel.setText("<br>".join(description))
90 self.pageContent.descriptionLabel.setVisible(True)
91 self.emit(SIGNAL("completeChanged()"))
95 def populateCpuList(self):
99 self.pageContent.cpuList.clear()
100 self.pageContent.cpuList.setCurrentItem(None)
101 infos = bertos_utils.loadCpuInfos(self.project())
103 item = QListWidgetItem(cpu["CPU_NAME"])
104 item.setData(Qt.UserRole, qvariant_converter.convertDict(cpu))
105 self.pageContent.cpuList.addItem(item)
107 def selectItem(self, cpu):
109 Selects the given cpu from the list.
111 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
112 if len(elements) == 1:
113 self.pageContent.cpuList.setCurrentItem(elements[0])