From b099122810ddfa22c7a1c0f35b13a44e0d39fabd Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 25 May 2020 09:55:45 +0100 Subject: [PATCH] Bug #1880395: fix regression version 4.17 Manage Authors no longer copies from author sort to author --- .../gui2/dialogs/edit_authors_dialog.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/dialogs/edit_authors_dialog.py b/src/calibre/gui2/dialogs/edit_authors_dialog.py index 7622961886..1d39eef101 100644 --- a/src/calibre/gui2/dialogs/edit_authors_dialog.py +++ b/src/calibre/gui2/dialogs/edit_authors_dialog.py @@ -410,22 +410,29 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): def do_recalc_author_sort(self): self.table.cellChanged.disconnect() for row in range(0,self.table.rowCount()): - item = self.table.item(row, 0) - aut = unicode_type(item.text()).strip() - c = self.table.item(row, 1) + item_aut = self.table.item(row, 0) + id_ = int(item_aut.data(Qt.UserRole)) + aut = unicode_type(item_aut.text()).strip() + item_aus = self.table.item(row, 1) # Sometimes trailing commas are left by changing between copy algs - c.setText(author_to_author_sort(aut).rstrip(',')) + aus = unicode_type(author_to_author_sort(aut)).rstrip(',') + if aus != self.original_authors[id_]['sort']: + item_aus.setIcon(self.edited_icon) + item_aus.setText(aus) + self.authors[id_]['sort'] = aus self.table.setFocus(Qt.OtherFocusReason) self.table.cellChanged.connect(self.cell_changed) def do_auth_sort_to_author(self): self.table.cellChanged.disconnect() for row in range(0,self.table.rowCount()): - item = self.table.item(row, 1) - aus = unicode_type(item.text()).strip() - c = self.table.item(row, 0) - # Sometimes trailing commas are left by changing between copy algs - c.setText(aus) + aus = unicode_type(self.table.item(row, 1).text()).strip() + item_aut = self.table.item(row, 0) + id_ = int(item_aut.data(Qt.UserRole)) + if aus != self.original_authors[id_]['name']: + item_aut.setIcon(self.edited_icon) + item_aut.setText(aus) + self.authors[id_]['name'] = aus self.table.setFocus(Qt.OtherFocusReason) self.table.cellChanged.connect(self.cell_changed)