24 class HgConflictsListDialog(QWidget, Ui_HgConflictsListDialog): |
28 class HgConflictsListDialog(QWidget, Ui_HgConflictsListDialog): |
25 """ |
29 """ |
26 Class implementing a dialog to show a list of files which had or still |
30 Class implementing a dialog to show a list of files which had or still |
27 have conflicts. |
31 have conflicts. |
28 """ |
32 """ |
|
33 |
29 StatusRole = Qt.ItemDataRole.UserRole + 1 |
34 StatusRole = Qt.ItemDataRole.UserRole + 1 |
30 FilenameRole = Qt.ItemDataRole.UserRole + 2 |
35 FilenameRole = Qt.ItemDataRole.UserRole + 2 |
31 |
36 |
32 def __init__(self, vcs, parent=None): |
37 def __init__(self, vcs, parent=None): |
33 """ |
38 """ |
34 Constructor |
39 Constructor |
35 |
40 |
36 @param vcs reference to the vcs object |
41 @param vcs reference to the vcs object |
37 @param parent parent widget (QWidget) |
42 @param parent parent widget (QWidget) |
38 """ |
43 """ |
39 super().__init__(parent) |
44 super().__init__(parent) |
40 self.setupUi(self) |
45 self.setupUi(self) |
41 |
46 |
42 self.__position = QPoint() |
47 self.__position = QPoint() |
43 |
48 |
44 self.buttonBox.button( |
49 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
45 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
50 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
46 self.buttonBox.button( |
51 |
47 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
52 self.conflictsList.headerItem().setText(self.conflictsList.columnCount(), "") |
48 |
53 self.conflictsList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
49 self.conflictsList.headerItem().setText( |
54 |
50 self.conflictsList.columnCount(), "") |
|
51 self.conflictsList.header().setSortIndicator( |
|
52 0, Qt.SortOrder.AscendingOrder) |
|
53 |
|
54 self.refreshButton = self.buttonBox.addButton( |
55 self.refreshButton = self.buttonBox.addButton( |
55 self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole) |
56 self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole |
56 self.refreshButton.setToolTip( |
57 ) |
57 self.tr("Press to refresh the list of conflicts")) |
58 self.refreshButton.setToolTip(self.tr("Press to refresh the list of conflicts")) |
58 self.refreshButton.setEnabled(False) |
59 self.refreshButton.setEnabled(False) |
59 |
60 |
60 self.vcs = vcs |
61 self.vcs = vcs |
61 self.project = ericApp().getObject("Project") |
62 self.project = ericApp().getObject("Project") |
62 |
63 |
63 self.__hgClient = vcs.getClient() |
64 self.__hgClient = vcs.getClient() |
64 |
65 |
65 def closeEvent(self, e): |
66 def closeEvent(self, e): |
66 """ |
67 """ |
67 Protected slot implementing a close event handler. |
68 Protected slot implementing a close event handler. |
68 |
69 |
69 @param e close event (QCloseEvent) |
70 @param e close event (QCloseEvent) |
70 """ |
71 """ |
71 if self.__hgClient.isExecuting(): |
72 if self.__hgClient.isExecuting(): |
72 self.__hgClient.cancel() |
73 self.__hgClient.cancel() |
73 |
74 |
74 self.__position = self.pos() |
75 self.__position = self.pos() |
75 |
76 |
76 e.accept() |
77 e.accept() |
77 |
78 |
78 def show(self): |
79 def show(self): |
79 """ |
80 """ |
80 Public slot to show the dialog. |
81 Public slot to show the dialog. |
81 """ |
82 """ |
82 if not self.__position.isNull(): |
83 if not self.__position.isNull(): |
83 self.move(self.__position) |
84 self.move(self.__position) |
84 |
85 |
85 super().show() |
86 super().show() |
86 |
87 |
87 def start(self): |
88 def start(self): |
88 """ |
89 """ |
89 Public slot to start the tags command. |
90 Public slot to start the tags command. |
90 """ |
91 """ |
91 self.errorGroup.hide() |
92 self.errorGroup.hide() |
92 QApplication.processEvents() |
93 QApplication.processEvents() |
93 |
94 |
94 self.intercept = False |
95 self.intercept = False |
95 |
96 |
96 self.activateWindow() |
97 self.activateWindow() |
97 self.raise_() |
98 self.raise_() |
98 |
99 |
99 self.conflictsList.clear() |
100 self.conflictsList.clear() |
100 self.__started = True |
101 self.__started = True |
101 self.__getEntries() |
102 self.__getEntries() |
102 |
103 |
103 def __getEntries(self): |
104 def __getEntries(self): |
104 """ |
105 """ |
105 Private method to get the conflict entries. |
106 Private method to get the conflict entries. |
106 """ |
107 """ |
107 args = self.vcs.initCommand("resolve") |
108 args = self.vcs.initCommand("resolve") |
108 args.append('--list') |
109 args.append("--list") |
109 |
110 |
110 out, err = self.__hgClient.runcommand(args) |
111 out, err = self.__hgClient.runcommand(args) |
111 if err: |
112 if err: |
112 self.__showError(err) |
113 self.__showError(err) |
113 if out: |
114 if out: |
114 for line in out.splitlines(): |
115 for line in out.splitlines(): |
120 def __finish(self): |
121 def __finish(self): |
121 """ |
122 """ |
122 Private slot called when the process finished or the user pressed |
123 Private slot called when the process finished or the user pressed |
123 the button. |
124 the button. |
124 """ |
125 """ |
125 self.buttonBox.button( |
126 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
126 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
127 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
127 self.buttonBox.button( |
128 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
128 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
129 |
129 self.buttonBox.button( |
|
130 QDialogButtonBox.StandardButton.Close).setDefault(True) |
|
131 |
|
132 self.refreshButton.setEnabled(True) |
130 self.refreshButton.setEnabled(True) |
133 |
131 |
134 self.__resizeColumns() |
132 self.__resizeColumns() |
135 self.__resort() |
133 self.__resort() |
136 self.on_conflictsList_itemSelectionChanged() |
134 self.on_conflictsList_itemSelectionChanged() |
137 |
135 |
138 @pyqtSlot(QAbstractButton) |
136 @pyqtSlot(QAbstractButton) |
139 def on_buttonBox_clicked(self, button): |
137 def on_buttonBox_clicked(self, button): |
140 """ |
138 """ |
141 Private slot called by a button of the button box clicked. |
139 Private slot called by a button of the button box clicked. |
142 |
140 |
143 @param button button that was clicked (QAbstractButton) |
141 @param button button that was clicked (QAbstractButton) |
144 """ |
142 """ |
145 if button == self.buttonBox.button( |
143 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
146 QDialogButtonBox.StandardButton.Close |
|
147 ): |
|
148 self.close() |
144 self.close() |
149 elif button == self.buttonBox.button( |
145 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
150 QDialogButtonBox.StandardButton.Cancel |
|
151 ): |
|
152 self.__hgClient.cancel() |
146 self.__hgClient.cancel() |
153 elif button == self.refreshButton: |
147 elif button == self.refreshButton: |
154 self.on_refreshButton_clicked() |
148 self.on_refreshButton_clicked() |
155 |
149 |
156 def __resort(self): |
150 def __resort(self): |
157 """ |
151 """ |
158 Private method to resort the tree. |
152 Private method to resort the tree. |
159 """ |
153 """ |
160 self.conflictsList.sortItems( |
154 self.conflictsList.sortItems( |
161 self.conflictsList.sortColumn(), |
155 self.conflictsList.sortColumn(), |
162 self.conflictsList.header().sortIndicatorOrder()) |
156 self.conflictsList.header().sortIndicatorOrder(), |
163 |
157 ) |
|
158 |
164 def __resizeColumns(self): |
159 def __resizeColumns(self): |
165 """ |
160 """ |
166 Private method to resize the list columns. |
161 Private method to resize the list columns. |
167 """ |
162 """ |
168 self.conflictsList.header().resizeSections( |
163 self.conflictsList.header().resizeSections( |
169 QHeaderView.ResizeMode.ResizeToContents) |
164 QHeaderView.ResizeMode.ResizeToContents |
|
165 ) |
170 self.conflictsList.header().setStretchLastSection(True) |
166 self.conflictsList.header().setStretchLastSection(True) |
171 |
167 |
172 def __generateItem(self, status, name): |
168 def __generateItem(self, status, name): |
173 """ |
169 """ |
174 Private method to generate a tag item in the tag list. |
170 Private method to generate a tag item in the tag list. |
175 |
171 |
176 @param status status of the file (string) |
172 @param status status of the file (string) |
177 @param name name of the file (string) |
173 @param name name of the file (string) |
178 """ |
174 """ |
179 itm = QTreeWidgetItem(self.conflictsList) |
175 itm = QTreeWidgetItem(self.conflictsList) |
180 if status == "U": |
176 if status == "U": |
182 elif status == "R": |
178 elif status == "R": |
183 itm.setText(0, self.tr("Resolved")) |
179 itm.setText(0, self.tr("Resolved")) |
184 else: |
180 else: |
185 itm.setText(0, self.tr("Unknown Status")) |
181 itm.setText(0, self.tr("Unknown Status")) |
186 itm.setText(1, name) |
182 itm.setText(1, name) |
187 |
183 |
188 itm.setData(0, self.StatusRole, status) |
184 itm.setData(0, self.StatusRole, status) |
189 itm.setData(0, self.FilenameRole, self.project.getAbsolutePath(name)) |
185 itm.setData(0, self.FilenameRole, self.project.getAbsolutePath(name)) |
190 |
186 |
191 def __processOutputLine(self, line): |
187 def __processOutputLine(self, line): |
192 """ |
188 """ |
193 Private method to process the lines of output. |
189 Private method to process the lines of output. |
194 |
190 |
195 @param line output line to be processed (string) |
191 @param line output line to be processed (string) |
196 """ |
192 """ |
197 status, filename = line.strip().split(None, 1) |
193 status, filename = line.strip().split(None, 1) |
198 self.__generateItem(status, filename) |
194 self.__generateItem(status, filename) |
199 |
195 |
200 def __showError(self, out): |
196 def __showError(self, out): |
201 """ |
197 """ |
202 Private slot to show some error. |
198 Private slot to show some error. |
203 |
199 |
204 @param out error to be shown (string) |
200 @param out error to be shown (string) |
205 """ |
201 """ |
206 self.errorGroup.show() |
202 self.errorGroup.show() |
207 self.errors.insertPlainText(out) |
203 self.errors.insertPlainText(out) |
208 self.errors.ensureCursorVisible() |
204 self.errors.ensureCursorVisible() |
209 |
205 |
210 @pyqtSlot() |
206 @pyqtSlot() |
211 def on_refreshButton_clicked(self): |
207 def on_refreshButton_clicked(self): |
212 """ |
208 """ |
213 Private slot to refresh the log. |
209 Private slot to refresh the log. |
214 """ |
210 """ |
215 self.buttonBox.button( |
211 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
216 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
212 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
217 self.buttonBox.button( |
213 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
218 QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
214 |
219 self.buttonBox.button( |
|
220 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
|
221 |
|
222 self.refreshButton.setEnabled(False) |
215 self.refreshButton.setEnabled(False) |
223 self.start() |
216 self.start() |
224 |
217 |
225 @pyqtSlot(QTreeWidgetItem, int) |
218 @pyqtSlot(QTreeWidgetItem, int) |
226 def on_conflictsList_itemDoubleClicked(self, item, column): |
219 def on_conflictsList_itemDoubleClicked(self, item, column): |
227 """ |
220 """ |
228 Private slot to open the double clicked entry. |
221 Private slot to open the double clicked entry. |
229 |
222 |
230 @param item reference to the double clicked item (QTreeWidgetItem) |
223 @param item reference to the double clicked item (QTreeWidgetItem) |
231 @param column column that was double clicked (integer) |
224 @param column column that was double clicked (integer) |
232 """ |
225 """ |
233 self.on_editButton_clicked() |
226 self.on_editButton_clicked() |
234 |
227 |
235 @pyqtSlot() |
228 @pyqtSlot() |
236 def on_conflictsList_itemSelectionChanged(self): |
229 def on_conflictsList_itemSelectionChanged(self): |
237 """ |
230 """ |
238 Private slot to handle a change of selected conflict entries. |
231 Private slot to handle a change of selected conflict entries. |
239 """ |
232 """ |
243 status = itm.data(0, self.StatusRole) |
236 status = itm.data(0, self.StatusRole) |
244 if status == "U": |
237 if status == "U": |
245 unresolved += 1 |
238 unresolved += 1 |
246 elif status == "R": |
239 elif status == "R": |
247 resolved += 1 |
240 resolved += 1 |
248 |
241 |
249 self.resolvedButton.setEnabled(unresolved > 0) |
242 self.resolvedButton.setEnabled(unresolved > 0) |
250 self.unresolvedButton.setEnabled(resolved > 0) |
243 self.unresolvedButton.setEnabled(resolved > 0) |
251 self.reMergeButton.setEnabled(unresolved > 0) |
244 self.reMergeButton.setEnabled(unresolved > 0) |
252 self.editButton.setEnabled( |
245 self.editButton.setEnabled( |
253 selectedCount == 1 and |
246 selectedCount == 1 |
254 Utilities.MimeTypes.isTextFile( |
247 and Utilities.MimeTypes.isTextFile( |
255 self.conflictsList.selectedItems()[0].data( |
248 self.conflictsList.selectedItems()[0].data(0, self.FilenameRole) |
256 0, self.FilenameRole))) |
249 ) |
257 |
250 ) |
|
251 |
258 @pyqtSlot() |
252 @pyqtSlot() |
259 def on_resolvedButton_clicked(self): |
253 def on_resolvedButton_clicked(self): |
260 """ |
254 """ |
261 Private slot to mark the selected entries as resolved. |
255 Private slot to mark the selected entries as resolved. |
262 """ |
256 """ |