mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression in previous release that caused the Tag browser view to jump around when renaming items
This commit is contained in:
parent
bcb3f1c555
commit
acc76f923a
@ -297,6 +297,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
|
||||
def __init__(self, parent, prefs=gprefs):
|
||||
QAbstractItemModel.__init__(self, parent)
|
||||
self.use_position_based_index_on_next_recount = False
|
||||
self.prefs = prefs
|
||||
self.node_map = {}
|
||||
self.category_nodes = []
|
||||
@ -1090,6 +1091,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
nkey_lower = icu_lower(nkey)
|
||||
|
||||
if ckey == nkey:
|
||||
self.use_position_based_index_on_next_recount = True
|
||||
return True
|
||||
|
||||
for c in sorted(user_cats.keys(), key=sort_key):
|
||||
@ -1112,6 +1114,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
user_cats[nkey + rest] = user_cats[ckey + rest]
|
||||
del user_cats[ckey + rest]
|
||||
self.user_categories_edited.emit(user_cats, nkey) # Does a refresh
|
||||
self.use_position_based_index_on_next_recount = True
|
||||
return True
|
||||
|
||||
key = item.tag.category
|
||||
@ -1129,10 +1132,12 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
error_dialog(self.gui_parent, _('Duplicate search name'),
|
||||
_('The saved search name %s is already used.')%val).exec_()
|
||||
return False
|
||||
self.use_position_based_index_on_next_recount = True
|
||||
self.db.saved_search_rename(unicode(item.data(role) or ''), val)
|
||||
item.tag.name = val
|
||||
self.search_item_renamed.emit() # Does a refresh
|
||||
else:
|
||||
self.use_position_based_index_on_next_recount = True
|
||||
restrict_to_book_ids=self.get_book_ids_to_use() if item.use_vl else None
|
||||
self.db.new_api.rename_items(key, {item.tag.id: val},
|
||||
restrict_to_book_ids=restrict_to_book_ids)
|
||||
|
@ -780,7 +780,12 @@ class TagsView(QTreeView): # {{{
|
||||
ci = self.currentIndex()
|
||||
if not ci.isValid():
|
||||
ci = self.indexAt(QPoint(10, 10))
|
||||
path = self.model().named_path_for_index(ci) if self.is_visible(ci) else None
|
||||
use_pos = self._model.use_position_based_index_on_next_recount
|
||||
self._model.use_position_based_index_on_next_recount = False
|
||||
if use_pos:
|
||||
path = self._model.path_for_index(ci) if self.is_visible(ci) else None
|
||||
else:
|
||||
path = self._model.named_path_for_index(ci) if self.is_visible(ci) else None
|
||||
expanded_categories, state_map = self.get_state()
|
||||
self._model.rebuild_node_tree(state_map=state_map)
|
||||
self.blockSignals(True)
|
||||
@ -789,9 +794,12 @@ class TagsView(QTreeView): # {{{
|
||||
if idx is not None and idx.isValid():
|
||||
self.expand(idx)
|
||||
if path is not None:
|
||||
index = self._model.index_for_named_path(path)
|
||||
if index.isValid():
|
||||
self.show_item_at_index(index)
|
||||
if use_pos:
|
||||
self.show_item_at_path(path)
|
||||
else:
|
||||
index = self._model.index_for_named_path(path)
|
||||
if index.isValid():
|
||||
self.show_item_at_index(index)
|
||||
self.blockSignals(False)
|
||||
|
||||
def show_item_at_path(self, path, box=False,
|
||||
|
Loading…
x
Reference in New Issue
Block a user