Add method to create the sources dir into the project.
[bertos.git] / wizard / BVersionPage.py
index 37097c4fb0ccd70d4de3cbd680998f42e80d7fa4..452e8a947309637d75906199b3ae0674894157e8 100644 (file)
@@ -48,7 +48,8 @@ class BVersionPage(BWizardPage):
     to use. This page show some pieces of information about the version.
     """
     
-    def __init__(self):
+    def __init__(self, edit=False):
+        self._edit = edit
         BWizardPage.__init__(self, UI_LOCATION + "/bertos_versions.ui")
         self.setTitle(self.tr("Select the BeRTOS directory"))
         self.setSubTitle(self.tr("The project created will be based on the BeRTOS version found"))
@@ -68,6 +69,14 @@ class BVersionPage(BWizardPage):
             return True
         else:
             return False
+
+    def nextId(self):
+        """
+        Overload of the QWizard nextId method.
+        """
+        # Pick up the class stored into the project in the 'folder' step
+        page_class = self.projectInfo("ROUTE")
+        return self.wizard().pageIndex(page_class)
     
     ####
     
@@ -117,7 +126,8 @@ class BVersionPage(BWizardPage):
         Slot called when the user remove a BeRTOS version.
         """
         item = self.pageContent.versionList.takeItem(self.pageContent.versionList.currentRow())
-        self.deleteVersion(qvariant_converter.getString(item.data(Qt.UserRole)))
+       if item:
+               self.deleteVersion(qvariant_converter.getString(item.data(Qt.UserRole)))
         self.emit(SIGNAL("completeChanged()"))
     
     def rowChanged(self):
@@ -151,8 +161,8 @@ class BVersionPage(BWizardPage):
         """
         Removes the given directory from the QSettings.
         """
-        versions = self.versions()
-        versions.remove(directory)
+        versions = [os.path.normpath(path) for path in self.versions()]
+        versions.remove(os.path.normpath(directory))
         self.setVersions(versions)
     
     def resetVersionList(self):
@@ -182,6 +192,8 @@ class BVersionPage(BWizardPage):
         Fills the version list with all the BeRTOS versions founded in the QSettings.
         """
         versions = set([])
+        if self._edit:
+            versions.add(self.projectInfo("SOURCES_PATH"))
         if os.name == "nt":
             import winreg_importer
             versions |= set([os.path.normpath(dir) for dir in winreg_importer.getBertosDirs()])