eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py

branch
eric7
changeset 9025
9fe8cfa14542
parent 8881
54e42bc2437a
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py	Wed Apr 13 18:16:23 2022 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py	Wed Apr 13 19:49:25 2022 +0200
@@ -22,10 +22,14 @@
         """
         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 parent parent widget of the dialog (QWidget)
+        @param tagsList list of tags
+        @type list of str
+        @param branchesList list of branches
+        @type list of str
+        @param bookmarksList list of bookmarks
+        @type list of str
+        @param parent parent widget of the dialog
+        @type QWidget
         """
         super().__init__(parent)
         self.setupUi(self)
@@ -46,185 +50,72 @@
             self.bookmark2Button.setHidden(True)
             self.bookmark2Combo.setHidden(True)
         
+        # connect various radio buttons and input fields
+        self.id1Button.toggled.connect(self.__updateOK)
+        self.id2Button.toggled.connect(self.__updateOK)
+        self.tag1Button.toggled.connect(self.__updateOK)
+        self.tag2Button.toggled.connect(self.__updateOK)
+        self.branch1Button.toggled.connect(self.__updateOK)
+        self.branch2Button.toggled.connect(self.__updateOK)
+        self.bookmark1Button.toggled.connect(self.__updateOK)
+        self.bookmark2Button.toggled.connect(self.__updateOK)
+        self.expression1Button.toggled.connect(self.__updateOK)
+        self.expression2Button.toggled.connect(self.__updateOK)
+        
+        self.id1Edit.textChanged.connect(self.__updateOK)
+        self.id2Edit.textChanged.connect(self.__updateOK)
+        self.expression1Edit.textChanged.connect(self.__updateOK)
+        self.expression2Edit.textChanged.connect(self.__updateOK)
+        
+        self.tag1Combo.editTextChanged.connect(self.__updateOK)
+        self.tag2Combo.editTextChanged.connect(self.__updateOK)
+        self.branch1Combo.editTextChanged.connect(self.__updateOK)
+        self.branch2Combo.editTextChanged.connect(self.__updateOK)
+        self.bookmark1Combo.editTextChanged.connect(self.__updateOK)
+        self.bookmark2Combo.editTextChanged.connect(self.__updateOK)
+        
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
     
+    @pyqtSlot()
     def __updateOK(self):
         """
         Private slot to update the OK button.
         """
         enabled = True
         if self.id1Button.isChecked():
-            enabled = enabled and self.id1Edit.text() != ""
+            enabled = enabled and bool(self.id1Edit.text())
         elif self.tag1Button.isChecked():
-            enabled = enabled and self.tag1Combo.currentText() != ""
+            enabled = enabled and bool(self.tag1Combo.currentText())
         elif self.branch1Button.isChecked():
-            enabled = enabled and self.branch1Combo.currentText() != ""
+            enabled = enabled and bool(self.branch1Combo.currentText())
         elif self.bookmark1Button.isChecked():
-            enabled = enabled and self.bookmark1Combo.currentText() != ""
+            enabled = enabled and bool(self.bookmark1Combo.currentText())
+        elif self.expression1Button.isChecked():
+            enabled = enabled and bool(self.expression1Edit.text())
         
         if self.id2Button.isChecked():
-            enabled = enabled and self.id2Edit.text() != ""
+            enabled = enabled and bool(self.id2Edit.text())
         elif self.tag2Button.isChecked():
-            enabled = enabled and self.tag2Combo.currentText() != ""
+            enabled = enabled and bool(self.tag2Combo.currentText())
         elif self.branch2Button.isChecked():
-            enabled = enabled and self.branch2Combo.currentText() != ""
+            enabled = enabled and bool(self.branch2Combo.currentText())
         elif self.bookmark2Button.isChecked():
-            enabled = enabled and self.bookmark2Combo.currentText() != ""
+            enabled = enabled and bool(self.bookmark2Combo.currentText())
+        elif self.expression2Button.isChecked():
+            enabled = enabled and bool(self.expression2Edit.text())
         
         self.buttonBox.button(
             QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
     
-    @pyqtSlot(bool)
-    def on_id1Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the ID1 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_id2Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the ID2 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_tag1Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Tag1 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_tag2Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Tag2 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_branch1Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Branch1 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_branch2Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Branch2 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_bookmark1Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Bookmark1 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(bool)
-    def on_bookmark2Button_toggled(self, checked):
-        """
-        Private slot to handle changes of the Bookmark2 select button.
-        
-        @param checked state of the button (boolean)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_id1Edit_textChanged(self, txt):
-        """
-        Private slot to handle changes of the ID1 edit.
-        
-        @param txt text of the edit (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_id2Edit_textChanged(self, txt):
-        """
-        Private slot to handle changes of the ID2 edit.
-        
-        @param txt text of the edit (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_tag1Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Tag1 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_tag2Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Tag2 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_branch1Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Branch1 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_branch2Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Branch2 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_bookmark1Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Bookmark1 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
-    @pyqtSlot(str)
-    def on_bookmark2Combo_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the Bookmark2 combo.
-        
-        @param txt text of the combo (string)
-        """
-        self.__updateOK()
-    
     def __getRevision(self, no):
         """
         Private method to generate the revision.
         
         @param no revision number to generate (1 or 2)
-        @return revision (string)
+        @type int
+        @return revision
+        @rtype str
         """
         if no == 1:
             numberButton = self.number1Button
@@ -237,6 +128,8 @@
             branchCombo = self.branch1Combo
             bookmarkButton = self.bookmark1Button
             bookmarkCombo = self.bookmark1Combo
+            expressionButton = self.expression1Button
+            expressionEdit = self.expression1Edit
             tipButton = self.tip1Button
             prevButton = self.prev1Button
             noneButton = self.none1Button
@@ -251,6 +144,8 @@
             branchCombo = self.branch2Combo
             bookmarkButton = self.bookmark2Button
             bookmarkCombo = self.bookmark2Combo
+            expressionButton = self.expression2Button
+            expressionEdit = self.expression2Edit
             tipButton = self.tip2Button
             prevButton = self.prev2Button
             noneButton = self.none2Button
@@ -265,6 +160,8 @@
             return branchCombo.currentText()
         elif bookmarkButton.isChecked():
             return bookmarkCombo.currentText()
+        elif expressionButton.isChecked():
+            return expressionEdit.text()
         elif tipButton.isChecked():
             return "tip"
         elif prevButton.isChecked():
@@ -278,7 +175,8 @@
         """
         Public method to get the revisions.
         
-        @return list two strings
+        @return list of two revisions
+        @rtype list of [str, str]
         """
         rev1 = self.__getRevision(1)
         rev2 = self.__getRevision(2)

eric ide

mercurial