4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
14 from PyQt4.QtGui import *
16 from BWizardPage import *
21 class BCreationPage(BWizardPage):
24 BWizardPage.__init__(self, UI_LOCATION + "/project_creation.ui")
25 self.setTitle(self.tr("Create the BeRTOS project"))
27 self._connectSignals()
28 self._completed = False
31 self._confirmGroup = QWidgetGroup(self.pageContent.summaryTree,
32 self.pageContent.createButton)
33 self._finalGroup = QWidgetGroup(self.pageContent.iconLabel,
34 self.pageContent.textLabel)
35 self._finalGroup.setVisible(False)
36 summary = self.pageContent.summaryTree
37 summary.setHeaderHidden(True)
38 summary.setColumnCount(1)
41 self._completed = False
43 self.pageContent.summaryTree.clear()
45 folderTitle = QTreeWidgetItem(QStringList([self.tr("Project folder")]))
46 folderItem = QTreeWidgetItem(folderTitle, QStringList([os.path.normpath(self._projectInfoRetrieve("PROJECT_PATH"))]))
47 topLevel.append(folderTitle)
48 versionTitle = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")]))
49 sources_path = self._projectInfoRetrieve("SOURCES_PATH")
50 version = QTreeWidgetItem(versionTitle, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)]))
51 sourcePath = QTreeWidgetItem(versionTitle, QStringList([self.tr("path: ") + os.path.normpath(sources_path)]))
52 topLevel.append(versionTitle)
53 cpuTitle = QTreeWidgetItem(QStringList([self.tr("CPU")]))
54 cpuName = QTreeWidgetItem(cpuTitle, QStringList([self.tr("cpu name: ") + self._projectInfoRetrieve("CPU_NAME")]))
55 topLevel.append(cpuTitle)
56 toolchainTitle = QTreeWidgetItem(QStringList([self.tr("Toolchain")]))
57 toolchainInfo = self._projectInfoRetrieve("TOOLCHAIN")
58 if "target" in toolchainInfo.keys():
59 toolchainTarget = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("target: " + toolchainInfo["target"])]))
60 if "version" in toolchainInfo.keys():
61 toolchainTarget = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("version: " + "GCC " + toolchainInfo["version"] + " (" + toolchainInfo["build"] + ")")]))
62 toolchainPath = QTreeWidgetItem(toolchainTitle, QStringList([self.tr("path: " + os.path.normpath(toolchainInfo["path"]))]))
63 topLevel.append(toolchainTitle)
64 moduleTitle = QTreeWidgetItem(QStringList([self.tr("Modules")]))
65 configurations = self._projectInfoRetrieve("CONFIGURATIONS")
67 for module, information in self._projectInfoRetrieve("MODULES").items():
68 if information["enabled"]:
69 if information["category"] not in moduleCategories.keys():
70 moduleCategories[information["category"]] = []
71 moduleItem = QTreeWidgetItem(QStringList([module + " - " + information["description"]]))
72 moduleCategories[information["category"]].append(moduleItem)
73 if len(information["configuration"]) > 0:
74 for property, data in configurations[information["configuration"]].items():
75 # If the final char of the brief is a dot (".") removes it.
79 configurationItem = QTreeWidgetItem(moduleItem, QStringList([brief + ": " + data["value"]]))
80 for key, value in moduleCategories.items():
81 categoryItem = QTreeWidgetItem(moduleTitle, QStringList([key]))
82 categoryItem.addChildren(value)
83 topLevel.append(moduleTitle)
84 self.pageContent.summaryTree.insertTopLevelItems(0, topLevel)
86 def _connectSignals(self):
87 self.connect(self.pageContent.createButton, SIGNAL("clicked(bool)"), self._createProject)
89 def _createProject(self):
90 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
91 self._confirmGroup.setVisible(False)
92 bertos_utils.createBertosProject(self.wizard().project())
93 self._finalGroup.setVisible(True)
94 self._completed = True
95 QApplication.restoreOverrideCursor()
96 self.emit(SIGNAL("completeChanged()"))
99 return self._completed
101 class QWidgetGroup(QObject):
103 Container class, this class contains widgets and permit to set some
104 properties of the contained widgets at the same time.
106 def __init__(self, *elements):
108 for element in elements:
109 self._widgets.append(element)
111 def addWidget(self, widget):
112 if widget not in self._widgets:
113 self._widgets.append(widget)
115 def setVisible(self, visible):
116 for widget in self._widgets:
117 widget.setVisible(visible)
120 for widget in self._widgets:
121 if not widget.isVisible():