10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import pyqtSlot, Qt |
14 from PyQt4.QtCore import pyqtSlot, Qt |
15 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ |
15 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, \ |
16 QApplication, QProgressDialog |
16 QTreeWidgetItem, QApplication, QProgressDialog |
17 |
17 |
18 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
19 from E5Gui.E5Application import e5App |
19 from E5Gui.E5Application import e5App |
20 |
20 |
21 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
21 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
39 self.setupUi(self) |
39 self.setupUi(self) |
40 |
40 |
41 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
41 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
42 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
42 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
43 |
43 |
44 self.summaryList.headerItem().setText(self.summaryList.columnCount(), "") |
44 self.summaryList.headerItem().setText( |
|
45 self.summaryList.columnCount(), "") |
45 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
46 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
46 |
47 |
47 self.cancelled = False |
48 self.cancelled = False |
48 self.path = '.' |
49 self.path = '.' |
49 self.reload = False |
50 self.reload = False |
61 self.__menu.addAction(self.trUtf8('Delete annotated files'), |
62 self.__menu.addAction(self.trUtf8('Delete annotated files'), |
62 self.__deleteAnnotated) |
63 self.__deleteAnnotated) |
63 self.__menu.addSeparator() |
64 self.__menu.addSeparator() |
64 self.__menu.addAction(self.trUtf8('Erase Coverage Info'), self.__erase) |
65 self.__menu.addAction(self.trUtf8('Erase Coverage Info'), self.__erase) |
65 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) |
66 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) |
66 self.resultList.customContextMenuRequested.connect(self.__showContextMenu) |
67 self.resultList.customContextMenuRequested.connect( |
|
68 self.__showContextMenu) |
67 |
69 |
68 def __format_lines(self, lines): |
70 def __format_lines(self, lines): |
69 """ |
71 """ |
70 Private method to format a list of integers into string by coalescing groups. |
72 Private method to format a list of integers into string by coalescing |
|
73 groups. |
71 |
74 |
72 @param lines list of integers |
75 @param lines list of integers |
73 @return string representing the list |
76 @return string representing the list |
74 """ |
77 """ |
75 pairs = [] |
78 pairs = [] |
106 else: |
110 else: |
107 return "{0:d}-{1:d}".format(start, end) |
111 return "{0:d}-{1:d}".format(start, end) |
108 |
112 |
109 return ", ".join(map(stringify, pairs)) |
113 return ", ".join(map(stringify, pairs)) |
110 |
114 |
111 def __createResultItem(self, file, statements, executed, coverage, excluded, missing): |
115 def __createResultItem(self, file, statements, executed, coverage, |
|
116 excluded, missing): |
112 """ |
117 """ |
113 Private method to create an entry in the result list. |
118 Private method to create an entry in the result list. |
114 |
119 |
115 @param file filename of file (string) |
120 @param file filename of file (string) |
116 @param statements amount of statements (integer) |
121 @param statements amount of statements (integer) |
232 self.summaryGroup.hide() |
239 self.summaryGroup.hide() |
233 |
240 |
234 if total_exceptions: |
241 if total_exceptions: |
235 E5MessageBox.warning(self, |
242 E5MessageBox.warning(self, |
236 self.trUtf8("Parse Error"), |
243 self.trUtf8("Parse Error"), |
237 self.trUtf8("""%n file(s) could not be parsed. Coverage info for""" |
244 self.trUtf8("""%n file(s) could not be parsed. Coverage""" |
238 """ these is not available.""", "", total_exceptions)) |
245 """ info for these is not available.""", "", |
|
246 total_exceptions)) |
239 |
247 |
240 self.__finish() |
248 self.__finish() |
241 |
249 |
242 def __finish(self): |
250 def __finish(self): |
243 """ |
251 """ |
244 Private slot called when the action finished or the user pressed the button. |
252 Private slot called when the action finished or the user pressed the |
|
253 button. |
245 """ |
254 """ |
246 self.cancelled = True |
255 self.cancelled = True |
247 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
256 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
248 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
257 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
249 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
258 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |