Fix "random" categories getting expanded because the state check didn't take hidden and empty categories into account

This commit is contained in:
Charles Haley 2017-06-14 13:26:44 +02:00
parent d6e28e2bf5
commit 8dbaf4a453

View File

@ -209,7 +209,13 @@ class TagsView(QTreeView): # {{{
def get_state(self): def get_state(self):
state_map = {} state_map = {}
expanded_categories = [] expanded_categories = []
for row, category in enumerate(self._model.category_nodes): row = -1
hide_empty_categories = self.model().prefs['tag_browser_hide_empty_categories']
for category in self._model.category_nodes:
if (category.category_key in self.hidden_categories or
(hide_empty_categories and len(category.child_tags()) == 0)):
continue
row += 1
if self.isExpanded(self._model.index(row, 0, QModelIndex())): if self.isExpanded(self._model.index(row, 0, QModelIndex())):
expanded_categories.append(category.category_key) expanded_categories.append(category.category_key)
states = [c.tag.state for c in category.child_tags()] states = [c.tag.state for c in category.child_tags()]