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._confirm_group = QWidgetGroup(self.pageContent.summaryTree,
32 self.pageContent.createButton)
33 self._final_group = QWidgetGroup(self.pageContent.iconLabel,
34 self.pageContent.textLabel)
35 self._final_group.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 folder_title = QTreeWidgetItem(QStringList([self.tr("Project folder")]))
46 folder_item = QTreeWidgetItem(folder_title, QStringList([os.path.normpath(self._projectInfoRetrieve("PROJECT_PATH"))]))
47 top_level.append(folder_title)
48 version_title = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")]))
49 sources_path = self._projectInfoRetrieve("SOURCES_PATH")
50 version = QTreeWidgetItem(version_title, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)]))
51 source_path = QTreeWidgetItem(version_title, QStringList([self.tr("path: ") + os.path.normpath(sources_path)]))
52 top_level.append(version_title)
53 cpu_title = QTreeWidgetItem(QStringList([self.tr("CPU")]))
54 cpu_name = QTreeWidgetItem(cpu_title, QStringList([self.tr("cpu name: ") + self._projectInfoRetrieve("CPU_NAME")]))
55 top_level.append(cpu_title)
56 toolchain_title = QTreeWidgetItem(QStringList([self.tr("Toolchain")]))
57 toolchain_info = self._projectInfoRetrieve("TOOLCHAIN")
58 if "target" in toolchain_info.keys():
59 toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("target: " + toolchain_info["target"])]))
60 if "version" in toolchain_info.keys():
61 toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("version: " + "GCC " + toolchain_info["version"] + " (" + toolchain_info["build"] + ")")]))
62 toolchain_path = QTreeWidgetItem(toolchain_title, QStringList([self.tr("path: " + os.path.normpath(toolchain_info["path"]))]))
63 top_level.append(toolchain_title)
64 module_title = QTreeWidgetItem(QStringList([self.tr("Modules")]))
65 configurations = self._projectInfoRetrieve("CONFIGURATIONS")
66 module_categories = {}
67 for module, information in self._projectInfoRetrieve("MODULES").items():
68 if information["enabled"]:
69 if information["category"] not in module_categories.keys():
70 module_categories[information["category"]] = []
71 moduleItem = QTreeWidgetItem(QStringList([module + " - " + information["description"]]))
72 module_categories[information["category"]].append(moduleItem)
73 if len(information["configuration"]) > 0:
74 for start, property in configurations[information["configuration"]]["paramlist"]:
75 # If the final char of the brief is a dot (".") removes it.
76 brief = configurations[information["configuration"]][property]["brief"]
79 configuration_item = QTreeWidgetItem(moduleItem, QStringList([brief + ": " + configurations[information["configuration"]][property]["value"]]))
80 for key, value in module_categories.items():
81 category_item = QTreeWidgetItem(module_title, QStringList([key]))
82 category_item.addChildren(value)
83 top_level.append(module_title)
84 self.pageContent.summaryTree.insertTopLevelItems(0, top_level)
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._confirm_group.setVisible(False)
92 bertos_utils.createBertosProject(self.wizard().project())
93 self._final_group.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():