92 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
92 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
93 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
93 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
94 |
94 |
95 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
95 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
96 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
96 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
|
97 |
|
98 self.addBuiltinButton.setIcon(UI.PixmapCache.getIcon("plus.png")) |
|
99 self.deleteBuiltinButton.setIcon(UI.PixmapCache.getIcon("minus.png")) |
97 |
100 |
98 self.checkProgress.setVisible(False) |
101 self.checkProgress.setVisible(False) |
99 self.checkProgressLabel.setVisible(False) |
102 self.checkProgressLabel.setVisible(False) |
100 self.checkProgressLabel.setMaximumWidth(600) |
103 self.checkProgressLabel.setMaximumWidth(600) |
101 |
104 |
323 "CopyrightAuthor" not in self.__data: |
326 "CopyrightAuthor" not in self.__data: |
324 self.__data["CopyrightMinFileSize"] = 0 |
327 self.__data["CopyrightMinFileSize"] = 0 |
325 self.__data["CopyrightAuthor"] = "" |
328 self.__data["CopyrightAuthor"] = "" |
326 if "FutureChecker" not in self.__data: |
329 if "FutureChecker" not in self.__data: |
327 self.__data["FutureChecker"] = "" |
330 self.__data["FutureChecker"] = "" |
|
331 if "BuiltinsChecker" not in self.__data: |
|
332 self.__data["BuiltinsChecker"] = { |
|
333 "str": ["unicode", ], |
|
334 "chr": ["unichr", ], |
|
335 } |
328 |
336 |
329 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
337 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
330 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
338 self.excludeMessagesEdit.setText(self.__data["ExcludeMessages"]) |
331 self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) |
339 self.includeMessagesEdit.setText(self.__data["IncludeMessages"]) |
332 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) |
340 self.repeatCheckBox.setChecked(self.__data["RepeatMessages"]) |
342 self.encodingsEdit.setText(self.__data["ValidEncodings"]) |
350 self.encodingsEdit.setText(self.__data["ValidEncodings"]) |
343 self.copyrightFileSizeSpinBox.setValue( |
351 self.copyrightFileSizeSpinBox.setValue( |
344 self.__data["CopyrightMinFileSize"]) |
352 self.__data["CopyrightMinFileSize"]) |
345 self.copyrightAuthorEdit.setText(self.__data["CopyrightAuthor"]) |
353 self.copyrightAuthorEdit.setText(self.__data["CopyrightAuthor"]) |
346 self.__initFuturesList(self.__data["FutureChecker"]) |
354 self.__initFuturesList(self.__data["FutureChecker"]) |
|
355 self.__initBuiltinsIgnoreList(self.__data["BuiltinsChecker"]) |
347 |
356 |
348 def start(self, fn, save=False, repeat=None): |
357 def start(self, fn, save=False, repeat=None): |
349 """ |
358 """ |
350 Public slot to start the code style check. |
359 Public slot to start the code style check. |
351 |
360 |
428 "CopyrightChecker": { |
437 "CopyrightChecker": { |
429 "MinFilesize": self.copyrightFileSizeSpinBox.value(), |
438 "MinFilesize": self.copyrightFileSizeSpinBox.value(), |
430 "Author": self.copyrightAuthorEdit.text(), |
439 "Author": self.copyrightAuthorEdit.text(), |
431 }, |
440 }, |
432 "FutureChecker": self.__getSelectedFutureImports(), |
441 "FutureChecker": self.__getSelectedFutureImports(), |
|
442 "BuiltinsChecker": self.__getBuiltinsIgnoreList(), |
433 } |
443 } |
434 |
444 |
435 self.__options = [excludeMessages, includeMessages, repeatMessages, |
445 self.__options = [excludeMessages, includeMessages, repeatMessages, |
436 fixCodes, noFixCodes, fixIssues, maxLineLength, |
446 fixCodes, noFixCodes, fixIssues, maxLineLength, |
437 hangClosing, docType, maxCodeComplexity, |
447 hangClosing, docType, maxCodeComplexity, |
753 "MaxCodeComplexity": self.complexitySpinBox.value(), |
763 "MaxCodeComplexity": self.complexitySpinBox.value(), |
754 "ValidEncodings": self.encodingsEdit.text(), |
764 "ValidEncodings": self.encodingsEdit.text(), |
755 "CopyrightMinFileSize": self.copyrightFileSizeSpinBox.value(), |
765 "CopyrightMinFileSize": self.copyrightFileSizeSpinBox.value(), |
756 "CopyrightAuthor": self.copyrightAuthorEdit.text(), |
766 "CopyrightAuthor": self.copyrightAuthorEdit.text(), |
757 "FutureChecker": self.__getSelectedFutureImports(), |
767 "FutureChecker": self.__getSelectedFutureImports(), |
|
768 "BuiltinsChecker": self.__getBuiltinsIgnoreList(), |
758 } |
769 } |
759 if data != self.__data: |
770 if data != self.__data: |
760 self.__data = data |
771 self.__data = data |
761 self.__project.setData("CHECKERSPARMS", "Pep8Checker", |
772 self.__project.setData("CHECKERSPARMS", "Pep8Checker", |
762 self.__data) |
773 self.__data) |
934 Preferences.Prefs.settings.value("PEP8/CopyrightMinFileSize", 0))) |
945 Preferences.Prefs.settings.value("PEP8/CopyrightMinFileSize", 0))) |
935 self.copyrightAuthorEdit.setText( |
946 self.copyrightAuthorEdit.setText( |
936 Preferences.Prefs.settings.value("PEP8/CopyrightAuthor", "")) |
947 Preferences.Prefs.settings.value("PEP8/CopyrightAuthor", "")) |
937 self.__initFuturesList( |
948 self.__initFuturesList( |
938 Preferences.Prefs.settings.value("PEP8/FutureChecker", "")) |
949 Preferences.Prefs.settings.value("PEP8/FutureChecker", "")) |
|
950 self.__initBuiltinsIgnoreList(Preferences.toDict( |
|
951 Preferences.Prefs.settings.value("PEP8/BuiltinsChecker", { |
|
952 "str": ["unicode", ], |
|
953 "chr": ["unichr", ], |
|
954 }))) |
939 |
955 |
940 @pyqtSlot() |
956 @pyqtSlot() |
941 def on_storeDefaultButton_clicked(self): |
957 def on_storeDefaultButton_clicked(self): |
942 """ |
958 """ |
943 Private slot to store the current configuration values as |
959 Private slot to store the current configuration values as |
974 "PEP8/CopyrightMinFileSize", self.copyrightFileSizeSpinBox.value()) |
990 "PEP8/CopyrightMinFileSize", self.copyrightFileSizeSpinBox.value()) |
975 Preferences.Prefs.settings.setValue( |
991 Preferences.Prefs.settings.setValue( |
976 "PEP8/CopyrightAuthor", self.copyrightAuthorEdit.text()) |
992 "PEP8/CopyrightAuthor", self.copyrightAuthorEdit.text()) |
977 Preferences.Prefs.settings.setValue( |
993 Preferences.Prefs.settings.setValue( |
978 "PEP8/FutureChecker", self.__getSelectedFutureImports()) |
994 "PEP8/FutureChecker", self.__getSelectedFutureImports()) |
|
995 Preferences.Prefs.settings.setValue( |
|
996 "PEP8/BuiltinsChecker", self.__getBuiltinsIgnoreList()) |
979 |
997 |
980 @pyqtSlot() |
998 @pyqtSlot() |
981 def on_resetDefaultButton_clicked(self): |
999 def on_resetDefaultButton_clicked(self): |
982 """ |
1000 """ |
983 Private slot to reset the configuration values to their default values. |
1001 Private slot to reset the configuration values to their default values. |
999 Preferences.Prefs.settings.setValue( |
1017 Preferences.Prefs.settings.setValue( |
1000 "PEP8/ValidEncodings", "latin-1, utf-8") |
1018 "PEP8/ValidEncodings", "latin-1, utf-8") |
1001 Preferences.Prefs.settings.setValue("PEP8/CopyrightMinFileSize", 0) |
1019 Preferences.Prefs.settings.setValue("PEP8/CopyrightMinFileSize", 0) |
1002 Preferences.Prefs.settings.setValue("PEP8/CopyrightAuthor", "") |
1020 Preferences.Prefs.settings.setValue("PEP8/CopyrightAuthor", "") |
1003 Preferences.Prefs.settings.setValue("PEP8/FutureChecker", "") |
1021 Preferences.Prefs.settings.setValue("PEP8/FutureChecker", "") |
|
1022 Preferences.Prefs.settings.setValue("PEP8/BuiltinsChecker", { |
|
1023 "str": ["unicode", ], |
|
1024 "chr": ["unichr", ], |
|
1025 }) |
1004 |
1026 |
1005 @pyqtSlot(QAbstractButton) |
1027 @pyqtSlot(QAbstractButton) |
1006 def on_buttonBox_clicked(self, button): |
1028 def on_buttonBox_clicked(self, button): |
1007 """ |
1029 """ |
1008 Private slot called by a button of the button box clicked. |
1030 Private slot called by a button of the button box clicked. |
1115 else: |
1137 else: |
1116 expectedImports = [] |
1138 expectedImports = [] |
1117 for row in range(self.futuresList.count()): |
1139 for row in range(self.futuresList.count()): |
1118 itm = self.futuresList.item(row) |
1140 itm = self.futuresList.item(row) |
1119 itm.setSelected(itm.text() in expectedImports) |
1141 itm.setSelected(itm.text() in expectedImports) |
|
1142 # TODO: change this to checkable items |
1120 |
1143 |
1121 def __getSelectedFutureImports(self): |
1144 def __getSelectedFutureImports(self): |
1122 """ |
1145 """ |
1123 Private method to get the expected future imports. |
1146 Private method to get the expected future imports. |
1124 |
1147 |
1125 @return expected future imports as a comma separated string |
1148 @return expected future imports as a comma separated string |
1126 @rtype str |
1149 @rtype str |
1127 """ |
1150 """ |
1128 selectedFutures = [i.text() for i in self.futuresList.selectedItems()] |
1151 selectedFutures = [i.text() for i in self.futuresList.selectedItems()] |
1129 return ", ".join(selectedFutures) |
1152 return ", ".join(selectedFutures) |
|
1153 |
|
1154 def __initBuiltinsIgnoreList(self, builtinsIgnoreDict): |
|
1155 """ |
|
1156 Private method to populate the list of shadowed builtins to be ignored. |
|
1157 |
|
1158 @param builtinsIgnoreDict dictionary containing the builtins |
|
1159 assignments to be ignored |
|
1160 @type dict of list of str |
|
1161 """ |
|
1162 self.builtinsAssignmentList.clear() |
|
1163 for left, rightList in builtinsIgnoreDict.items(): |
|
1164 for right in rightList: |
|
1165 QTreeWidgetItem(self.builtinsAssignmentList, [left, right]) |
|
1166 |
|
1167 self.on_builtinsAssignmentList_itemSelectionChanged() |
|
1168 |
|
1169 def __getBuiltinsIgnoreList(self): |
|
1170 """ |
|
1171 Private method to get a dictionary containing the builtins assignments |
|
1172 to be ignored. |
|
1173 |
|
1174 @return dictionary containing the builtins assignments to be ignored |
|
1175 @rtype dict of list of str |
|
1176 """ |
|
1177 builtinsIgnoreDict = {} |
|
1178 for row in range(self.builtinsAssignmentList.topLevelItemCount()): |
|
1179 itm = self.builtinsAssignmentList.topLevelItem(row) |
|
1180 left, right = itm.text(0), itm.text(1) |
|
1181 if left not in builtinsIgnoreDict: |
|
1182 builtinsIgnoreDict[left] = [] |
|
1183 builtinsIgnoreDict[left].append(right) |
|
1184 |
|
1185 return builtinsIgnoreDict |
|
1186 |
|
1187 @pyqtSlot() |
|
1188 def on_builtinsAssignmentList_itemSelectionChanged(self): |
|
1189 """ |
|
1190 Private slot to react upon changes of the selected builtin assignments. |
|
1191 """ |
|
1192 self.deleteBuiltinButton.setEnabled( |
|
1193 len(self.builtinsAssignmentList.selectedItems()) > 0) |
|
1194 |
|
1195 @pyqtSlot() |
|
1196 def on_addBuiltinButton_clicked(self): |
|
1197 """ |
|
1198 Slot documentation goes here. |
|
1199 """ |
|
1200 from .CodeStyleAddBuiltinIgnoreDialog import \ |
|
1201 CodeStyleAddBuiltinIgnoreDialog |
|
1202 dlg = CodeStyleAddBuiltinIgnoreDialog(self) |
|
1203 if dlg.exec_() == QDialog.Accepted: |
|
1204 left, right = dlg.getData() |
|
1205 QTreeWidgetItem(self.builtinsAssignmentList, [left, right]) |
|
1206 |
|
1207 @pyqtSlot() |
|
1208 def on_deleteBuiltinButton_clicked(self): |
|
1209 """ |
|
1210 Private slot to delete the selected items from the list. |
|
1211 """ |
|
1212 for itm in self.builtinsAssignmentList.selectedItems(): |
|
1213 index = self.builtinsAssignmentList.indexOfTopLevelItem(itm) |
|
1214 self.builtinsAssignmentList.takeTopLevelItem(index) |
|
1215 del itm |