DataViews/CodeMetricsDialog.py

changeset 570
43a680c5c8e6
parent 454
d28d558f7484
child 791
9ec2ac20e54e
diff -r 21191e634b47 -r 43a680c5c8e6 DataViews/CodeMetricsDialog.py
--- a/DataViews/CodeMetricsDialog.py	Sun Sep 05 13:36:40 2010 +0200
+++ b/DataViews/CodeMetricsDialog.py	Sun Sep 05 17:47:33 2010 +0200
@@ -8,14 +8,18 @@
 """
 
 import os
+import fnmatch
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
 from .Ui_CodeMetricsDialog import Ui_CodeMetricsDialog
 from . import CodeMetrics
+
 import Utilities
 
+import UI.PixmapCache
+
 class CodeMetricsDialog(QDialog, Ui_CodeMetricsDialog):
     """
     Class implementing a dialog to display the code metrics.
@@ -46,6 +50,11 @@
         self.resultList.setContextMenuPolicy(Qt.CustomContextMenu)
         self.resultList.customContextMenuRequested.connect(self.__showContextMenu)
         
+        self.__fileList = []
+        self.__project = None
+        self.clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png"))
+        self.filterFrame.setVisible(False)
+        
     def __resizeResultColumns(self):
         """
         Private method to resize the list columns.
@@ -84,13 +93,40 @@
         itm = QTreeWidgetItem(self.summaryList, [col0, col1])
         itm.setTextAlignment(1, Qt.Alignment(Qt.AlignRight))
         
+    def prepare(self, fileList, project):
+        """
+        Public method to prepare the dialog with a list of filenames.
+        
+        @param fileList list of filenames (list of strings)
+        @param project reference to the project object (Project)
+        """
+        self.__fileList = fileList[:]
+        self.__project = project
+        
+        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
+        self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+        
+        self.filterFrame.setVisible(True)
+        
+        self.__data = self.__project.getData("OTHERTOOLSPARMS", "CodeMetrics")
+        if self.__data is None or "ExcludeFiles" not in self.__data:
+            self.__data = {"ExcludeFiles" : ""}
+        self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
+        
     def start(self, fn):
         """
         Public slot to start the code metrics determination.
         
-        @param fn file or list of files or directory to be show
+        @param fn file or list of files or directory to show
                 the code metrics for (string or list of strings)
         """
+        self.cancelled = False
+        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
+        self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
+        self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
+        QApplication.processEvents()
+        
         loc = QLocale()
         if isinstance(fn, list):
             files = fn
@@ -200,6 +236,28 @@
         elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
             self.__finish()
         
+    @pyqtSlot()
+    def on_startButton_clicked(self):
+        """
+        Private slot to start a code metrics run.
+        """
+        fileList = self.__fileList[:]
+        
+        filterString = self.excludeFilesEdit.text()
+        if "ExcludeFiles" not in self.__data or \
+           filterString != self.__data["ExcludeFiles"]:
+            self.__data["ExcludeFiles"] = filterString
+            self.__project.setData("OTHERTOOLSPARMS", "CodeMetrics", self.__data)
+        filterList = filterString.split(",")
+        if filterList:
+            for filter in filterList:
+                fileList = \
+                    [f for f in fileList if not fnmatch.fnmatch(f, filter.strip())]
+        
+        self.resultList.clear()
+        self.summaryList.clear()
+        self.start(fileList)
+        
     def __showContextMenu(self, coord):
         """
         Private slot to show the context menu of the listview.

eric ide

mercurial