Rollback to previous selected version if the user doesn't confirm the version change.
[bertos.git] / wizard / BEditingDialog.py
index 46c184d25e10c345abb7194c6d0e1c4d42e475e1..617cebff2b0c16a9b0f7dee080b7b955c2d2bda0 100644 (file)
@@ -72,6 +72,7 @@ class BEditingDialog(QDialog):
         button_layout.addWidget(self.apply_button)
         layout.addLayout(button_layout)
         self.setLayout(layout)
+        self.setWindowTitle(self.tr("Edit %1 project").arg(os.path.basename(self.module_page.projectInfo("SOURCES_PATH"))))
 
     def setupMenu(self):
         self.menu = QMenu(self.tr("Advanced options"))
@@ -90,7 +91,15 @@ class BEditingDialog(QDialog):
         dialog = QDialog()
         layout = QVBoxLayout()
         toolchain_page = BToolchainPage()
+       current_toolchain = toolchain_page.projectInfo("TOOLCHAIN")
         toolchain_page.reloadData()
+       # TODO: to be moved in BToolchainPage
+       for toolchain_row in range(toolchain_page.pageContent.toolchainList.count()):
+            toolchain = qvariant_converter.getStringDict(toolchain_page.pageContent.toolchainList.item(toolchain_row).data(Qt.UserRole))
+           if toolchain["path"] == current_toolchain["path"]:
+                toolchain_page.pageContent.toolchainList.setCurrentRow(toolchain_row)
+               toolchain_page.selectionChanged()
+               break
         layout.addWidget(toolchain_page)
         button_layout = QHBoxLayout()
         button_layout.addStretch()
@@ -102,6 +111,7 @@ class BEditingDialog(QDialog):
         layout.addLayout(button_layout)
         dialog.setLayout(layout)
         dialog.connect(ok_button, SIGNAL("clicked()"), dialog.accept)
+        dialog.setWindowTitle(self.tr("Change toolchain"))
         if dialog.exec_():
             toolchain = qvariant_converter.getStringDict(toolchain_page.currentItem().data(Qt.UserRole))
             toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
@@ -123,6 +133,7 @@ class BEditingDialog(QDialog):
         dialog.setLayout(layout)
         dialog.connect(ok_button, SIGNAL("clicked()"), dialog.accept)
         current_version = version_page.projectInfo("SOURCES_PATH")
+        dialog.setWindowTitle(self.tr("Change BeRTOS version"))
         if dialog.exec_():
             version = qvariant_converter.getString(version_page.currentItem().data(Qt.UserRole))
             if version != current_version:
@@ -149,6 +160,9 @@ class BEditingDialog(QDialog):
                     version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
                     bertos_utils.setEnabledModules(version_page.project(), enabled_modules)
                     self.module_page.fillModuleTree()
+               else:
+                   # Rollback version to the previous selected one.
+                   version_page.setProjectInfo("SOURCES_PATH", current_version)
 
     def apply(self):
         createBertosProject(self.module_page.project(), edit=True)