eric6/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.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) 2010 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a backout operation.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot, QDateTime
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_HgBackoutDialog import Ui_HgBackoutDialog
16
17
18 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog):
19 """
20 Class implementing a dialog to enter the data for a backout operation.
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 parent widget (QWidget)
31 """
32 super(HgBackoutDialog, self).__init__(parent)
33 self.setupUi(self)
34
35 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
36
37 self.tagCombo.addItems(sorted(tagsList))
38 self.branchCombo.addItems(["default"] + sorted(branchesList))
39 if bookmarksList is not None:
40 self.bookmarkCombo.addItems(sorted(bookmarksList))
41 else:
42 self.bookmarkButton.setHidden(True)
43 self.bookmarkCombo.setHidden(True)
44
45 self.__initDateTime = QDateTime.currentDateTime()
46 self.dateEdit.setDateTime(self.__initDateTime)
47
48 def __updateOK(self):
49 """
50 Private slot to update the OK button.
51 """
52 enabled = True
53 if self.noneButton.isChecked():
54 enabled = False
55 elif self.idButton.isChecked():
56 enabled = self.idEdit.text() != ""
57 elif self.tagButton.isChecked():
58 enabled = self.tagCombo.currentText() != ""
59 elif self.branchButton.isChecked():
60 enabled = self.branchCombo.currentText() != ""
61 elif self.bookmarkButton.isChecked():
62 enabled = self.bookmarkCombo.currentText() != ""
63
64 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
65
66 @pyqtSlot(bool)
67 def on_idButton_toggled(self, checked):
68 """
69 Private slot to handle changes of the ID select button.
70
71 @param checked state of the button (boolean)
72 """
73 self.__updateOK()
74
75 @pyqtSlot(bool)
76 def on_tagButton_toggled(self, checked):
77 """
78 Private slot to handle changes of the Tag select button.
79
80 @param checked state of the button (boolean)
81 """
82 self.__updateOK()
83
84 @pyqtSlot(bool)
85 def on_branchButton_toggled(self, checked):
86 """
87 Private slot to handle changes of the Branch select button.
88
89 @param checked state of the button (boolean)
90 """
91 self.__updateOK()
92
93 @pyqtSlot(bool)
94 def on_bookmarkButton_toggled(self, checked):
95 """
96 Private slot to handle changes of the Bookmark select button.
97
98 @param checked state of the button (boolean)
99 """
100 self.__updateOK()
101
102 @pyqtSlot(bool)
103 def on_noneButton_toggled(self, checked):
104 """
105 Private slot to handle the toggling of the None revision button.
106
107 @param checked flag indicating the checked state (boolean)
108 """
109 self.__updateOK()
110
111 @pyqtSlot(str)
112 def on_idEdit_textChanged(self, txt):
113 """
114 Private slot to handle changes of the ID edit.
115
116 @param txt text of the edit (string)
117 """
118 self.__updateOK()
119
120 @pyqtSlot(str)
121 def on_tagCombo_editTextChanged(self, txt):
122 """
123 Private slot to handle changes of the Tag combo.
124
125 @param txt text of the combo (string)
126 """
127 self.__updateOK()
128
129 @pyqtSlot(str)
130 def on_branchCombo_editTextChanged(self, txt):
131 """
132 Private slot to handle changes of the Branch combo.
133
134 @param txt text of the combo (string)
135 """
136 self.__updateOK()
137
138 @pyqtSlot(str)
139 def on_bookmarkCombo_editTextChanged(self, txt):
140 """
141 Private slot to handle changes of the Bookmark combo.
142
143 @param txt text of the combo (string)
144 """
145 self.__updateOK()
146
147 def getParameters(self):
148 """
149 Public method to retrieve the backout data.
150
151 @return tuple naming the revision, a flag indicating a
152 merge, the commit date, the commit user and a commit message
153 (string, boolean, string, string, string)
154 """
155 if self.numberButton.isChecked():
156 rev = "rev({0})".format(self.numberSpinBox.value())
157 elif self.idButton.isChecked():
158 rev = "id({0})".format(self.idEdit.text())
159 elif self.tagButton.isChecked():
160 rev = self.tagCombo.currentText()
161 elif self.branchButton.isChecked():
162 rev = self.branchCombo.currentText()
163 elif self.bookmarkButton.isChecked():
164 rev = self.bookmarkCombo.currentText()
165 else:
166 rev = ""
167
168 if self.dateEdit.dateTime() != self.__initDateTime:
169 date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm")
170 else:
171 date = ""
172
173 if self.messageEdit.toPlainText():
174 msg = self.messageEdit.toPlainText()
175 else:
176 msg = self.tr("Backed out changeset <{0}>.").format(rev)
177
178 return (rev,
179 self.mergeCheckBox.isChecked,
180 date,
181 self.userEdit.text(),
182 msg
183 )

eric ide

mercurial