Reformat error messages.
[bertos.git] / wizard / BCreationPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # This file is part of BeRTOS.
5 #
6 # Bertos is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 #
20 # As a special exception, you may use this file as part of a free software
21 # library without restriction.  Specifically, if other files instantiate
22 # templates or use macros or inline functions from this file, or you compile
23 # this file and link it with other files to produce an executable, this
24 # file does not by itself cause the resulting executable to be covered by
25 # the GNU General Public License.  This exception does not however
26 # invalidate any other reasons why the executable file might be covered by
27 # the GNU General Public License.
28 #
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
30 #
31 # $Id$
32 #
33 # Author: Lorenzo Berni <duplo@develer.com>
34 #
35
36 import os
37
38 from PyQt4.QtGui import *
39
40 from BWizardPage import *
41 import bertos_utils
42
43 from const import *
44
45 class BCreationPage(BWizardPage):
46     
47     def __init__(self):
48         BWizardPage.__init__(self, UI_LOCATION + "/project_creation.ui")
49         self.setTitle(self.tr("Settings summary"))
50         self._completed = False
51
52     ## Overloaded BWizardPage methods ##
53     
54     def setupUi(self):
55         summary = self.pageContent.summaryTree
56         summary.setHeaderHidden(True)
57         summary.setColumnCount(1)
58         self.setButtonText(QWizard.NextButton, self.tr("Create"))
59     
60     def reloadData(self):
61         self.setupUi()
62         self.pageContent.summaryTree.clear()
63         top_level = []
64         folder_title = QTreeWidgetItem(QStringList([self.tr("Project folder")]))
65         folder_item = QTreeWidgetItem(folder_title, QStringList([os.path.normpath(self.projectInfo("PROJECT_PATH"))]))
66         top_level.append(folder_title)
67         version_title = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")]))
68         sources_path = self.projectInfo("BERTOS_PATH")
69         version = QTreeWidgetItem(version_title, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)]))
70         source_path = QTreeWidgetItem(version_title, QStringList([self.tr("path: ") + os.path.normpath(sources_path)]))
71         top_level.append(version_title)
72         cpu_title = QTreeWidgetItem(QStringList([self.tr("CPU")]))
73         cpu_name = QTreeWidgetItem(cpu_title, QStringList([self.tr("cpu name: ") + self.projectInfo("CPU_NAME")]))
74         cpu_freq = QTreeWidgetItem(cpu_title, QStringList([self.tr("frequency: ") + self.projectInfo("SELECTED_FREQ") + "Hz"]))
75         top_level.append(cpu_title)
76         toolchain_title = QTreeWidgetItem(QStringList([self.tr("Toolchain")]))
77         toolchain_info = self.projectInfo("TOOLCHAIN")
78         if "target" in toolchain_info:
79             toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("target: " + toolchain_info["target"].strip())]))
80         version = ""
81         if "version" in toolchain_info:
82             version += "version: " + "GCC " + toolchain_info["version"].strip() + " "
83         if "build" in toolchain_info:
84             version += "(" + toolchain_info["build"].strip() + ")"
85         if "version" in toolchain_info:
86             toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([version]))
87         toolchain_path = QTreeWidgetItem(toolchain_title, QStringList([self.tr("path: " + os.path.normpath(toolchain_info["path"]))]))
88         top_level.append(toolchain_title)
89         module_title = QTreeWidgetItem(QStringList([self.tr("Modules")]))
90         configurations = self.projectInfo("CONFIGURATIONS")
91         module_categories = {}
92         for module, information in self.projectInfo("MODULES").items():
93             if information["enabled"]:
94                 if information["category"] not in module_categories:
95                     module_categories[information["category"]] = []
96                 moduleItem = QTreeWidgetItem(QStringList([module + " - " + information["description"]]))
97                 module_categories[information["category"]].append(moduleItem)
98                 if len(information["configuration"]) > 0:
99                     for start, property in configurations[information["configuration"]]["paramlist"]:
100                         # If the final char of the brief is a dot (".") removes it.
101                         brief = configurations[information["configuration"]][property]["brief"]
102                         if brief[-1] == ".":
103                             brief = brief[:-1]
104                         configuration_item = QTreeWidgetItem(moduleItem, QStringList([brief + ": " + configurations[information["configuration"]][property]["value"]]))
105         for key, value in module_categories.items():
106             category_item = QTreeWidgetItem(module_title, QStringList([key]))
107             category_item.addChildren(value)
108         top_level.append(module_title)
109         self.pageContent.summaryTree.insertTopLevelItems(0, top_level)
110         for item in top_level:
111             self.pageContent.summaryTree.expandItem(item)
112     
113     ####