Move revision to wizard pages; remove version file from repository.
[bertos.git] / wizard / BWizard.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2008 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 copy
13
14 from PyQt4.QtCore import *
15 from PyQt4.QtGui import *
16
17 import BFolderPage
18 import BVersionPage
19 import BCpuPage
20 import BToolchainPage
21 import BModulePage
22 import BOutputPage
23 import BCreationPage
24 import BFinalPage
25
26 try:
27     from version import wizard_version
28 except ImportError:
29     wizard_version = "sandbox"
30
31 class BWizard(QWizard):
32     """
33     Main class of the wizard. It adds the pages automatically.
34     """
35
36     def __init__(self, page_list):
37         QWizard.__init__(self)
38         self.setWindowTitle(self.tr("Create a BeRTOS project - rev.%1").arg(wizard_version))
39         self.setWindowIcon(QIcon(":/images/appicon.png"))
40         self.setOption(QWizard.DisabledBackButtonOnLastPage, True)
41         self.addPages(page_list)
42         self.connectSignals()
43
44     def addPages(self, page_list):
45         """
46         Adds the pages in the wizard.
47         """
48         for page in page_list:
49             self.addPage(page())
50
51     def connectSignals(self):
52         """
53         Connects the signals with the related slots.
54         """
55         self.connect(self, SIGNAL("currentIdChanged(int)"), self.pageChanged)
56
57     def pageChanged(self, pageId):
58         """
59         Slot called when the user change the current page. It calls the reloadData
60         method of the next page.
61         """
62         page = self.page(pageId)
63         if page:
64             page.reloadData()
65
66     def project(self):
67         """
68         Returns the BProject associated with the wizard.
69         """
70         return copy.deepcopy(QApplication.instance().project)