--- a/RefactoringRope/ChangesPreviewDialog.py Sat Jun 25 18:06:56 2022 +0200 +++ b/RefactoringRope/ChangesPreviewDialog.py Wed Sep 21 15:30:34 2022 +0200 @@ -17,12 +17,13 @@ """ Class implementing the Changes preview dialog. """ + ChangeRole = Qt.ItemDataRole.UserRole - + def __init__(self, description, changes, parent): """ Constructor - + @param description description of the changes @type str @param changes list of lists containing the change data @@ -31,11 +32,12 @@ @type QWidget """ PreviewDialogBase.__init__(self, parent) - + self.buttonBox.addButton( - self.tr("&Apply Changes"), QDialogButtonBox.ButtonRole.AcceptRole) + self.tr("&Apply Changes"), QDialogButtonBox.ButtonRole.AcceptRole + ) self.buttonBox.addButton(QDialogButtonBox.StandardButton.Cancel) - + self.description.setText(description) for changeTitle, changeText in changes: itm = QListWidgetItem(changeTitle, self.changesList) @@ -44,14 +46,13 @@ itm.setData(ChangesPreviewDialog.ChangeRole, changeText) if self.changesList.count(): self.changesList.item(0).setSelected(True) - self.on_changesList_currentItemChanged( - self.changesList.item(0), None) - + self.on_changesList_currentItemChanged(self.changesList.item(0), None) + @pyqtSlot(QListWidgetItem, QListWidgetItem) def on_changesList_currentItemChanged(self, current, previous): """ Private slot called when a change is selected. - + @param current reference to the new current item @type QListWidgetItem @param previous reference to the old current item @@ -59,13 +60,11 @@ """ if current is None: return - + self.previewEdit.clear() - for line in ( - current.data(ChangesPreviewDialog.ChangeRole).splitlines(True) - ): + for line in current.data(ChangesPreviewDialog.ChangeRole).splitlines(True): try: charFormat = self.formats[line[0]] except (IndexError, KeyError): - charFormat = self.formats[' '] + charFormat = self.formats[" "] self._appendText(line, charFormat)