mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Edit Book: Spell check dialog: Add an option to make filtering the word list case sensitive
This commit is contained in:
parent
a6450d47a3
commit
466383c519
@ -57,7 +57,7 @@ d['editor_xml_toolbar'] = ['pretty-current', 'insert-tag']
|
|||||||
d['editor_html_toolbar'] = ['fix-html-current', 'pretty-current', 'insert-image', 'insert-hyperlink', 'insert-tag', 'change-paragraph']
|
d['editor_html_toolbar'] = ['fix-html-current', 'pretty-current', 'insert-image', 'insert-hyperlink', 'insert-tag', 'change-paragraph']
|
||||||
d['editor_format_toolbar'] = [('format-text-' + x) for x in (
|
d['editor_format_toolbar'] = [('format-text-' + x) for x in (
|
||||||
'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'color', 'background-color')]
|
'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'color', 'background-color')]
|
||||||
|
d['spell_check_case_sensitive_search'] = False
|
||||||
del d
|
del d
|
||||||
|
|
||||||
ucase_map = {l:string.ascii_uppercase[i] for i, l in enumerate(string.ascii_lowercase)}
|
ucase_map = {l:string.ascii_uppercase[i] for i, l in enumerate(string.ascii_lowercase)}
|
||||||
|
@ -31,7 +31,7 @@ from calibre.spell.dictionary import (
|
|||||||
get_dictionary, DictionaryLocale, dprefs, remove_dictionary, rename_dictionary)
|
get_dictionary, DictionaryLocale, dprefs, remove_dictionary, rename_dictionary)
|
||||||
from calibre.spell.import_from import import_from_oxt
|
from calibre.spell.import_from import import_from_oxt
|
||||||
from calibre.utils.localization import calibre_langcode_to_name, get_language, get_lang, canonicalize_lang
|
from calibre.utils.localization import calibre_langcode_to_name, get_language, get_lang, canonicalize_lang
|
||||||
from calibre.utils.icu import sort_key, primary_sort_key, primary_contains
|
from calibre.utils.icu import sort_key, primary_sort_key, primary_contains, contains
|
||||||
|
|
||||||
LANG = 0
|
LANG = 0
|
||||||
COUNTRY = 1
|
COUNTRY = 1
|
||||||
@ -693,7 +693,8 @@ class WordsModel(QAbstractTableModel):
|
|||||||
def filter_item(self, x):
|
def filter_item(self, x):
|
||||||
if self.show_only_misspelt and self.spell_map[x]:
|
if self.show_only_misspelt and self.spell_map[x]:
|
||||||
return False
|
return False
|
||||||
if self.filter_expression is not None and not primary_contains(self.filter_expression, x[0]):
|
func = contains if tprefs['spell_check_case_sensitive_search'] else primary_contains
|
||||||
|
if self.filter_expression is not None and not func(self.filter_expression, x[0]):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -986,10 +987,15 @@ class SpellCheck(Dialog):
|
|||||||
om.stateChanged.connect(self.update_show_only_misspelt)
|
om.stateChanged.connect(self.update_show_only_misspelt)
|
||||||
self.case_sensitive_sort = cs = QCheckBox(_('Case &sensitive sort'))
|
self.case_sensitive_sort = cs = QCheckBox(_('Case &sensitive sort'))
|
||||||
cs.setChecked(tprefs['spell_check_case_sensitive_sort'])
|
cs.setChecked(tprefs['spell_check_case_sensitive_sort'])
|
||||||
|
cs.setToolTip(_('When sorting the list of words, be case sensitive'))
|
||||||
cs.stateChanged.connect(self.sort_type_changed)
|
cs.stateChanged.connect(self.sort_type_changed)
|
||||||
|
self.case_sensitive_search = cs2 = QCheckBox(_('Case sensitive sea&rch'))
|
||||||
|
cs2.setToolTip(_('When filtering the list of words, be case sensitive'))
|
||||||
|
cs2.setChecked(tprefs['spell_check_case_sensitive_search'])
|
||||||
|
cs2.stateChanged.connect(self.search_type_changed)
|
||||||
self.hb = h = QHBoxLayout()
|
self.hb = h = QHBoxLayout()
|
||||||
self.summary = s = QLabel('')
|
self.summary = s = QLabel('')
|
||||||
self.main.l.addLayout(h), h.addWidget(s), h.addWidget(om), h.addWidget(cs), h.addStretch(1)
|
self.main.l.addLayout(h), h.addWidget(s), h.addWidget(om), h.addWidget(cs), h.addWidget(cs2), h.addStretch(1)
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev.key() in (Qt.Key_Enter, Qt.Key_Return):
|
if ev.key() in (Qt.Key_Enter, Qt.Key_Return):
|
||||||
@ -1004,6 +1010,11 @@ class SpellCheck(Dialog):
|
|||||||
hh = self.words_view.horizontalHeader()
|
hh = self.words_view.horizontalHeader()
|
||||||
self.words_view.sortByColumn(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
|
self.words_view.sortByColumn(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
|
||||||
|
|
||||||
|
def search_type_changed(self):
|
||||||
|
tprefs['spell_check_case_sensitive_search'] = bool(self.case_sensitive_search.isChecked())
|
||||||
|
if unicode(self.filter_text.text()).strip():
|
||||||
|
self.do_filter()
|
||||||
|
|
||||||
def show_next_occurrence(self):
|
def show_next_occurrence(self):
|
||||||
self.word_activated(self.words_view.currentIndex())
|
self.word_activated(self.words_view.currentIndex())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user