lm3s1968: be sure to enable clock gating for GPIO port G before using any of the...
[bertos.git] / wizard / BRoutePage.py
index 633fac4affd2355ab82c811ac5771b12a0280046..b34f790050986e74fab5d39588993afa6c341478 100644 (file)
@@ -44,6 +44,7 @@ from BToolchainPage import BToolchainPage
 import const
 import qvariant_converter
 from bertos_utils import presetList
+from toolchain_manager import ToolchainManager
 
 class BRoutePage(BWizardPage):
     """
@@ -61,7 +62,9 @@ class BRoutePage(BWizardPage):
         """
         Overload of the QWizardPage isComplete method.
         """
-        return False
+        self.setProjectInfo("EMPTY_MAIN", self.empty_main)
+        self.setProjectInfo("BASE_MODE", not self.advanced)
+        return True
 
     def nextId(self):
         """
@@ -72,7 +75,22 @@ class BRoutePage(BWizardPage):
         if self.advanced:
             return self.wizard().pageIndex(BToolchainPage)
         else:
-            return self.wizard().pageIndex(BOutputPage)
+            cpu_info = self.projectInfo("CPU_INFOS")
+            if cpu_info:
+                target = cpu_info["TOOLCHAIN"]
+            else:
+                # It seems that the nextId method is called before the
+                # reloadData one (that is called after the page changing.
+                #
+                # TODO: fix this awful code lines
+                target = None
+            # Try to find a suitable toolchain automatically
+            tm = ToolchainManager()
+            suitable_toolchains = tm.suitableToolchains(target)
+            if len(suitable_toolchains) == 1:
+                return self.wizard().pageIndex(BOutputPage)
+            else:
+                return self.wizard().pageIndex(BToolchainPage)
 
     ####
 
@@ -88,13 +106,19 @@ class BRoutePage(BWizardPage):
         """
         Overload of the BWizardPage connectSignals method.
         """
-        pass
+        self.connect(self.pageContent.emptyCheckBox, SIGNAL("stateChanged(int)"), self, SIGNAL("completeChanged()"))
+        self.connect(self.pageContent.baseButton, SIGNAL("toggled(bool)"), self, SIGNAL("completeChanged()"))
 
     def reloadData(self):
         """
         Overload of the BWizardPage reloadData method.
         """
-        pass
+        preset = self.projectInfo('PROJECT_PRESET')
+        try:
+            QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+            self.project.loadProjectFromPreset(preset)
+        finally:
+            QApplication.instance().restoreOverrideCursor()
 
     ####
 
@@ -106,3 +130,10 @@ class BRoutePage(BWizardPage):
     @property
     def advanced(self):
         return self.pageContent.advancedButton.isChecked()
+
+    @property
+    def empty_main(self):
+        if self.advanced:
+            return self.pageContent.emptyCheckBox.isChecked()
+        else:
+            return False