Fixed a few bugs and added an 'activated' action to the various result lists. release-0.2.0

Sun, 20 Sep 2015 13:49:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 20 Sep 2015 13:49:22 +0200
changeset 18
58ce8a433422
parent 17
97c15db4a7c1
child 19
5d0eb64c2ed9

Fixed a few bugs and added an 'activated' action to the various result lists.

ChangeLog file | annotate | diff | comparison | revisions
PluginMetricsRadon.py file | annotate | diff | comparison | revisions
PluginMetricsRadon.zip file | annotate | diff | comparison | revisions
RadonMetrics/CyclomaticComplexityDialog.py file | annotate | diff | comparison | revisions
RadonMetrics/CyclomaticComplexityDialog.ui file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html file | annotate | diff | comparison | revisions
RadonMetrics/MaintainabilityIndexDialog.py file | annotate | diff | comparison | revisions
RadonMetrics/RawMetricsDialog.py file | annotate | diff | comparison | revisions
--- a/ChangeLog	Sun Sep 20 12:17:19 2015 +0200
+++ b/ChangeLog	Sun Sep 20 13:49:22 2015 +0200
@@ -1,4 +1,7 @@
 ChangeLog
 ---------
+Version 0.2.0:
+- bug fixes
+
 Version 0.1.0:
 - first development release
--- a/PluginMetricsRadon.py	Sun Sep 20 12:17:19 2015 +0200
+++ b/PluginMetricsRadon.py	Sun Sep 20 13:49:22 2015 +0200
@@ -28,7 +28,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "0.1.0"
+version = "0.2.0"
 className = "RadonMetricsPlugin"
 packageName = "RadonMetrics"
 shortDescription = "Code metrics plugin using radon package"
@@ -620,6 +620,8 @@
         self.__editorMetricsActs.append(act)
         
         e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
+        e5App().getObject("Project").projectClosed.connect(
+            self.__projectClosed)
         e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
             .showMenu.connect(self.__projectBrowserShowMenu)
         e5App().getObject("ViewManager").editorOpenedEd.connect(
@@ -638,6 +640,8 @@
         """
         e5App().getObject("Project").showMenu.disconnect(
             self.__projectShowMenu)
+        e5App().getObject("Project").projectClosed.disconnect(
+            self.__projectClosed)
         e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
             .showMenu.disconnect(self.__projectBrowserShowMenu)
         e5App().getObject("ViewManager").editorOpenedEd.disconnect(
@@ -844,8 +848,9 @@
                      tuple(Preferences.getPython("Python3Extensions")) +
                      tuple(Preferences.getPython("PythonExtensions")))]
         
-        from RadonMetrics.RawMetricsDialog import RawMetricsDialog
-        self.__projectRawMetricsDialog = RawMetricsDialog(self)
+        if self.__projectRawMetricsDialog is None:
+            from RadonMetrics.RawMetricsDialog import RawMetricsDialog
+            self.__projectRawMetricsDialog = RawMetricsDialog(self)
         self.__projectRawMetricsDialog.show()
         self.__projectRawMetricsDialog.prepare(files, project)
     
@@ -867,8 +872,9 @@
             except AttributeError:
                 fn = itm.dirName()
         
-        from RadonMetrics.RawMetricsDialog import RawMetricsDialog
-        self.__projectBrowserRawMetricsDialog = RawMetricsDialog(self)
+        if self.__projectBrowserRawMetricsDialog is None:
+            from RadonMetrics.RawMetricsDialog import RawMetricsDialog
+            self.__projectBrowserRawMetricsDialog = RawMetricsDialog(self)
         self.__projectBrowserRawMetricsDialog.show()
         self.__projectBrowserRawMetricsDialog.start(fn)
     
@@ -880,8 +886,9 @@
         editor = e5App().getObject("ViewManager").activeWindow()
         if editor is not None:
             if editor.checkDirty() and editor.getFileName() is not None:
-                from RadonMetrics.RawMetricsDialog import RawMetricsDialog
-                self.__editorRawMetricsDialog = RawMetricsDialog(self)
+                if self.__editorRawMetricsDialog is None:
+                    from RadonMetrics.RawMetricsDialog import RawMetricsDialog
+                    self.__editorRawMetricsDialog = RawMetricsDialog(self)
                 self.__editorRawMetricsDialog.show()
                 self.__editorRawMetricsDialog.start(editor.getFileName())
     
@@ -903,9 +910,10 @@
                      tuple(Preferences.getPython("Python3Extensions")) +
                      tuple(Preferences.getPython("PythonExtensions")))]
         
-        from RadonMetrics.MaintainabilityIndexDialog import \
-            MaintainabilityIndexDialog
-        self.__projectMIDialog = MaintainabilityIndexDialog(self)
+        if self.__projectMIDialog is None:
+            from RadonMetrics.MaintainabilityIndexDialog import \
+                MaintainabilityIndexDialog
+            self.__projectMIDialog = MaintainabilityIndexDialog(self)
         self.__projectMIDialog.show()
         self.__projectMIDialog.prepare(files, project)
     
@@ -927,9 +935,10 @@
             except AttributeError:
                 fn = itm.dirName()
         
-        from RadonMetrics.MaintainabilityIndexDialog import \
-            MaintainabilityIndexDialog
-        self.__projectBrowserMIDialog = MaintainabilityIndexDialog(self)
+        if self.__projectBrowserMIDialog is None:
+            from RadonMetrics.MaintainabilityIndexDialog import \
+                MaintainabilityIndexDialog
+            self.__projectBrowserMIDialog = MaintainabilityIndexDialog(self)
         self.__projectBrowserMIDialog.show()
         self.__projectBrowserMIDialog.start(fn)
     
@@ -941,9 +950,10 @@
         editor = e5App().getObject("ViewManager").activeWindow()
         if editor is not None:
             if editor.checkDirty() and editor.getFileName() is not None:
-                from RadonMetrics.MaintainabilityIndexDialog import \
-                    MaintainabilityIndexDialog
-                self.__editorMIDialog = MaintainabilityIndexDialog(self)
+                if self.__editorMIDialog is None:
+                    from RadonMetrics.MaintainabilityIndexDialog import \
+                        MaintainabilityIndexDialog
+                    self.__editorMIDialog = MaintainabilityIndexDialog(self)
                 self.__editorMIDialog.show()
                 self.__editorMIDialog.start(editor.getFileName())
     
@@ -1037,3 +1047,16 @@
                 """ complexity</li>"""
                 """</ul></p>"""
             ).format(__version__))
+    
+    ##################################################################
+    ## Project handling methods
+    ##################################################################
+    
+    def __projectClosed(self):
+        """
+        Private slot to handle closing a project.
+        """
+        self.__projectCCDialog and self.__projectCCDialog.clear()
+        self.__projectMIDialog and self.__projectMIDialog.clear()
+        self.__projectRawMetricsDialog and \
+            self.__projectRawMetricsDialog.clear()
Binary file PluginMetricsRadon.zip has changed
--- 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)
--- a/RadonMetrics/CyclomaticComplexityDialog.ui	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/CyclomaticComplexityDialog.ui	Sun Sep 20 13:49:22 2015 +0200
@@ -84,6 +84,9 @@
      <property name="alternatingRowColors">
       <bool>true</bool>
      </property>
+     <property name="expandsOnDoubleClick">
+      <bool>false</bool>
+     </property>
      <column>
       <property name="text">
        <string>Type</string>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.PluginMetricsRadon.html	Sun Sep 20 13:49:22 2015 +0200
@@ -117,6 +117,9 @@
 <td><a href="#RadonMetricsPlugin.__projectBrowserShowMenu">__projectBrowserShowMenu</a></td>
 <td>Private slot called, when the the project browser context menu or a submenu is about to be shown.</td>
 </tr><tr>
+<td><a href="#RadonMetricsPlugin.__projectClosed">__projectClosed</a></td>
+<td>Private slot to handle closing a project.</td>
+</tr><tr>
 <td><a href="#RadonMetricsPlugin.__projectCyclomaticComplexity">__projectCyclomaticComplexity</a></td>
 <td>Private slot used to calculate the cyclomatic complexity for the project.</td>
 </tr><tr>
@@ -292,7 +295,12 @@
 <dd>
 reference to the menu (QMenu)
 </dd>
-</dl><a NAME="RadonMetricsPlugin.__projectCyclomaticComplexity" ID="RadonMetricsPlugin.__projectCyclomaticComplexity"></a>
+</dl><a NAME="RadonMetricsPlugin.__projectClosed" ID="RadonMetricsPlugin.__projectClosed"></a>
+<h4>RadonMetricsPlugin.__projectClosed</h4>
+<b>__projectClosed</b>(<i></i>)
+<p>
+        Private slot to handle closing a project.
+</p><a NAME="RadonMetricsPlugin.__projectCyclomaticComplexity" ID="RadonMetricsPlugin.__projectCyclomaticComplexity"></a>
 <h4>RadonMetricsPlugin.__projectCyclomaticComplexity</h4>
 <b>__projectCyclomaticComplexity</b>(<i></i>)
 <p>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.CyclomaticComplexityDialog.html	Sun Sep 20 13:49:22 2015 +0200
@@ -50,7 +50,7 @@
 QDialog, Ui_CyclomaticComplexityDialog
 <h3>Class Attributes</h3>
 <table>
-<tr><td>None</td></tr>
+<tr><td>FilePathRole</td></tr><tr><td>LineNumberRole</td></tr>
 </table>
 <h3>Class Methods</h3>
 <table>
@@ -95,6 +95,9 @@
 <td><a href="#CyclomaticComplexityDialog.__showContextMenu">__showContextMenu</a></td>
 <td>Private slot to show the context menu of the resultlist.</td>
 </tr><tr>
+<td><a href="#CyclomaticComplexityDialog.clear">clear</a></td>
+<td>Public method to clear all results.</td>
+</tr><tr>
 <td><a href="#CyclomaticComplexityDialog.cyclomaticComplexity">cyclomaticComplexity</a></td>
 <td>Public method to start a cyclomatic complexity calculation for one Python file.</td>
 </tr><tr>
@@ -104,6 +107,9 @@
 <td><a href="#CyclomaticComplexityDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
 <td>Private slot called by a button of the button box clicked.</td>
 </tr><tr>
+<td><a href="#CyclomaticComplexityDialog.on_resultList_itemActivated">on_resultList_itemActivated</a></td>
+<td>Private slot to handle the activation of a result item.</td>
+</tr><tr>
 <td><a href="#CyclomaticComplexityDialog.on_startButton_clicked">on_startButton_clicked</a></td>
 <td>Private slot to start a cyclomatic complexity run.</td>
 </tr><tr>
@@ -247,7 +253,12 @@
 <dd>
 the position of the mouse pointer (QPoint)
 </dd>
-</dl><a NAME="CyclomaticComplexityDialog.cyclomaticComplexity" ID="CyclomaticComplexityDialog.cyclomaticComplexity"></a>
+</dl><a NAME="CyclomaticComplexityDialog.clear" ID="CyclomaticComplexityDialog.clear"></a>
+<h4>CyclomaticComplexityDialog.clear</h4>
+<b>clear</b>(<i></i>)
+<p>
+        Public method to clear all results.
+</p><a NAME="CyclomaticComplexityDialog.cyclomaticComplexity" ID="CyclomaticComplexityDialog.cyclomaticComplexity"></a>
 <h4>CyclomaticComplexityDialog.cyclomaticComplexity</h4>
 <b>cyclomaticComplexity</b>(<i>codestring=''</i>)
 <p>
@@ -277,7 +288,12 @@
 <dd>
 button that was clicked
 </dd>
-</dl><a NAME="CyclomaticComplexityDialog.on_startButton_clicked" ID="CyclomaticComplexityDialog.on_startButton_clicked"></a>
+</dl><a NAME="CyclomaticComplexityDialog.on_resultList_itemActivated" ID="CyclomaticComplexityDialog.on_resultList_itemActivated"></a>
+<h4>CyclomaticComplexityDialog.on_resultList_itemActivated</h4>
+<b>on_resultList_itemActivated</b>(<i>item, column</i>)
+<p>
+        Private slot to handle the activation of a result item.
+</p><a NAME="CyclomaticComplexityDialog.on_startButton_clicked" ID="CyclomaticComplexityDialog.on_startButton_clicked"></a>
 <h4>CyclomaticComplexityDialog.on_startButton_clicked</h4>
 <b>on_startButton_clicked</b>(<i></i>)
 <p>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.MaintainabilityIndexDialog.html	Sun Sep 20 13:49:22 2015 +0200
@@ -48,7 +48,7 @@
 QDialog, Ui_MaintainabilityIndexDialog
 <h3>Class Attributes</h3>
 <table>
-<tr><td>None</td></tr>
+<tr><td>FilePathRole</td></tr>
 </table>
 <h3>Class Methods</h3>
 <table>
@@ -81,6 +81,9 @@
 <td><a href="#MaintainabilityIndexDialog.__resizeResultColumns">__resizeResultColumns</a></td>
 <td>Private method to resize the list columns.</td>
 </tr><tr>
+<td><a href="#MaintainabilityIndexDialog.clear">clear</a></td>
+<td>Public method to clear all results.</td>
+</tr><tr>
 <td><a href="#MaintainabilityIndexDialog.maintainabilityIndex">maintainabilityIndex</a></td>
 <td>Public method to start a maintainability index calculation for one Python file.</td>
 </tr><tr>
@@ -90,6 +93,9 @@
 <td><a href="#MaintainabilityIndexDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
 <td>Private slot called by a button of the button box clicked.</td>
 </tr><tr>
+<td><a href="#MaintainabilityIndexDialog.on_resultList_itemActivated">on_resultList_itemActivated</a></td>
+<td>Private slot to handle the activation of a result item.</td>
+</tr><tr>
 <td><a href="#MaintainabilityIndexDialog.on_startButton_clicked">on_startButton_clicked</a></td>
 <td>Private slot to start a maintainability index run.</td>
 </tr><tr>
@@ -193,6 +199,11 @@
 <b>__resizeResultColumns</b>(<i></i>)
 <p>
         Private method to resize the list columns.
+</p><a NAME="MaintainabilityIndexDialog.clear" ID="MaintainabilityIndexDialog.clear"></a>
+<h4>MaintainabilityIndexDialog.clear</h4>
+<b>clear</b>(<i></i>)
+<p>
+        Public method to clear all results.
 </p><a NAME="MaintainabilityIndexDialog.maintainabilityIndex" ID="MaintainabilityIndexDialog.maintainabilityIndex"></a>
 <h4>MaintainabilityIndexDialog.maintainabilityIndex</h4>
 <b>maintainabilityIndex</b>(<i>codestring=''</i>)
@@ -223,7 +234,12 @@
 <dd>
 button that was clicked
 </dd>
-</dl><a NAME="MaintainabilityIndexDialog.on_startButton_clicked" ID="MaintainabilityIndexDialog.on_startButton_clicked"></a>
+</dl><a NAME="MaintainabilityIndexDialog.on_resultList_itemActivated" ID="MaintainabilityIndexDialog.on_resultList_itemActivated"></a>
+<h4>MaintainabilityIndexDialog.on_resultList_itemActivated</h4>
+<b>on_resultList_itemActivated</b>(<i>item, column</i>)
+<p>
+        Private slot to handle the activation of a result item.
+</p><a NAME="MaintainabilityIndexDialog.on_startButton_clicked" ID="MaintainabilityIndexDialog.on_startButton_clicked"></a>
 <h4>MaintainabilityIndexDialog.on_startButton_clicked</h4>
 <b>on_startButton_clicked</b>(<i></i>)
 <p>
--- a/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.RawMetricsDialog.html	Sun Sep 20 13:49:22 2015 +0200
@@ -48,7 +48,7 @@
 QDialog, Ui_RawMetricsDialog
 <h3>Class Attributes</h3>
 <table>
-<tr><td>None</td></tr>
+<tr><td>FilePathRole</td></tr>
 </table>
 <h3>Class Methods</h3>
 <table>
@@ -90,9 +90,15 @@
 <td><a href="#RawMetricsDialog.__resizeResultColumns">__resizeResultColumns</a></td>
 <td>Private method to resize the list columns.</td>
 </tr><tr>
+<td><a href="#RawMetricsDialog.clear">clear</a></td>
+<td>Public method to clear all results.</td>
+</tr><tr>
 <td><a href="#RawMetricsDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
 <td>Private slot called by a button of the button box clicked.</td>
 </tr><tr>
+<td><a href="#RawMetricsDialog.on_resultList_itemActivated">on_resultList_itemActivated</a></td>
+<td>Private slot to handle the activation of a result item.</td>
+</tr><tr>
 <td><a href="#RawMetricsDialog.on_startButton_clicked">on_startButton_clicked</a></td>
 <td>Private slot to start a code metrics run.</td>
 </tr><tr>
@@ -240,6 +246,11 @@
 <b>__resizeResultColumns</b>(<i></i>)
 <p>
         Private method to resize the list columns.
+</p><a NAME="RawMetricsDialog.clear" ID="RawMetricsDialog.clear"></a>
+<h4>RawMetricsDialog.clear</h4>
+<b>clear</b>(<i></i>)
+<p>
+        Public method to clear all results.
 </p><a NAME="RawMetricsDialog.on_buttonBox_clicked" ID="RawMetricsDialog.on_buttonBox_clicked"></a>
 <h4>RawMetricsDialog.on_buttonBox_clicked</h4>
 <b>on_buttonBox_clicked</b>(<i>button</i>)
@@ -250,7 +261,12 @@
 <dd>
 button that was clicked
 </dd>
-</dl><a NAME="RawMetricsDialog.on_startButton_clicked" ID="RawMetricsDialog.on_startButton_clicked"></a>
+</dl><a NAME="RawMetricsDialog.on_resultList_itemActivated" ID="RawMetricsDialog.on_resultList_itemActivated"></a>
+<h4>RawMetricsDialog.on_resultList_itemActivated</h4>
+<b>on_resultList_itemActivated</b>(<i>item, column</i>)
+<p>
+        Private slot to handle the activation of a result item.
+</p><a NAME="RawMetricsDialog.on_startButton_clicked" ID="RawMetricsDialog.on_startButton_clicked"></a>
 <h4>RawMetricsDialog.on_startButton_clicked</h4>
 <b>on_startButton_clicked</b>(<i></i>)
 <p>
--- a/RadonMetrics/MaintainabilityIndexDialog.py	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/MaintainabilityIndexDialog.py	Sun Sep 20 13:49:22 2015 +0200
@@ -34,6 +34,8 @@
     """
     Class implementing a dialog to show maintainability indexes.
     """
+    FilePathRole = Qt.UserRole + 1
+    
     def __init__(self, radonService, parent=None):
         """
         Constructor
@@ -110,6 +112,7 @@
         itm.setTextAlignment(2, Qt.Alignment(Qt.AlignHCenter))
         if values["rank"] in self.__rankColors:
             itm.setBackground(2, self.__rankColors[values["rank"]])
+        itm.setData(0, self.FilePathRole, filename)
         
         if values["rank"] in self.__summary:
             self.__summary[values["rank"]] += 1
@@ -170,7 +173,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)
@@ -358,6 +364,7 @@
             
             # reenable updates of the list
             self.resultList.setSortingEnabled(True)
+            self.resultList.sortItems(0, Qt.AscendingOrder)
             self.resultList.setUpdatesEnabled(True)
             
             self.cancelled = True
@@ -427,3 +434,20 @@
                     [f for f in fileList if not fnmatch.fnmatch(f, filter)]
         
         self.start(fileList)
+    
+    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)
+        if filename:
+            vm = e5App().getObject("ViewManager")
+            vm.openSourceFile(filename)
--- a/RadonMetrics/RawMetricsDialog.py	Sun Sep 20 12:17:19 2015 +0200
+++ b/RadonMetrics/RawMetricsDialog.py	Sun Sep 20 13:49:22 2015 +0200
@@ -35,6 +35,8 @@
     """
     Class implementing a dialog to show raw code metrics.
     """
+    FilePathRole = Qt.UserRole + 1
+    
     def __init__(self, radonService, parent=None):
         """
         Constructor
@@ -124,6 +126,7 @@
         itm = QTreeWidgetItem(self.resultList, data)
         for col in range(1, 10):
             itm.setTextAlignment(col, Qt.Alignment(Qt.AlignRight))
+        itm.setData(0, self.FilePathRole, filename)
     
     def __createErrorItem(self, filename, message):
         """
@@ -181,7 +184,10 @@
         """
         self.__errorItem = None
         self.resultList.clear()
+        self.summaryList.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)
@@ -386,6 +392,7 @@
             
             # reenable updates of the list
             self.resultList.setSortingEnabled(True)
+            self.resultList.sortItems(0, Qt.AscendingOrder)
             self.resultList.setUpdatesEnabled(True)
             
             self.__createSummary()
@@ -480,3 +487,20 @@
                     [f for f in fileList if not fnmatch.fnmatch(f, filter)]
         
         self.start(fileList)
+    
+    def clear(self):
+        """
+        Public method to clear all results.
+        """
+        self.resultList.clear()
+        self.summaryList.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)
+        if filename:
+            vm = e5App().getObject("ViewManager")
+            vm.openSourceFile(filename)

eric ide

mercurial