Option to turn of primary collation

This commit is contained in:
Kovid Goyal 2012-07-06 21:11:01 +05:30
commit e49c702797
5 changed files with 64 additions and 41 deletions

View File

@ -26,6 +26,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('search_as_you_type', config)
r('highlight_search_matches', config)
r('limit_search_columns', prefs)
r('use_primary_find_in_search', prefs)
r('limit_search_columns_to', prefs, setting=CommaSeparatedList)
fl = db.field_metadata.get_search_terms()
self.opt_limit_search_columns_to.update_items_cache(fl)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>670</width>
<height>556</height>
<height>663</height>
</rect>
</property>
<property name="windowTitle">
@ -21,14 +21,21 @@
</property>
</widget>
</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">
<property name="text">
<string>&amp;Highlight search results instead of restricting the book list to the results</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>What to search by default</string>
@ -77,17 +84,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<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 &amp;histories</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Grouped Search Terms</string>
@ -107,12 +104,6 @@
</item>
<item>
<widget class="QComboBox" name="gst_names">
<property name="editable">
<bool>true</bool>
</property>
<property name="minimumContentsLength">
<number>10</number>
</property>
<property name="toolTip">
<string>Contains the names of the currently-defined group search terms.
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
a search term by changing the value box then pressing Save.</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="minimumContentsLength">
<number>10</number>
</property>
</widget>
</item>
<item>
@ -201,7 +198,17 @@ to be shown as user categories</string>
</layout>
</widget>
</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 &amp;histories</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox22">
<property name="title">
<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">
<property name="text">
<string>&lt;p&gt;When you search for similar books by right clicking the
book and selecting "Similar books...",
book and selecting &quot;Similar books...&quot;,
calibre constructs a search using the column lookup names specified below.
By changing the lookup name to a grouped search term you can
search multiple columns at once.&lt;/p&gt;</string>
@ -239,8 +246,7 @@ to be shown as user categories</string>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="opt_similar_authors_match_kind">
</widget>
<widget class="QComboBox" name="opt_similar_authors_match_kind"/>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_222">
@ -260,8 +266,7 @@ to be shown as user categories</string>
</widget>
</item>
<item row="1" column="5">
<widget class="QComboBox" name="opt_similar_series_match_kind">
</widget>
<widget class="QComboBox" name="opt_similar_series_match_kind"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_223">
@ -271,12 +276,10 @@ to be shown as user categories</string>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="similar_tags_search_key">
</widget>
<widget class="QComboBox" name="similar_tags_search_key"/>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="opt_similar_tags_match_kind">
</widget>
<widget class="QComboBox" name="opt_similar_tags_match_kind"/>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_224">
@ -286,12 +289,10 @@ to be shown as user categories</string>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="similar_publisher_search_key">
</widget>
<widget class="QComboBox" name="similar_publisher_search_key"/>
</item>
<item row="2" column="5">
<widget class="QComboBox" name="opt_similar_publisher_match_kind">
</widget>
<widget class="QComboBox" name="opt_similar_publisher_match_kind"/>
</item>
</layout>
</widget>

View File

@ -341,9 +341,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
tweak = self.tweaks.data(idx, Qt.UserRole)
self.context_menu = QMenu(self)
self.context_menu.addAction(self.copy_icon,
_('Copy to clipboard'),
partial(self.copy_item_to_clipboard,
val=tweak.name))
_('Copy to clipboard'),
partial(self.copy_item_to_clipboard,
val=u"%s (%s: %s)"%(tweak.name,
_('ID'),
tweak.var_names[0])))
self.context_menu.popup(self.mapToGlobal(point))
return True

View File

@ -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
CONTAINS_MATCH = 0
EQUALS_MATCH = 1
@ -148,9 +151,12 @@ def _match(query, value, matchkind):
elif query == t:
return True
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:
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:
pass
return False
@ -611,6 +617,9 @@ class ResultCache(SearchQueryParser): # {{{
def get_matches(self, location, query, candidates=None,
allow_recursion=True):
global pref_use_primary_find_in_search
pref_use_primary_find_in_search = prefs['use_primary_find_in_search']
matches = set([])
if candidates is None:
candidates = self.universal_set()
@ -637,8 +646,10 @@ class ResultCache(SearchQueryParser): # {{{
else:
invert = False
for loc in location:
matches |= self.get_matches(loc, query,
m = self.get_matches(loc, query,
candidates=candidates, allow_recursion=False)
matches |= m
candidates -= m
if invert:
matches = self.universal_set() - matches
return matches
@ -655,8 +666,10 @@ class ResultCache(SearchQueryParser): # {{{
if terms:
for l in terms:
try:
matches |= self.get_matches(l, query,
m = self.get_matches(l, query,
candidates=candidates, allow_recursion=allow_recursion)
matches |= m
candidates -= m
except:
pass
return matches

View File

@ -422,6 +422,12 @@ def _prefs():
'title:Red. Enter a list of search/lookup names '
'separated by commas. Only takes effect if you set the option '
'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.')
return c