RadonMetrics/MaintainabilityIndexDialog.py

changeset 18
58ce8a433422
parent 15
62ffe3d426e5
child 24
edaf153da771
--- 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)

eric ide

mercurial