self.tr("Changing the BeRTOS version will destroy all the modification done on the BeRTOS sources"),
QMessageBox.Ok | QMessageBox.Cancel
) == QMessageBox.Ok:
- qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
- dialog.version_page.setProjectInfo("SOURCES_PATH", version)
- dialog.version_page.setProjectInfo("OLD_SOURCES_PATH", current_version)
- enabled_modules = bertos_utils.enabledModules(dialog.version_page.project())
- old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
- dialog.version_page.project().loadSourceTree()
- bertos_utils.loadModuleData(dialog.version_page.project())
- new_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
- merged_configuration = {}
- for conf in new_configuration:
- if conf in old_configuration:
- configuration = bertos_utils.updateConfigurationValues(new_configuration[conf], old_configuration[conf])
- else:
- configuration = new_configuration[conf]
- merged_configuration[conf] = configuration
- dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
- bertos_utils.setEnabledModules(dialog.version_page.project(), enabled_modules)
- self.module_page.fillModuleTree()
- qApp.restoreOverrideCursor()
+ try:
+ qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+ dialog.version_page.setProjectInfo("SOURCES_PATH", version)
+ dialog.version_page.setProjectInfo("OLD_SOURCES_PATH", current_version)
+ enabled_modules = bertos_utils.enabledModules(dialog.version_page.project())
+ old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+ dialog.version_page.project().loadSourceTree()
+ bertos_utils.loadModuleData(dialog.version_page.project())
+ new_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+ merged_configuration = {}
+ for conf in new_configuration:
+ if conf in old_configuration:
+ configuration = bertos_utils.updateConfigurationValues(new_configuration[conf], old_configuration[conf])
+ else:
+ configuration = new_configuration[conf]
+ merged_configuration[conf] = configuration
+ dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
+ bertos_utils.setEnabledModules(dialog.version_page.project(), enabled_modules)
+ self.module_page.fillModuleTree()
+ finally:
+ qApp.restoreOverrideCursor()
else:
# Rollback version to the previous selected one.
dialog.version_page.setProjectInfo("SOURCES_PATH", current_version)
def apply(self):
- qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
- createBertosProject(self.module_page.project(), edit=True)
- qApp.restoreOverrideCursor()
+ try:
+ qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+ createBertosProject(self.module_page.project(), edit=True)
+ finally:
+ qApp.restoreOverrideCursor()
self.accept()
def toolchains(self):
"""
Overload of the BWizardPage reloadData method.
"""
- QApplication.instance().setOverrideCursor(Qt.WaitCursor)
- self.setupUi()
- self.loadModuleData()
- self.fillModuleTree()
- QApplication.instance().restoreOverrideCursor()
+ try:
+ QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+ self.setupUi()
+ self.loadModuleData()
+ self.fillModuleTree()
+ finally:
+ QApplication.instance().restoreOverrideCursor()
####
"""
Resolves the selection dependencies.
"""
- qApp.setOverrideCursor(Qt.WaitCursor)
- modules = self.projectInfo("MODULES")
- modules[selectedModule]["enabled"] = True
- self.setProjectInfo("MODULES", modules)
- depends = self.projectInfo("MODULES")[selectedModule]["depends"]
- unsatisfied = []
- if self.pageContent.automaticFix.isChecked():
- unsatisfied = self.selectDependencyCheck(selectedModule)
- if len(unsatisfied) > 0:
- for module in unsatisfied:
- modules = self.projectInfo("MODULES")
- modules[module]["enabled"] = True
- for category in range(self.pageContent.moduleTree.topLevelItemCount()):
- item = self.pageContent.moduleTree.topLevelItem(category)
- for child in range(item.childCount()):
- if unicode(item.child(child).text(0)) in unsatisfied:
- self.setBold(item.child(child), True)
- self.setBold(item, True)
- item.child(child).setCheckState(0, Qt.Checked)
- qApp.restoreOverrideCursor()
-
- def moduleUnselected(self, unselectedModule):
- """
- Resolves the unselection dependencies.
- """
- qApp.setOverrideCursor(Qt.WaitCursor)
- modules = self.projectInfo("MODULES")
- modules[unselectedModule]["enabled"] = False
- self.setProjectInfo("MODULES", modules)
- unsatisfied = []
- unsatisfied_params = []
- if self.pageContent.automaticFix.isChecked():
- unsatisfied, unsatisfied_params = self.unselectDependencyCheck(unselectedModule)
- if len(unsatisfied) > 0 or len(unsatisfied_params) > 0:
- message = []
- heading = self.tr("The module %1 is needed by").arg(unselectedModule)
- message.append(heading)
- module_list = ", ".join(unsatisfied)
- param_list = ", ".join(["%s (%s)" %(param_name, module) for module, param_name in unsatisfied_params])
- if module_list:
- message.append(QString(module_list))
- if module_list and param_list:
- message.append(self.tr("and by"))
- if param_list:
- message.append(QString(param_list))
- message_str = QStringList(message).join(" ")
- message_str.append(self.tr("\n\nDo you want to automatically fix these conflicts?"))
- qApp.restoreOverrideCursor()
- choice = QMessageBox.warning(self, self.tr("Dependency error"), message_str, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
+ try:
qApp.setOverrideCursor(Qt.WaitCursor)
- if choice == QMessageBox.Yes:
+ modules = self.projectInfo("MODULES")
+ modules[selectedModule]["enabled"] = True
+ self.setProjectInfo("MODULES", modules)
+ depends = self.projectInfo("MODULES")[selectedModule]["depends"]
+ unsatisfied = []
+ if self.pageContent.automaticFix.isChecked():
+ unsatisfied = self.selectDependencyCheck(selectedModule)
+ if len(unsatisfied) > 0:
for module in unsatisfied:
modules = self.projectInfo("MODULES")
- modules[module]["enabled"] = False
+ modules[module]["enabled"] = True
for category in range(self.pageContent.moduleTree.topLevelItemCount()):
item = self.pageContent.moduleTree.topLevelItem(category)
for child in range(item.childCount()):
if unicode(item.child(child).text(0)) in unsatisfied:
- item.child(child).setCheckState(0, Qt.Unchecked)
- for module, param in unsatisfied_params:
- configuration_file = self.projectInfo("MODULES")[module]["configuration"]
- configurations = self.projectInfo("CONFIGURATIONS")
- configurations[configuration_file][param]["value"] = "0"
- self.setProjectInfo("CONFIGURATIONS", configurations)
+ self.setBold(item.child(child), True)
+ self.setBold(item, True)
+ item.child(child).setCheckState(0, Qt.Checked)
+ finally:
+ qApp.restoreOverrideCursor()
+
+ def moduleUnselected(self, unselectedModule):
+ """
+ Resolves the unselection dependencies.
+ """
+ try:
+ qApp.setOverrideCursor(Qt.WaitCursor)
+ modules = self.projectInfo("MODULES")
+ modules[unselectedModule]["enabled"] = False
+ self.setProjectInfo("MODULES", modules)
+ unsatisfied = []
+ unsatisfied_params = []
+ if self.pageContent.automaticFix.isChecked():
+ unsatisfied, unsatisfied_params = self.unselectDependencyCheck(unselectedModule)
+ if len(unsatisfied) > 0 or len(unsatisfied_params) > 0:
+ message = []
+ heading = self.tr("The module %1 is needed by").arg(unselectedModule)
+ message.append(heading)
+ module_list = ", ".join(unsatisfied)
+ param_list = ", ".join(["%s (%s)" %(param_name, module) for module, param_name in unsatisfied_params])
+ if module_list:
+ message.append(QString(module_list))
+ if module_list and param_list:
+ message.append(self.tr("and by"))
+ if param_list:
+ message.append(QString(param_list))
+ message_str = QStringList(message).join(" ")
+ message_str.append(self.tr("\n\nDo you want to automatically fix these conflicts?"))
+ qApp.restoreOverrideCursor()
+ choice = QMessageBox.warning(self, self.tr("Dependency error"), message_str, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
+ qApp.setOverrideCursor(Qt.WaitCursor)
+ if choice == QMessageBox.Yes:
+ for module in unsatisfied:
+ modules = self.projectInfo("MODULES")
+ modules[module]["enabled"] = False
+ for category in range(self.pageContent.moduleTree.topLevelItemCount()):
+ item = self.pageContent.moduleTree.topLevelItem(category)
+ for child in range(item.childCount()):
+ if unicode(item.child(child).text(0)) in unsatisfied:
+ item.child(child).setCheckState(0, Qt.Unchecked)
+ for module, param in unsatisfied_params:
+ configuration_file = self.projectInfo("MODULES")[module]["configuration"]
+ configurations = self.projectInfo("CONFIGURATIONS")
+ configurations[configuration_file][param]["value"] = "0"
+ self.setProjectInfo("CONFIGURATIONS", configurations)
+ finally:
qApp.restoreOverrideCursor()
def selectDependencyCheck(self, module):