Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 5636
709a306baa81
parent 5625
b75a6da67559
child 5661
ae4f5cdc3d00
--- 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):

eric ide

mercurial