예제 #1
0
    def do_author_sort_edit(self, parent, id_, select_sort=True,
                            select_link=False, is_first_letter=False):
        '''
        Open the manage authors dialog
        '''

        db = self.library_view.model().db
        editor = EditAuthorsDialog(parent, db, id_, select_sort, select_link,
                                   partial(self.get_book_ids, db=db, category='authors'),
                                   is_first_letter)
        if editor.exec_() == editor.Accepted:
            # Save and restore the current selections. Note that some changes
            # will cause sort orders to change, so don't bother with attempting
            # to restore the position. Restoring the state has the side effect
            # of refreshing book details.
            with self.library_view.preserve_state(preserve_hpos=False, preserve_vpos=False):
                affected_books, id_map = set(), {}
                db = db.new_api
                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}
                if rename_map:
                    affected_books, id_map = db.rename_items('authors', rename_map)
                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}
                affected_books |= db.set_link_for_authors(link_map)
                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}
                affected_books |= db.set_sort_for_authors(sort_map)
                self.library_view.model().refresh_ids(affected_books, current_row=self.library_view.currentIndex().row())
                self.tags_view.recount()
예제 #2
0
    def do_author_sort_edit(self, parent, id_, select_sort=True, select_link=False):
        '''
        Open the manage authors dialog
        '''

        db = self.library_view.model().db
        editor = EditAuthorsDialog(parent, db, id_, select_sort, select_link)
        d = editor.exec_()
        if d:
            # Save and restore the current selections. Note that some changes
            # will cause sort orders to change, so don't bother with attempting
            # to restore the position. Restoring the state has the side effect
            # of refreshing book details.
            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:
                    if old_author != new_author:
                        # The id might change if the new author already exists
                        id2 = db.rename_author(id2, new_author)
                    db.set_sort_field_for_author(id2, unicode(new_sort),
                                                 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()
예제 #3
0
파일: ui.py 프로젝트: iwannafly/calibre
 def do_author_sort_edit(self,
                         parent,
                         id,
                         select_sort=True,
                         select_link=False):
     '''
     Open the manage authors dialog
     '''
     db = self.library_view.model().db
     editor = EditAuthorsDialog(parent, db, id, select_sort, select_link)
     d = editor.exec_()
     if d:
         for (id, old_author, new_author, new_sort,
              new_link) in editor.result:
             if old_author != new_author:
                 # The id might change if the new author already exists
                 id = db.rename_author(id, new_author)
             db.set_sort_field_for_author(id,
                                          unicode(new_sort),
                                          commit=False,
                                          notify=False)
             db.set_link_field_for_author(id,
                                          unicode(new_link),
                                          commit=False,
                                          notify=False)
         db.commit()
         self.library_view.model().refresh()
         self.tags_view.recount()
예제 #4
0
파일: ui.py 프로젝트: Eksmo/calibre
 def do_author_sort_edit(self, parent, id, select_sort=True, select_link=False):
     '''
     Open the manage authors dialog
     '''
     db = self.library_view.model().db
     editor = EditAuthorsDialog(parent, db, id, select_sort, select_link)
     d = editor.exec_()
     if d:
         for (id, old_author, new_author, new_sort, new_link) in editor.result:
             if old_author != new_author:
                 # The id might change if the new author already exists
                 id = db.rename_author(id, new_author)
             db.set_sort_field_for_author(id, unicode(new_sort),
                                          commit=False, notify=False)
             db.set_link_field_for_author(id, unicode(new_link),
                                          commit=False, notify=False)
         db.commit()
         self.library_view.model().refresh()
         self.tags_view.recount()
예제 #5
0
파일: ui.py 프로젝트: rlugojr/calibre
    def do_author_sort_edit(self, parent, id_, select_sort=True, select_link=False):
        '''
        Open the manage authors dialog
        '''

        db = self.library_view.model().db
        editor = EditAuthorsDialog(parent, db, id_, select_sort, select_link)
        if editor.exec_() == editor.Accepted:
            # Save and restore the current selections. Note that some changes
            # will cause sort orders to change, so don't bother with attempting
            # to restore the position. Restoring the state has the side effect
            # of refreshing book details.
            with self.library_view.preserve_state(preserve_hpos=False, preserve_vpos=False):
                affected_books, id_map = set(), {}
                db = db.new_api
                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}
                if rename_map:
                    affected_books, id_map = db.rename_items('authors', rename_map)
                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}
                affected_books |= db.set_link_for_authors(link_map)
                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}
                affected_books |= db.set_sort_for_authors(sort_map)
                self.library_view.model().refresh_ids(affected_books, current_row=self.library_view.currentIndex().row())
                self.tags_view.recount()