Plugins/VcsPlugins/vcsMercurial/HgRevisionSelectionDialog.py

changeset 1017
919147f2b518
parent 1011
0b118aefae5b
child 1131
7781e396c903
diff -r 72b6b0778e06 -r 919147f2b518 Plugins/VcsPlugins/vcsMercurial/HgRevisionSelectionDialog.py
--- a/Plugins/VcsPlugins/vcsMercurial/HgRevisionSelectionDialog.py	Sat May 07 13:37:58 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgRevisionSelectionDialog.py	Sat May 07 17:56:31 2011 +0200
@@ -7,7 +7,8 @@
 Module implementing a dialog to select a revision.
 """
 
-from PyQt4.QtGui import QDialog
+from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtGui import QDialog, QDialogButtonBox
 
 from .Ui_HgRevisionSelectionDialog import Ui_HgRevisionSelectionDialog
 
@@ -16,26 +17,123 @@
     """
     Class implementing a dialog to select a revision.
     """
-    def __init__(self, tagsList, branchesList, showNone=False, parent=None):
+    def __init__(self, tagsList, branchesList, bookmarksList=None, showNone=False,
+                 parent=None):
         """
         Constructor
         
         @param tagsList list of tags (list of strings)
         @param branchesList list of branches (list of strings)
+        @param bookmarksList list of bookmarks (list of strings)
         @param showNone flag influencing the label of the 'None' selection (boolean)
         @param parent parent widget (QWidget)
         """
         QDialog.__init__(self, parent)
         self.setupUi(self)
        
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
+        
         self.tagCombo.addItems(sorted(tagsList))
         self.branchCombo.addItems(["default"] + sorted(branchesList))
+        if bookmarksList is not None:
+            self.bookmarkCombo.addItems(sorted(bookmarksList))
+        else:
+            self.bookmarkButton.setHidden(True)
+            self.bookmarkCombo.setHidden(True)
         
         if showNone:
             self.tipButton.setText(self.trUtf8("No revision selected"))
             self.tipButton.setToolTip(self.trUtf8(
                 "Select to not specify a specific revision"))
     
+    def __updateOK(self):
+        """
+        Private slot to update the OK button.
+        """
+        enabled = True
+        if self.idButton.isChecked():
+            enabled = self.idEdit.text() != ""
+        elif self.tagButton.isChecked():
+            enabled = self.tagCombo.currentText() != ""
+        elif self.branchButton.isChecked():
+            enabled = self.branchCombo.currentText() != ""
+        elif self.bookmarkButton.isChecked():
+            enabled = self.bookmarkCombo.currentText() != ""
+        
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
+    
+    @pyqtSlot(bool)
+    def on_idButton_toggled(self, checked):
+        """
+        Private slot to handle changes of the ID select button.
+        
+        @param checked state of the button (boolean)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(bool)
+    def on_tagButton_toggled(self, checked):
+        """
+        Private slot to handle changes of the Tag select button.
+        
+        @param checked state of the button (boolean)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(bool)
+    def on_branchButton_toggled(self, checked):
+        """
+        Private slot to handle changes of the Branch select button.
+        
+        @param checked state of the button (boolean)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(bool)
+    def on_bookmarkButton_toggled(self, checked):
+        """
+        Private slot to handle changes of the Bookmark select button.
+        
+        @param checked state of the button (boolean)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(str)
+    def on_idEdit_textChanged(self, txt):
+        """
+        Private slot to handle changes of the ID edit.
+        
+        @param txt text of the edit (string)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(str)
+    def on_tagCombo_editTextChanged(self, txt):
+        """
+        Private slot to handle changes of the Tag combo.
+        
+        @param txt text of the combo (string)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(str)
+    def on_branchCombo_editTextChanged(self, txt):
+        """
+        Private slot to handle changes of the Branch combo.
+        
+        @param txt text of the combo (string)
+        """
+        self.__updateOK()
+    
+    @pyqtSlot(str)
+    def on_bookmarkCombo_editTextChanged(self, txt):
+        """
+        Private slot to handle changes of the Bookmark combo.
+        
+        @param txt text of the combo (string)
+        """
+        self.__updateOK()
+    
     def getRevision(self):
         """
         Public method to retrieve the selected revision.
@@ -50,6 +148,8 @@
             rev = self.tagCombo.currentText()
         elif self.branchButton.isChecked():
             rev = self.branchCombo.currentText()
+        elif self.bookmarkButton.isChecked():
+            rev = self.bookmarkCombo.currentText()
         else:
             rev = ""
         

eric ide

mercurial