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

eric ide

mercurial