mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Two minor improvements:
1) Clear the temporary VL if the search box is empty instead of giving an error. 2) Escape regexp special characters in tag browser first letter searches. Use super-quoting to make escaping work reliably.
This commit is contained in:
parent
ce78a29fc8
commit
8fa523dd70
@ -453,10 +453,10 @@ class SearchRestrictionMixin:
|
|||||||
db.data.set_base_restriction_name('')
|
db.data.set_base_restriction_name('')
|
||||||
elif library == '*':
|
elif library == '*':
|
||||||
if not self.search.current_text:
|
if not self.search.current_text:
|
||||||
error_dialog(self, _('No search'),
|
# Clear the temporary VL if the search box is empty
|
||||||
_('There is no current search to use'), show=True)
|
db.data.set_base_restriction('')
|
||||||
return
|
db.data.set_base_restriction_name('')
|
||||||
|
else:
|
||||||
txt = _build_full_search_string(self)
|
txt = _build_full_search_string(self)
|
||||||
try:
|
try:
|
||||||
db.data.search_getting_ids('', txt, use_virtual_library=False)
|
db.data.search_getting_ids('', txt, use_virtual_library=False)
|
||||||
|
@ -1717,15 +1717,18 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
letters_seen = {}
|
letters_seen = {}
|
||||||
for subnode in tag_item.children:
|
for subnode in tag_item.children:
|
||||||
if subnode.tag.sort:
|
if subnode.tag.sort:
|
||||||
letters_seen[subnode.tag.sort[0]] = True
|
c = subnode.tag.sort[0]
|
||||||
|
if c in r'\.^$[]|()':
|
||||||
|
c = f'\\{c}'
|
||||||
|
letters_seen[c] = True
|
||||||
if letters_seen:
|
if letters_seen:
|
||||||
charclass = ''.join(letters_seen)
|
charclass = ''.join(letters_seen)
|
||||||
if k == 'author_sort':
|
if k == 'author_sort':
|
||||||
expr = r'%s:"~(^[%s])|(&\s*[%s])"'%(k, charclass, charclass)
|
expr = r'%s:"""~(^[%s])|(&\s*[%s])"""'%(k, charclass, charclass)
|
||||||
elif k == 'series':
|
elif k == 'series':
|
||||||
expr = r'series_sort:"~^[%s]"'%(charclass)
|
expr = r'series_sort:"""~^[%s]"""'%(charclass)
|
||||||
else:
|
else:
|
||||||
expr = r'%s:"~^[%s]"'%(k, charclass)
|
expr = r'%s:"""~^[%s]"""'%(k, charclass)
|
||||||
else:
|
else:
|
||||||
expr = r'%s:false'%(k)
|
expr = r'%s:false'%(k)
|
||||||
if node_searches[tag_item.tag.state] == 'true':
|
if node_searches[tag_item.tag.state] == 'true':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user