17 |
17 |
18 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog): |
18 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to enter the data for a backout operation. |
20 Class implementing a dialog to enter the data for a backout operation. |
21 """ |
21 """ |
22 def __init__(self, tagsList, branchesList, bookmarksList=None, |
22 |
23 parent=None): |
23 def __init__(self, tagsList, branchesList, bookmarksList=None, parent=None): |
24 """ |
24 """ |
25 Constructor |
25 Constructor |
26 |
26 |
27 @param tagsList list of tags |
27 @param tagsList list of tags |
28 @type list of str |
28 @type list of str |
29 @param branchesList list of branches |
29 @param branchesList list of branches |
30 @type list of str |
30 @type list of str |
31 @param bookmarksList list of bookmarks |
31 @param bookmarksList list of bookmarks |
33 @param parent parent widget |
33 @param parent parent widget |
34 @type QWidget |
34 @type QWidget |
35 """ |
35 """ |
36 super().__init__(parent) |
36 super().__init__(parent) |
37 self.setupUi(self) |
37 self.setupUi(self) |
38 |
38 |
39 self.buttonBox.button( |
39 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
40 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
40 |
41 |
|
42 project = ericApp().getObject("Project") |
41 project = ericApp().getObject("Project") |
43 pwl, pel = project.getProjectDictionaries() |
42 pwl, pel = project.getProjectDictionaries() |
44 language = project.getProjectSpellLanguage() |
43 language = project.getProjectSpellLanguage() |
45 self.messageEdit.setLanguageWithPWL( |
44 self.messageEdit.setLanguageWithPWL(language, pwl or None, pel or None) |
46 language, pwl or None, pel or None) |
45 |
47 |
|
48 self.tagCombo.addItems(sorted(tagsList)) |
46 self.tagCombo.addItems(sorted(tagsList)) |
49 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
47 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
50 if bookmarksList is not None: |
48 if bookmarksList is not None: |
51 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
49 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
52 else: |
50 else: |
53 self.bookmarkButton.setHidden(True) |
51 self.bookmarkButton.setHidden(True) |
54 self.bookmarkCombo.setHidden(True) |
52 self.bookmarkCombo.setHidden(True) |
55 |
53 |
56 # connect various radio buttons and input fields |
54 # connect various radio buttons and input fields |
57 self.idButton.toggled.connect(self.__updateOK) |
55 self.idButton.toggled.connect(self.__updateOK) |
58 self.tagButton.toggled.connect(self.__updateOK) |
56 self.tagButton.toggled.connect(self.__updateOK) |
59 self.branchButton.toggled.connect(self.__updateOK) |
57 self.branchButton.toggled.connect(self.__updateOK) |
60 self.bookmarkButton.toggled.connect(self.__updateOK) |
58 self.bookmarkButton.toggled.connect(self.__updateOK) |
61 self.expressionButton.toggled.connect(self.__updateOK) |
59 self.expressionButton.toggled.connect(self.__updateOK) |
62 self.noneButton.toggled.connect(self.__updateOK) |
60 self.noneButton.toggled.connect(self.__updateOK) |
63 |
61 |
64 self.idEdit.textChanged.connect(self.__updateOK) |
62 self.idEdit.textChanged.connect(self.__updateOK) |
65 self.expressionEdit.textChanged.connect(self.__updateOK) |
63 self.expressionEdit.textChanged.connect(self.__updateOK) |
66 |
64 |
67 self.tagCombo.editTextChanged.connect(self.__updateOK) |
65 self.tagCombo.editTextChanged.connect(self.__updateOK) |
68 self.branchCombo.editTextChanged.connect(self.__updateOK) |
66 self.branchCombo.editTextChanged.connect(self.__updateOK) |
69 self.bookmarkCombo.editTextChanged.connect(self.__updateOK) |
67 self.bookmarkCombo.editTextChanged.connect(self.__updateOK) |
70 |
68 |
71 self.__initDateTime = QDateTime.currentDateTime() |
69 self.__initDateTime = QDateTime.currentDateTime() |
72 self.dateEdit.setDateTime(self.__initDateTime) |
70 self.dateEdit.setDateTime(self.__initDateTime) |
73 |
71 |
74 @pyqtSlot() |
72 @pyqtSlot() |
75 def __updateOK(self): |
73 def __updateOK(self): |
76 """ |
74 """ |
77 Private slot to update the OK button. |
75 Private slot to update the OK button. |
78 """ |
76 """ |
87 enabled = bool(self.branchCombo.currentText()) |
85 enabled = bool(self.branchCombo.currentText()) |
88 elif self.bookmarkButton.isChecked(): |
86 elif self.bookmarkButton.isChecked(): |
89 enabled = bool(self.bookmarkCombo.currentText()) |
87 enabled = bool(self.bookmarkCombo.currentText()) |
90 elif self.expressionButton.isChecked(): |
88 elif self.expressionButton.isChecked(): |
91 enabled = enabled and bool(self.expressionEdit.text()) |
89 enabled = enabled and bool(self.expressionEdit.text()) |
92 |
90 |
93 self.buttonBox.button( |
91 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
94 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
92 |
95 |
|
96 def getParameters(self): |
93 def getParameters(self): |
97 """ |
94 """ |
98 Public method to retrieve the backout data. |
95 Public method to retrieve the backout data. |
99 |
96 |
100 @return tuple naming the revision, a flag indicating a |
97 @return tuple naming the revision, a flag indicating a |
101 merge, the commit date, the commit user and a commit message |
98 merge, the commit date, the commit user and a commit message |
102 @rtype tuple of (str, bool, str, str, str) |
99 @rtype tuple of (str, bool, str, str, str) |
103 """ |
100 """ |
104 if self.numberButton.isChecked(): |
101 if self.numberButton.isChecked(): |
113 rev = self.bookmarkCombo.currentText() |
110 rev = self.bookmarkCombo.currentText() |
114 elif self.expressionButton.isChecked(): |
111 elif self.expressionButton.isChecked(): |
115 rev = self.expressionEdit.text() |
112 rev = self.expressionEdit.text() |
116 else: |
113 else: |
117 rev = "" |
114 rev = "" |
118 |
115 |
119 date = ( |
116 date = ( |
120 self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
117 self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
121 if self.dateEdit.dateTime() != self.__initDateTime else |
118 if self.dateEdit.dateTime() != self.__initDateTime |
122 "" |
119 else "" |
123 ) |
120 ) |
124 |
121 |
125 msg = ( |
122 msg = ( |
126 self.messageEdit.toPlainText() |
123 self.messageEdit.toPlainText() |
127 if self.messageEdit.toPlainText() else |
124 if self.messageEdit.toPlainText() |
128 self.tr("Backed out changeset <{0}>.").format(rev) |
125 else self.tr("Backed out changeset <{0}>.").format(rev) |
129 ) |
126 ) |
130 |
127 |
131 return (rev, |
128 return (rev, self.mergeCheckBox.isChecked, date, self.userEdit.text(), msg) |
132 self.mergeCheckBox.isChecked, |
|
133 date, |
|
134 self.userEdit.text(), |
|
135 msg |
|
136 ) |
|