This commit is contained in:
Kovid Goyal 2022-10-05 19:17:36 +05:30
commit c824c23a38
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 4 deletions

View File

@ -1204,10 +1204,13 @@ class TagsModel(QAbstractItemModel): # {{{
data[category] = [t for t in data[category] data[category] = [t for t in data[category]
if lower(t.name).find(filter_by) >= 0] if lower(t.name).find(filter_by) >= 0]
# Build a dict of the keys that have data # Build a dict of the keys that have data.
# Always add user categories so that the constructed hierarchy works.
# This means that empty categories will be displayed unless the 'hide
# empty categories' box is checked.
tb_categories = self.db.field_metadata tb_categories = self.db.field_metadata
for category in tb_categories: for category in tb_categories:
if category in data: # The search category can come and go if category in data or category.startswith('@'):
self.categories[category] = tb_categories[category]['name'] self.categories[category] = tb_categories[category]['name']
# Now build the list of fields in display order. A lot of this is to # Now build the list of fields in display order. A lot of this is to

View File

@ -976,8 +976,12 @@ class TagsView(QTreeView): # {{{
# Hide/Show/Restore categories # Hide/Show/Restore categories
self.context_menu.addSeparator() self.context_menu.addSeparator()
self.context_menu.addAction(_('Hide category %s') % category.replace('&', '&&'), # Because of the strange way hierarchy works in user categories
partial(self.context_menu_handler, action='hide', # where child nodes actually exist we must limit hiding to top-
# level categories, which will hide that category and children
if not key.startswith('@') or '.' not in key:
self.context_menu.addAction(_('Hide category %s') % category.replace('&', '&&'),
partial(self.context_menu_handler, action='hide',
category=key)).setIcon(QIcon.ic('minus.png')) category=key)).setIcon(QIcon.ic('minus.png'))
add_show_hidden_categories() add_show_hidden_categories()