RadonMetrics/MaintainabilityIndexDialog.py

changeset 18
58ce8a433422
parent 15
62ffe3d426e5
child 24
edaf153da771
equal deleted inserted replaced
17:97c15db4a7c1 18:58ce8a433422
32 32
33 class MaintainabilityIndexDialog(QDialog, Ui_MaintainabilityIndexDialog): 33 class MaintainabilityIndexDialog(QDialog, Ui_MaintainabilityIndexDialog):
34 """ 34 """
35 Class implementing a dialog to show maintainability indexes. 35 Class implementing a dialog to show maintainability indexes.
36 """ 36 """
37 FilePathRole = Qt.UserRole + 1
38
37 def __init__(self, radonService, parent=None): 39 def __init__(self, radonService, parent=None):
38 """ 40 """
39 Constructor 41 Constructor
40 42
41 @param radonService reference to the service 43 @param radonService reference to the service
108 itm = QTreeWidgetItem(self.resultList, data) 110 itm = QTreeWidgetItem(self.resultList, data)
109 itm.setTextAlignment(1, Qt.Alignment(Qt.AlignRight)) 111 itm.setTextAlignment(1, Qt.Alignment(Qt.AlignRight))
110 itm.setTextAlignment(2, Qt.Alignment(Qt.AlignHCenter)) 112 itm.setTextAlignment(2, Qt.Alignment(Qt.AlignHCenter))
111 if values["rank"] in self.__rankColors: 113 if values["rank"] in self.__rankColors:
112 itm.setBackground(2, self.__rankColors[values["rank"]]) 114 itm.setBackground(2, self.__rankColors[values["rank"]])
115 itm.setData(0, self.FilePathRole, filename)
113 116
114 if values["rank"] in self.__summary: 117 if values["rank"] in self.__summary:
115 self.__summary[values["rank"]] += 1 118 self.__summary[values["rank"]] += 1
116 119
117 def __createErrorItem(self, filename, message): 120 def __createErrorItem(self, filename, message):
168 the maintainability index for 171 the maintainability index for
169 @type str or list of str 172 @type str or list of str
170 """ 173 """
171 self.__errorItem = None 174 self.__errorItem = None
172 self.resultList.clear() 175 self.resultList.clear()
176 self.summaryLabel.clear()
173 self.cancelled = False 177 self.cancelled = False
178 QApplication.processEvents()
179
174 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 180 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
175 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 181 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
176 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 182 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
177 QApplication.processEvents() 183 QApplication.processEvents()
178 184
356 if not self.__finished: 362 if not self.__finished:
357 self.__finished = True 363 self.__finished = True
358 364
359 # reenable updates of the list 365 # reenable updates of the list
360 self.resultList.setSortingEnabled(True) 366 self.resultList.setSortingEnabled(True)
367 self.resultList.sortItems(0, Qt.AscendingOrder)
361 self.resultList.setUpdatesEnabled(True) 368 self.resultList.setUpdatesEnabled(True)
362 369
363 self.cancelled = True 370 self.cancelled = True
364 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 371 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
365 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 372 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
425 for filter in filterList: 432 for filter in filterList:
426 fileList = \ 433 fileList = \
427 [f for f in fileList if not fnmatch.fnmatch(f, filter)] 434 [f for f in fileList if not fnmatch.fnmatch(f, filter)]
428 435
429 self.start(fileList) 436 self.start(fileList)
437
438 def clear(self):
439 """
440 Public method to clear all results.
441 """
442 self.resultList.clear()
443 self.summaryLabel.clear()
444
445 @pyqtSlot(QTreeWidgetItem, int)
446 def on_resultList_itemActivated(self, item, column):
447 """
448 Private slot to handle the activation of a result item.
449 """
450 filename = item.data(0, self.FilePathRole)
451 if filename:
452 vm = e5App().getObject("ViewManager")
453 vm.openSourceFile(filename)

eric ide

mercurial