Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

changeset 571
1a4101cb87eb
parent 564
b3d966393ba9
child 678
d388291f5b6c
diff -r 43a680c5c8e6 -r 1a4101cb87eb Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Sun Sep 05 17:47:33 2010 +0200
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Sun Sep 05 18:34:37 2010 +0200
@@ -8,6 +8,7 @@
 """
 
 import os
+import fnmatch
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
@@ -54,6 +55,11 @@
         self.cancelled = False
         self.__lastFileItem = None
         
+        self.__fileList = []
+        self.__project = None
+        self.clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png"))
+        self.filterFrame.setVisible(False)
+        
     def __resort(self):
         """
         Private method to resort the tree.
@@ -90,6 +96,27 @@
         itm.setData(0, self.errorRole, error)
         itm.setData(0, self.warningRole, isWarning)
         
+    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("CHECKERSPARMS", "SyntaxChecker")
+        if self.__data is None or "ExcludeFiles" not in self.__data:
+            self.__data = {"ExcludeFiles" : ""}
+        self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
+        
     def start(self, fn, codestring = ""):
         """
         Public slot to start the syntax check.
@@ -99,6 +126,12 @@
         @param codestring string containing the code to be checked (string).
             If this is given, file must be a single file name.
         """
+        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()
+        
         if isinstance(fn, list):
             files = fn
         elif os.path.isdir(fn):
@@ -198,6 +231,27 @@
         elif button == self.showButton:
             self.on_showButton_clicked()
         
+    @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("CHECKERSPARMS", "SyntaxChecker", 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.start(fileList)
+        
     def on_resultList_itemActivated(self, itm, col):
         """
         Private slot to handle the activation of an item. 
@@ -256,4 +310,4 @@
         for file in openFiles:
             editor = vm.getOpenEditor(file)
             editor.clearSyntaxError()
-            editor.clearFlakesWarnings()
\ No newline at end of file
+            editor.clearFlakesWarnings()

eric ide

mercurial