Add icon for the window
[bertos.git] / wizard / BCreationPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 import os
13
14 from PyQt4.QtGui import *
15
16 from BWizardPage import *
17 import bertos_utils
18
19 from const import *
20
21 class BCreationPage(BWizardPage):
22     
23     def __init__(self):
24         BWizardPage.__init__(self, UI_LOCATION + "/project_creation.ui")
25         self.setTitle(self.tr("Create the BeRTOS project"))
26         self._completed = False
27
28     ## Overloaded BWizardPage methods ##
29     
30     def setupUi(self):
31         summary = self.pageContent.summaryTree
32         summary.setHeaderHidden(True)
33         summary.setColumnCount(1)
34         self.setButtonText(QWizard.NextButton, self.tr("Create"))
35     
36     def reloadData(self):
37         self.setupUi()
38         self.pageContent.summaryTree.clear()
39         top_level = []
40         folder_title = QTreeWidgetItem(QStringList([self.tr("Project folder")]))
41         folder_item = QTreeWidgetItem(folder_title, QStringList([os.path.normpath(self.projectInfo("PROJECT_PATH"))]))
42         top_level.append(folder_title)
43         version_title = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")]))
44         sources_path = self.projectInfo("SOURCES_PATH")
45         version = QTreeWidgetItem(version_title, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)]))
46         source_path = QTreeWidgetItem(version_title, QStringList([self.tr("path: ") + os.path.normpath(sources_path)]))
47         top_level.append(version_title)
48         cpu_title = QTreeWidgetItem(QStringList([self.tr("CPU")]))
49         cpu_name = QTreeWidgetItem(cpu_title, QStringList([self.tr("cpu name: ") + self.projectInfo("CPU_NAME")]))
50         top_level.append(cpu_title)
51         toolchain_title = QTreeWidgetItem(QStringList([self.tr("Toolchain")]))
52         toolchain_info = self.projectInfo("TOOLCHAIN")
53         if "target" in toolchain_info.keys():
54             toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("target: " + toolchain_info["target"])]))
55         if "version" in toolchain_info.keys():
56             toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("version: " + "GCC " + toolchain_info["version"] + " (" + toolchain_info["build"] + ")")]))
57         toolchain_path = QTreeWidgetItem(toolchain_title, QStringList([self.tr("path: " + os.path.normpath(toolchain_info["path"]))]))
58         top_level.append(toolchain_title)
59         module_title = QTreeWidgetItem(QStringList([self.tr("Modules")]))
60         configurations = self.projectInfo("CONFIGURATIONS")
61         module_categories = {}
62         for module, information in self.projectInfo("MODULES").items():
63             if information["enabled"]:
64                 if information["category"] not in module_categories.keys():
65                     module_categories[information["category"]] = []
66                 moduleItem = QTreeWidgetItem(QStringList([module + " - " + information["description"]]))
67                 module_categories[information["category"]].append(moduleItem)
68                 if len(information["configuration"]) > 0:
69                     for start, property in configurations[information["configuration"]]["paramlist"]:
70                         # If the final char of the brief is a dot (".") removes it.
71                         brief = configurations[information["configuration"]][property]["brief"]
72                         if brief[-1] == ".":
73                             brief = brief[:-1]
74                         configuration_item = QTreeWidgetItem(moduleItem, QStringList([brief + ": " + configurations[information["configuration"]][property]["value"]]))
75         for key, value in module_categories.items():
76             category_item = QTreeWidgetItem(module_title, QStringList([key]))
77             category_item.addChildren(value)
78         top_level.append(module_title)
79         self.pageContent.summaryTree.insertTopLevelItems(0, top_level)
80     
81     ####