13 import fnmatch |
13 import fnmatch |
14 |
14 |
15 from PyQt5.QtCore import pyqtSlot, Qt, QTimer |
15 from PyQt5.QtCore import pyqtSlot, Qt, QTimer |
16 from PyQt5.QtGui import QIcon |
16 from PyQt5.QtGui import QIcon |
17 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QAbstractButton, \ |
17 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QAbstractButton, \ |
18 QDialogButtonBox, QApplication, QHeaderView |
18 QDialogButtonBox, QApplication, QHeaderView, QListWidgetItem |
19 |
19 |
20 from E5Gui.E5Application import e5App |
20 from E5Gui.E5Application import e5App |
21 |
21 |
22 from .Ui_CodeStyleCheckerDialog import Ui_CodeStyleCheckerDialog |
22 from .Ui_CodeStyleCheckerDialog import Ui_CodeStyleCheckerDialog |
23 |
23 |
75 UI.PixmapCache.getIcon("select.png")) |
75 UI.PixmapCache.getIcon("select.png")) |
76 |
76 |
77 self.docTypeComboBox.addItem(self.tr("PEP-257"), "pep257") |
77 self.docTypeComboBox.addItem(self.tr("PEP-257"), "pep257") |
78 self.docTypeComboBox.addItem(self.tr("Eric"), "eric") |
78 self.docTypeComboBox.addItem(self.tr("Eric"), "eric") |
79 |
79 |
80 self.futuresList.addItems(self.availableFutures) |
80 for future in CodeStyleCheckerDialog.availableFutures: |
|
81 itm = QListWidgetItem(future, self.futuresList) |
|
82 itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) |
|
83 itm.setCheckState(Qt.Unchecked) |
81 |
84 |
82 self.statisticsButton = self.buttonBox.addButton( |
85 self.statisticsButton = self.buttonBox.addButton( |
83 self.tr("Statistics..."), QDialogButtonBox.ActionRole) |
86 self.tr("Statistics..."), QDialogButtonBox.ActionRole) |
84 self.statisticsButton.setToolTip( |
87 self.statisticsButton.setToolTip( |
85 self.tr("Press to show some statistics for the last run")) |
88 self.tr("Press to show some statistics for the last run")) |
1136 if bool(i.strip())] |
1139 if bool(i.strip())] |
1137 else: |
1140 else: |
1138 expectedImports = [] |
1141 expectedImports = [] |
1139 for row in range(self.futuresList.count()): |
1142 for row in range(self.futuresList.count()): |
1140 itm = self.futuresList.item(row) |
1143 itm = self.futuresList.item(row) |
1141 itm.setSelected(itm.text() in expectedImports) |
1144 if itm.text() in expectedImports: |
1142 # TODO: change this to checkable items |
1145 itm.setCheckState(Qt.Checked) |
|
1146 else: |
|
1147 itm.setCheckState(Qt.Unchecked) |
1143 |
1148 |
1144 def __getSelectedFutureImports(self): |
1149 def __getSelectedFutureImports(self): |
1145 """ |
1150 """ |
1146 Private method to get the expected future imports. |
1151 Private method to get the expected future imports. |
1147 |
1152 |
1148 @return expected future imports as a comma separated string |
1153 @return expected future imports as a comma separated string |
1149 @rtype str |
1154 @rtype str |
1150 """ |
1155 """ |
1151 # TODO: change this to checkable items |
1156 selectedFutures = [] |
1152 selectedFutures = [i.text() for i in self.futuresList.selectedItems()] |
1157 for row in range(self.futuresList.count()): |
|
1158 itm = self.futuresList.item(row) |
|
1159 if itm.checkState() == Qt.Checked: |
|
1160 selectedFutures.append(itm.text()) |
1153 return ", ".join(selectedFutures) |
1161 return ", ".join(selectedFutures) |
1154 |
1162 |
1155 def __initBuiltinsIgnoreList(self, builtinsIgnoreDict): |
1163 def __initBuiltinsIgnoreList(self, builtinsIgnoreDict): |
1156 """ |
1164 """ |
1157 Private method to populate the list of shadowed builtins to be ignored. |
1165 Private method to populate the list of shadowed builtins to be ignored. |