mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Option to turn of primary collation
This commit is contained in:
commit
e49c702797
@ -26,6 +26,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
r('search_as_you_type', config)
|
r('search_as_you_type', config)
|
||||||
r('highlight_search_matches', config)
|
r('highlight_search_matches', config)
|
||||||
r('limit_search_columns', prefs)
|
r('limit_search_columns', prefs)
|
||||||
|
r('use_primary_find_in_search', prefs)
|
||||||
r('limit_search_columns_to', prefs, setting=CommaSeparatedList)
|
r('limit_search_columns_to', prefs, setting=CommaSeparatedList)
|
||||||
fl = db.field_metadata.get_search_terms()
|
fl = db.field_metadata.get_search_terms()
|
||||||
self.opt_limit_search_columns_to.update_items_cache(fl)
|
self.opt_limit_search_columns_to.update_items_cache(fl)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>670</width>
|
<width>670</width>
|
||||||
<height>556</height>
|
<height>663</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -21,14 +21,21 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="opt_use_primary_find_in_search">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unaccented characters match accented characters</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="opt_highlight_search_matches">
|
<widget class="QCheckBox" name="opt_highlight_search_matches">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Highlight search results instead of restricting the book list to the results</string>
|
<string>&Highlight search results instead of restricting the book list to the results</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>What to search by default</string>
|
<string>What to search by default</string>
|
||||||
@ -77,17 +84,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="clear_history_button">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Clear search histories from all over calibre. Including the book list, e-book viewer, fetch news dialog, etc.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear search &histories</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Grouped Search Terms</string>
|
<string>Grouped Search Terms</string>
|
||||||
@ -107,12 +104,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="gst_names">
|
<widget class="QComboBox" name="gst_names">
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="minimumContentsLength">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Contains the names of the currently-defined group search terms.
|
<string>Contains the names of the currently-defined group search terms.
|
||||||
Create a new name by entering it into the empty box, then
|
Create a new name by entering it into the empty box, then
|
||||||
@ -120,6 +111,12 @@ pressing Save. Rename a search term by selecting it then
|
|||||||
changing the name and pressing Save. Change the value of
|
changing the name and pressing Save. Change the value of
|
||||||
a search term by changing the value box then pressing Save.</string>
|
a search term by changing the value box then pressing Save.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="minimumContentsLength">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -201,7 +198,17 @@ to be shown as user categories</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="clear_history_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Clear search histories from all over calibre. Including the book list, e-book viewer, fetch news dialog, etc.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear search &histories</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="groupBox22">
|
<widget class="QGroupBox" name="groupBox22">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>What to search when searching similar books</string>
|
<string>What to search when searching similar books</string>
|
||||||
@ -211,7 +218,7 @@ to be shown as user categories</string>
|
|||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><p>When you search for similar books by right clicking the
|
<string><p>When you search for similar books by right clicking the
|
||||||
book and selecting "Similar books...",
|
book and selecting "Similar books...",
|
||||||
calibre constructs a search using the column lookup names specified below.
|
calibre constructs a search using the column lookup names specified below.
|
||||||
By changing the lookup name to a grouped search term you can
|
By changing the lookup name to a grouped search term you can
|
||||||
search multiple columns at once.</p></string>
|
search multiple columns at once.</p></string>
|
||||||
@ -239,8 +246,7 @@ to be shown as user categories</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QComboBox" name="opt_similar_authors_match_kind">
|
<widget class="QComboBox" name="opt_similar_authors_match_kind"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
<item row="1" column="3">
|
||||||
<widget class="QLabel" name="label_222">
|
<widget class="QLabel" name="label_222">
|
||||||
@ -260,8 +266,7 @@ to be shown as user categories</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="5">
|
<item row="1" column="5">
|
||||||
<widget class="QComboBox" name="opt_similar_series_match_kind">
|
<widget class="QComboBox" name="opt_similar_series_match_kind"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_223">
|
<widget class="QLabel" name="label_223">
|
||||||
@ -271,12 +276,10 @@ to be shown as user categories</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="similar_tags_search_key">
|
<widget class="QComboBox" name="similar_tags_search_key"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QComboBox" name="opt_similar_tags_match_kind">
|
<widget class="QComboBox" name="opt_similar_tags_match_kind"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="QLabel" name="label_224">
|
<widget class="QLabel" name="label_224">
|
||||||
@ -286,12 +289,10 @@ to be shown as user categories</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4">
|
<item row="2" column="4">
|
||||||
<widget class="QComboBox" name="similar_publisher_search_key">
|
<widget class="QComboBox" name="similar_publisher_search_key"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="5">
|
<item row="2" column="5">
|
||||||
<widget class="QComboBox" name="opt_similar_publisher_match_kind">
|
<widget class="QComboBox" name="opt_similar_publisher_match_kind"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -341,9 +341,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
tweak = self.tweaks.data(idx, Qt.UserRole)
|
tweak = self.tweaks.data(idx, Qt.UserRole)
|
||||||
self.context_menu = QMenu(self)
|
self.context_menu = QMenu(self)
|
||||||
self.context_menu.addAction(self.copy_icon,
|
self.context_menu.addAction(self.copy_icon,
|
||||||
_('Copy to clipboard'),
|
_('Copy to clipboard'),
|
||||||
partial(self.copy_item_to_clipboard,
|
partial(self.copy_item_to_clipboard,
|
||||||
val=tweak.name))
|
val=u"%s (%s: %s)"%(tweak.name,
|
||||||
|
_('ID'),
|
||||||
|
tweak.var_names[0])))
|
||||||
self.context_menu.popup(self.mapToGlobal(point))
|
self.context_menu.popup(self.mapToGlobal(point))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -118,6 +118,9 @@ class MetadataBackup(Thread): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
# This is a global for performance
|
||||||
|
pref_use_primary_find_in_search = False
|
||||||
|
|
||||||
### Global utility function for get_match here and in gui2/library.py
|
### Global utility function for get_match here and in gui2/library.py
|
||||||
CONTAINS_MATCH = 0
|
CONTAINS_MATCH = 0
|
||||||
EQUALS_MATCH = 1
|
EQUALS_MATCH = 1
|
||||||
@ -148,9 +151,12 @@ def _match(query, value, matchkind):
|
|||||||
elif query == t:
|
elif query == t:
|
||||||
return True
|
return True
|
||||||
elif matchkind == REGEXP_MATCH:
|
elif matchkind == REGEXP_MATCH:
|
||||||
return re.search(query, icu_lower(t), re.I|re.UNICODE)
|
return re.search(query, t, re.I|re.UNICODE)
|
||||||
elif matchkind == CONTAINS_MATCH:
|
elif matchkind == CONTAINS_MATCH:
|
||||||
return primary_find(query, t)[0] != -1
|
if pref_use_primary_find_in_search:
|
||||||
|
return primary_find(query, t)[0] != -1
|
||||||
|
else:
|
||||||
|
return query in t
|
||||||
except re.error:
|
except re.error:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
@ -611,6 +617,9 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
|
|
||||||
def get_matches(self, location, query, candidates=None,
|
def get_matches(self, location, query, candidates=None,
|
||||||
allow_recursion=True):
|
allow_recursion=True):
|
||||||
|
global pref_use_primary_find_in_search
|
||||||
|
pref_use_primary_find_in_search = prefs['use_primary_find_in_search']
|
||||||
|
|
||||||
matches = set([])
|
matches = set([])
|
||||||
if candidates is None:
|
if candidates is None:
|
||||||
candidates = self.universal_set()
|
candidates = self.universal_set()
|
||||||
@ -637,8 +646,10 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
else:
|
else:
|
||||||
invert = False
|
invert = False
|
||||||
for loc in location:
|
for loc in location:
|
||||||
matches |= self.get_matches(loc, query,
|
m = self.get_matches(loc, query,
|
||||||
candidates=candidates, allow_recursion=False)
|
candidates=candidates, allow_recursion=False)
|
||||||
|
matches |= m
|
||||||
|
candidates -= m
|
||||||
if invert:
|
if invert:
|
||||||
matches = self.universal_set() - matches
|
matches = self.universal_set() - matches
|
||||||
return matches
|
return matches
|
||||||
@ -655,8 +666,10 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
if terms:
|
if terms:
|
||||||
for l in terms:
|
for l in terms:
|
||||||
try:
|
try:
|
||||||
matches |= self.get_matches(l, query,
|
m = self.get_matches(l, query,
|
||||||
candidates=candidates, allow_recursion=allow_recursion)
|
candidates=candidates, allow_recursion=allow_recursion)
|
||||||
|
matches |= m
|
||||||
|
candidates -= m
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return matches
|
return matches
|
||||||
|
@ -422,6 +422,12 @@ def _prefs():
|
|||||||
'title:Red. Enter a list of search/lookup names '
|
'title:Red. Enter a list of search/lookup names '
|
||||||
'separated by commas. Only takes effect if you set the option '
|
'separated by commas. Only takes effect if you set the option '
|
||||||
'to limit search columns above.'))
|
'to limit search columns above.'))
|
||||||
|
c.add_opt('use_primary_find_in_search', default=True,
|
||||||
|
help=_('Characters typed in the search box will match their '
|
||||||
|
'accented versions, based on the language you have chosen '
|
||||||
|
'for the calibre interface. For example, in '
|
||||||
|
u' English, searching for n will match ñ and n, but if '
|
||||||
|
'your language is Spanish it will only match n.'))
|
||||||
|
|
||||||
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
|
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
|
||||||
return c
|
return c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user