Plugins/VcsPlugins/vcsMercurial/StripExtension/HgStripDialog.py

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

eric ide

mercurial