Changed some lists of the style checker to contain checkable items.

Sat, 18 Mar 2017 16:20:08 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 18 Mar 2017 16:20:08 +0100
changeset 5636
709a306baa81
parent 5632
d8ba4e4779a3
child 5637
468856aafa10

Changed some lists of the style checker to contain checkable items.

Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Sat Mar 18 14:39:01 2017 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Sat Mar 18 16:20:08 2017 +0100
@@ -15,7 +15,7 @@
 from PyQt5.QtCore import pyqtSlot, Qt, QTimer
 from PyQt5.QtGui import QIcon
 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QAbstractButton, \
-    QDialogButtonBox, QApplication, QHeaderView
+    QDialogButtonBox, QApplication, QHeaderView, QListWidgetItem
 
 from E5Gui.E5Application import e5App
 
@@ -77,7 +77,10 @@
         self.docTypeComboBox.addItem(self.tr("PEP-257"), "pep257")
         self.docTypeComboBox.addItem(self.tr("Eric"), "eric")
         
-        self.futuresList.addItems(self.availableFutures)
+        for future in CodeStyleCheckerDialog.availableFutures:
+            itm = QListWidgetItem(future, self.futuresList)
+            itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
+            itm.setCheckState(Qt.Unchecked)
         
         self.statisticsButton = self.buttonBox.addButton(
             self.tr("Statistics..."), QDialogButtonBox.ActionRole)
@@ -1138,8 +1141,10 @@
             expectedImports = []
         for row in range(self.futuresList.count()):
             itm = self.futuresList.item(row)
-            itm.setSelected(itm.text() in expectedImports)
-        # TODO: change this to checkable items
+            if itm.text() in expectedImports:
+                itm.setCheckState(Qt.Checked)
+            else:
+                itm.setCheckState(Qt.Unchecked)
     
     def __getSelectedFutureImports(self):
         """
@@ -1148,8 +1153,11 @@
         @return expected future imports as a comma separated string
         @rtype str
         """
-        # TODO: change this to checkable items
-        selectedFutures = [i.text() for i in self.futuresList.selectedItems()]
+        selectedFutures = []
+        for row in range(self.futuresList.count()):
+            itm = self.futuresList.item(row)
+            if itm.checkState() == Qt.Checked:
+                selectedFutures.append(itm.text())
         return ", ".join(selectedFutures)
     
     def __initBuiltinsIgnoreList(self, builtinsIgnoreDict):
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py	Sat Mar 18 14:39:01 2017 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py	Sat Mar 18 16:20:08 2017 +0100
@@ -9,6 +9,7 @@
 
 from __future__ import unicode_literals
 
+from PyQt5.QtCore import Qt
 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
 
 from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog
@@ -59,10 +60,12 @@
                 itm.setIcon(0, UI.PixmapCache.getIcon("namingError.png"))
             elif code.startswith("D"):
                 itm.setIcon(0, UI.PixmapCache.getIcon("docstringError.png"))
+            itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
             if code in codeList:
-                itm.setSelected(True)
+                itm.setCheckState(0, Qt.Checked)
                 codeList.remove(code)
-                # TODO: change this to checkable items
+            else:
+                itm.setCheckState(0, Qt.Unchecked)
         self.codeTable.resizeColumnToContents(0)
         self.codeTable.resizeColumnToContents(1)
         self.codeTable.header().setStretchLastSection(True)
@@ -77,8 +80,9 @@
         """
         selectedCodes = []
         
-        # TODO: change this to checkable items
-        for itm in self.codeTable.selectedItems():
-            selectedCodes.append(itm.text(0))
+        for index in range(self.codeTable.topLevelItemCount()):
+            itm = self.codeTable.topLevelItem(index)
+            if itm.checkState(0) == Qt.Checked:
+                selectedCodes.append(itm.text(0))
         
         return ", ".join(self.__extraCodes + selectedCodes)

eric ide

mercurial