From 489de501920c77877d7b221e269ee277051bc240 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 9 Aug 2010 08:49:03 +0100 Subject: [PATCH] Added a button to force recomputation of the author sort field. Useful after changing the tweak. --- .../gui2/dialogs/edit_authors_dialog.py | 18 +++++++++++++++++- .../gui2/dialogs/edit_authors_dialog.ui | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/edit_authors_dialog.py b/src/calibre/gui2/dialogs/edit_authors_dialog.py index aab8a46c25..7fe50181a3 100644 --- a/src/calibre/gui2/dialogs/edit_authors_dialog.py +++ b/src/calibre/gui2/dialogs/edit_authors_dialog.py @@ -48,8 +48,10 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): select_item = sort self.table.resizeColumnsToContents() - # set up the signal after the table is filled + # set up the cellChanged signal only after the table is filled self.table.cellChanged.connect(self.cell_changed) + + # set up sort buttons self.sort_by_author.setCheckable(True) self.sort_by_author.setChecked(False) self.sort_by_author.clicked.connect(self.do_sort_by_author) @@ -61,6 +63,9 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): self.sort_by_author_sort.setChecked(True) self.author_sort_order = 1 + # set up author sort calc button + self.recalc_author_sort.clicked.connect(self.do_recalc_author_sort) + if select_item is not None: self.table.setCurrentItem(select_item) self.table.editItem(select_item) @@ -89,6 +94,17 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): if orig_aut != aut or orig_sort != sort: self.result.append((id, orig_aut, aut, sort)) + 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(item.text()).strip() + c = self.table.item(row, 1) + # Sometimes trailing commas are left by changing between copy algs + c.setText(author_to_author_sort(aut).rstrip(',')) + self.table.setFocus(Qt.OtherFocusReason) + self.table.cellChanged.connect(self.cell_changed) + def cell_changed(self, row, col): if col == 0: item = self.table.item(row, 0) diff --git a/src/calibre/gui2/dialogs/edit_authors_dialog.ui b/src/calibre/gui2/dialogs/edit_authors_dialog.ui index 2352508540..a4ec6836ea 100644 --- a/src/calibre/gui2/dialogs/edit_authors_dialog.ui +++ b/src/calibre/gui2/dialogs/edit_authors_dialog.ui @@ -49,6 +49,13 @@ + + + + Recalculate all author sort values + + +