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 self.pageContent.frequencyLabel.setVisible(True)
36 self.pageContent.frequencySpinBox.setVisible(True)
37 infos = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))
38 for key, value in infos.items():
39 if type(CPU_DEF[key]) == list:
40 infos[key] = qvariant_converter.getStringList(value)
41 if type(CPU_DEF[key]) == str or type(CPU_DEF) == unicode:
42 infos[key] = qvariant_converter.getString(value)
43 self.setProjectInfo("CPU_INFOS", infos)
44 self.setProjectInfo("CPU_NAME", unicode(self.pageContent.cpuList.currentItem().text()))
45 self.setProjectInfo("SELECTED_FREQ", unicode(long(self.pageContent.frequencySpinBox.value())))
52 ## Overloaded BWizardPage methods ##
56 Overload of the BWizardPage setupUi method.
58 self.pageContent.cpuList.setSortingEnabled(True)
59 self.pageContent.descriptionLabel.setVisible(False)
60 self.pageContent.descriptionLabel.setText("")
61 self.pageContent.frequencyLabel.setVisible(False)
62 self.pageContent.frequencySpinBox.setVisible(False)
64 def connectSignals(self):
66 Overload of the BWizardPage connectSignals method.
68 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
69 self.connect(self.pageContent.frequencySpinBox, SIGNAL("valueChanged(double)"), self.freqChanged)
73 Overload of the BWizardPage reloadData method.
75 QApplication.instance().setOverrideCursor(Qt.WaitCursor)
76 bertos_utils.loadSourceTree(self.project())
77 self.populateCpuList()
78 cpu_name = self.projectInfo("CPU_NAME")
80 if not cpu_name is None:
81 self.selectItem(cpu_name)
82 QApplication.instance().restoreOverrideCursor()
83 self.emit(SIGNAL("completeChanged()"))
91 Slot called when the user select an entry from the cpu list.
93 description = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DESC"]
94 description = qvariant_converter.getStringList(description)
95 frequency = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DEFAULT_FREQ"]
96 frequency = qvariant_converter.getString(frequency)
97 frequency = frequency.replace("U", "").replace("L", "")
98 self.pageContent.descriptionLabel.setText("<br>".join(description))
99 self.pageContent.descriptionLabel.setVisible(True)
100 self.pageContent.frequencySpinBox.setValue(long(frequency))
101 self.emit(SIGNAL("completeChanged()"))
103 def freqChanged(self):
104 self.emit(SIGNAL("completeChanged()"))
108 def populateCpuList(self):
112 self.pageContent.cpuList.clear()
113 self.pageContent.cpuList.setCurrentItem(None)
114 infos = bertos_utils.loadCpuInfos(self.project())
116 item = QListWidgetItem(cpu["CPU_NAME"])
117 item.setData(Qt.UserRole, qvariant_converter.convertDict(cpu))
118 self.pageContent.cpuList.addItem(item)
120 def selectItem(self, cpu):
122 Selects the given cpu from the list.
124 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
125 if len(elements) == 1:
126 self.pageContent.cpuList.setCurrentItem(elements[0])