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, QTreeWidgetItem, \ |
14 QApplication, QProgressDialog |
14 QApplication, QProgressDialog |
|
15 |
|
16 from E5Gui.E5Application import e5App |
15 |
17 |
16 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
18 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
17 |
19 |
18 import Utilities |
20 import Utilities |
19 from DebugClients.Python3.coverage import coverage |
21 from DebugClients.Python3.coverage import coverage |
43 self.reload = False |
45 self.reload = False |
44 |
46 |
45 self.excludeList = ['# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]'] |
47 self.excludeList = ['# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]'] |
46 |
48 |
47 self.__menu = QMenu(self) |
49 self.__menu = QMenu(self) |
|
50 self.__menu.addSeparator() |
|
51 self.openAct = self.__menu.addAction(self.trUtf8("Open"), |
|
52 self.__openFile) |
|
53 self.__menu.addSeparator() |
48 self.annotate = self.__menu.addAction(self.trUtf8('Annotate'), |
54 self.annotate = self.__menu.addAction(self.trUtf8('Annotate'), |
49 self.__annotate) |
55 self.__annotate) |
50 self.__menu.addAction(self.trUtf8('Annotate all'), self.__annotateAll) |
56 self.__menu.addAction(self.trUtf8('Annotate all'), self.__annotateAll) |
51 self.__menu.addAction(self.trUtf8('Delete annotated files'), |
57 self.__menu.addAction(self.trUtf8('Delete annotated files'), |
52 self.__deleteAnnotated) |
58 self.__deleteAnnotated) |
117 excluded, |
123 excluded, |
118 missing |
124 missing |
119 ]) |
125 ]) |
120 for col in range(1, 4): |
126 for col in range(1, 4): |
121 itm.setTextAlignment(col, Qt.AlignRight) |
127 itm.setTextAlignment(col, Qt.AlignRight) |
|
128 if statements != executed: |
|
129 font = itm.font(0) |
|
130 font.setBold(True) |
|
131 for col in range(itm.columnCount()): |
|
132 itm.setFont(col, font) |
122 |
133 |
123 def start(self, cfn, fn): |
134 def start(self, cfn, fn): |
124 """ |
135 """ |
125 Public slot to start the coverage data evaluation. |
136 Public slot to start the coverage data evaluation. |
126 |
137 |
243 @param coord the position of the mouse pointer (QPoint) |
254 @param coord the position of the mouse pointer (QPoint) |
244 """ |
255 """ |
245 itm = self.resultList.itemAt(coord) |
256 itm = self.resultList.itemAt(coord) |
246 if itm: |
257 if itm: |
247 self.annotate.setEnabled(True) |
258 self.annotate.setEnabled(True) |
|
259 self.openAct.setEnabled(True) |
248 else: |
260 else: |
249 self.annotate.setEnabled(False) |
261 self.annotate.setEnabled(False) |
|
262 self.openAct.setEnabled(False) |
250 self.__menu.popup(self.mapToGlobal(coord)) |
263 self.__menu.popup(self.mapToGlobal(coord)) |
|
264 |
|
265 def __openFile(self, itm=None): |
|
266 """ |
|
267 Private slot to open the selected file. |
|
268 |
|
269 @param itm reference to the item to be opened (QTreeWidgetItem) |
|
270 """ |
|
271 if itm is None: |
|
272 itm = self.resultList.currentItem() |
|
273 fn = itm.text(0) |
|
274 |
|
275 vm = e5App().getObject("ViewManager") |
|
276 vm.openSourceFile(fn) |
|
277 editor = vm.getOpenEditor(fn) |
|
278 editor.codeCoverageShowAnnotations() |
251 |
279 |
252 def __annotate(self): |
280 def __annotate(self): |
253 """ |
281 """ |
254 Private slot to handle the annotate context menu action. |
282 Private slot to handle the annotate context menu action. |
255 |
283 |
347 self.cancelled = False |
375 self.cancelled = False |
348 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
376 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
349 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
377 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
350 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
378 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
351 self.start(self.__cfn, self.__fn) |
379 self.start(self.__cfn, self.__fn) |
|
380 |
|
381 @pyqtSlot(QTreeWidgetItem, int) |
|
382 def on_resultList_itemActivated(self, item, column): |
|
383 """ |
|
384 Private slot to handle the activation of an item. |
|
385 |
|
386 @param item reference to the activated item (QTreeWidgetItem) |
|
387 @param column column the item was activated in (integer) |
|
388 """ |
|
389 self.__openFile(item) |