eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py

branch
eric7
changeset 9025
9fe8cfa14542
parent 8881
54e42bc2437a
equal deleted inserted replaced
9024:640778fcd474 9025:9fe8cfa14542
20 def __init__(self, tagsList, branchesList, bookmarksList=None, 20 def __init__(self, tagsList, branchesList, bookmarksList=None,
21 parent=None): 21 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 parent parent widget of the dialog (QWidget) 28 @type list of str
29 @param bookmarksList list of bookmarks
30 @type list of str
31 @param parent parent widget of the dialog
32 @type QWidget
29 """ 33 """
30 super().__init__(parent) 34 super().__init__(parent)
31 self.setupUi(self) 35 self.setupUi(self)
32 36
33 self.buttonBox.button( 37 self.buttonBox.button(
44 self.bookmark1Button.setHidden(True) 48 self.bookmark1Button.setHidden(True)
45 self.bookmark1Combo.setHidden(True) 49 self.bookmark1Combo.setHidden(True)
46 self.bookmark2Button.setHidden(True) 50 self.bookmark2Button.setHidden(True)
47 self.bookmark2Combo.setHidden(True) 51 self.bookmark2Combo.setHidden(True)
48 52
53 # connect various radio buttons and input fields
54 self.id1Button.toggled.connect(self.__updateOK)
55 self.id2Button.toggled.connect(self.__updateOK)
56 self.tag1Button.toggled.connect(self.__updateOK)
57 self.tag2Button.toggled.connect(self.__updateOK)
58 self.branch1Button.toggled.connect(self.__updateOK)
59 self.branch2Button.toggled.connect(self.__updateOK)
60 self.bookmark1Button.toggled.connect(self.__updateOK)
61 self.bookmark2Button.toggled.connect(self.__updateOK)
62 self.expression1Button.toggled.connect(self.__updateOK)
63 self.expression2Button.toggled.connect(self.__updateOK)
64
65 self.id1Edit.textChanged.connect(self.__updateOK)
66 self.id2Edit.textChanged.connect(self.__updateOK)
67 self.expression1Edit.textChanged.connect(self.__updateOK)
68 self.expression2Edit.textChanged.connect(self.__updateOK)
69
70 self.tag1Combo.editTextChanged.connect(self.__updateOK)
71 self.tag2Combo.editTextChanged.connect(self.__updateOK)
72 self.branch1Combo.editTextChanged.connect(self.__updateOK)
73 self.branch2Combo.editTextChanged.connect(self.__updateOK)
74 self.bookmark1Combo.editTextChanged.connect(self.__updateOK)
75 self.bookmark2Combo.editTextChanged.connect(self.__updateOK)
76
49 msh = self.minimumSizeHint() 77 msh = self.minimumSizeHint()
50 self.resize(max(self.width(), msh.width()), msh.height()) 78 self.resize(max(self.width(), msh.width()), msh.height())
51 79
80 @pyqtSlot()
52 def __updateOK(self): 81 def __updateOK(self):
53 """ 82 """
54 Private slot to update the OK button. 83 Private slot to update the OK button.
55 """ 84 """
56 enabled = True 85 enabled = True
57 if self.id1Button.isChecked(): 86 if self.id1Button.isChecked():
58 enabled = enabled and self.id1Edit.text() != "" 87 enabled = enabled and bool(self.id1Edit.text())
59 elif self.tag1Button.isChecked(): 88 elif self.tag1Button.isChecked():
60 enabled = enabled and self.tag1Combo.currentText() != "" 89 enabled = enabled and bool(self.tag1Combo.currentText())
61 elif self.branch1Button.isChecked(): 90 elif self.branch1Button.isChecked():
62 enabled = enabled and self.branch1Combo.currentText() != "" 91 enabled = enabled and bool(self.branch1Combo.currentText())
63 elif self.bookmark1Button.isChecked(): 92 elif self.bookmark1Button.isChecked():
64 enabled = enabled and self.bookmark1Combo.currentText() != "" 93 enabled = enabled and bool(self.bookmark1Combo.currentText())
94 elif self.expression1Button.isChecked():
95 enabled = enabled and bool(self.expression1Edit.text())
65 96
66 if self.id2Button.isChecked(): 97 if self.id2Button.isChecked():
67 enabled = enabled and self.id2Edit.text() != "" 98 enabled = enabled and bool(self.id2Edit.text())
68 elif self.tag2Button.isChecked(): 99 elif self.tag2Button.isChecked():
69 enabled = enabled and self.tag2Combo.currentText() != "" 100 enabled = enabled and bool(self.tag2Combo.currentText())
70 elif self.branch2Button.isChecked(): 101 elif self.branch2Button.isChecked():
71 enabled = enabled and self.branch2Combo.currentText() != "" 102 enabled = enabled and bool(self.branch2Combo.currentText())
72 elif self.bookmark2Button.isChecked(): 103 elif self.bookmark2Button.isChecked():
73 enabled = enabled and self.bookmark2Combo.currentText() != "" 104 enabled = enabled and bool(self.bookmark2Combo.currentText())
105 elif self.expression2Button.isChecked():
106 enabled = enabled and bool(self.expression2Edit.text())
74 107
75 self.buttonBox.button( 108 self.buttonBox.button(
76 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 109 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
77
78 @pyqtSlot(bool)
79 def on_id1Button_toggled(self, checked):
80 """
81 Private slot to handle changes of the ID1 select button.
82
83 @param checked state of the button (boolean)
84 """
85 self.__updateOK()
86
87 @pyqtSlot(bool)
88 def on_id2Button_toggled(self, checked):
89 """
90 Private slot to handle changes of the ID2 select button.
91
92 @param checked state of the button (boolean)
93 """
94 self.__updateOK()
95
96 @pyqtSlot(bool)
97 def on_tag1Button_toggled(self, checked):
98 """
99 Private slot to handle changes of the Tag1 select button.
100
101 @param checked state of the button (boolean)
102 """
103 self.__updateOK()
104
105 @pyqtSlot(bool)
106 def on_tag2Button_toggled(self, checked):
107 """
108 Private slot to handle changes of the Tag2 select button.
109
110 @param checked state of the button (boolean)
111 """
112 self.__updateOK()
113
114 @pyqtSlot(bool)
115 def on_branch1Button_toggled(self, checked):
116 """
117 Private slot to handle changes of the Branch1 select button.
118
119 @param checked state of the button (boolean)
120 """
121 self.__updateOK()
122
123 @pyqtSlot(bool)
124 def on_branch2Button_toggled(self, checked):
125 """
126 Private slot to handle changes of the Branch2 select button.
127
128 @param checked state of the button (boolean)
129 """
130 self.__updateOK()
131
132 @pyqtSlot(bool)
133 def on_bookmark1Button_toggled(self, checked):
134 """
135 Private slot to handle changes of the Bookmark1 select button.
136
137 @param checked state of the button (boolean)
138 """
139 self.__updateOK()
140
141 @pyqtSlot(bool)
142 def on_bookmark2Button_toggled(self, checked):
143 """
144 Private slot to handle changes of the Bookmark2 select button.
145
146 @param checked state of the button (boolean)
147 """
148 self.__updateOK()
149
150 @pyqtSlot(str)
151 def on_id1Edit_textChanged(self, txt):
152 """
153 Private slot to handle changes of the ID1 edit.
154
155 @param txt text of the edit (string)
156 """
157 self.__updateOK()
158
159 @pyqtSlot(str)
160 def on_id2Edit_textChanged(self, txt):
161 """
162 Private slot to handle changes of the ID2 edit.
163
164 @param txt text of the edit (string)
165 """
166 self.__updateOK()
167
168 @pyqtSlot(str)
169 def on_tag1Combo_editTextChanged(self, txt):
170 """
171 Private slot to handle changes of the Tag1 combo.
172
173 @param txt text of the combo (string)
174 """
175 self.__updateOK()
176
177 @pyqtSlot(str)
178 def on_tag2Combo_editTextChanged(self, txt):
179 """
180 Private slot to handle changes of the Tag2 combo.
181
182 @param txt text of the combo (string)
183 """
184 self.__updateOK()
185
186 @pyqtSlot(str)
187 def on_branch1Combo_editTextChanged(self, txt):
188 """
189 Private slot to handle changes of the Branch1 combo.
190
191 @param txt text of the combo (string)
192 """
193 self.__updateOK()
194
195 @pyqtSlot(str)
196 def on_branch2Combo_editTextChanged(self, txt):
197 """
198 Private slot to handle changes of the Branch2 combo.
199
200 @param txt text of the combo (string)
201 """
202 self.__updateOK()
203
204 @pyqtSlot(str)
205 def on_bookmark1Combo_editTextChanged(self, txt):
206 """
207 Private slot to handle changes of the Bookmark1 combo.
208
209 @param txt text of the combo (string)
210 """
211 self.__updateOK()
212
213 @pyqtSlot(str)
214 def on_bookmark2Combo_editTextChanged(self, txt):
215 """
216 Private slot to handle changes of the Bookmark2 combo.
217
218 @param txt text of the combo (string)
219 """
220 self.__updateOK()
221 110
222 def __getRevision(self, no): 111 def __getRevision(self, no):
223 """ 112 """
224 Private method to generate the revision. 113 Private method to generate the revision.
225 114
226 @param no revision number to generate (1 or 2) 115 @param no revision number to generate (1 or 2)
227 @return revision (string) 116 @type int
117 @return revision
118 @rtype str
228 """ 119 """
229 if no == 1: 120 if no == 1:
230 numberButton = self.number1Button 121 numberButton = self.number1Button
231 numberSpinBox = self.number1SpinBox 122 numberSpinBox = self.number1SpinBox
232 idButton = self.id1Button 123 idButton = self.id1Button
235 tagCombo = self.tag1Combo 126 tagCombo = self.tag1Combo
236 branchButton = self.branch1Button 127 branchButton = self.branch1Button
237 branchCombo = self.branch1Combo 128 branchCombo = self.branch1Combo
238 bookmarkButton = self.bookmark1Button 129 bookmarkButton = self.bookmark1Button
239 bookmarkCombo = self.bookmark1Combo 130 bookmarkCombo = self.bookmark1Combo
131 expressionButton = self.expression1Button
132 expressionEdit = self.expression1Edit
240 tipButton = self.tip1Button 133 tipButton = self.tip1Button
241 prevButton = self.prev1Button 134 prevButton = self.prev1Button
242 noneButton = self.none1Button 135 noneButton = self.none1Button
243 else: 136 else:
244 numberButton = self.number2Button 137 numberButton = self.number2Button
249 tagCombo = self.tag2Combo 142 tagCombo = self.tag2Combo
250 branchButton = self.branch2Button 143 branchButton = self.branch2Button
251 branchCombo = self.branch2Combo 144 branchCombo = self.branch2Combo
252 bookmarkButton = self.bookmark2Button 145 bookmarkButton = self.bookmark2Button
253 bookmarkCombo = self.bookmark2Combo 146 bookmarkCombo = self.bookmark2Combo
147 expressionButton = self.expression2Button
148 expressionEdit = self.expression2Edit
254 tipButton = self.tip2Button 149 tipButton = self.tip2Button
255 prevButton = self.prev2Button 150 prevButton = self.prev2Button
256 noneButton = self.none2Button 151 noneButton = self.none2Button
257 152
258 if numberButton.isChecked(): 153 if numberButton.isChecked():
263 return tagCombo.currentText() 158 return tagCombo.currentText()
264 elif branchButton.isChecked(): 159 elif branchButton.isChecked():
265 return branchCombo.currentText() 160 return branchCombo.currentText()
266 elif bookmarkButton.isChecked(): 161 elif bookmarkButton.isChecked():
267 return bookmarkCombo.currentText() 162 return bookmarkCombo.currentText()
163 elif expressionButton.isChecked():
164 return expressionEdit.text()
268 elif tipButton.isChecked(): 165 elif tipButton.isChecked():
269 return "tip" 166 return "tip"
270 elif prevButton.isChecked(): 167 elif prevButton.isChecked():
271 return "." 168 return "."
272 elif noneButton.isChecked(): 169 elif noneButton.isChecked():
276 173
277 def getRevisions(self): 174 def getRevisions(self):
278 """ 175 """
279 Public method to get the revisions. 176 Public method to get the revisions.
280 177
281 @return list two strings 178 @return list of two revisions
179 @rtype list of [str, str]
282 """ 180 """
283 rev1 = self.__getRevision(1) 181 rev1 = self.__getRevision(1)
284 rev2 = self.__getRevision(2) 182 rev2 = self.__getRevision(2)
285 183
286 return [rev1, rev2] 184 return [rev1, rev2]

eric ide

mercurial