Change search to match a tag item X when a user category path @A.X is searched, in addition to the items in category A.X

This commit is contained in:
Charles Haley 2011-02-22 16:55:27 +00:00
parent 68af4f7a1b
commit 82e23f1bd7

View File

@ -423,12 +423,22 @@ class ResultCache(SearchQueryParser): # {{{
return res
user_cats = self.db_prefs.get('user_categories', [])
c = set(candidates)
l = location.rfind('.')
if l > 0:
alt_loc = location[0:l]
alt_item = location[l+1:]
for key in user_cats:
if key == location or key.startswith(location + '.'):
for (item, category, ign) in user_cats[key]:
s = self.get_matches(category, '=' + item, candidates=c)
c -= s
res |= s
elif key == alt_loc:
for (item, category, ign) in user_cats[key]:
if item == alt_item:
s = self.get_matches(category, '=' + item, candidates=c)
c -= s
res |= s
if query == 'false':
return candidates - res
return res