diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index db60693fa7..132355b12a 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -9,9 +9,10 @@ from PyQt4.QtGui import QDialog from calibre.gui2 import qstring_to_unicode from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog from calibre.gui2.dialogs.tag_editor import TagEditor -from calibre.ebooks.metadata import string_to_authors +from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): + def __init__(self, window, rows, db): QDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) @@ -54,8 +55,15 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): if au: au = string_to_authors(au) self.db.set_authors(id, au, notify=False) + if self.auto_author_sort.isChecked(): + aut = self.db.authors(id, index_is_id=True) + aut = aut if aut else '' + aut = [a.strip().replace('|', ',') for a in aut.strip().split(',')] + x = authors_to_sort_string(aut) + if x: + self.db.set_author_sort(id, x, notify=False) aus = qstring_to_unicode(self.author_sort.text()) - if aus: + if aus and self.author_sort.isEnabled(): self.db.set_author_sort(id, aus, notify=False) if self.write_rating: self.db.set_rating(id, 2*self.rating.value(), notify=False) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index b4a4106d87..4597b987f5 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -56,7 +56,7 @@ - + Author S&ort: @@ -69,14 +69,14 @@ - + Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. - + &Rating: @@ -89,7 +89,7 @@ - + Rating of this book. 0-5 stars @@ -108,7 +108,7 @@ - + &Publisher: @@ -121,14 +121,14 @@ - + Change the publisher of this book - + Add Ta&gs: @@ -141,14 +141,14 @@ - + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. - + Open Tag Editor @@ -162,7 +162,7 @@ - + &Remove tags: @@ -172,14 +172,14 @@ - + Comma separated list of tags to remove from the books. - + &Series: @@ -195,7 +195,7 @@ - + List of known series. You can add new series. @@ -214,10 +214,10 @@ - + - + Remove &format: @@ -227,6 +227,13 @@ + + + + A&utomatically set author sort + + + @@ -257,8 +264,8 @@ accept() - 248 - 254 + 252 + 382 157 @@ -273,8 +280,8 @@ reject() - 316 - 260 + 320 + 382 286 @@ -282,5 +289,21 @@ + + auto_author_sort + toggled(bool) + author_sort + setDisabled(bool) + + + 240 + 95 + + + 240 + 113 + + +