eric7/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the revisions for the hg diff command.
8 """
9
10 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgRevisionsSelectionDialog import Ui_HgRevisionsSelectionDialog
14
15
16 class HgRevisionsSelectionDialog(QDialog, Ui_HgRevisionsSelectionDialog):
17 """
18 Class implementing a dialog to enter the revisions for the hg diff command.
19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None,
21 parent=None):
22 """
23 Constructor
24
25 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings)
27 @param bookmarksList list of bookmarks (list of strings)
28 @param parent parent widget of the dialog (QWidget)
29 """
30 super().__init__(parent)
31 self.setupUi(self)
32
33 self.buttonBox.button(
34 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
35
36 self.tag1Combo.addItems(sorted(tagsList))
37 self.tag2Combo.addItems(sorted(tagsList))
38 self.branch1Combo.addItems(["default"] + sorted(branchesList))
39 self.branch2Combo.addItems(["default"] + sorted(branchesList))
40 if bookmarksList is not None:
41 self.bookmark1Combo.addItems(sorted(bookmarksList))
42 self.bookmark2Combo.addItems(sorted(bookmarksList))
43 else:
44 self.bookmark1Button.setHidden(True)
45 self.bookmark1Combo.setHidden(True)
46 self.bookmark2Button.setHidden(True)
47 self.bookmark2Combo.setHidden(True)
48
49 msh = self.minimumSizeHint()
50 self.resize(max(self.width(), msh.width()), msh.height())
51
52 def __updateOK(self):
53 """
54 Private slot to update the OK button.
55 """
56 enabled = True
57 if self.id1Button.isChecked():
58 enabled = enabled and self.id1Edit.text() != ""
59 elif self.tag1Button.isChecked():
60 enabled = enabled and self.tag1Combo.currentText() != ""
61 elif self.branch1Button.isChecked():
62 enabled = enabled and self.branch1Combo.currentText() != ""
63 elif self.bookmark1Button.isChecked():
64 enabled = enabled and self.bookmark1Combo.currentText() != ""
65
66 if self.id2Button.isChecked():
67 enabled = enabled and self.id2Edit.text() != ""
68 elif self.tag2Button.isChecked():
69 enabled = enabled and self.tag2Combo.currentText() != ""
70 elif self.branch2Button.isChecked():
71 enabled = enabled and self.branch2Combo.currentText() != ""
72 elif self.bookmark2Button.isChecked():
73 enabled = enabled and self.bookmark2Combo.currentText() != ""
74
75 self.buttonBox.button(
76 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
222 def __getRevision(self, no):
223 """
224 Private method to generate the revision.
225
226 @param no revision number to generate (1 or 2)
227 @return revision (string)
228 """
229 if no == 1:
230 numberButton = self.number1Button
231 numberSpinBox = self.number1SpinBox
232 idButton = self.id1Button
233 idEdit = self.id1Edit
234 tagButton = self.tag1Button
235 tagCombo = self.tag1Combo
236 branchButton = self.branch1Button
237 branchCombo = self.branch1Combo
238 bookmarkButton = self.bookmark1Button
239 bookmarkCombo = self.bookmark1Combo
240 tipButton = self.tip1Button
241 prevButton = self.prev1Button
242 noneButton = self.none1Button
243 else:
244 numberButton = self.number2Button
245 numberSpinBox = self.number2SpinBox
246 idButton = self.id2Button
247 idEdit = self.id2Edit
248 tagButton = self.tag2Button
249 tagCombo = self.tag2Combo
250 branchButton = self.branch2Button
251 branchCombo = self.branch2Combo
252 bookmarkButton = self.bookmark2Button
253 bookmarkCombo = self.bookmark2Combo
254 tipButton = self.tip2Button
255 prevButton = self.prev2Button
256 noneButton = self.none2Button
257
258 if numberButton.isChecked():
259 return "rev({0})".format(numberSpinBox.value())
260 elif idButton.isChecked():
261 return "id({0})".format(idEdit.text())
262 elif tagButton.isChecked():
263 return tagCombo.currentText()
264 elif branchButton.isChecked():
265 return branchCombo.currentText()
266 elif bookmarkButton.isChecked():
267 return bookmarkCombo.currentText()
268 elif tipButton.isChecked():
269 return "tip"
270 elif prevButton.isChecked():
271 return "."
272 elif noneButton.isChecked():
273 return ""
274
275 return ""
276
277 def getRevisions(self):
278 """
279 Public method to get the revisions.
280
281 @return list two strings
282 """
283 rev1 = self.__getRevision(1)
284 rev2 = self.__getRevision(2)
285
286 return [rev1, rev2]

eric ide

mercurial