--- a/src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnPropListDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnPropListDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -14,7 +14,11 @@ from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtWidgets import ( - QWidget, QHeaderView, QApplication, QDialogButtonBox, QTreeWidgetItem + QWidget, + QHeaderView, + QApplication, + QDialogButtonBox, + QTreeWidgetItem, ) from EricUtilities.EricMutexLocker import EricMutexLocker @@ -28,88 +32,84 @@ Class implementing a dialog to show the output of the svn proplist command process. """ + def __init__(self, vcs, parent=None): """ Constructor - + @param vcs reference to the vcs object @param parent parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) SvnDialogMixin.__init__(self) - + self.refreshButton = self.buttonBox.addButton( - self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole) + self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole + ) self.refreshButton.setToolTip( - self.tr("Press to refresh the properties display")) + self.tr("Press to refresh the properties display") + ) self.refreshButton.setEnabled(False) - self.buttonBox.button( - QDialogButtonBox.StandardButton.Close).setEnabled(False) - self.buttonBox.button( - QDialogButtonBox.StandardButton.Cancel).setDefault(True) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) + self.vcs = vcs - + self.propsList.headerItem().setText(self.propsList.columnCount(), "") - self.propsList.header().setSortIndicator( - 0, Qt.SortOrder.AscendingOrder) - + self.propsList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder) + self.client = self.vcs.getClient() self.client.callback_cancel = self._clientCancelCallback self.client.callback_get_login = self._clientLoginCallback self.client.callback_ssl_server_trust_prompt = ( self._clientSslServerTrustPromptCallback ) - + def __resort(self): """ Private method to resort the tree. """ self.propsList.sortItems( - self.propsList.sortColumn(), - self.propsList.header().sortIndicatorOrder()) - + self.propsList.sortColumn(), self.propsList.header().sortIndicatorOrder() + ) + def __resizeColumns(self): """ Private method to resize the list columns. """ - self.propsList.header().resizeSections( - QHeaderView.ResizeMode.ResizeToContents) + self.propsList.header().resizeSections(QHeaderView.ResizeMode.ResizeToContents) self.propsList.header().setStretchLastSection(True) - + def __generateItem(self, path, propName, propValue): """ Private method to generate a properties item in the properties list. - + @param path file/directory name the property applies to (string) @param propName name of the property (string) @param propValue value of the property (string) """ QTreeWidgetItem(self.propsList, [path, propName, propValue]) - + def start(self, fn, recursive=False): """ Public slot to start the svn status command. - + @param fn filename(s) (string or list of strings) @param recursive flag indicating a recursive list is requested """ self.errorGroup.hide() - + self.propsList.clear() - + self.__args = fn self.__recursive = recursive - - self.buttonBox.button( - QDialogButtonBox.StandardButton.Close).setEnabled(False) - self.buttonBox.button( - QDialogButtonBox.StandardButton.Cancel).setEnabled(True) - self.buttonBox.button( - QDialogButtonBox.StandardButton.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) self.refreshButton.setEnabled(False) - + QApplication.processEvents() self.propsFound = False if isinstance(fn, list): @@ -117,7 +117,7 @@ else: dname, fname = self.vcs.splitPath(fn) fnames = [fname] - + cwd = os.getcwd() os.chdir(dname) with EricMutexLocker(self.vcs.vcsExecutionMutex): @@ -128,20 +128,17 @@ for propName, propVal in list(prop.items()): self.__generateItem(path, propName, propVal) self.propsFound = True - if ( - counter % 30 == 0 and - self._clientCancelCallback() - ): + if counter % 30 == 0 and self._clientCancelCallback(): # check for cancel every 30 items break if self._clientCancelCallback(): break except pysvn.ClientError as e: self.__showError(e.args[0]) - + self.__finish() os.chdir(cwd) - + def __finish(self): """ Private slot called when the process finished or the user pressed the @@ -149,49 +146,42 @@ """ if not self.propsFound: self.__generateItem("", self.tr("None"), "") - + self.__resort() self.__resizeColumns() - - 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.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) + self.refreshButton.setEnabled(True) - + self._cancel() - + def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. - + @param button button that was clicked (QAbstractButton) """ - if button == self.buttonBox.button( - QDialogButtonBox.StandardButton.Close - ): + if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): self.close() - elif button == self.buttonBox.button( - QDialogButtonBox.StandardButton.Cancel - ): + elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): self.__finish() elif button == self.refreshButton: self.on_refreshButton_clicked() - + @pyqtSlot() def on_refreshButton_clicked(self): """ Private slot to refresh the status display. """ self.start(self.__args, recursive=self.__recursive) - + def __showError(self, msg): """ Private slot to show an error message. - + @param msg error message to show (string) """ self.errorGroup.show()