eric6/PluginManager/PluginRepositoryDialog.py

changeset 8143
2c730d5fd177
parent 7960
e8fc383322f7
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
54 @signal closeAndInstall() emitted when the Close & Install button is 54 @signal closeAndInstall() emitted when the Close & Install button is
55 pressed 55 pressed
56 """ 56 """
57 closeAndInstall = pyqtSignal() 57 closeAndInstall = pyqtSignal()
58 58
59 DescrRole = Qt.UserRole 59 DescrRole = Qt.ItemDataRole.UserRole
60 UrlRole = Qt.UserRole + 1 60 UrlRole = Qt.ItemDataRole.UserRole + 1
61 FilenameRole = Qt.UserRole + 2 61 FilenameRole = Qt.ItemDataRole.UserRole + 2
62 AuthorRole = Qt.UserRole + 3 62 AuthorRole = Qt.ItemDataRole.UserRole + 3
63 63
64 PluginStatusUpToDate = 0 64 PluginStatusUpToDate = 0
65 PluginStatusNew = 1 65 PluginStatusNew = 1
66 PluginStatusLocalUpdate = 2 66 PluginStatusLocalUpdate = 2
67 PluginStatusRemoteUpdate = 3 67 PluginStatusRemoteUpdate = 3
87 else: 87 else:
88 self.__pluginManager = pluginManager 88 self.__pluginManager = pluginManager
89 self.__external = False 89 self.__external = False
90 90
91 self.__updateButton = self.buttonBox.addButton( 91 self.__updateButton = self.buttonBox.addButton(
92 self.tr("Update"), QDialogButtonBox.ActionRole) 92 self.tr("Update"), QDialogButtonBox.ButtonRole.ActionRole)
93 self.__downloadButton = self.buttonBox.addButton( 93 self.__downloadButton = self.buttonBox.addButton(
94 self.tr("Download"), QDialogButtonBox.ActionRole) 94 self.tr("Download"), QDialogButtonBox.ButtonRole.ActionRole)
95 self.__downloadButton.setEnabled(False) 95 self.__downloadButton.setEnabled(False)
96 self.__downloadInstallButton = self.buttonBox.addButton( 96 self.__downloadInstallButton = self.buttonBox.addButton(
97 self.tr("Download && Install"), 97 self.tr("Download && Install"),
98 QDialogButtonBox.ActionRole) 98 QDialogButtonBox.ButtonRole.ActionRole)
99 self.__downloadInstallButton.setEnabled(False) 99 self.__downloadInstallButton.setEnabled(False)
100 self.__downloadCancelButton = self.buttonBox.addButton( 100 self.__downloadCancelButton = self.buttonBox.addButton(
101 self.tr("Cancel"), QDialogButtonBox.ActionRole) 101 self.tr("Cancel"), QDialogButtonBox.ButtonRole.ActionRole)
102 self.__downloadCancelButton.setEnabled(False) 102 self.__downloadCancelButton.setEnabled(False)
103 self.__installButton = self.buttonBox.addButton( 103 self.__installButton = self.buttonBox.addButton(
104 self.tr("Close && Install"), QDialogButtonBox.ActionRole) 104 self.tr("Close && Install"),
105 QDialogButtonBox.ButtonRole.ActionRole)
105 self.__installButton.setEnabled(False) 106 self.__installButton.setEnabled(False)
106 self.__closeButton = self.buttonBox.button(QDialogButtonBox.Close) 107 self.__closeButton = self.buttonBox.button(
108 QDialogButtonBox.StandardButton.Close)
107 self.__closeButton.setEnabled(True) 109 self.__closeButton.setEnabled(True)
108 110
109 self.repositoryUrlEdit.setText( 111 self.repositoryUrlEdit.setText(
110 Preferences.getUI("PluginRepositoryUrl6")) 112 Preferences.getUI("PluginRepositoryUrl6"))
111 113
112 self.repositoryList.headerItem().setText( 114 self.repositoryList.headerItem().setText(
113 self.repositoryList.columnCount(), "") 115 self.repositoryList.columnCount(), "")
114 self.repositoryList.header().setSortIndicator(0, Qt.AscendingOrder) 116 self.repositoryList.header().setSortIndicator(
117 0, Qt.SortOrder.AscendingOrder)
115 118
116 self.__pluginContextMenu = QMenu(self) 119 self.__pluginContextMenu = QMenu(self)
117 self.__hideAct = self.__pluginContextMenu.addAction( 120 self.__hideAct = self.__pluginContextMenu.addAction(
118 self.tr("Hide"), self.__hidePlugin) 121 self.tr("Hide"), self.__hidePlugin)
119 self.__hideSelectedAct = self.__pluginContextMenu.addAction( 122 self.__hideSelectedAct = self.__pluginContextMenu.addAction(
391 self.downloadProgress.setValue(0) 394 self.downloadProgress.setValue(0)
392 395
393 if os.path.exists(self.pluginRepositoryFile): 396 if os.path.exists(self.pluginRepositoryFile):
394 self.__repositoryMissing = False 397 self.__repositoryMissing = False
395 f = QFile(self.pluginRepositoryFile) 398 f = QFile(self.pluginRepositoryFile)
396 if f.open(QIODevice.ReadOnly): 399 if f.open(QIODevice.OpenModeFlag.ReadOnly):
397 from E5XML.PluginRepositoryReader import PluginRepositoryReader 400 from E5XML.PluginRepositoryReader import PluginRepositoryReader
398 reader = PluginRepositoryReader(f, self.addEntry) 401 reader = PluginRepositoryReader(f, self.addEntry)
399 reader.readXML() 402 reader.readXML()
400 self.repositoryList.resizeColumnToContents(0) 403 self.repositoryList.resizeColumnToContents(0)
401 self.repositoryList.resizeColumnToContents(1) 404 self.repositoryList.resizeColumnToContents(1)
449 self.__downloadCancelButton.setEnabled(True) 452 self.__downloadCancelButton.setEnabled(True)
450 453
451 self.statusLabel.setText(url) 454 self.statusLabel.setText(url)
452 455
453 request = QNetworkRequest(QUrl(url)) 456 request = QNetworkRequest(QUrl(url))
454 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute, 457 request.setAttribute(
455 QNetworkRequest.AlwaysNetwork) 458 QNetworkRequest.Attribute.CacheLoadControlAttribute,
459 QNetworkRequest.CacheLoadControl.AlwaysNetwork)
456 reply = self.__networkManager.get(request) 460 reply = self.__networkManager.get(request)
457 reply.finished.connect( 461 reply.finished.connect(
458 lambda: self.__downloadFileDone(reply, filename, doneMethod)) 462 lambda: self.__downloadFileDone(reply, filename, doneMethod))
459 reply.downloadProgress.connect(self.__downloadProgress) 463 reply.downloadProgress.connect(self.__downloadProgress)
460 self.__replies.append(reply) 464 self.__replies.append(reply)
476 self.__downloadCancelButton.setEnabled(False) 480 self.__downloadCancelButton.setEnabled(False)
477 481
478 ok = True 482 ok = True
479 if reply in self.__replies: 483 if reply in self.__replies:
480 self.__replies.remove(reply) 484 self.__replies.remove(reply)
481 if reply.error() != QNetworkReply.NoError: 485 if reply.error() != QNetworkReply.NetworkError.NoError:
482 ok = False 486 ok = False
483 if reply.error() != QNetworkReply.OperationCanceledError: 487 if (
488 reply.error() !=
489 QNetworkReply.NetworkError.OperationCanceledError
490 ):
484 E5MessageBox.warning( 491 E5MessageBox.warning(
485 self, 492 self,
486 self.tr("Error downloading file"), 493 self.tr("Error downloading file"),
487 self.tr( 494 self.tr(
488 """<p>Could not download the requested file""" 495 """<p>Could not download the requested file"""
501 len(self.__selectedItems())) 508 len(self.__selectedItems()))
502 reply.deleteLater() 509 reply.deleteLater()
503 return 510 return
504 511
505 downloadIODevice = QFile(fileName + ".tmp") 512 downloadIODevice = QFile(fileName + ".tmp")
506 downloadIODevice.open(QIODevice.WriteOnly) 513 downloadIODevice.open(QIODevice.OpenModeFlag.WriteOnly)
507 # read data in chunks 514 # read data in chunks
508 chunkSize = 64 * 1024 * 1024 515 chunkSize = 64 * 1024 * 1024
509 while True: 516 while True:
510 data = reply.read(chunkSize) 517 data = reply.read(chunkSize)
511 if data is None or len(data) == 0: 518 if data is None or len(data) == 0:
808 815
809 def __closeAndInstall(self): 816 def __closeAndInstall(self):
810 """ 817 """
811 Private slot to handle the closeAndInstall signal. 818 Private slot to handle the closeAndInstall signal.
812 """ 819 """
813 self.done(QDialog.Accepted + 1) 820 self.done(QDialog.DialogCode.Accepted + 1)
814 821
815 def getDownloadedPlugins(self): 822 def getDownloadedPlugins(self):
816 """ 823 """
817 Public method to get the list of recently downloaded plugin files. 824 Public method to get the list of recently downloaded plugin files.
818 825
961 # step 3: delete entries of obsolete plug-ins 968 # step 3: delete entries of obsolete plug-ins
962 pluginRepositoryFile = os.path.join(Utilities.getConfigDir(), 969 pluginRepositoryFile = os.path.join(Utilities.getConfigDir(),
963 "PluginRepository") 970 "PluginRepository")
964 if os.path.exists(pluginRepositoryFile): 971 if os.path.exists(pluginRepositoryFile):
965 f = QFile(pluginRepositoryFile) 972 f = QFile(pluginRepositoryFile)
966 if f.open(QIODevice.ReadOnly): 973 if f.open(QIODevice.OpenModeFlag.ReadOnly):
967 from E5XML.PluginRepositoryReader import PluginRepositoryReader 974 from E5XML.PluginRepositoryReader import PluginRepositoryReader
968 reader = PluginRepositoryReader(f, registerPlugin) 975 reader = PluginRepositoryReader(f, registerPlugin)
969 reader.readXML() 976 reader.readXML()
970 977
971 for pluginName in downloads: 978 for pluginName in downloads:

eric ide

mercurial