mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix Manage Authors dialog causing current search in the book list to be cleared. Fixes #1432324 [Book selection discarded when using the Manage Authors dialog](https://bugs.launchpad.net/calibre/+bug/1432324)
This commit is contained in:
parent
2842e53d09
commit
d1651232a4
@ -282,23 +282,22 @@ class TagBrowserMixin(object): # {{{
|
|||||||
|
|
||||||
db = self.library_view.model().db
|
db = self.library_view.model().db
|
||||||
editor = EditAuthorsDialog(parent, db, id_, select_sort, select_link)
|
editor = EditAuthorsDialog(parent, db, id_, select_sort, select_link)
|
||||||
d = editor.exec_()
|
if editor.exec_() == editor.Accepted:
|
||||||
if d:
|
|
||||||
# Save and restore the current selections. Note that some changes
|
# Save and restore the current selections. Note that some changes
|
||||||
# will cause sort orders to change, so don't bother with attempting
|
# will cause sort orders to change, so don't bother with attempting
|
||||||
# to restore the position. Restoring the state has the side effect
|
# to restore the position. Restoring the state has the side effect
|
||||||
# of refreshing book details.
|
# of refreshing book details.
|
||||||
with self.library_view.preserve_state(preserve_hpos=False, preserve_vpos=False):
|
with self.library_view.preserve_state(preserve_hpos=False, preserve_vpos=False):
|
||||||
for (id2, old_author, new_author, new_sort, new_link) in editor.result:
|
affected_books, id_map = set(), {}
|
||||||
if old_author != new_author:
|
db = db.new_api
|
||||||
# The id might change if the new author already exists
|
rename_map = {author_id:new_author for author_id, old_author, new_author, new_sort, new_link in editor.result if old_author != new_author}
|
||||||
id2 = db.rename_author(id2, new_author)
|
if rename_map:
|
||||||
db.set_sort_field_for_author(id2, unicode(new_sort),
|
affected_books, id_map = db.rename_items('authors', rename_map)
|
||||||
commit=False, notify=False)
|
link_map = {id_map.get(author_id, author_id):new_link for author_id, old_author, new_author, new_sort, new_link in editor.result}
|
||||||
db.set_link_field_for_author(id2, unicode(new_link),
|
affected_books |= db.set_link_for_authors(link_map)
|
||||||
commit=False, notify=False)
|
sort_map = {id_map.get(author_id, author_id):new_sort for author_id, old_author, new_author, new_sort, new_link in editor.result}
|
||||||
db.commit()
|
affected_books |= db.set_sort_for_authors(sort_map)
|
||||||
self.library_view.model().refresh()
|
self.library_view.model().refresh_ids(affected_books, current_row=self.library_view.currentIndex().row())
|
||||||
self.tags_view.recount()
|
self.tags_view.recount()
|
||||||
|
|
||||||
def drag_drop_finished(self, ids):
|
def drag_drop_finished(self, ids):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user