mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fixes #2027727 [Accented characters in tag browser find](https://bugs.launchpad.net/calibre/+bug/2027727)
This commit is contained in:
commit
52c3084aa3
@ -1249,13 +1249,21 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
else:
|
||||
use_exact_match = False
|
||||
filter_by = self.filter_categories_by
|
||||
|
||||
if prefs['use_primary_find_in_search']:
|
||||
final_equals = lambda x, y: primary_strcmp(x, y) == 0
|
||||
final_contains = primary_contains
|
||||
else:
|
||||
final_equals = lambda x, y: strcmp(x, y) == 0
|
||||
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
|
||||
|
||||
for category in data.keys():
|
||||
if use_exact_match:
|
||||
data[category] = [t for t in data[category]
|
||||
if lower(t.name) == filter_by]
|
||||
if final_equals(t.name, filter_by)]
|
||||
else:
|
||||
data[category] = [t for t in data[category]
|
||||
if lower(t.name).find(filter_by) >= 0]
|
||||
if final_contains(filter_by, t.name)]
|
||||
|
||||
# Build a dict of the keys that have data.
|
||||
# Always add user categories so that the constructed hierarchy works.
|
||||
@ -1843,12 +1851,13 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
self.path_found = None
|
||||
if start_path is None:
|
||||
start_path = []
|
||||
|
||||
if prefs['use_primary_find_in_search']:
|
||||
final_strcmp = primary_strcmp
|
||||
final_equals = lambda x, y: primary_strcmp(x, y) == 0
|
||||
final_contains = primary_contains
|
||||
else:
|
||||
final_strcmp = strcmp
|
||||
final_contains = contains
|
||||
final_equals = lambda x, y: strcmp(x, y) == 0
|
||||
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
|
||||
|
||||
def process_tag(depth, tag_index, tag_item, start_path):
|
||||
path = self.path_for_index(tag_index)
|
||||
@ -1858,8 +1867,8 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if tag is None:
|
||||
return False
|
||||
name = tag.original_name
|
||||
if (equals_match and final_strcmp(name, txt) == 0) or \
|
||||
(not equals_match and final_contains(txt, name)):
|
||||
if ((equals_match and final_equals(name, txt)) or
|
||||
(not equals_match and final_contains(txt, name))):
|
||||
self.path_found = path
|
||||
return True
|
||||
for i,c in enumerate(tag_item.children):
|
||||
|
@ -577,15 +577,23 @@ class TagBrowserBar(QWidget): # {{{
|
||||
self.item_search.initialize('tag_browser_search')
|
||||
self.item_search.completer().setCaseSensitivity(Qt.CaseSensitivity.CaseSensitive)
|
||||
self.item_search.setToolTip(
|
||||
'<p>' +_(
|
||||
'Search for items. If the text begins with equals (=) the search is '
|
||||
'exact match, otherwise it is "contains" finding items containing '
|
||||
'the text anywhere in the item name. Both exact and contains '
|
||||
'searches ignore case. You can limit the search to particular '
|
||||
'categories using syntax similar to search. For example, '
|
||||
'tags:foo will find foo in any tag, but not in authors etc. Entering '
|
||||
'*foo will collapse all categories then showing only those categories '
|
||||
'with items containing the text "foo"') + '</p>')
|
||||
_('<p>'
|
||||
'Search for items in the Tag browser. If the search text begins '
|
||||
'with an equals sign (=) then the search is "equals", otherwise '
|
||||
'it is "contains". Both the equals and contains searches ignore '
|
||||
'case. If the preference <em>Preferences -> Searching -> Unaccented '
|
||||
'characters match accented characters ...</em> is checked then a '
|
||||
'<em>Character variant search</em> is used, where characters '
|
||||
'match regardless of accents, and punctuation is significant. See '
|
||||
'<em>The search interface</em> in the calibre manual for more explanation.'
|
||||
'</p><p>'
|
||||
'You can limit the search to particular categories using syntax '
|
||||
"similar to calibre's <em>Search</em>. For example, tags:foo will "
|
||||
'find foo in tags but not in authors etc.'
|
||||
'</p><p>'
|
||||
'Entering *foo will collapse all categories before doing the '
|
||||
'search.'
|
||||
'</p>'))
|
||||
ac = QAction(parent)
|
||||
parent.addAction(ac)
|
||||
parent.keyboard.register_shortcut('tag browser find box',
|
||||
|
Loading…
x
Reference in New Issue
Block a user