7 Module implementing a dialog to select code style message codes. |
7 Module implementing a dialog to select code style message codes. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
|
12 from PyQt5.QtCore import Qt |
12 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
13 |
14 |
14 from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog |
15 from .Ui_CodeStyleCodeSelectionDialog import Ui_CodeStyleCodeSelectionDialog |
15 |
16 |
16 import UI.PixmapCache |
17 import UI.PixmapCache |
57 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) |
58 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) |
58 elif code.startswith("N"): |
59 elif code.startswith("N"): |
59 itm.setIcon(0, UI.PixmapCache.getIcon("namingError.png")) |
60 itm.setIcon(0, UI.PixmapCache.getIcon("namingError.png")) |
60 elif code.startswith("D"): |
61 elif code.startswith("D"): |
61 itm.setIcon(0, UI.PixmapCache.getIcon("docstringError.png")) |
62 itm.setIcon(0, UI.PixmapCache.getIcon("docstringError.png")) |
|
63 itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) |
62 if code in codeList: |
64 if code in codeList: |
63 itm.setSelected(True) |
65 itm.setCheckState(0, Qt.Checked) |
64 codeList.remove(code) |
66 codeList.remove(code) |
65 # TODO: change this to checkable items |
67 else: |
|
68 itm.setCheckState(0, Qt.Unchecked) |
66 self.codeTable.resizeColumnToContents(0) |
69 self.codeTable.resizeColumnToContents(0) |
67 self.codeTable.resizeColumnToContents(1) |
70 self.codeTable.resizeColumnToContents(1) |
68 self.codeTable.header().setStretchLastSection(True) |
71 self.codeTable.header().setStretchLastSection(True) |
69 |
72 |
70 self.__extraCodes = codeList[:] |
73 self.__extraCodes = codeList[:] |
75 |
78 |
76 @return comma separated list of selected codes (string) |
79 @return comma separated list of selected codes (string) |
77 """ |
80 """ |
78 selectedCodes = [] |
81 selectedCodes = [] |
79 |
82 |
80 # TODO: change this to checkable items |
83 for index in range(self.codeTable.topLevelItemCount()): |
81 for itm in self.codeTable.selectedItems(): |
84 itm = self.codeTable.topLevelItem(index) |
82 selectedCodes.append(itm.text(0)) |
85 if itm.checkState(0) == Qt.Checked: |
|
86 selectedCodes.append(itm.text(0)) |
83 |
87 |
84 return ", ".join(self.__extraCodes + selectedCodes) |
88 return ", ".join(self.__extraCodes + selectedCodes) |