From cc410ac6dab734abb5f8d0f834bdfe547839daa1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 30 Nov 2017 13:35:39 +0530 Subject: [PATCH] Tag browser: Fix use of the tweak to control order of items in the Tag browser causing unexpected expansion of items after editing metadata. Fixes #1730245 [Tag browser unexpectedly expands after edit](https://bugs.launchpad.net/calibre/+bug/1730245) --- src/calibre/gui2/tag_browser/view.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 3a7d7fbed5..e638371223 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -13,7 +13,7 @@ from itertools import izip from PyQt5.Qt import ( QStyledItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon, QApplication, - QMenu, QPoint, QModelIndex, QToolTip, QCursor, QDrag, QRect, + QMenu, QPoint, QToolTip, QCursor, QDrag, QRect, QLinearGradient, QPalette, QColor, QPen, QBrush, QFont ) @@ -220,7 +220,8 @@ class TagsView(QTreeView): # {{{ (hide_empty_categories and len(category.child_tags()) == 0)): continue row += 1 - if self.isExpanded(self._model.index(row, 0, QModelIndex())): + index = self._model.index_for_category(category.category_key) + if index is not None and self.isExpanded(index): expanded_categories.append(category.category_key) states = [c.tag.state for c in category.child_tags()] names = [(c.tag.name, c.tag.category) for c in category.child_tags()]