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..6518e6a1b0 100644
--- a/src/calibre/gui2/dialogs/edit_authors_dialog.ui
+++ b/src/calibre/gui2/dialogs/edit_authors_dialog.ui
@@ -6,7 +6,7 @@
0
0
- 730
+ 768
342
@@ -49,6 +49,16 @@
+ -
+
+
+ Reset all the author sort values to a value automatically generated from the author. Exactly how this value is automatically generated can be controlled via Preferences->Advanced->Tweaks
+
+
+ Recalculate all author sort values
+
+
+
-