RadonMetrics/CyclomaticComplexityDialog.py

changeset 18
58ce8a433422
parent 15
62ffe3d426e5
child 21
fe094e33a295
--- a/RadonMetrics/CyclomaticComplexityDialog.py	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/CyclomaticComplexityDialog.py	Sun Sep 20 13:49:22 2015 +0200
@@ -39,6 +39,9 @@
     Class implementing a dialog to show the cyclomatic complexity (McCabe
     complexity).
     """
+    FilePathRole = Qt.UserRole + 1
+    LineNumberRole = Qt.UserRole + 2
+    
     def __init__(self, radonService, parent=None):
         """
         Constructor
@@ -146,6 +149,8 @@
             [self.__project.getRelativePath(filename)])
         itm.setExpanded(True)
         itm.setFirstColumnSpanned(True)
+        itm.setData(0, self.FilePathRole, filename)
+        itm.setData(0, self.LineNumberRole, 1)
         return itm
     
     def __createResultItem(self, parentItem, values):
@@ -171,6 +176,9 @@
             itm.setBackground(3, self.__rankColors[values["rank"]])
         if values["type"] in self.__typeColors:
             itm.setForeground(0, self.__typeColors[values["type"]])
+        itm.setData(0, self.FilePathRole,
+                    parentItem.data(0, self.FilePathRole))
+        itm.setData(0, self.LineNumberRole, values["lineno"])
         
         if "methods" in values:
             itm.setExpanded(True)
@@ -238,7 +246,10 @@
         """
         self.__errorItem = None
         self.resultList.clear()
+        self.summaryLabel.clear()
         self.cancelled = False
+        QApplication.processEvents()
+        
         self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
         self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
         self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
@@ -549,3 +560,21 @@
         """
         for index in range(self.resultList.topLevelItemCount()):
             self.resultList.topLevelItem(index).setExpanded(True)
+    
+    def clear(self):
+        """
+        Public method to clear all results.
+        """
+        self.resultList.clear()
+        self.summaryLabel.clear()
+    
+    @pyqtSlot(QTreeWidgetItem, int)
+    def on_resultList_itemActivated(self, item, column):
+        """
+        Private slot to handle the activation of a result item.
+        """
+        filename = item.data(0, self.FilePathRole)
+        lineno = item.data(0, self.LineNumberRole)
+        if filename:
+            vm = e5App().getObject("ViewManager")
+            vm.openSourceFile(filename, lineno)

eric ide

mercurial