Disable the remove button if the selected version is one of the default versions
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 22 Apr 2009 16:15:48 +0000 (16:15 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 22 Apr 2009 16:15:48 +0000 (16:15 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2637 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BVersionPage.py

index ed44d48bd242c6bff9c6b3bbeafed12e77a0fb15..04a956d0c88975012e73b09c20d34e71cf678b38 100644 (file)
@@ -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