eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionSelectionDialog.py

branch
eric7
changeset 9025
9fe8cfa14542
parent 8881
54e42bc2437a
equal deleted inserted replaced
9024:640778fcd474 9025:9fe8cfa14542
16 class HgRevisionSelectionDialog(QDialog, Ui_HgRevisionSelectionDialog): 16 class HgRevisionSelectionDialog(QDialog, Ui_HgRevisionSelectionDialog):
17 """ 17 """
18 Class implementing a dialog to select a revision. 18 Class implementing a dialog to select a revision.
19 """ 19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None, 20 def __init__(self, tagsList, branchesList, bookmarksList=None,
21 noneLabel="", parent=None): 21 noneLabel="", revset=True, parent=None):
22 """ 22 """
23 Constructor 23 Constructor
24 24
25 @param tagsList list of tags (list of strings) 25 @param tagsList list of tags
26 @param branchesList list of branches (list of strings) 26 @type list of str
27 @param bookmarksList list of bookmarks (list of strings) 27 @param branchesList list of branches
28 @param noneLabel labeltext for "no revision selected" (string) 28 @type list of str
29 @param parent parent widget (QWidget) 29 @param bookmarksList list of bookmarks
30 @type list of str
31 @param noneLabel labeltext for "no revision selected"
32 @type str
33 @param revset flag indicating to allow the revision or ID given as a
34 revset
35 @type bool
36 @param parent parent widget
37 @type QWidget
30 """ 38 """
31 super().__init__(parent) 39 super().__init__(parent)
32 self.setupUi(self) 40 self.setupUi(self)
33 41
34 self.buttonBox.button( 42 self.buttonBox.button(
43 self.bookmarkCombo.setHidden(True) 51 self.bookmarkCombo.setHidden(True)
44 52
45 if noneLabel: 53 if noneLabel:
46 self.noneButton.setText(noneLabel) 54 self.noneButton.setText(noneLabel)
47 55
56 self.__revset = revset
57 self.expressionButton.setEnabled(revset)
58
59 # connect various radio buttons and input fields
60 self.idButton.toggled.connect(self.__updateOK)
61 self.tagButton.toggled.connect(self.__updateOK)
62 self.branchButton.toggled.connect(self.__updateOK)
63 self.bookmarkButton.toggled.connect(self.__updateOK)
64 self.expressionButton.toggled.connect(self.__updateOK)
65
66 self.idEdit.textChanged.connect(self.__updateOK)
67 self.expressionEdit.textChanged.connect(self.__updateOK)
68
69 self.tagCombo.editTextChanged.connect(self.__updateOK)
70 self.branchCombo.editTextChanged.connect(self.__updateOK)
71 self.bookmarkCombo.editTextChanged.connect(self.__updateOK)
72
48 msh = self.minimumSizeHint() 73 msh = self.minimumSizeHint()
49 self.resize(max(self.width(), msh.width()), msh.height()) 74 self.resize(max(self.width(), msh.width()), msh.height())
50 75
76 @pyqtSlot()
51 def __updateOK(self): 77 def __updateOK(self):
52 """ 78 """
53 Private slot to update the OK button. 79 Private slot to update the OK button.
54 """ 80 """
55 enabled = True 81 enabled = True
56 if self.idButton.isChecked(): 82 if self.idButton.isChecked():
57 enabled = self.idEdit.text() != "" 83 enabled = bool(self.idEdit.text())
58 elif self.tagButton.isChecked(): 84 elif self.tagButton.isChecked():
59 enabled = self.tagCombo.currentText() != "" 85 enabled = bool(self.tagCombo.currentText())
60 elif self.branchButton.isChecked(): 86 elif self.branchButton.isChecked():
61 enabled = self.branchCombo.currentText() != "" 87 enabled = bool(self.branchCombo.currentText())
62 elif self.bookmarkButton.isChecked(): 88 elif self.bookmarkButton.isChecked():
63 enabled = self.bookmarkCombo.currentText() != "" 89 enabled = bool(self.bookmarkCombo.currentText())
90 elif self.expressionButton.isChecked():
91 enabled = enabled and bool(self.expressionEdit.text())
64 92
65 self.buttonBox.button( 93 self.buttonBox.button(
66 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 94 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
67 95
68 @pyqtSlot(bool) 96 def getRevision(self):
69 def on_idButton_toggled(self, checked):
70 """
71 Private slot to handle changes of the ID select button.
72
73 @param checked state of the button (boolean)
74 """
75 self.__updateOK()
76
77 @pyqtSlot(bool)
78 def on_tagButton_toggled(self, checked):
79 """
80 Private slot to handle changes of the Tag select button.
81
82 @param checked state of the button (boolean)
83 """
84 self.__updateOK()
85
86 @pyqtSlot(bool)
87 def on_branchButton_toggled(self, checked):
88 """
89 Private slot to handle changes of the Branch select button.
90
91 @param checked state of the button (boolean)
92 """
93 self.__updateOK()
94
95 @pyqtSlot(bool)
96 def on_bookmarkButton_toggled(self, checked):
97 """
98 Private slot to handle changes of the Bookmark select button.
99
100 @param checked state of the button (boolean)
101 """
102 self.__updateOK()
103
104 @pyqtSlot(str)
105 def on_idEdit_textChanged(self, txt):
106 """
107 Private slot to handle changes of the ID edit.
108
109 @param txt text of the edit (string)
110 """
111 self.__updateOK()
112
113 @pyqtSlot(str)
114 def on_tagCombo_editTextChanged(self, txt):
115 """
116 Private slot to handle changes of the Tag combo.
117
118 @param txt text of the combo (string)
119 """
120 self.__updateOK()
121
122 @pyqtSlot(str)
123 def on_branchCombo_editTextChanged(self, txt):
124 """
125 Private slot to handle changes of the Branch combo.
126
127 @param txt text of the combo (string)
128 """
129 self.__updateOK()
130
131 @pyqtSlot(str)
132 def on_bookmarkCombo_editTextChanged(self, txt):
133 """
134 Private slot to handle changes of the Bookmark combo.
135
136 @param txt text of the combo (string)
137 """
138 self.__updateOK()
139
140 def getRevision(self, revset=True):
141 """ 97 """
142 Public method to retrieve the selected revision. 98 Public method to retrieve the selected revision.
143 99
144 @param revset flag indicating to get the revision or ID as a
145 revset
146 @type bool
147 @return selected revision 100 @return selected revision
148 @rtype str 101 @rtype str
149 """ 102 """
150 if self.numberButton.isChecked(): 103 if self.numberButton.isChecked():
151 if revset: 104 if self.__revset:
152 rev = "rev({0})".format(self.numberSpinBox.value()) 105 rev = "rev({0})".format(self.numberSpinBox.value())
153 else: 106 else:
154 rev = str(self.numberSpinBox.value()) 107 rev = str(self.numberSpinBox.value())
155 elif self.idButton.isChecked(): 108 elif self.idButton.isChecked():
156 if revset: 109 if self.__revset:
157 rev = "id({0})".format(self.idEdit.text()) 110 rev = "id({0})".format(self.idEdit.text())
158 else: 111 else:
159 rev = self.idEdit.text() 112 rev = self.idEdit.text()
160 elif self.tagButton.isChecked(): 113 elif self.tagButton.isChecked():
161 rev = self.tagCombo.currentText() 114 rev = self.tagCombo.currentText()
162 elif self.branchButton.isChecked(): 115 elif self.branchButton.isChecked():
163 rev = self.branchCombo.currentText() 116 rev = self.branchCombo.currentText()
164 elif self.bookmarkButton.isChecked(): 117 elif self.bookmarkButton.isChecked():
165 rev = self.bookmarkCombo.currentText() 118 rev = self.bookmarkCombo.currentText()
119 elif self.expressionButton.isChecked():
120 rev = self.expressionEdit.text()
166 elif self.tipButton.isChecked(): 121 elif self.tipButton.isChecked():
167 rev = "tip" 122 rev = "tip"
168 else: 123 else:
169 rev = "" 124 rev = ""
170 125

eric ide

mercurial