eric6/PipInterface/PipPackagesWidget.py

changeset 8143
2c730d5fd177
parent 8090
c53117374255
child 8152
0c740fcffd34
--- a/eric6/PipInterface/PipPackagesWidget.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/PipInterface/PipPackagesWidget.py	Tue Mar 02 17:17:09 2021 +0100
@@ -146,7 +146,7 @@
     ShowProcessEntryPointsMode = 2
     ShowProcessFilesListMode = 3
     
-    SearchVersionRole = Qt.UserRole + 1
+    SearchVersionRole = Qt.ItemDataRole.UserRole + 1
     
     def __init__(self, pip, parent=None):
         """
@@ -164,9 +164,11 @@
             "pip_supermenu_button")
         self.pipMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu"))
         self.pipMenuButton.setToolTip(self.tr("pip Menu"))
-        self.pipMenuButton.setPopupMode(QToolButton.InstantPopup)
-        self.pipMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
-        self.pipMenuButton.setFocusPolicy(Qt.NoFocus)
+        self.pipMenuButton.setPopupMode(
+            QToolButton.ToolButtonPopupMode.InstantPopup)
+        self.pipMenuButton.setToolButtonStyle(
+            Qt.ToolButtonStyle.ToolButtonIconOnly)
+        self.pipMenuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus)
         self.pipMenuButton.setAutoRaise(True)
         self.pipMenuButton.setShowMenuInside(True)
         
@@ -183,7 +185,8 @@
         
         self.__pip = pip
         
-        self.packagesList.header().setSortIndicator(0, Qt.AscendingOrder)
+        self.packagesList.header().setSortIndicator(
+            0, Qt.SortOrder.AscendingOrder)
         
         self.__infoLabels = {
             "name": self.tr("Name:"),
@@ -256,8 +259,12 @@
         
         venvName = self.environmentsComboBox.currentText()
         if venvName:
-            available = len(self.packagesList.findItems(
-                "pip", Qt.MatchExactly | Qt.MatchCaseSensitive)) == 1
+            available = (
+                len(self.packagesList.findItems(
+                    "pip",
+                    Qt.MatchFlag.MatchExactly |
+                    Qt.MatchFlag.MatchCaseSensitive)) == 1
+            )
         
         return available
     
@@ -273,7 +280,9 @@
         venvName = self.environmentsComboBox.currentText()
         if venvName:
             pipList = self.packagesList.findItems(
-                "pip", Qt.MatchExactly | Qt.MatchCaseSensitive)
+                "pip",
+                Qt.MatchFlag.MatchExactly | Qt.MatchFlag.MatchCaseSensitive
+            )
             if len(pipList) > 0:
                 pipVersionTuple = Globals.versionToTuple(pipList[0].text(1))
         
@@ -377,12 +386,15 @@
                     )
                     for package, _version, latest in outdatedPackages:
                         items = self.packagesList.findItems(
-                            package, Qt.MatchExactly | Qt.MatchCaseSensitive)
+                            package,
+                            Qt.MatchFlag.MatchExactly |
+                            Qt.MatchFlag.MatchCaseSensitive
+                        )
                         if items:
                             itm = items[0]
                             itm.setText(2, latest)
                     
-                    self.packagesList.sortItems(0, Qt.AscendingOrder)
+                    self.packagesList.sortItems(0, Qt.SortOrder.AscendingOrder)
                     for col in range(self.packagesList.columnCount()):
                         self.packagesList.resizeColumnToContents(col)
                     self.packagesList.setUpdatesEnabled(True)
@@ -490,7 +502,7 @@
                 
                 header = self.infoWidget.header()
                 header.setStretchLastSection(False)
-                header.resizeSections(QHeaderView.ResizeToContents)
+                header.resizeSections(QHeaderView.ResizeMode.ResizeToContents)
                 if (
                     header.sectionSize(0) + header.sectionSize(1) <
                     header.width()
@@ -559,7 +571,9 @@
             self.__populateEnvironments()
             
             index = self.environmentsComboBox.findText(
-                currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive)
+                currentEnvironment,
+                Qt.MatchFlag.MatchExactly | Qt.MatchFlag.MatchCaseSensitive
+            )
             if index != -1:
                 self.environmentsComboBox.setCurrentIndex(index)
         
@@ -677,7 +691,7 @@
         self.searchWidget.setVisible(checked)
         
         if checked:
-            self.searchEditName.setFocus(Qt.OtherFocusReason)
+            self.searchEditName.setFocus(Qt.FocusReason.OtherFocusReason)
             self.searchEditName.selectAll()
             
             self.__updateSearchActionButtons()
@@ -735,8 +749,9 @@
         url.setQuery(urlQuery)
         
         request = QNetworkRequest(QUrl(url))
-        request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
-                             QNetworkRequest.AlwaysNetwork)
+        request.setAttribute(
+            QNetworkRequest.Attribute.CacheLoadControlAttribute,
+            QNetworkRequest.CacheLoadControl.AlwaysNetwork)
         reply = self.__pip.getNetworkAccessManager().get(request)
         reply.finished.connect(
             lambda: self.__searchResponse(reply))
@@ -755,7 +770,7 @@
         urlQuery = QUrlQuery(reply.url())
         searchTerm = urlQuery.queryItemValue("q")
         
-        if reply.error() != QNetworkReply.NoError:
+        if reply.error() != QNetworkReply.NetworkError.NoError:
             E5MessageBox.warning(
                 None,
                 self.tr("Search PyPI"),
@@ -805,7 +820,7 @@
         
         header = self.searchResultList.header()
         header.setStretchLastSection(False)
-        header.resizeSections(QHeaderView.ResizeToContents)
+        header.resizeSections(QHeaderView.ResizeMode.ResizeToContents)
         headerSize = 0
         for col in range(header.count()):
             headerSize += header.sectionSize(col)
@@ -821,7 +836,7 @@
         self.__updateSearchActionButtons()
         self.__updateSearchButton()
         
-        self.searchEditName.setFocus(Qt.OtherFocusReason)
+        self.searchEditName.setFocus(Qt.FocusReason.OtherFocusReason)
     
     @pyqtSlot()
     def on_installButton_clicked(self):
@@ -1081,7 +1096,7 @@
         if venvName:
             from .PipPackagesInputDialog import PipPackagesInputDialog
             dlg = PipPackagesInputDialog(self, self.tr("Install Packages"))
-            if dlg.exec() == QDialog.Accepted:
+            if dlg.exec() == QDialog.DialogCode.Accepted:
                 packages, user = dlg.getData()
                 self.executeInstallPackages(packages, userSite=user)
     
@@ -1094,7 +1109,7 @@
         if venvName:
             from .PipFileSelectionDialog import PipFileSelectionDialog
             dlg = PipFileSelectionDialog(self, "package")
-            if dlg.exec() == QDialog.Accepted:
+            if dlg.exec() == QDialog.DialogCode.Accepted:
                 package, user = dlg.getData()
                 if package and os.path.exists(package):
                     self.executeInstallPackages([package], userSite=user)

eric ide

mercurial