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 #1912074 [Enhancement Request: Increase size of Edit Saved Search](https://bugs.launchpad.net/calibre/+bug/1912074) Fixes #1912081 [Saved searches are case-sensitive](https://bugs.launchpad.net/calibre/+bug/1912081)
This commit is contained in:
commit
e3cde00f98
@ -424,7 +424,11 @@ class SavedSearchQueries(object): # {{{
|
||||
db._set_pref(self.opt_name, self.queries)
|
||||
|
||||
def lookup(self, name):
|
||||
return self.queries.get(self.force_unicode(name), None)
|
||||
sn = self.force_unicode(name).lower()
|
||||
for n, q in self.queries.items():
|
||||
if sn == n.lower():
|
||||
return q
|
||||
return None
|
||||
|
||||
def delete(self, name):
|
||||
db = self.db
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QFormLayout, QIcon, QLabel, QLineEdit, QListWidget, Qt, QVBoxLayout, QDialog, QDialogButtonBox
|
||||
QFormLayout, QIcon, QLabel, QLineEdit, QListWidget, Qt, QVBoxLayout, QDialog,
|
||||
QDialogButtonBox, QPlainTextEdit
|
||||
)
|
||||
|
||||
from calibre import prepare_string_for_xml
|
||||
@ -51,12 +52,12 @@ class AddSavedSearch(Dialog):
|
||||
l.addRow(_('&Name:'), n)
|
||||
n.setPlaceholderText(_('The Saved search name'))
|
||||
|
||||
self.search = s = QLineEdit(self)
|
||||
self.search = s = QPlainTextEdit(self)
|
||||
s.setMinimumWidth(400)
|
||||
l.addRow(_('&Search:'), s)
|
||||
s.setPlaceholderText(_('The search expression'))
|
||||
if self.initial_search:
|
||||
s.setText(self.initial_search)
|
||||
s.setPlainText(self.initial_search)
|
||||
n.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
l.addRow(self.bb)
|
||||
|
||||
@ -68,7 +69,7 @@ class AddSavedSearch(Dialog):
|
||||
_('No search name'),
|
||||
_('You must specify a name for the Saved search'),
|
||||
show=True)
|
||||
expression = self.search.text().strip()
|
||||
expression = self.search.toPlainText().strip()
|
||||
if not expression:
|
||||
return error_dialog(
|
||||
self,
|
||||
@ -182,7 +183,7 @@ class SavedSearchEditor(Dialog):
|
||||
validate=self.validate_edit)
|
||||
d.setWindowTitle(_('Edit saved search'))
|
||||
d.sname.setText(n)
|
||||
d.search.setText(self.searches[n])
|
||||
d.search.setPlainText(self.searches[n])
|
||||
if d.exec_() != QDialog.DialogCode.Accepted:
|
||||
return
|
||||
name, expression = d.accepted_data
|
||||
|
@ -348,9 +348,11 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
func_names = sorted(self.funcs)
|
||||
self.function.clear()
|
||||
self.function.addItem('')
|
||||
self.function.addItems(func_names)
|
||||
for f in func_names:
|
||||
self.function.addItem('{} -- {}'.format(f,
|
||||
self.function_type_string(f, longform=False)), f)
|
||||
self.function.setCurrentIndex(0)
|
||||
self.function.currentIndexChanged[native_string_type].connect(self.function_changed)
|
||||
self.function.currentIndexChanged.connect(self.function_changed)
|
||||
self.textbox_changed()
|
||||
self.rule = (None, '')
|
||||
|
||||
@ -440,8 +442,18 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
self.highlighter.check_cursor_pos(t[position-1], block_number,
|
||||
pos_in_block)
|
||||
|
||||
def function_type_string(self, name, longform=True):
|
||||
if self.funcs[name].is_python:
|
||||
if name in self.builtins:
|
||||
return (_('Built-in template function') if longform else
|
||||
_('Built-in function'))
|
||||
return (_('User defined Python template function') if longform else
|
||||
_('User function'))
|
||||
else:
|
||||
return (_('Stored user defined template') if longform else _('Stored template'))
|
||||
|
||||
def function_changed(self, toWhat):
|
||||
name = unicode_type(toWhat)
|
||||
name = unicode_type(self.function.itemData(toWhat))
|
||||
self.source_code.clear()
|
||||
self.documentation.clear()
|
||||
self.func_type.clear()
|
||||
@ -451,10 +463,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
self.source_code.setPlainText(self.builtin_source_dict[name])
|
||||
else:
|
||||
self.source_code.setPlainText(self.funcs[name].program_text)
|
||||
if self.funcs[name].is_python:
|
||||
self.func_type.setText(_('Template function in Python'))
|
||||
else:
|
||||
self.func_type.setText(_('Stored template'))
|
||||
self.func_type.setText(self.function_type_string(name, longform=True))
|
||||
|
||||
def accept(self):
|
||||
txt = unicode_type(self.textbox.toPlainText()).rstrip()
|
||||
|
@ -66,7 +66,11 @@ class SavedSearchQueries(object):
|
||||
self.save_queries()
|
||||
|
||||
def lookup(self, name):
|
||||
return self.queries.get(self.force_unicode(name), None)
|
||||
sn = self.force_unicode(name).lower()
|
||||
for n, q in self.queries.items():
|
||||
if sn == n.lower():
|
||||
return q
|
||||
return None
|
||||
|
||||
def delete(self, name):
|
||||
self.queries.pop(self.force_unicode(name), False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user