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