Reuse the node information (not the nodes themselves) for generated hierarchical nodes so that search indications show everywhere the node appears.

This commit is contained in:
Charles Haley 2015-11-21 15:10:24 +01:00
parent 3fe3e66880
commit 09c43ac86d

View File

@ -560,19 +560,24 @@ class TagsModel(QAbstractItemModel): # {{{
'5state' if tag.category != 'search' else '3state' '5state' if tag.category != 'search' else '3state'
else: else:
if i < len(components)-1: if i < len(components)-1:
t = copy.copy(tag) original_name = '.'.join(components[:i+1])
t.original_name = '.'.join(components[:i+1]) t = self.intermediate_nodes.get((original_name, tag.category), None)
t.count = 0 if t is None:
if key != 'search': t = copy.copy(tag)
# This 'manufactured' intermediate node can t.original_name = original_name
# be searched, but cannot be edited. t.count = 0
t.is_editable = False if key != 'search':
else: # This 'manufactured' intermediate node can
t.is_searchable = t.is_editable = False # be searched, but cannot be edited.
t.is_editable = False
else:
t.is_searchable = t.is_editable = False
self.intermediate_nodes[(original_name, tag.category)] = t
else: else:
t = tag t = tag
if not in_uc: if not in_uc:
t.original_name = t.name t.original_name = t.name
self.intermediate_nodes[(t.original_name, tag.category)] = t
t.is_hierarchical = \ t.is_hierarchical = \
'5state' if t.category != 'search' else '3state' '5state' if t.category != 'search' else '3state'
t.name = comp t.name = comp
@ -587,6 +592,7 @@ class TagsModel(QAbstractItemModel): # {{{
# Build the entire node tree. Note that category_nodes is in field # Build the entire node tree. Note that category_nodes is in field
# metadata order so the user categories will be at the end # metadata order so the user categories will be at the end
self.intermediate_nodes = {}
for category in self.category_nodes: for category in self.category_nodes:
process_one_node(category, collapse_model, process_one_node(category, collapse_model,
state_map.get(category.category_key, {})) state_map.get(category.category_key, {}))