--- a/VultureChecker/VultureCheckerDialog.py Tue May 25 19:30:18 2021 +0200 +++ b/VultureChecker/VultureCheckerDialog.py Tue May 25 19:36:03 2021 +0200 @@ -11,15 +11,15 @@ import fnmatch import contextlib -from PyQt5.QtCore import pyqtSlot, qVersion, Qt, QTimer, QRegExp -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot, Qt, QTimer +from PyQt6.QtWidgets import ( QDialog, QDialogButtonBox, QAbstractButton, QHeaderView, QTreeWidgetItem, QApplication, QMenu ) from .Ui_VultureCheckerDialog import Ui_VultureCheckerDialog -from E5Gui.E5Application import e5App +from EricWidgets.EricApplication import ericApp import Preferences import Utilities @@ -59,8 +59,8 @@ """ Class implementing a dialog to show the vulture check results. """ - FilePathRole = Qt.UserRole + 1 - TypeRole = Qt.UserRole + 2 + FilePathRole = Qt.ItemDataRole.UserRole + 1 + TypeRole = Qt.ItemDataRole.UserRole + 2 def __init__(self, vultureService, parent=None): """ @@ -73,10 +73,12 @@ """ super().__init__(parent) self.setupUi(self) - self.setWindowFlags(Qt.Window) + self.setWindowFlags(Qt.WindowType.Window) - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) self.resultList.headerItem().setText(self.resultList.columnCount(), "") @@ -101,7 +103,7 @@ self.cancelled = False - self.__project = e5App().getObject("Project") + self.__project = ericApp().getObject("Project") self.__finished = True self.__errorItem = None self.__data = None @@ -133,13 +135,13 @@ self.__errorItem = QTreeWidgetItem(self.resultList, [ self.tr("Errors")]) self.__errorItem.setExpanded(True) - self.__errorItem.setForeground(0, Qt.red) + self.__errorItem.setForeground(0, Qt.GlobalColor.red) msg = "{0} ({1})".format(self.__project.getRelativePath(filename), message) - if not self.resultList.findItems(msg, Qt.MatchExactly): + if not self.resultList.findItems(msg, Qt.MatchFlag.MatchExactly): itm = QTreeWidgetItem(self.__errorItem, [msg]) - itm.setForeground(0, Qt.red) + itm.setForeground(0, Qt.GlobalColor.red) itm.setFirstColumnSpanned(True) def prepare(self, fileList, project): @@ -154,9 +156,12 @@ self.__fileList = fileList[:] self.__project = project - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) self.filterFrame.setVisible(True) @@ -197,11 +202,13 @@ self.cancelled = False self.__errorItem = None self.resultList.clear() - QApplication.processEvents() - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setDefault(True) QApplication.processEvents() self.__prepareResultLists() @@ -210,8 +217,7 @@ self.files = fn elif os.path.isdir(fn): self.files = [] - extensions = set(Preferences.getPython("PythonExtensions") + - Preferences.getPython("Python3Extensions")) + extensions = set(Preferences.getPython("Python3Extensions")) for ext in extensions: self.files.extend( Utilities.direntries(fn, True, '*{0}'.format(ext), 0)) @@ -373,22 +379,22 @@ # reenable updates of the list self.resultList.setSortingEnabled(True) - self.resultList.sortItems(0, Qt.AscendingOrder) + self.resultList.sortItems(0, Qt.SortOrder.AscendingOrder) self.resultList.setUpdatesEnabled(True) self.cancelled = True - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) self.resultList.header().resizeSections( QHeaderView.ResizeToContents) self.resultList.header().setStretchLastSection(True) - if qVersion() >= "5.0.0": - self.resultList.header().setSectionResizeMode( - QHeaderView.Interactive) - else: - self.resultList.header().setResizeMode(QHeaderView.Interactive) + self.resultList.header().setSectionResizeMode( + QHeaderView.ResizeMode.Interactive) self.checkProgress.setVisible(False) self.checkProgressLabel.setVisible(False) @@ -406,9 +412,13 @@ @param button button that was clicked @type QAbstractButton """ - if button == self.buttonBox.button(QDialogButtonBox.Close): + if button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Close + ): self.close() - elif button == self.buttonBox.button(QDialogButtonBox.Cancel): + elif button == self.buttonBox.button( + QDialogButtonBox.StandardButton.Cancel + ): self.cancelled = True if self.__batch: self.vultureService.cancelVultureCheckBatch() @@ -460,7 +470,7 @@ except ValueError: lineno = 1 if filename: - vm = e5App().getObject("ViewManager") + vm = ericApp().getObject("ViewManager") vm.openSourceFile(filename, lineno) def __prepareResultLists(self): @@ -521,9 +531,8 @@ """ filteredList = itemList for pattern in self.__data["WhiteLists"]["__patterns__"]: - regExp = QRegExp(pattern, Qt.CaseSensitive, QRegExp.Wildcard) filteredList = [item for item in filteredList - if not regExp.exactMatch(item.name)] + if not fnmatch.fnmatchcase(item.name, pattern)] return filteredList # __IGNORE_WARNING_M834__ def __filterUnusedItems(self, unused, whitelistName): @@ -643,8 +652,8 @@ "{0:3d}%".format(item.confidence), translatedType]) itm.setData(0, self.FilePathRole, item.filename) itm.setData(0, self.TypeRole, item.typ) - itm.setTextAlignment(0, Qt.Alignment(Qt.AlignRight)) # line no - itm.setTextAlignment(2, Qt.Alignment(Qt.AlignRight)) # confidence + itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight) # line no + itm.setTextAlignment(2, Qt.AlignmentFlag.AlignRight) # confidence def __createFileItem(self, filename): """ @@ -709,7 +718,7 @@ """ from .EditWhiteListDialog import EditWhiteListDialog dlg = EditWhiteListDialog(self.__data["WhiteLists"]) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: whitelists = dlg.getWhiteLists() self.__storeWhiteLists(whitelists)