eric6/Plugins/VcsPlugins/vcsMercurial/StripExtension/HgStripDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
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 data to strip changesets.
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_HgStripDialog import Ui_HgStripDialog
16
17
18 class HgStripDialog(QDialog, Ui_HgStripDialog):
19 """
20 Class implementing a dialog to enter the data to strip changesets.
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(HgStripDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.tagCombo.addItems(sorted(tagsList))
42 self.branchCombo.addItems(["default"] + sorted(branchesList))
43 if bookmarksList is not None:
44 self.bookmarkCombo.addItems([""] + sorted(bookmarksList))
45 self.idEdit.setText(rev)
46
47 msh = self.minimumSizeHint()
48 self.resize(max(self.width(), msh.width()), msh.height())
49
50 self.__updateOK()
51
52 self.idEdit.setFocus()
53
54 def __updateOK(self):
55 """
56 Private slot to update the OK button.
57 """
58 enabled = True
59 if self.numberButton.isChecked():
60 enabled = enabled and self.numberSpinBox.value() >= 0
61 elif self.idButton.isChecked():
62 enabled = enabled and self.idEdit.text() != ""
63 elif self.tagButton.isChecked():
64 enabled = enabled and self.tagCombo.currentText() != ""
65 elif self.branchButton.isChecked():
66 enabled = enabled and self.branchCombo.currentText() != ""
67
68 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
69
70 @pyqtSlot(bool)
71 def on_numberButton_toggled(self, checked):
72 """
73 Private slot to handle changes of the Number select button.
74
75 @param checked state of the button
76 @type bool
77 """
78 self.__updateOK()
79
80 @pyqtSlot(bool)
81 def on_idButton_toggled(self, checked):
82 """
83 Private slot to handle changes of the ID select button.
84
85 @param checked state of the button
86 @type bool
87 """
88 self.__updateOK()
89
90 @pyqtSlot(bool)
91 def on_tagButton_toggled(self, checked):
92 """
93 Private slot to handle changes of the Tag select button.
94
95 @param checked state of the button
96 @type bool
97 """
98 self.__updateOK()
99
100 @pyqtSlot(bool)
101 def on_branchButton_toggled(self, checked):
102 """
103 Private slot to handle changes of the Branch select button.
104
105 @param checked state of the button
106 @type bool
107 """
108 self.__updateOK()
109
110 @pyqtSlot(int)
111 def on_numberSpinBox_valueChanged(self, val):
112 """
113 Private slot to handle changes of the Number spin box.
114
115 @param val value of the spin box
116 @type int
117 """
118 self.__updateOK()
119
120 @pyqtSlot(str)
121 def on_idEdit_textChanged(self, txt):
122 """
123 Private slot to handle changes of the ID edit.
124
125 @param txt text of the edit
126 @type str
127 """
128 self.__updateOK()
129
130 @pyqtSlot(str)
131 def on_tagCombo_editTextChanged(self, txt):
132 """
133 Private slot to handle changes of the Tag combo.
134
135 @param txt text of the combo
136 @type str
137 """
138 self.__updateOK()
139
140 @pyqtSlot(str)
141 def on_branchCombo_editTextChanged(self, txt):
142 """
143 Private slot to handle changes of the Branch combo.
144
145 @param txt text of the combo
146 @type str
147 """
148 self.__updateOK()
149
150 def __getRevision(self):
151 """
152 Private method to generate the revision.
153
154 @return revision
155 @rtype str
156 """
157 if self.numberButton.isChecked():
158 return "rev({0})".format(self.numberSpinBox.value())
159 elif self.idButton.isChecked():
160 return "id({0})".format(self.idEdit.text())
161 elif self.tagButton.isChecked():
162 return self.tagCombo.currentText()
163 elif self.branchButton.isChecked():
164 return self.branchCombo.currentText()
165 else:
166 # should not happen
167 return ""
168
169 def getData(self):
170 """
171 Public method to retrieve the data for the strip action.
172
173 @return tuple with the revision, a bookmark name, a flag indicating
174 to enforce the strip action, a flag indicating to omit the creation
175 of backup bundles and a flag indicating to not modify the working
176 directory
177 @rtype tuple (str, str, bool, bool, bool)
178 """
179 return (
180 self.__getRevision(),
181 self.bookmarkCombo.currentText(),
182 self.forceCheckBox.isChecked(),
183 self.noBackupCheckBox.isChecked(),
184 self.keepCheckBox.isChecked(),
185 )

eric ide

mercurial