eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 8143
2c730d5fd177
parent 7980
2c3f14a3c595
child 8166
bd5cd5858503
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Tue Mar 02 17:17:09 2021 +0100
@@ -42,14 +42,14 @@
     """
     Class implementing a dialog to show the results of the code style check.
     """
-    filenameRole = Qt.UserRole + 1
-    lineRole = Qt.UserRole + 2
-    positionRole = Qt.UserRole + 3
-    messageRole = Qt.UserRole + 4
-    fixableRole = Qt.UserRole + 5
-    codeRole = Qt.UserRole + 6
-    ignoredRole = Qt.UserRole + 7
-    argsRole = Qt.UserRole + 8
+    filenameRole = Qt.ItemDataRole.UserRole + 1
+    lineRole = Qt.ItemDataRole.UserRole + 2
+    positionRole = Qt.ItemDataRole.UserRole + 3
+    messageRole = Qt.ItemDataRole.UserRole + 4
+    fixableRole = Qt.ItemDataRole.UserRole + 5
+    codeRole = Qt.ItemDataRole.UserRole + 6
+    ignoredRole = Qt.ItemDataRole.UserRole + 7
+    argsRole = Qt.ItemDataRole.UserRole + 8
     
     availableFutures = [
         'division', 'absolute_import', 'with_statement',
@@ -108,7 +108,7 @@
         """
         super(CodeStyleCheckerDialog, self).__init__(parent)
         self.setupUi(self)
-        self.setWindowFlags(Qt.Window)
+        self.setWindowFlags(Qt.WindowType.Window)
         
         self.__project = project
         
@@ -128,14 +128,14 @@
         
         for category, text in CodeStyleCheckerDialog.checkCategories.items():
             itm = QListWidgetItem(text, self.categoriesList)
-            itm.setData(Qt.UserRole, category)
-            itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
-            itm.setCheckState(Qt.Unchecked)
+            itm.setData(Qt.ItemDataRole.UserRole, category)
+            itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
+            itm.setCheckState(Qt.CheckState.Unchecked)
         
         for future in CodeStyleCheckerDialog.availableFutures:
             itm = QListWidgetItem(future, self.futuresList)
-            itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
-            itm.setCheckState(Qt.Unchecked)
+            itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
+            itm.setCheckState(Qt.CheckState.Unchecked)
         
         self.dsaHighRiskCombo.addItems(
             CodeStyleCheckerDialog.cryptoBitSelectionsDsaRsa)
@@ -153,10 +153,12 @@
         self.statisticsButton.setEnabled(False)
         self.showButton.setEnabled(False)
         self.cancelButton.setEnabled(True)
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(False)
         
         self.resultList.headerItem().setText(self.resultList.columnCount(), "")
-        self.resultList.header().setSortIndicator(0, Qt.AscendingOrder)
+        self.resultList.header().setSortIndicator(
+            0, Qt.SortOrder.AscendingOrder)
         
         self.addBuiltinButton.setIcon(UI.PixmapCache.getIcon("plus"))
         self.deleteBuiltinButton.setIcon(UI.PixmapCache.getIcon("minus"))
@@ -217,13 +219,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 __createFileErrorItem(self, filename, message):
@@ -309,12 +311,12 @@
             itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable"))
             fixable = True
         
-        itm.setTextAlignment(0, Qt.AlignRight)
-        itm.setTextAlignment(1, Qt.AlignHCenter)
+        itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
+        itm.setTextAlignment(1, Qt.AlignmentFlag.AlignHCenter)
         
-        itm.setTextAlignment(0, Qt.AlignVCenter)
-        itm.setTextAlignment(1, Qt.AlignVCenter)
-        itm.setTextAlignment(2, Qt.AlignVCenter)
+        itm.setTextAlignment(0, Qt.AlignmentFlag.AlignVCenter)
+        itm.setTextAlignment(1, Qt.AlignmentFlag.AlignVCenter)
+        itm.setTextAlignment(2, Qt.AlignmentFlag.AlignVCenter)
         
         itm.setData(0, self.filenameRole, filename)
         itm.setData(0, self.lineRole, int(result["line"]))
@@ -412,8 +414,10 @@
         self.__project = project
         self.__forProject = True
         
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
-        self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(True)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setDefault(True)
         self.cancelButton.setEnabled(False)
         
         self.__data = self.__project.getData("CHECKERSPARMS", "Pep8Checker")
@@ -614,7 +618,8 @@
         self.mainWidget.setCurrentWidget(self.progressTab)
         
         self.cancelled = False
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setEnabled(False)
         self.cancelButton.setEnabled(True)
         self.cancelButton.setDefault(True)
         self.statisticsButton.setEnabled(False)
@@ -1008,7 +1013,7 @@
         self.checkProgressLabel.setPath(fn)
         
         # remove file from the list of jobs to do
-        fileItems = self.progressList.findItems(fn, Qt.MatchExactly)
+        fileItems = self.progressList.findItems(fn, Qt.MatchFlag.MatchExactly)
         if fileItems:
             row = self.progressList.row(fileItems[0])
             self.progressList.takeItem(row)
@@ -1024,8 +1029,10 @@
             self.__finished = True
             
             self.cancelled = True
-            self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
-            self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+            self.buttonBox.button(
+                QDialogButtonBox.StandardButton.Close).setEnabled(True)
+            self.buttonBox.button(
+                QDialogButtonBox.StandardButton.Close).setDefault(True)
             self.cancelButton.setEnabled(False)
             self.statisticsButton.setEnabled(True)
             self.showButton.setEnabled(True)
@@ -1045,7 +1052,7 @@
             else:
                 self.showButton.setEnabled(True)
             self.resultList.header().resizeSections(
-                QHeaderView.ResizeToContents)
+                QHeaderView.ResizeMode.ResizeToContents)
             self.resultList.header().setStretchLastSection(True)
             
             self.checkProgress.setVisible(False)
@@ -1177,7 +1184,7 @@
         from .CodeStyleCodeSelectionDialog import CodeStyleCodeSelectionDialog
         dlg = CodeStyleCodeSelectionDialog(edit.text(), categories,
                                            showFixCodes, self)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             edit.setText(dlg.getSelectedCodes())
     
     @pyqtSlot()
@@ -1668,7 +1675,9 @@
         @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()
     
     def __clearErrors(self, files):
@@ -1774,9 +1783,9 @@
         for row in range(self.futuresList.count()):
             itm = self.futuresList.item(row)
             if itm.text() in expectedImports:
-                itm.setCheckState(Qt.Checked)
+                itm.setCheckState(Qt.CheckState.Checked)
             else:
-                itm.setCheckState(Qt.Unchecked)
+                itm.setCheckState(Qt.CheckState.Unchecked)
     
     def __getSelectedFutureImports(self):
         """
@@ -1788,7 +1797,7 @@
         selectedFutures = []
         for row in range(self.futuresList.count()):
             itm = self.futuresList.item(row)
-            if itm.checkState() == Qt.Checked:
+            if itm.checkState() == Qt.CheckState.Checked:
                 selectedFutures.append(itm.text())
         return ", ".join(selectedFutures)
     
@@ -1842,7 +1851,7 @@
             CodeStyleAddBuiltinIgnoreDialog
         )
         dlg = CodeStyleAddBuiltinIgnoreDialog(self)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             left, right = dlg.getData()
             QTreeWidgetItem(self.builtinsAssignmentList, [left, right])
     
@@ -1873,10 +1882,10 @@
                 CodeStyleCheckerDialog.checkCategories.keys())
         for row in range(self.categoriesList.count()):
             itm = self.categoriesList.item(row)
-            if itm.data(Qt.UserRole) in enabledCategoriesList:
-                itm.setCheckState(Qt.Checked)
+            if itm.data(Qt.ItemDataRole.UserRole) in enabledCategoriesList:
+                itm.setCheckState(Qt.CheckState.Checked)
             else:
-                itm.setCheckState(Qt.Unchecked)
+                itm.setCheckState(Qt.CheckState.Unchecked)
     
     def __getCategories(self, enabled, asList=False):
         """
@@ -1890,13 +1899,13 @@
         @return checker categories as a list or comma separated string
         @rtype str or list of str
         """
-        state = Qt.Checked if enabled else Qt.Unchecked
+        state = Qt.CheckState.Checked if enabled else Qt.CheckState.Unchecked
         
         checkerList = []
         for row in range(self.categoriesList.count()):
             itm = self.categoriesList.item(row)
             if itm.checkState() == state:
-                checkerList.append(itm.data(Qt.UserRole))
+                checkerList.append(itm.data(Qt.ItemDataRole.UserRole))
         if asList:
             return checkerList
         else:
@@ -1996,7 +2005,7 @@
             self,
             self.tr("Commented Code Whitelist Pattern"),
             self.tr("Enter a Commented Code Whitelist Pattern"),
-            QLineEdit.Normal)
+            QLineEdit.EchoMode.Normal)
         if ok and pattern:
             QListWidgetItem(pattern, self.whitelistWidget)
     

eric ide

mercurial