mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Tag browser: When right clicking ona saved search add a menu option to search using the raw search expression. Fixes #1816274 [Edit or copy saved search text](https://bugs.launchpad.net/calibre/+bug/1816274)
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
692214e589
@ -608,10 +608,10 @@ class SavedSearchBoxMixin(object): # {{{
|
||||
self.current_db.new_api.ensure_has_search_category(fail_on_existing=False)
|
||||
self.do_rebuild_saved_searches()
|
||||
|
||||
def get_saved_search_text(self):
|
||||
def get_saved_search_text(self, search_name=None):
|
||||
db = self.current_db
|
||||
try:
|
||||
current_search = self.search.currentText()
|
||||
current_search = search_name if search_name else self.search.currentText()
|
||||
if not current_search.startswith('search:'):
|
||||
raise ValueError()
|
||||
# This strange expression accounts for the four ways a search can be written:
|
||||
|
@ -149,6 +149,7 @@ class TagsView(QTreeView): # {{{
|
||||
self.setAutoExpandDelay(500)
|
||||
self.pane_is_visible = False
|
||||
self.search_icon = QIcon(I('search.png'))
|
||||
self.search_copy_icon = QIcon(I("search_copy_saved.png"))
|
||||
self.user_category_icon = QIcon(I('tb_folder.png'))
|
||||
self.delete_icon = QIcon(I('list_remove.png'))
|
||||
self.rename_icon = QIcon(I('edit-undo.png'))
|
||||
@ -413,6 +414,10 @@ class TagsView(QTreeView): # {{{
|
||||
if action == 'search':
|
||||
self._toggle(index, set_to=search_state)
|
||||
return
|
||||
if action == "raw_search":
|
||||
from calibre.gui2.ui import get_gui
|
||||
get_gui().get_saved_search_text(search_name='search:' + key)
|
||||
return
|
||||
if action == 'add_to_category':
|
||||
tag = index.tag
|
||||
if len(index.children) > 0:
|
||||
@ -589,6 +594,11 @@ class TagsView(QTreeView): # {{{
|
||||
partial(self.context_menu_handler, action='search',
|
||||
search_state=TAG_SEARCH_STATES['mark_minus'],
|
||||
index=index))
|
||||
self.context_menu.addAction(self.search_copy_icon,
|
||||
_('Search using saved search expression'),
|
||||
partial(self.context_menu_handler, action='raw_search',
|
||||
key=tag.name))
|
||||
|
||||
self.context_menu.addSeparator()
|
||||
elif key.startswith('@') and not item.is_gst:
|
||||
if item.can_be_edited:
|
||||
|
Loading…
x
Reference in New Issue
Block a user