RadonMetrics/CyclomaticComplexityDialog.py

changeset 55
755bc8e1485a
parent 53
4a179abb79e6
child 60
cd2dd96c3c12
--- a/RadonMetrics/CyclomaticComplexityDialog.py	Sat Mar 31 13:05:51 2018 +0200
+++ b/RadonMetrics/CyclomaticComplexityDialog.py	Sun Nov 25 18:32:27 2018 +0100
@@ -42,12 +42,14 @@
     FilePathRole = Qt.UserRole + 1
     LineNumberRole = Qt.UserRole + 2
     
-    def __init__(self, radonService, parent=None):
+    def __init__(self, radonService, isSingle=False, parent=None):
         """
         Constructor
         
         @param radonService reference to the service
         @type RadonMetricsPlugin
+        @param isSingle flag indicating a single file dialog
+        @type bool
         @param parent reference to the parent widget
         @type QWidget
         """
@@ -69,6 +71,7 @@
         self.radonService.error.connect(self.__processError)
         self.radonService.batchFinished.connect(self.__batchFinished)
         
+        self.__isSingle = isSingle
         self.cancelled = False
         
         self.__project = e5App().getObject("Project")
@@ -251,15 +254,16 @@
         @param minRank minimum rank of entries to be shown
         @type str (one character out of A - F)
         """
+        self.cancelled = False
         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)
+        self.rankComboBox.setEnabled(False)
         QApplication.processEvents()
         
         if isinstance(fn, list):
@@ -278,6 +282,8 @@
         for f in self.files[:]:
             if not os.path.exists(f):
                 self.files.remove(f)
+        if self.__isSingle:
+            self.__fileList = self.files[:]
         
         self.__summary = {
             "A": 0,
@@ -290,7 +296,7 @@
         self.__ccSum = 0
         self.__ccCount = 0
         
-        self.__minimumRank = minRank
+        self.__minimumRank = self.rankComboBox.currentText()
         
         if len(self.files) > 0:
             # disable updates of the list for speed
@@ -475,6 +481,7 @@
             self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
             self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
             self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+            self.rankComboBox.setEnabled(True)
             
             self.resultList.header().resizeSections(
                 QHeaderView.ResizeToContents)
@@ -567,7 +574,7 @@
             self.__project.setData(
                 "OTHERTOOLSPARMS", "RadonCodeMetrics", self.__data)
         
-        self.start(fileList, minRank=minimumRank)
+        self.start(fileList)
     
     def __showContextMenu(self, coord):
         """
@@ -614,3 +621,14 @@
         if filename:
             vm = e5App().getObject("ViewManager")
             vm.openSourceFile(filename, lineno)
+    
+    @pyqtSlot(str)
+    def on_rankComboBox_activated(self, rank):
+        """
+        Private slot to handle the selection of a minimum rank.
+        
+        @param rank selected minimum rank
+        @type str
+        """
+        if self.__isSingle:
+            self.start(self.__fileList[:])

eric ide

mercurial