Restore selections and update book details after using manage authors.

This commit is contained in:
Charles Haley 2013-05-26 11:19:57 +02:00
parent 06a7d3a383
commit 24f25f5f2a

View File

@ -290,25 +290,31 @@ class TagBrowserMixin(object): # {{{
self.library_view.select_rows(ids) self.library_view.select_rows(ids)
# refreshing the tags view happens at the emit()/call() site # refreshing the tags view happens at the emit()/call() site
def do_author_sort_edit(self, parent, id, select_sort=True, select_link=False): def do_author_sort_edit(self, parent, id_, select_sort=True, select_link=False):
''' '''
Open the manage authors dialog Open the manage authors dialog
''' '''
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_() d = editor.exec_()
if d: if d:
for (id, old_author, new_author, new_sort, new_link) in editor.result: # Save and restore the current selections. Note that some changes
if old_author != new_author: # will cause sort orders to change, so don't bother with attempting
# The id might change if the new author already exists # to restore the position. Restoring the state has the side effect
id = db.rename_author(id, new_author) # of refreshing book details.
db.set_sort_field_for_author(id, unicode(new_sort), with self.library_view.preserve_state(preserve_hpos=False, preserve_vpos=False):
commit=False, notify=False) for (id2, old_author, new_author, new_sort, new_link) in editor.result:
db.set_link_field_for_author(id, unicode(new_link), if old_author != new_author:
commit=False, notify=False) # The id might change if the new author already exists
db.commit() id2 = db.rename_author(id2, new_author)
self.library_view.model().refresh() db.set_sort_field_for_author(id2, unicode(new_sort),
self.tags_view.recount() commit=False, notify=False)
db.set_link_field_for_author(id2, unicode(new_link),
commit=False, notify=False)
db.commit()
self.library_view.model().refresh()
self.tags_view.recount()
def drag_drop_finished(self, ids): def drag_drop_finished(self, ids):
self.library_view.model().refresh_ids(ids) self.library_view.model().refresh_ids(ids)