57 |
57 |
58 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
58 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
59 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
59 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
60 |
60 |
61 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
61 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
|
62 |
|
63 self.rankComboBox.addItems(["A", "B", "C", "D", "E", "F"]) |
|
64 self.rankComboBox.setCurrentText("D") |
|
65 self.__minimumRank = "D" |
62 |
66 |
63 self.radonService = radonService |
67 self.radonService = radonService |
64 self.radonService.complexityDone.connect(self.__processResult) |
68 self.radonService.complexityDone.connect(self.__processResult) |
65 self.radonService.error.connect(self.__processError) |
69 self.radonService.error.connect(self.__processError) |
66 self.radonService.batchFinished.connect(self.__batchFinished) |
70 self.radonService.batchFinished.connect(self.__batchFinished) |
143 @type str |
147 @type str |
144 @return reference to the created item |
148 @return reference to the created item |
145 @rtype QTreeWidgetItem |
149 @rtype QTreeWidgetItem |
146 """ |
150 """ |
147 itm = QTreeWidgetItem( |
151 itm = QTreeWidgetItem( |
148 self.resultList, |
|
149 [self.__project.getRelativePath(filename)]) |
152 [self.__project.getRelativePath(filename)]) |
150 itm.setExpanded(True) |
|
151 itm.setFirstColumnSpanned(True) |
|
152 itm.setData(0, self.FilePathRole, filename) |
153 itm.setData(0, self.FilePathRole, filename) |
153 itm.setData(0, self.LineNumberRole, 1) |
154 itm.setData(0, self.LineNumberRole, 1) |
154 return itm |
155 return itm |
155 |
156 |
156 def __createResultItem(self, parentItem, values): |
157 def __createResultItem(self, parentItem, values): |
160 @param parentItem reference to the parent item |
161 @param parentItem reference to the parent item |
161 @type QTreeWidgetItem |
162 @type QTreeWidgetItem |
162 @param values values to be displayed |
163 @param values values to be displayed |
163 @type dict |
164 @type dict |
164 """ |
165 """ |
165 itm = QTreeWidgetItem(parentItem, [ |
166 if values["rank"] >= self.__minimumRank: |
166 self.__mappedType[values["type"]], |
167 itm = QTreeWidgetItem(parentItem, [ |
167 values["fullname"], |
168 self.__mappedType[values["type"]], |
168 "{0:3}".format(values["complexity"]), |
169 values["fullname"], |
169 values["rank"], |
170 "{0:3}".format(values["complexity"]), |
170 "{0:6}".format(values["lineno"]), |
171 values["rank"], |
171 ]) |
172 "{0:6}".format(values["lineno"]), |
172 itm.setTextAlignment(2, Qt.Alignment(Qt.AlignRight)) |
173 ]) |
173 itm.setTextAlignment(3, Qt.Alignment(Qt.AlignHCenter)) |
174 itm.setTextAlignment(2, Qt.Alignment(Qt.AlignRight)) |
174 itm.setTextAlignment(4, Qt.Alignment(Qt.AlignRight)) |
175 itm.setTextAlignment(3, Qt.Alignment(Qt.AlignHCenter)) |
175 if values["rank"] in self.__rankColors: |
176 itm.setTextAlignment(4, Qt.Alignment(Qt.AlignRight)) |
176 itm.setBackground(3, self.__rankColors[values["rank"]]) |
177 if values["rank"] in self.__rankColors: |
177 if values["type"] in self.__typeColors: |
178 itm.setBackground(3, self.__rankColors[values["rank"]]) |
178 itm.setForeground(0, self.__typeColors[values["type"]]) |
179 if values["type"] in self.__typeColors: |
179 itm.setData(0, self.FilePathRole, |
180 itm.setForeground(0, self.__typeColors[values["type"]]) |
180 parentItem.data(0, self.FilePathRole)) |
181 itm.setData(0, self.FilePathRole, |
181 itm.setData(0, self.LineNumberRole, values["lineno"]) |
182 parentItem.data(0, self.FilePathRole)) |
|
183 itm.setData(0, self.LineNumberRole, values["lineno"]) |
182 |
184 |
183 if "methods" in values: |
185 if "methods" in values: |
184 itm.setExpanded(True) |
|
185 for method in values["methods"]: |
186 for method in values["methods"]: |
186 self.__createResultItem(itm, method) |
187 self.__createResultItem(parentItem, method) |
187 |
188 |
188 if "closures" in values and values["closures"]: |
189 if "closures" in values and values["closures"]: |
189 itm.setExpanded(True) |
|
190 for closure in values["closures"]: |
190 for closure in values["closures"]: |
191 self.__createResultItem(itm, closure) |
191 self.__createResultItem(parentItem, closure) |
192 |
192 |
193 def __createErrorItem(self, filename, message): |
193 def __createErrorItem(self, filename, message): |
194 """ |
194 """ |
195 Private slot to create a new error item in the result list. |
195 Private slot to create a new error item in the result list. |
196 |
196 |
234 "OTHERTOOLSPARMS", "RadonCodeMetrics") |
234 "OTHERTOOLSPARMS", "RadonCodeMetrics") |
235 if self.__data is None or "ExcludeFiles" not in self.__data: |
235 if self.__data is None or "ExcludeFiles" not in self.__data: |
236 self.__data = {"ExcludeFiles": ""} |
236 self.__data = {"ExcludeFiles": ""} |
237 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
237 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
238 |
238 |
239 def start(self, fn): |
239 def start(self, fn, minRank="D"): |
240 """ |
240 """ |
241 Public slot to start the cyclomatic complexity determination. |
241 Public slot to start the cyclomatic complexity determination. |
242 |
242 |
243 @param fn file or list of files or directory to show |
243 @param fn file or list of files or directory to show |
244 the cyclomatic complexity for |
244 the cyclomatic complexity for |
245 @type str or list of str |
245 @type str or list of str |
|
246 @param minRank minimum rank of entries to be shown |
|
247 @type str (one character out of A - F) |
246 """ |
248 """ |
247 self.__errorItem = None |
249 self.__errorItem = None |
248 self.resultList.clear() |
250 self.resultList.clear() |
249 self.summaryLabel.clear() |
251 self.summaryLabel.clear() |
250 self.cancelled = False |
252 self.cancelled = False |
417 # Check if it's the requested file, otherwise ignore signal if not |
421 # Check if it's the requested file, otherwise ignore signal if not |
418 # in batch mode |
422 # in batch mode |
419 if not self.__batch and fn != self.filename: |
423 if not self.__batch and fn != self.filename: |
420 return |
424 return |
421 |
425 |
|
426 self.checkProgressLabel.setPath(self.__project.getRelativePath(fn)) |
|
427 QApplication.processEvents() |
|
428 |
422 if "error" in result: |
429 if "error" in result: |
423 self.__createErrorItem(fn, result["error"]) |
430 self.__createErrorItem(fn, result["error"]) |
424 else: |
431 else: |
425 if result["result"]: |
432 if result["result"]: |
426 fitm = self.__createFileItem(fn) |
433 fitm = self.__createFileItem(fn) |
427 for resultDict in result["result"]: |
434 for resultDict in result["result"]: |
428 self.__createResultItem(fitm, resultDict) |
435 self.__createResultItem(fitm, resultDict) |
|
436 if fitm.childCount() > 0: |
|
437 self.resultList.addTopLevelItem(fitm) |
|
438 fitm.setExpanded(True) |
|
439 fitm.setFirstColumnSpanned(True) |
429 |
440 |
430 self.__ccCount += result["count"] |
441 self.__ccCount += result["count"] |
431 self.__ccSum += result["total_cc"] |
442 self.__ccSum += result["total_cc"] |
432 for rank in result["summary"]: |
443 for rank in result["summary"]: |
433 self.__summary[rank] += result["summary"][rank] |
444 self.__summary[rank] += result["summary"][rank] |
434 |
445 |
435 self.progress += 1 |
446 self.progress += 1 |
436 |
447 |
437 self.checkProgress.setValue(self.progress) |
448 self.checkProgress.setValue(self.progress) |
438 self.checkProgressLabel.setPath(self.__project.getRelativePath(fn)) |
|
439 QApplication.processEvents() |
449 QApplication.processEvents() |
440 |
450 |
441 if not self.__batch: |
451 if not self.__batch: |
442 self.cyclomaticComplexity() |
452 self.cyclomaticComplexity() |
443 |
453 |