4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
12 from PyQt4.QtGui import *
14 from BWizardPage import *
19 class BCreationPage(BWizardPage):
22 BWizardPage.__init__(self, UI_LOCATION + "/project_creation.ui")
23 self.setTitle(self.tr("Create the BeRTOS project"))
25 self._connectSignals()
26 self._completed = False
29 self._confirmGroup = QWidgetGroup(self.pageContent.summaryTree,
30 self.pageContent.createButton)
31 self._finalGroup = QWidgetGroup(self.pageContent.iconLabel,
32 self.pageContent.textLabel)
33 self._finalGroup.setVisible(False)
34 summary = self.pageContent.summaryTree
35 summary.setHeaderHidden(True)
36 summary.setColumnCount(1)
39 self._completed = False
41 self.pageContent.summaryTree.clear()
43 folderTitle = QTreeWidgetItem(QStringList([self.tr("Project folder")]))
44 folderItem = QTreeWidgetItem(folderTitle, QStringList([self._projectInfoRetrieve("PROJECT_PATH")]))
45 topLevel.append(folderTitle)
46 versionTitle = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")]))
47 sources_path = self._projectInfoRetrieve("SOURCES_PATH")
48 version = QTreeWidgetItem(versionTitle, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)]))
49 sourcePath = QTreeWidgetItem(versionTitle, QStringList([self.tr("path: ") + sources_path]))
50 topLevel.append(versionTitle)
51 cpuTitle = QTreeWidgetItem(QStringList([self.tr("CPU")]))
52 cpuName = QTreeWidgetItem(cpuTitle, QStringList([self.tr("cpu name: ") + self._projectInfoRetrieve("CPU_NAME")]))
53 topLevel.append(cpuTitle)
54 toolchainTitle = QTreeWidgetItem(QStringList([self.tr("Toolchain")]))
55 toolchainInfo = self._projectInfoRetrieve("TOOLCHAIN")
56 if "target" in toolchainInfo.keys():
57 toolchainTarget = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("target: " + toolchainInfo["target"])]))
58 if "version" in toolchainInfo.keys():
59 toolchainTarget = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("version: " + "GCC " + toolchainInfo["version"] + " (" + toolchainInfo["build"] + ")")]))
60 toolchainPath = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("path: " + toolchainInfo["path"])]))
61 topLevel.append(toolchainTitle)
62 moduleTitle = QTreeWidgetItem(QStringList([self.tr("Modules")]))
63 configurations = self._projectInfoRetrieve("CONFIGURATIONS")
64 for module, information in self._projectInfoRetrieve("MODULES").items():
65 if information["enabled"]:
66 moduleItem = QTreeWidgetItem(moduleTitle, QStringList([module + " - " + information["description"]]))
67 if len(information["configuration"]) > 0:
68 for property, data in configurations[information["configuration"]].items():
69 configurationItem = QTreeWidgetItem(moduleItem, QStringList([data["brief"] + " " + data["value"]]))
70 topLevel.append(moduleTitle)
71 self.pageContent.summaryTree.insertTopLevelItems(0, topLevel)
73 def _connectSignals(self):
74 self.connect(self.pageContent.createButton, SIGNAL("clicked(bool)"), self._createProject)
76 def _createProject(self):
77 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
78 self._confirmGroup.setVisible(False)
79 bertos_utils.createBertosProject(self.wizard().project())
80 self._finalGroup.setVisible(True)
81 self._completed = True
82 QApplication.restoreOverrideCursor()
83 self.emit(SIGNAL("completeChanged()"))
86 return self._completed
88 class QWidgetGroup(QObject):
90 Container class, this class contains widgets and permit to set some
91 properties of the contained widgets at the same time.
93 def __init__(self, *elements):
95 for element in elements:
96 self._widgets.append(element)
98 def addWidget(self, widget):
99 if widget not in self._widgets:
100 self._widgets.append(widget)
102 def setVisible(self, visible):
103 for widget in self._widgets:
104 widget.setVisible(visible)
107 for widget in self._widgets:
108 if not widget.isVisible():