7 Module implementing a dialog to show a list of applied and unapplied patches. |
7 Module implementing a dialog to show a list of applied and unapplied patches. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 |
17 |
18 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
18 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
20 QTreeWidgetItem, QLineEdit |
20 QTreeWidgetItem, QLineEdit |
21 |
21 |
22 from E5Gui import E5MessageBox |
22 from E5Gui import E5MessageBox |
23 |
23 |
24 from .Ui_HgQueuesListDialog import Ui_HgQueuesListDialog |
24 from .Ui_HgQueuesListDialog import Ui_HgQueuesListDialog |
25 |
|
26 import Preferences |
|
27 |
25 |
28 |
26 |
29 class HgQueuesListDialog(QDialog, Ui_HgQueuesListDialog): |
27 class HgQueuesListDialog(QDialog, Ui_HgQueuesListDialog): |
30 """ |
28 """ |
31 Class implementing a dialog to show a list of applied and unapplied |
29 Class implementing a dialog to show a list of applied and unapplied |
53 self.process.finished.connect(self.__procFinished) |
51 self.process.finished.connect(self.__procFinished) |
54 self.process.readyReadStandardOutput.connect(self.__readStdout) |
52 self.process.readyReadStandardOutput.connect(self.__readStdout) |
55 self.process.readyReadStandardError.connect(self.__readStderr) |
53 self.process.readyReadStandardError.connect(self.__readStderr) |
56 |
54 |
57 self.__statusDict = { |
55 self.__statusDict = { |
58 "A": self.trUtf8("applied"), |
56 "A": self.tr("applied"), |
59 "U": self.trUtf8("not applied"), |
57 "U": self.tr("not applied"), |
60 "G": self.trUtf8("guarded"), |
58 "G": self.tr("guarded"), |
61 "D": self.trUtf8("missing"), |
59 "D": self.tr("missing"), |
62 } |
60 } |
63 |
61 |
64 self.show() |
62 self.show() |
65 QCoreApplication.processEvents() |
63 QCoreApplication.processEvents() |
66 |
64 |
116 if missing: |
114 if missing: |
117 self.__mode = "missing" |
115 self.__mode = "missing" |
118 else: |
116 else: |
119 self.__mode = "qseries" |
117 self.__mode = "qseries" |
120 |
118 |
121 args = [] |
119 args = self.vcs.initCommand("qseries") |
122 args.append('qseries') |
|
123 args.append('--summary') |
120 args.append('--summary') |
124 args.append('--verbose') |
121 args.append('--verbose') |
125 if missing: |
122 if missing: |
126 args.append('--missing') |
123 args.append('--missing') |
127 |
124 |
153 if not procStarted: |
150 if not procStarted: |
154 self.inputGroup.setEnabled(False) |
151 self.inputGroup.setEnabled(False) |
155 self.inputGroup.hide() |
152 self.inputGroup.hide() |
156 E5MessageBox.critical( |
153 E5MessageBox.critical( |
157 self, |
154 self, |
158 self.trUtf8('Process Generation Error'), |
155 self.tr('Process Generation Error'), |
159 self.trUtf8( |
156 self.tr( |
160 'The process {0} could not be started. ' |
157 'The process {0} could not be started. ' |
161 'Ensure, that it is in the search path.' |
158 'Ensure, that it is in the search path.' |
162 ).format('hg')) |
159 ).format('hg')) |
163 else: |
160 else: |
164 self.inputGroup.setEnabled(True) |
161 self.inputGroup.setEnabled(True) |
195 if not procStarted: |
191 if not procStarted: |
196 self.inputGroup.setEnabled(False) |
192 self.inputGroup.setEnabled(False) |
197 self.inputGroup.hide() |
193 self.inputGroup.hide() |
198 E5MessageBox.critical( |
194 E5MessageBox.critical( |
199 self, |
195 self, |
200 self.trUtf8('Process Generation Error'), |
196 self.tr('Process Generation Error'), |
201 self.trUtf8( |
197 self.tr( |
202 'The process {0} could not be started. ' |
198 'The process {0} could not be started. ' |
203 'Ensure, that it is in the search path.' |
199 'Ensure, that it is in the search path.' |
204 ).format('hg')) |
200 ).format('hg')) |
205 else: |
201 else: |
206 self.inputGroup.setEnabled(True) |
202 self.inputGroup.setEnabled(True) |
229 self.process = None |
225 self.process = None |
230 |
226 |
231 if self.patchesList.topLevelItemCount() == 0: |
227 if self.patchesList.topLevelItemCount() == 0: |
232 # no patches present |
228 # no patches present |
233 self.__generateItem( |
229 self.__generateItem( |
234 0, "", self.trUtf8("no patches found"), "", True) |
230 0, "", self.tr("no patches found"), "", True) |
235 self.__resizeColumns() |
231 self.__resizeColumns() |
236 self.__resort() |
232 self.__resort() |
237 |
233 |
238 def on_buttonBox_clicked(self, button): |
234 def on_buttonBox_clicked(self, button): |
239 """ |
235 """ |
300 if index == -1: |
296 if index == -1: |
301 index = "" |
297 index = "" |
302 try: |
298 try: |
303 statusStr = self.__statusDict[status] |
299 statusStr = self.__statusDict[status] |
304 except KeyError: |
300 except KeyError: |
305 statusStr = self.trUtf8("unknown") |
301 statusStr = self.tr("unknown") |
306 itm = QTreeWidgetItem(self.patchesList) |
302 itm = QTreeWidgetItem(self.patchesList) |
307 itm.setData(0, Qt.DisplayRole, index) |
303 itm.setData(0, Qt.DisplayRole, index) |
308 itm.setData(1, Qt.DisplayRole, name) |
304 itm.setData(1, Qt.DisplayRole, name) |
309 itm.setData(2, Qt.DisplayRole, statusStr) |
305 itm.setData(2, Qt.DisplayRole, statusStr) |
310 itm.setData(3, Qt.DisplayRole, summary) |
306 itm.setData(3, Qt.DisplayRole, summary) |
342 the contents pane. |
338 the contents pane. |
343 """ |
339 """ |
344 self.process.setReadChannel(QProcess.StandardOutput) |
340 self.process.setReadChannel(QProcess.StandardOutput) |
345 |
341 |
346 while self.process.canReadLine(): |
342 while self.process.canReadLine(): |
347 s = str(self.process.readLine(), |
343 s = str(self.process.readLine(), self.vcs.getEncoding(), |
348 Preferences.getSystem("IOEncoding"), |
|
349 'replace').strip() |
344 'replace').strip() |
350 self.__processOutputLine(s) |
345 self.__processOutputLine(s) |
351 |
346 |
352 def __processOutputLine(self, line): |
347 def __processOutputLine(self, line): |
353 """ |
348 """ |
380 It reads the error output of the process and inserts it into the |
375 It reads the error output of the process and inserts it into the |
381 error pane. |
376 error pane. |
382 """ |
377 """ |
383 if self.process is not None: |
378 if self.process is not None: |
384 s = str(self.process.readAllStandardError(), |
379 s = str(self.process.readAllStandardError(), |
385 Preferences.getSystem("IOEncoding"), |
380 self.vcs.getEncoding(), 'replace') |
386 'replace') |
|
387 self.__showError(s) |
381 self.__showError(s) |
388 |
382 |
389 def __showError(self, out): |
383 def __showError(self, out): |
390 """ |
384 """ |
391 Private slot to show some error. |
385 Private slot to show some error. |