From 72789b9f8ed050ed97c3e66a9aa707740f6656f2 Mon Sep 17 00:00:00 2001 From: duplo Date: Wed, 22 Apr 2009 16:15:48 +0000 Subject: [PATCH] Disable the remove button if the selected version is one of the default versions git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2637 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BVersionPage.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/wizard/BVersionPage.py b/wizard/BVersionPage.py index ed44d48b..04a956d0 100644 --- a/wizard/BVersionPage.py +++ b/wizard/BVersionPage.py @@ -100,6 +100,10 @@ class BVersionPage(BWizardPage): """ Slot called when the user select an entry from the version list. """ + if self.isDefaultVersion(self.currentVersion()): + self.disableRemoveButton() + else: + self.enableRemoveButton() self.emit(SIGNAL("completeChanged()")) def updateClicked(self): @@ -166,6 +170,18 @@ class BVersionPage(BWizardPage): if not selected: self.setCurrentItem(self.latestVersionItem()) + def disableRemoveButton(self): + """ + Disable the Remove button. + """ + self.pageContent.removeButton.setEnabled(False) + + def enableRemoveButton(self): + """ + Enable the Remove button. + """ + self.pageContent.removeButton.setEnabled(True) + def latestVersionItem(self): """ Returns the latest BeRTOS version founded. @@ -183,4 +199,27 @@ class BVersionPage(BWizardPage): """ Select the given item in the version list. """ - self.pageContent.versionList.setCurrentItem(item) \ No newline at end of file + self.pageContent.versionList.setCurrentItem(item) + + def currentItem(self): + """ + Returns the current selected item. + """ + return self.pageContent.versionList.currentItem() + + def currentVersion(self): + """ + Return the path of the selected version. + """ + current = self.currentItem() + return qvariant_converter.getString(current.data(Qt.UserRole)) + + def isDefaultVersion(self, version): + """ + Returns True if the given version is one of the default versions. + """ + if os.name == "nt": + import winreg_importer + if version in winreg_importer.getBertosDirs(): + return True + return False \ No newline at end of file -- 2.25.1