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"))
27 self.freq_modified = False
29 ## Overloaded QWizardPage methods ##
33 Overload of the QWizardPage isComplete method.
35 if self.pageContent.cpuList.currentRow() != -1:
36 self.pageContent.frequencyLabel.setVisible(True)
37 self.pageContent.frequencySpinBox.setVisible(True)
38 infos = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))
39 for key, value in infos.items():
40 if type(CPU_DEF[key]) == list:
41 infos[key] = qvariant_converter.getStringList(value)
42 if type(CPU_DEF[key]) == str or type(CPU_DEF) == unicode:
43 infos[key] = qvariant_converter.getString(value)
44 self.setProjectInfo("CPU_INFOS", infos)
45 self.setProjectInfo("CPU_NAME", unicode(self.pageContent.cpuList.currentItem().text()))
46 self.setProjectInfo("SELECTED_FREQ", unicode(long(self.pageContent.frequencySpinBox.value())))
53 ## Overloaded BWizardPage methods ##
57 Overload of the BWizardPage setupUi method.
59 self.pageContent.cpuList.setSortingEnabled(True)
60 self.pageContent.descriptionLabel.setVisible(False)
61 self.pageContent.descriptionLabel.setText("")
62 self.pageContent.frequencyLabel.setVisible(False)
63 self.pageContent.frequencySpinBox.setVisible(False)
65 def connectSignals(self):
67 Overload of the BWizardPage connectSignals method.
69 self.connect(self.pageContent.cpuList, SIGNAL("itemSelectionChanged()"), self.rowChanged)
70 self.connect(self.pageContent.frequencySpinBox, SIGNAL("editingFinished()"), self.freqChanged)
74 Overload of the BWizardPage reloadData method.
76 QApplication.instance().setOverrideCursor(Qt.WaitCursor)
77 bertos_utils.loadSourceTree(self.project())
78 self.populateCpuList()
79 cpu_name = self.projectInfo("CPU_NAME")
81 if not cpu_name is None:
82 self.selectItem(cpu_name)
83 QApplication.instance().restoreOverrideCursor()
84 self.emit(SIGNAL("completeChanged()"))
92 Slot called when the user select an entry from the cpu list.
94 description = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DESC"]
95 description = qvariant_converter.getStringList(description)
96 if not self.freq_modified:
97 # Retrieve the default cpu frequency when the value isn't already modified
98 current_freq = qvariant_converter.getDict(self.pageContent.cpuList.currentItem().data(Qt.UserRole))["CPU_DEFAULT_FREQ"]
99 current_freq = qvariant_converter.getString(current_freq)
100 current_freq = long(current_freq.replace("U", "").replace("L", ""))
101 self.pageContent.frequencySpinBox.setValue(long(current_freq))
102 self.pageContent.descriptionLabel.setText("<br>".join(description))
103 self.pageContent.descriptionLabel.setVisible(True)
104 self.emit(SIGNAL("completeChanged()"))
106 def freqChanged(self):
108 Slot called when the user change the frequency value.
110 self.freq_modified = True
111 self.emit(SIGNAL("completeChanged()"))
115 def populateCpuList(self):
119 self.pageContent.cpuList.clear()
120 self.pageContent.cpuList.setCurrentItem(None)
121 infos = bertos_utils.loadCpuInfos(self.project())
123 item = QListWidgetItem(cpu["CPU_NAME"])
124 item.setData(Qt.UserRole, qvariant_converter.convertDict(cpu))
125 self.pageContent.cpuList.addItem(item)
127 def selectItem(self, cpu):
129 Selects the given cpu from the list.
131 elements = self.pageContent.cpuList.findItems(cpu, Qt.MatchCaseSensitive)
132 if len(elements) == 1:
133 self.pageContent.cpuList.setCurrentItem(elements[0])