eric6/Plugins/VcsPlugins/vcsMercurial/HgRevisionsSelectionDialog.py

changeset 6942
2602857055c5
parent 6891
93f82da09f22
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2019 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 __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_HgRevisionsSelectionDialog import Ui_HgRevisionsSelectionDialog
16
17
18 class HgRevisionsSelectionDialog(QDialog, Ui_HgRevisionsSelectionDialog):
19 """
20 Class implementing a dialog to enter the revisions for the hg diff command.
21 """
22 def __init__(self, tagsList, branchesList, bookmarksList=None,
23 parent=None):
24 """
25 Constructor
26
27 @param tagsList list of tags (list of strings)
28 @param branchesList list of branches (list of strings)
29 @param bookmarksList list of bookmarks (list of strings)
30 @param parent parent widget of the dialog (QWidget)
31 """
32 super(HgRevisionsSelectionDialog, self).__init__(parent)
33 self.setupUi(self)
34
35 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
36
37 self.tag1Combo.addItems(sorted(tagsList))
38 self.tag2Combo.addItems(sorted(tagsList))
39 self.branch1Combo.addItems(["default"] + sorted(branchesList))
40 self.branch2Combo.addItems(["default"] + sorted(branchesList))
41 if bookmarksList is not None:
42 self.bookmark1Combo.addItems(sorted(bookmarksList))
43 self.bookmark2Combo.addItems(sorted(bookmarksList))
44 else:
45 self.bookmark1Button.setHidden(True)
46 self.bookmark1Combo.setHidden(True)
47 self.bookmark2Button.setHidden(True)
48 self.bookmark2Combo.setHidden(True)
49
50 msh = self.minimumSizeHint()
51 self.resize(max(self.width(), msh.width()), msh.height())
52
53 def __updateOK(self):
54 """
55 Private slot to update the OK button.
56 """
57 enabled = True
58 if self.id1Button.isChecked():
59 enabled = enabled and self.id1Edit.text() != ""
60 elif self.tag1Button.isChecked():
61 enabled = enabled and self.tag1Combo.currentText() != ""
62 elif self.branch1Button.isChecked():
63 enabled = enabled and self.branch1Combo.currentText() != ""
64 elif self.bookmark1Button.isChecked():
65 enabled = enabled and self.bookmark1Combo.currentText() != ""
66
67 if self.id2Button.isChecked():
68 enabled = enabled and self.id2Edit.text() != ""
69 elif self.tag2Button.isChecked():
70 enabled = enabled and self.tag2Combo.currentText() != ""
71 elif self.branch2Button.isChecked():
72 enabled = enabled and self.branch2Combo.currentText() != ""
73 elif self.bookmark2Button.isChecked():
74 enabled = enabled and self.bookmark2Combo.currentText() != ""
75
76 self.buttonBox.button(QDialogButtonBox.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