mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Bug 2063171: still another ampersand escape bug
Also fixed a similar problem in the virtual library additional restrictions menu.
This commit is contained in:
parent
d1bbe63eb1
commit
94d17acbde
@ -452,6 +452,7 @@ class SavedSearchBoxMixin: # {{{
|
||||
use_hierarchy = 'search' in db.new_api.pref('categories_using_hierarchy', [])
|
||||
submenus = {}
|
||||
for name in sorted(db.saved_search_names(), key=lambda x: primary_sort_key(x.strip())):
|
||||
display_name = name.replace('&', '&&')
|
||||
current_menu = menu
|
||||
if use_hierarchy:
|
||||
components = tuple(n.strip() for n in name.split('.'))
|
||||
@ -461,14 +462,16 @@ class SavedSearchBoxMixin: # {{{
|
||||
for i,c in enumerate(hierarchy, start=1):
|
||||
hierarchical_prefix = '.'.join(hierarchy[:i])
|
||||
if hierarchical_prefix not in submenus:
|
||||
current_menu = current_menu.addMenu(c)
|
||||
current_menu = current_menu.addMenu(c.replace('&', '&&'))
|
||||
current_menu.setIcon(folder_icon)
|
||||
submenus[hierarchical_prefix] = current_menu
|
||||
else:
|
||||
current_menu = submenus[hierarchical_prefix]
|
||||
ac = add_action(current_menu, name, last, partial(self.search.set_search_string, 'search:"='+name+'"'))
|
||||
ac = add_action(current_menu, display_name, last.replace('&', '&&'),
|
||||
partial(self.search.set_search_string, 'search:"='+name+'"'))
|
||||
else:
|
||||
ac = add_action(current_menu, name, name, partial(self.search.set_search_string, 'search:"='+name+'"'))
|
||||
ac = add_action(current_menu, display_name, display_name,
|
||||
partial(self.search.set_search_string, 'search:"='+name+'"'))
|
||||
if ac.icon().isNull():
|
||||
ac.setIcon(search_icon)
|
||||
|
||||
|
@ -590,14 +590,16 @@ class SearchRestrictionMixin:
|
||||
dex = 0
|
||||
def add_action(current_menu, name, last):
|
||||
nonlocal dex
|
||||
def compare_fix_amps(name1, name2):
|
||||
return (self._trim_restriction_name(name1).replace('&&', '&') ==
|
||||
self._trim_restriction_name(name2).replace('&&', '&'))
|
||||
self.search_restriction.addItem(name)
|
||||
txt = self._trim_restriction_name(last)
|
||||
if self._trim_restriction_name(name) == self._trim_restriction_name(current_restriction):
|
||||
if compare_fix_amps(name, current_restriction):
|
||||
a = current_menu.addAction(self.checked, txt if txt else self.no_restriction)
|
||||
else:
|
||||
a = current_menu.addAction(txt if txt else self.no_restriction)
|
||||
a.triggered.connect(partial(self.search_restriction_triggered,
|
||||
action=a, index=dex))
|
||||
a.triggered.connect(partial(self.search_restriction_triggered, action=a, index=dex))
|
||||
dex += 1
|
||||
return a
|
||||
|
||||
@ -649,10 +651,9 @@ class SearchRestrictionMixin:
|
||||
if i == 1:
|
||||
self.apply_text_search_restriction(str(self.search.currentText()))
|
||||
elif i == 2 and str(self.search_restriction.currentText()).startswith('*'):
|
||||
self.apply_text_search_restriction(
|
||||
str(self.search_restriction.currentText())[1:])
|
||||
self.apply_text_search_restriction(str(self.search_restriction.currentText())[1:])
|
||||
else:
|
||||
r = str(self.search_restriction.currentText())
|
||||
r = str(self.search_restriction.currentText()).replace('&&', '&')
|
||||
if r is not None and r != '':
|
||||
restriction = 'search:"%s"'%(r)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user