RadonMetrics/CyclomaticComplexityDialog.py

changeset 55
755bc8e1485a
parent 53
4a179abb79e6
child 60
cd2dd96c3c12
equal deleted inserted replaced
54:f7a462d6ec26 55:755bc8e1485a
40 complexity). 40 complexity).
41 """ 41 """
42 FilePathRole = Qt.UserRole + 1 42 FilePathRole = Qt.UserRole + 1
43 LineNumberRole = Qt.UserRole + 2 43 LineNumberRole = Qt.UserRole + 2
44 44
45 def __init__(self, radonService, parent=None): 45 def __init__(self, radonService, isSingle=False, parent=None):
46 """ 46 """
47 Constructor 47 Constructor
48 48
49 @param radonService reference to the service 49 @param radonService reference to the service
50 @type RadonMetricsPlugin 50 @type RadonMetricsPlugin
51 @param isSingle flag indicating a single file dialog
52 @type bool
51 @param parent reference to the parent widget 53 @param parent reference to the parent widget
52 @type QWidget 54 @type QWidget
53 """ 55 """
54 super(CyclomaticComplexityDialog, self).__init__(parent) 56 super(CyclomaticComplexityDialog, self).__init__(parent)
55 self.setupUi(self) 57 self.setupUi(self)
67 self.radonService = radonService 69 self.radonService = radonService
68 self.radonService.complexityDone.connect(self.__processResult) 70 self.radonService.complexityDone.connect(self.__processResult)
69 self.radonService.error.connect(self.__processError) 71 self.radonService.error.connect(self.__processError)
70 self.radonService.batchFinished.connect(self.__batchFinished) 72 self.radonService.batchFinished.connect(self.__batchFinished)
71 73
74 self.__isSingle = isSingle
72 self.cancelled = False 75 self.cancelled = False
73 76
74 self.__project = e5App().getObject("Project") 77 self.__project = e5App().getObject("Project")
75 self.__locale = QLocale() 78 self.__locale = QLocale()
76 self.__finished = True 79 self.__finished = True
249 the cyclomatic complexity for 252 the cyclomatic complexity for
250 @type str or list of str 253 @type str or list of str
251 @param minRank minimum rank of entries to be shown 254 @param minRank minimum rank of entries to be shown
252 @type str (one character out of A - F) 255 @type str (one character out of A - F)
253 """ 256 """
257 self.cancelled = False
254 self.__errorItem = None 258 self.__errorItem = None
255 self.resultList.clear() 259 self.resultList.clear()
256 self.summaryLabel.clear() 260 self.summaryLabel.clear()
257 self.cancelled = False
258 QApplication.processEvents() 261 QApplication.processEvents()
259 262
260 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 263 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
261 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 264 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
262 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 265 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
266 self.rankComboBox.setEnabled(False)
263 QApplication.processEvents() 267 QApplication.processEvents()
264 268
265 if isinstance(fn, list): 269 if isinstance(fn, list):
266 self.files = fn 270 self.files = fn
267 elif os.path.isdir(fn): 271 elif os.path.isdir(fn):
276 self.files.sort() 280 self.files.sort()
277 # check for missing files 281 # check for missing files
278 for f in self.files[:]: 282 for f in self.files[:]:
279 if not os.path.exists(f): 283 if not os.path.exists(f):
280 self.files.remove(f) 284 self.files.remove(f)
285 if self.__isSingle:
286 self.__fileList = self.files[:]
281 287
282 self.__summary = { 288 self.__summary = {
283 "A": 0, 289 "A": 0,
284 "B": 0, 290 "B": 0,
285 "C": 0, 291 "C": 0,
288 "F": 0, 294 "F": 0,
289 } 295 }
290 self.__ccSum = 0 296 self.__ccSum = 0
291 self.__ccCount = 0 297 self.__ccCount = 0
292 298
293 self.__minimumRank = minRank 299 self.__minimumRank = self.rankComboBox.currentText()
294 300
295 if len(self.files) > 0: 301 if len(self.files) > 0:
296 # disable updates of the list for speed 302 # disable updates of the list for speed
297 self.resultList.setUpdatesEnabled(False) 303 self.resultList.setUpdatesEnabled(False)
298 self.resultList.setSortingEnabled(False) 304 self.resultList.setSortingEnabled(False)
473 479
474 self.cancelled = True 480 self.cancelled = True
475 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 481 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
476 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 482 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
477 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 483 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
484 self.rankComboBox.setEnabled(True)
478 485
479 self.resultList.header().resizeSections( 486 self.resultList.header().resizeSections(
480 QHeaderView.ResizeToContents) 487 QHeaderView.ResizeToContents)
481 self.resultList.header().setStretchLastSection(True) 488 self.resultList.header().setStretchLastSection(True)
482 if qVersion() >= "5.0.0": 489 if qVersion() >= "5.0.0":
565 572
566 if dataChanged: 573 if dataChanged:
567 self.__project.setData( 574 self.__project.setData(
568 "OTHERTOOLSPARMS", "RadonCodeMetrics", self.__data) 575 "OTHERTOOLSPARMS", "RadonCodeMetrics", self.__data)
569 576
570 self.start(fileList, minRank=minimumRank) 577 self.start(fileList)
571 578
572 def __showContextMenu(self, coord): 579 def __showContextMenu(self, coord):
573 """ 580 """
574 Private slot to show the context menu of the resultlist. 581 Private slot to show the context menu of the resultlist.
575 582
612 filename = item.data(0, self.FilePathRole) 619 filename = item.data(0, self.FilePathRole)
613 lineno = item.data(0, self.LineNumberRole) 620 lineno = item.data(0, self.LineNumberRole)
614 if filename: 621 if filename:
615 vm = e5App().getObject("ViewManager") 622 vm = e5App().getObject("ViewManager")
616 vm.openSourceFile(filename, lineno) 623 vm.openSourceFile(filename, lineno)
624
625 @pyqtSlot(str)
626 def on_rankComboBox_activated(self, rank):
627 """
628 Private slot to handle the selection of a minimum rank.
629
630 @param rank selected minimum rank
631 @type str
632 """
633 if self.__isSingle:
634 self.start(self.__fileList[:])

eric ide

mercurial