--- a/PluginManager/PluginRepositoryDialog.py Tue Oct 15 22:03:54 2013 +0200 +++ b/PluginManager/PluginRepositoryDialog.py Fri Oct 18 23:00:41 2013 +0200 @@ -14,10 +14,12 @@ import os import zipfile -from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, QProcess -from PyQt4.QtGui import QWidget, QDialogButtonBox, QAbstractButton, QTreeWidgetItem, \ - QDialog, QVBoxLayout -from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply +from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, \ + QProcess +from PyQt4.QtGui import QWidget, QDialogButtonBox, QAbstractButton, \ + QTreeWidgetItem, QDialog, QVBoxLayout +from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, \ + QNetworkReply from .Ui_PluginRepositoryDialog import Ui_PluginRepositoryDialog @@ -49,7 +51,8 @@ """ Class implementing a dialog showing the available plugins. - @signal closeAndInstall() emitted when the Close & Install button is pressed + @signal closeAndInstall() emitted when the Close & Install button is + pressed """ closeAndInstall = pyqtSignal() @@ -58,30 +61,34 @@ Constructor @param parent parent of this dialog (QWidget) + @param external flag indicating an instatiation as a main + window (boolean) """ super(PluginRepositoryWidget, self).__init__(parent) self.setupUi(self) - self.__updateButton = \ - self.buttonBox.addButton(self.trUtf8("Update"), QDialogButtonBox.ActionRole) - self.__downloadButton = \ - self.buttonBox.addButton(self.trUtf8("Download"), QDialogButtonBox.ActionRole) + self.__updateButton = self.buttonBox.addButton( + self.trUtf8("Update"), QDialogButtonBox.ActionRole) + self.__downloadButton = self.buttonBox.addButton( + self.trUtf8("Download"), QDialogButtonBox.ActionRole) self.__downloadButton.setEnabled(False) self.__downloadInstallButton = \ self.buttonBox.addButton(self.trUtf8("Download && Install"), QDialogButtonBox.ActionRole) self.__downloadInstallButton.setEnabled(False) - self.__downloadCancelButton = \ - self.buttonBox.addButton(self.trUtf8("Cancel"), QDialogButtonBox.ActionRole) + self.__downloadCancelButton = self.buttonBox.addButton( + self.trUtf8("Cancel"), QDialogButtonBox.ActionRole) self.__installButton = \ self.buttonBox.addButton(self.trUtf8("Close && Install"), QDialogButtonBox.ActionRole) self.__downloadCancelButton.setEnabled(False) self.__installButton.setEnabled(False) - self.repositoryUrlEdit.setText(Preferences.getUI("PluginRepositoryUrl5")) + self.repositoryUrlEdit.setText( + Preferences.getUI("PluginRepositoryUrl5")) - self.repositoryList.headerItem().setText(self.repositoryList.columnCount(), "") + self.repositoryList.headerItem().setText( + self.repositoryList.columnCount(), "") self.repositoryList.header().setSortIndicator(0, Qt.AscendingOrder) self.pluginRepositoryFile = \ @@ -111,6 +118,8 @@ def on_buttonBox_clicked(self, button): """ Private slot to handle the click of a button of the button box. + + @param button reference to the button pressed (QAbstractButton) """ if button == self.__updateButton: self.__updateList() @@ -241,7 +250,8 @@ self.__downloadInstallButton.setEnabled(False) self.__installButton.setEnabled(False) for itm in self.repositoryList.selectedItems(): - if itm not in [self.__stableItem, self.__unstableItem, self.__unknownItem]: + if itm not in [self.__stableItem, self.__unstableItem, + self.__unknownItem]: url = itm.data(0, urlRole) filename = os.path.join( Preferences.getPluginManager("DownloadPath"), @@ -282,8 +292,9 @@ """ Private method to resort the tree. """ - self.repositoryList.sortItems(self.repositoryList.sortColumn(), - self.repositoryList.header().sortIndicatorOrder()) + self.repositoryList.sortItems( + self.repositoryList.sortColumn(), + self.repositoryList.header().sortIndicatorOrder()) def __populateList(self): """ @@ -313,9 +324,10 @@ self.repositoryUrlEdit.setText(url) E5MessageBox.warning(self, self.trUtf8("Plugins Repository URL Changed"), - self.trUtf8("""The URL of the Plugins Repository has""" - """ changed. Select the "Update" button to get""" - """ the new repository file.""")) + self.trUtf8( + """The URL of the Plugins Repository has""" + """ changed. Select the "Update" button to get""" + """ the new repository file.""")) else: E5MessageBox.critical(self, self.trUtf8("Read plugins repository file"), @@ -325,8 +337,8 @@ else: self.__repositoryMissing = True QTreeWidgetItem(self.repositoryList, - ["", - self.trUtf8("No plugin repository file available.\nSelect Update.") + ["", self.trUtf8( + "No plugin repository file available.\nSelect Update.") ]) self.repositoryList.resizeColumnToContents(1) @@ -378,8 +390,8 @@ E5MessageBox.warning(self, self.trUtf8("Error downloading file"), self.trUtf8( - """<p>Could not download the requested file from {0}.</p>""" - """<p>Error: {1}</p>""" + """<p>Could not download the requested file""" + """ from {0}.</p><p>Error: {1}</p>""" ).format(self.__downloadURL, reply.errorString()) ) self.downloadProgress.setValue(0) @@ -391,8 +403,10 @@ self.repositoryList.setCurrentItem( self.repositoryList.topLevelItem(0)) else: - self.__downloadButton.setEnabled(len(self.__selectedItems())) - self.__downloadInstallButton.setEnabled(len(self.__selectedItems())) + self.__downloadButton.setEnabled( + len(self.__selectedItems())) + self.__downloadInstallButton.setEnabled( + len(self.__selectedItems())) return self.__downloadIODevice.open(QIODevice.WriteOnly) @@ -428,7 +442,8 @@ self.downloadProgress.setMaximum(total) self.downloadProgress.setValue(done) - def addEntry(self, name, short, description, url, author, version, filename, status): + def addEntry(self, name, short, description, url, author, version, + filename, status): """ Public method to add an entry to the list. @@ -444,19 +459,22 @@ if status == "stable": if self.__stableItem is None: self.__stableItem = \ - QTreeWidgetItem(self.repositoryList, [self.trUtf8("Stable")]) + QTreeWidgetItem(self.repositoryList, + [self.trUtf8("Stable")]) self.__stableItem.setExpanded(True) parent = self.__stableItem elif status == "unstable": if self.__unstableItem is None: self.__unstableItem = \ - QTreeWidgetItem(self.repositoryList, [self.trUtf8("Unstable")]) + QTreeWidgetItem(self.repositoryList, + [self.trUtf8("Unstable")]) self.__unstableItem.setExpanded(True) parent = self.__unstableItem else: if self.__unknownItem is None: self.__unknownItem = \ - QTreeWidgetItem(self.repositoryList, [self.trUtf8("Unknown")]) + QTreeWidgetItem(self.repositoryList, + [self.trUtf8("Unknown")]) self.__unknownItem.setExpanded(True) parent = self.__unknownItem itm = QTreeWidgetItem(parent, [name, version, short]) @@ -521,7 +539,8 @@ @pyqtSlot(bool) def on_repositoryUrlEditButton_toggled(self, checked): """ - Private slot to set the read only status of the repository URL line edit. + Private slot to set the read only status of the repository URL line + edit. @param checked state of the push button (boolean) """ @@ -585,7 +604,8 @@ self.setCentralWidget(self.cw) self.resize(size) - self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) + self.setStyle(Preferences.getUI("Style"), + Preferences.getUI("StyleSheet")) self.cw.buttonBox.accepted[()].connect(self.close) self.cw.buttonBox.rejected[()].connect(self.close) @@ -602,7 +622,8 @@ args.append(applPath) args += self.cw.getDownloadedPlugins() - if not os.path.isfile(applPath) or not proc.startDetached(sys.executable, args): + if not os.path.isfile(applPath) or \ + not proc.startDetached(sys.executable, args): E5MessageBox.critical(self, self.trUtf8('Process Generation Error'), self.trUtf8(