mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show search expression in tooltip for saved search entries in tag browser
This commit is contained in:
parent
b4f84a8fb4
commit
9b229f3951
@ -22,10 +22,10 @@ class Tag(object):
|
||||
|
||||
__slots__ = ('name', 'original_name', 'id', 'count', 'state', 'is_hierarchical',
|
||||
'is_editable', 'is_searchable', 'id_set', 'avg_rating', 'sort',
|
||||
'use_sort_as_name', 'icon', 'category')
|
||||
'use_sort_as_name', 'icon', 'category', 'search_expression')
|
||||
|
||||
def __init__(self, name, id=None, count=0, state=0, avg=0, sort=None,
|
||||
icon=None, category=None, id_set=None,
|
||||
icon=None, category=None, id_set=None, search_expression=None,
|
||||
is_editable=True, is_searchable=True, use_sort_as_name=False):
|
||||
self.name = self.original_name = name
|
||||
self.id = id
|
||||
@ -40,6 +40,7 @@ class Tag(object):
|
||||
self.use_sort_as_name = use_sort_as_name
|
||||
self.icon = icon
|
||||
self.category = category
|
||||
self.search_expression = search_expression
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s:%s:%s:%s:%s'%(self.name, self.count, self.id, self.state, self.category)
|
||||
@ -237,7 +238,7 @@ def get_categories(dbcache, sort='name', book_ids=None, icon_map=None,
|
||||
icon = icon_map['search']
|
||||
queries = dbcache._search_api.saved_searches.queries
|
||||
for srch in sorted(queries, key=sort_key):
|
||||
items.append(Tag(srch, sort=srch, icon=icon,
|
||||
items.append(Tag(srch, sort=srch, icon=icon, search_expression=queries[srch],
|
||||
category='search', is_editable=False))
|
||||
if len(items):
|
||||
categories['search'] = items
|
||||
|
@ -169,6 +169,8 @@ class TagTreeItem(object): # {{{
|
||||
tt.append(_('Average rating for books in this category: %.1f') % ar)
|
||||
elif self.type == self.TAG and ar is not None:
|
||||
tt.append(_('Books in this category are unrated'))
|
||||
if self.type == self.TAG and self.tag.category == 'search':
|
||||
tt.append(_('Search expression:') + ' ' + self.tag.search_expression)
|
||||
return '\n'.join(tt)
|
||||
if role == DRAG_IMAGE_ROLE:
|
||||
return self.icon_state_map[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user