Add TOOLCHAIN in the tags
[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         version = ""
56         if "version" in toolchain_info.keys():
57             version += "version: " + "GCC " + toolchain_info["version"] + " "
58         if "build" in toolchain_info.keys():
59             version += "(" + toolchain_info["build"] + ")"
60         if "version" in toolchain_info.keys():
61             toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([version]))
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.projectInfo("CONFIGURATIONS")
66         module_categories = {}
67         for module, information in self.projectInfo("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"]
77                         if brief[-1] == ".":
78                             brief = brief[:-1]
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)
85     
86     ####