eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py

branch
eric7
changeset 8790
548df4df8256
parent 8318
962bce857696
child 8881
54e42bc2437a
diff -r b165effc3c62 -r 548df4df8256 eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py
--- a/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py	Wed Nov 24 20:08:25 2021 +0100
+++ b/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py	Thu Nov 25 17:48:51 2021 +0100
@@ -16,7 +16,7 @@
 
 from .translations import getMessageCodes, getTranslatedMessage
 
-import UI.PixmapCache
+from . import CodeStyleCheckerUtilities
 
 
 class CodeStyleCodeSelectionDialog(QDialog, Ui_CodeStyleCodeSelectionDialog):
@@ -58,40 +58,25 @@
                 # filter by category
                 selectableCodes = [x for x in selectableCodes
                                    if x[0] not in categories]
-        for code in sorted(selectableCodes):
-            message = getTranslatedMessage(code, [], example=True)
+        for msgCode in sorted(selectableCodes):
+            message = getTranslatedMessage(msgCode, [], example=True)
             if message is None:
                 # try with extension
                 for ext in ("L", "M", "H", "1"):
-                    message = getTranslatedMessage("{0}.{1}".format(code, ext),
-                                                   [], example=True)
+                    message = getTranslatedMessage(
+                        "{0}.{1}".format(msgCode, ext), [], example=True
+                    )
                     if message is not None:
                         break
                 else:
                     continue
             itm = QTreeWidgetItem(self.codeTable, [
-                code, "\n".join(textWrapper.wrap(message))])
-            if code.startswith(("W", "C", "M")):
-                itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
-            elif code.startswith("E"):
-                itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError"))
-            elif code.startswith(("A", "N")):
-                itm.setIcon(0, UI.PixmapCache.getIcon("namingError"))
-            elif code.startswith("D"):
-                itm.setIcon(0, UI.PixmapCache.getIcon("docstringError"))
-            elif code.startswith("S"):
-                itm.setIcon(0, UI.PixmapCache.getIcon("securityLow"))
-            elif code.startswith("P"):
-                itm.setIcon(0, UI.PixmapCache.getIcon("dirClosed"))
-            elif code.startswith("Y"):
-                itm.setIcon(0, UI.PixmapCache.getIcon("filePython"))
-            else:
-                # unknown category prefix => warning
-                itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
+                msgCode, "\n".join(textWrapper.wrap(message))])
+            CodeStyleCheckerUtilities.setItemIcon(itm, 0, msgCode)
             itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
-            if code in codeList:
+            if msgCode in codeList:
                 itm.setCheckState(0, Qt.CheckState.Checked)
-                codeList.remove(code)
+                codeList.remove(msgCode)
             else:
                 itm.setCheckState(0, Qt.CheckState.Unchecked)
         self.codeTable.resizeColumnToContents(0)

eric ide

mercurial