From 9b229f3951844a5de264b225d1920d14fbebf359 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 23 Nov 2015 13:13:39 +0530 Subject: [PATCH] Show search expression in tooltip for saved search entries in tag browser --- src/calibre/db/categories.py | 7 ++++--- src/calibre/gui2/tag_browser/model.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/db/categories.py b/src/calibre/db/categories.py index 361cdd02d0..b3c72090d7 100644 --- a/src/calibre/db/categories.py +++ b/src/calibre/db/categories.py @@ -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 diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index 9151b8edc4..bc4cdaa2f5 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -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]