If no BeRTOS version is selected the Wizard automatically select the latest
[bertos.git] / wizard / BWizard.py
index 851021cec4f7a9b4d05c3ff9bba18209a83c7b20..a4436623bc965e803c431c31ee8aebf133afec59 100644 (file)
@@ -4,11 +4,13 @@
 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
 # All rights reserved.
 #
-# $Id:$
+# $Id$
 #
 # Author: Lorenzo Berni <duplo@develer.com>
 #
 
+import copy
+
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
@@ -17,26 +19,47 @@ import BVersionPage
 import BCpuPage
 import BToolchainPage
 import BModulePage
+import BOutputPage
+import BCreationPage
+import BFinalPage
 
 class BWizard(QWizard):
+    """
+    Main class of the wizard. It adds the pages automatically.
+    """
     
-    def __init__(self):
+    def __init__(self, page_list):
         QWizard.__init__(self)
         self.setWindowTitle(self.tr("Create a BeRTOS project"))
-        self._addPages()
-        self._connectSignals()
-    
-    def _addPages(self):
-        self.addPage(BFolderPage.BFolderPage())
-        self.addPage(BVersionPage.BVersionPage())
-        self.addPage(BCpuPage.BCpuPage())
-        self.addPage(BToolchainPage.BToolchainPage())
-        self.addPage(BModulePage.BModulePage())
+        self.setWindowIcon(QIcon(":/images/appicon.png"))
+        self.setOption(QWizard.DisabledBackButtonOnLastPage, True)
+        self.addPages(page_list)
+        self.connectSignals()
     
-    def _connectSignals(self):
-        self.connect(self, SIGNAL("currentIdChanged(int)"), self._pageChanged)
+    def addPages(self, page_list):
+        """
+        Adds the pages in the wizard.
+        """
+        for page in page_list:
+            self.addPage(page())
+
+    def connectSignals(self):
+        """
+        Connects the signals with the related slots.
+        """
+        self.connect(self, SIGNAL("currentIdChanged(int)"), self.pageChanged)
     
-    def _pageChanged(self, pageId):
+    def pageChanged(self, pageId):
+        """
+        Slot called when the user change the current page. It calls the reloadData
+        method of the next page.
+        """
         page = self.page(pageId)
-        if page is not None:
-            page.reloadData()
\ No newline at end of file
+        if page:
+            page.reloadData()
+    
+    def project(self):
+        """
+        Returns the BProject associated with the wizard.
+        """
+        return copy.deepcopy(QApplication.instance().project)