RadonMetrics/RawMetricsDialog.py

changeset 18
58ce8a433422
parent 14
5f206edea27e
child 24
edaf153da771
equal deleted inserted replaced
17:97c15db4a7c1 18:58ce8a433422
33 33
34 class RawMetricsDialog(QDialog, Ui_RawMetricsDialog): 34 class RawMetricsDialog(QDialog, Ui_RawMetricsDialog):
35 """ 35 """
36 Class implementing a dialog to show raw code metrics. 36 Class implementing a dialog to show raw code metrics.
37 """ 37 """
38 FilePathRole = Qt.UserRole + 1
39
38 def __init__(self, radonService, parent=None): 40 def __init__(self, radonService, parent=None):
39 """ 41 """
40 Constructor 42 Constructor
41 43
42 @param radonService reference to the service 44 @param radonService reference to the service
122 (values["comments"] + values["multi"]) / 124 (values["comments"] + values["multi"]) /
123 (float(values["loc"]) or 1))) 125 (float(values["loc"]) or 1)))
124 itm = QTreeWidgetItem(self.resultList, data) 126 itm = QTreeWidgetItem(self.resultList, data)
125 for col in range(1, 10): 127 for col in range(1, 10):
126 itm.setTextAlignment(col, Qt.Alignment(Qt.AlignRight)) 128 itm.setTextAlignment(col, Qt.Alignment(Qt.AlignRight))
129 itm.setData(0, self.FilePathRole, filename)
127 130
128 def __createErrorItem(self, filename, message): 131 def __createErrorItem(self, filename, message):
129 """ 132 """
130 Private slot to create a new error item in the result list. 133 Private slot to create a new error item in the result list.
131 134
179 the code metrics for 182 the code metrics for
180 @type str or list of str 183 @type str or list of str
181 """ 184 """
182 self.__errorItem = None 185 self.__errorItem = None
183 self.resultList.clear() 186 self.resultList.clear()
187 self.summaryList.clear()
184 self.cancelled = False 188 self.cancelled = False
189 QApplication.processEvents()
190
185 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 191 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
186 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 192 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
187 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 193 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
188 QApplication.processEvents() 194 QApplication.processEvents()
189 195
384 if not self.__finished: 390 if not self.__finished:
385 self.__finished = True 391 self.__finished = True
386 392
387 # reenable updates of the list 393 # reenable updates of the list
388 self.resultList.setSortingEnabled(True) 394 self.resultList.setSortingEnabled(True)
395 self.resultList.sortItems(0, Qt.AscendingOrder)
389 self.resultList.setUpdatesEnabled(True) 396 self.resultList.setUpdatesEnabled(True)
390 397
391 self.__createSummary() 398 self.__createSummary()
392 399
393 self.cancelled = True 400 self.cancelled = True
478 for filter in filterList: 485 for filter in filterList:
479 fileList = \ 486 fileList = \
480 [f for f in fileList if not fnmatch.fnmatch(f, filter)] 487 [f for f in fileList if not fnmatch.fnmatch(f, filter)]
481 488
482 self.start(fileList) 489 self.start(fileList)
490
491 def clear(self):
492 """
493 Public method to clear all results.
494 """
495 self.resultList.clear()
496 self.summaryList.clear()
497
498 @pyqtSlot(QTreeWidgetItem, int)
499 def on_resultList_itemActivated(self, item, column):
500 """
501 Private slot to handle the activation of a result item.
502 """
503 filename = item.data(0, self.FilePathRole)
504 if filename:
505 vm = e5App().getObject("ViewManager")
506 vm.openSourceFile(filename)

eric ide

mercurial