eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCodeSelectionDialog.py

branch
eric7
changeset 8790
548df4df8256
parent 8318
962bce857696
child 8881
54e42bc2437a
equal deleted inserted replaced
8789:b165effc3c62 8790:548df4df8256
14 14
15 from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog 15 from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog
16 16
17 from .translations import getMessageCodes, getTranslatedMessage 17 from .translations import getMessageCodes, getTranslatedMessage
18 18
19 import UI.PixmapCache 19 from . import CodeStyleCheckerUtilities
20 20
21 21
22 class CodeStyleCodeSelectionDialog(QDialog, Ui_CodeStyleCodeSelectionDialog): 22 class CodeStyleCodeSelectionDialog(QDialog, Ui_CodeStyleCodeSelectionDialog):
23 """ 23 """
24 Class implementing a dialog to select code style message codes. 24 Class implementing a dialog to select code style message codes.
56 ) 56 )
57 if categories: 57 if categories:
58 # filter by category 58 # filter by category
59 selectableCodes = [x for x in selectableCodes 59 selectableCodes = [x for x in selectableCodes
60 if x[0] not in categories] 60 if x[0] not in categories]
61 for code in sorted(selectableCodes): 61 for msgCode in sorted(selectableCodes):
62 message = getTranslatedMessage(code, [], example=True) 62 message = getTranslatedMessage(msgCode, [], example=True)
63 if message is None: 63 if message is None:
64 # try with extension 64 # try with extension
65 for ext in ("L", "M", "H", "1"): 65 for ext in ("L", "M", "H", "1"):
66 message = getTranslatedMessage("{0}.{1}".format(code, ext), 66 message = getTranslatedMessage(
67 [], example=True) 67 "{0}.{1}".format(msgCode, ext), [], example=True
68 )
68 if message is not None: 69 if message is not None:
69 break 70 break
70 else: 71 else:
71 continue 72 continue
72 itm = QTreeWidgetItem(self.codeTable, [ 73 itm = QTreeWidgetItem(self.codeTable, [
73 code, "\n".join(textWrapper.wrap(message))]) 74 msgCode, "\n".join(textWrapper.wrap(message))])
74 if code.startswith(("W", "C", "M")): 75 CodeStyleCheckerUtilities.setItemIcon(itm, 0, msgCode)
75 itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
76 elif code.startswith("E"):
77 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError"))
78 elif code.startswith(("A", "N")):
79 itm.setIcon(0, UI.PixmapCache.getIcon("namingError"))
80 elif code.startswith("D"):
81 itm.setIcon(0, UI.PixmapCache.getIcon("docstringError"))
82 elif code.startswith("S"):
83 itm.setIcon(0, UI.PixmapCache.getIcon("securityLow"))
84 elif code.startswith("P"):
85 itm.setIcon(0, UI.PixmapCache.getIcon("dirClosed"))
86 elif code.startswith("Y"):
87 itm.setIcon(0, UI.PixmapCache.getIcon("filePython"))
88 else:
89 # unknown category prefix => warning
90 itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
91 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) 76 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
92 if code in codeList: 77 if msgCode in codeList:
93 itm.setCheckState(0, Qt.CheckState.Checked) 78 itm.setCheckState(0, Qt.CheckState.Checked)
94 codeList.remove(code) 79 codeList.remove(msgCode)
95 else: 80 else:
96 itm.setCheckState(0, Qt.CheckState.Unchecked) 81 itm.setCheckState(0, Qt.CheckState.Unchecked)
97 self.codeTable.resizeColumnToContents(0) 82 self.codeTable.resizeColumnToContents(0)
98 self.codeTable.resizeColumnToContents(1) 83 self.codeTable.resizeColumnToContents(1)
99 self.codeTable.header().setStretchLastSection(True) 84 self.codeTable.header().setStretchLastSection(True)

eric ide

mercurial