Tag browser: When renaming items dont reset the library view and try not to scroll the Tag Browser itself

This commit is contained in:
Kovid Goyal 2010-12-22 10:39:14 -07:00
parent be17dd8e4b
commit d59a20fc2a

View File

@ -695,8 +695,10 @@ class TagsModel(QAbstractItemModel): # {{{
def setData(self, index, value, role=Qt.EditRole): def setData(self, index, value, role=Qt.EditRole):
if not index.isValid(): if not index.isValid():
return NONE return NONE
# set up to position at the category label # set up to reposition at the same item. We can do this except if
path = self.path_for_index(self.parent(index)) # working with the last item and that item is deleted, in which case
# we position at the parent label
path = index.model().path_for_index(index)
val = unicode(value.toString()) val = unicode(value.toString())
if not val: if not val:
error_dialog(self.tags_view, _('Item is blank'), error_dialog(self.tags_view, _('Item is blank'),
@ -947,18 +949,22 @@ class TagBrowserMixin(object): # {{{
for old_id in to_rename[text]: for old_id in to_rename[text]:
rename_func(old_id, new_name=unicode(text)) rename_func(old_id, new_name=unicode(text))
# Clean up everything, as information could have changed for many books. # Clean up the library view
self.library_view.model().refresh() self.do_tag_item_renamed()
self.tags_view.set_new_model() self.tags_view.set_new_model() # does a refresh for free
self.tags_view.recount()
self.saved_search.clear()
self.search.clear()
def do_tag_item_renamed(self): def do_tag_item_renamed(self):
# Clean up library view and search # Clean up library view and search
self.library_view.model().refresh() # get information to redo the selection
self.saved_search.clear() rows = [r.row() for r in \
self.search.clear() self.library_view.selectionModel().selectedRows()]
m = self.library_view.model()
ids = [m.id(r) for r in rows]
m.refresh(reset=False)
m.research()
self.library_view.select_rows(ids)
# refreshing the tags view happens at the emit()/call() site
def do_author_sort_edit(self, parent, id): def do_author_sort_edit(self, parent, id):
db = self.library_view.model().db db = self.library_view.model().db