Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditConfigDialog.py

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

eric ide

mercurial