Make BWizard generic: now it can be used for both creating and editing projects
[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 class BWizard(QWizard):
27     """
28     Main class of the wizard. It adds the pages automatically.
29     """
30     
31     def __init__(self, page_list):
32         QWizard.__init__(self)
33         self.setWindowTitle(self.tr("Create a BeRTOS project"))
34         self.setOption(QWizard.DisabledBackButtonOnLastPage, True)
35         self.addPages(page_list)
36         self.connectSignals()
37     
38     def addPages(self, page_list):
39         """
40         Adds the pages in the wizard.
41         """
42         for page in page_list:
43             self.addPage(page())
44
45     def connectSignals(self):
46         """
47         Connects the signals with the related slots.
48         """
49         self.connect(self, SIGNAL("currentIdChanged(int)"), self.pageChanged)
50     
51     def pageChanged(self, pageId):
52         """
53         Slot called when the user change the current page. It calls the reloadData
54         method of the next page.
55         """
56         page = self.page(pageId)
57         if page is not None:
58             page.reloadData()
59     
60     def project(self):
61         """
62         Returns the BProject associated with the wizard.
63         """
64         return copy.deepcopy(QApplication.instance().project)