eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditConfigDialog.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) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the histedit parameters.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QButtonGroup
14
15 from .Ui_HgHisteditConfigDialog import Ui_HgHisteditConfigDialog
16
17
18 class HgHisteditConfigDialog(QDialog, Ui_HgHisteditConfigDialog):
19 """
20 Class implementing a dialog to enter the histedit parameters.
21 """
22 def __init__(self, tagsList, branchesList, bookmarksList=None, rev="",
23 parent=None):
24 """
25 Constructor
26
27 @param tagsList list of tags
28 @type list of str
29 @param branchesList list of branches
30 @type list of str
31 @param bookmarksList list of bookmarks
32 @type list of str
33 @keyparam rev revision to strip from
34 @type str
35 @param parent reference to the parent widget
36 @type QWidget
37 """
38 super(HgHisteditConfigDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.__sourceRevisionButtonGroup = QButtonGroup(self)
42 self.__sourceRevisionButtonGroup.addButton(self.defaultButton)
43 self.__sourceRevisionButtonGroup.addButton(self.outgoingButton)
44 self.__sourceRevisionButtonGroup.addButton(self.revisionButton)
45
46 self.tagCombo.addItems(sorted(tagsList))
47 self.branchCombo.addItems(["default"] + sorted(branchesList))
48 if bookmarksList is not None:
49 self.bookmarkCombo.addItems(sorted(bookmarksList))
50
51 self.idEdit.setText(rev)
52 if rev:
53 self.revisionButton.setChecked(True)
54 else:
55 self.defaultButton.setChecked(True)
56
57 msh = self.minimumSizeHint()
58 self.resize(max(self.width(), msh.width()), msh.height())
59
60 self.__updateOK()
61
62 def __updateOK(self):
63 """
64 Private slot to update the OK button.
65 """
66 enabled = True
67
68 if self.revisionButton.isChecked():
69 if self.idButton.isChecked():
70 enabled = enabled and bool(self.idEdit.text())
71 elif self.tagButton.isChecked():
72 enabled = enabled and bool(self.tagCombo.currentText())
73 elif self.branchButton.isChecked():
74 enabled = enabled and bool(self.branchCombo.currentText())
75 elif self.bookmarkButton.isChecked():
76 enabled = enabled and bool(self.bookmarkCombo.currentText())
77
78 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
79
80 @pyqtSlot(bool)
81 def on_defaultButton_toggled(self, checked):
82 """
83 Private slot to handle changes of the Default select button.
84
85 @param checked state of the button
86 @type bool
87 """
88 self.__updateOK()
89
90 @pyqtSlot(bool)
91 def on_outgoingButton_toggled(self, checked):
92 """
93 Private slot to handle changes of the Outgoing select button.
94
95 @param checked state of the button
96 @type bool
97 """
98 self.__updateOK()
99
100 @pyqtSlot(bool)
101 def on_revisionButton_toggled(self, checked):
102 """
103 Private slot to handle changes of the Revision select button.
104
105 @param checked state of the button
106 @type bool
107 """
108 self.__updateOK()
109
110 @pyqtSlot(bool)
111 def on_idButton_toggled(self, checked):
112 """
113 Private slot to handle changes of the ID select button.
114
115 @param checked state of the button (boolean)
116 """
117 self.__updateOK()
118
119 @pyqtSlot(bool)
120 def on_tagButton_toggled(self, checked):
121 """
122 Private slot to handle changes of the Tag select button.
123
124 @param checked state of the button (boolean)
125 """
126 self.__updateOK()
127
128 @pyqtSlot(bool)
129 def on_branch1Button_toggled(self, checked):
130 """
131 Private slot to handle changes of the Branch select button.
132
133 @param checked state of the button (boolean)
134 """
135 self.__updateOK()
136
137 @pyqtSlot(bool)
138 def on_bookmarkButton_toggled(self, checked):
139 """
140 Private slot to handle changes of the Bookmark select button.
141
142 @param checked state of the button (boolean)
143 """
144 self.__updateOK()
145
146 @pyqtSlot(int)
147 def on_numberSpinBox_valueChanged(self, val):
148 """
149 Private slot to handle changes of the Number spin box.
150
151 @param val value of the spin box
152 @type int
153 """
154 self.__updateOK()
155
156 @pyqtSlot(str)
157 def on_idEdit_textChanged(self, txt):
158 """
159 Private slot to handle changes of the ID edit.
160
161 @param txt text of the edit
162 @type str
163 """
164 self.__updateOK()
165
166 @pyqtSlot(str)
167 def on_tagCombo_editTextChanged(self, txt):
168 """
169 Private slot to handle changes of the Tag combo.
170
171 @param txt text of the combo
172 @type str
173 """
174 self.__updateOK()
175
176 @pyqtSlot(str)
177 def on_branchCombo_editTextChanged(self, txt):
178 """
179 Private slot to handle changes of the Branch combo.
180
181 @param txt text of the combo
182 @type str
183 """
184 self.__updateOK()
185
186 @pyqtSlot(str)
187 def on_bookmarkCombo_editTextChanged(self, txt):
188 """
189 Private slot to handle changes of the Bookmark combo.
190
191 @param txt text of the combo
192 @type str
193 """
194 self.__updateOK()
195
196 def __getRevision(self):
197 """
198 Private method to generate the revision.
199
200 @return revision
201 @rtype str
202 """
203 if self.defaultButton.isChecked():
204 return ""
205 elif self.outgoingButton.isChecked():
206 return "--outgoing"
207 else:
208 # self.revisionButton.isChecked()
209 if self.numberButton.isChecked():
210 return "rev({0})".format(self.numberSpinBox.value())
211 elif self.idButton.isChecked():
212 return "id({0})".format(self.idEdit.text())
213 elif self.tagButton.isChecked():
214 return self.tagCombo.currentText()
215 elif self.branchButton.isChecked():
216 return self.branchCombo.currentText()
217 elif self.bookmarkButton.isChecked():
218 return self.bookmarkCombo.currentText()
219
220 return ""
221
222 def getData(self):
223 """
224 Public method to retrieve the data for the strip action.
225
226 @return tuple with the revision, a flag indicating to to outgoing and a
227 flag indicating to keep old nodes
228 @rtype tuple (str, bool, bool)
229 """
230 return (
231 self.__getRevision(),
232 self.forceCheckBox.isChecked(),
233 self.keepCheckBox.isChecked(),
234 )

eric ide

mercurial