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 #1951673 [Clicking on field Search Mode resets previous field](https://bugs.launchpad.net/calibre/+bug/1951673)
This commit is contained in:
commit
304ada7f44
@ -886,38 +886,23 @@ as that of the first selected book.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="xlabel_21">
|
<widget class="QLabel" name="xlabel_24">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Search &field:</string>
|
<string>Search &mode:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>search_field</cstring>
|
<cstring>search_mode</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="search_field">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The name of the field that you want to search</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="2">
|
|
||||||
<layout class="QHBoxLayout" name="HLayout_4">
|
<layout class="QHBoxLayout" name="HLayout_4">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="xlabel_24">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search &mode:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>search_mode</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="search_mode">
|
<widget class="QComboBox" name="search_mode">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Choose whether to use basic text matching or advanced regular expression matching</string>
|
<string><p>Choose whether to use basic text matching or advanced
|
||||||
|
regular expression matching. Changing the mode clears all the fields
|
||||||
|
in this dialog.</p></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -937,6 +922,23 @@ as that of the first selected book.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="xlabel_21">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search &field:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>search_field</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="search_field">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The name of the field that you want to search</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="s_r_src_ident_label">
|
<widget class="QLabel" name="s_r_src_ident_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Identifier type:</string>
|
<string>&Identifier type:</string>
|
||||||
@ -946,7 +948,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QComboBox" name="s_r_src_ident">
|
<widget class="QComboBox" name="s_r_src_ident">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -959,7 +961,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="template_label">
|
<widget class="QLabel" name="template_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Template:</string>
|
<string>&Template:</string>
|
||||||
@ -969,7 +971,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="HistoryLineEdit" name="s_r_template">
|
<widget class="HistoryLineEdit" name="s_r_template">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -982,7 +984,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="xlabel_2">
|
<widget class="QLabel" name="xlabel_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Search for:</string>
|
<string>&Search for:</string>
|
||||||
@ -992,7 +994,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="HistoryLineEdit" name="search_for">
|
<widget class="HistoryLineEdit" name="search_for">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -1005,7 +1007,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2">
|
<item row="7" column="2">
|
||||||
<widget class="QCheckBox" name="case_sensitive">
|
<widget class="QCheckBox" name="case_sensitive">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Check this box if the search string must match exactly upper and lower case. Uncheck it if case is to be ignored</string>
|
<string>Check this box if the search string must match exactly upper and lower case. Uncheck it if case is to be ignored</string>
|
||||||
@ -1018,7 +1020,7 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="xlabel_4">
|
<widget class="QLabel" name="xlabel_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Replace with:</string>
|
<string>&Replace with:</string>
|
||||||
@ -1028,14 +1030,14 @@ as that of the first selected book.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="HistoryLineEdit" name="replace_with">
|
<widget class="HistoryLineEdit" name="replace_with">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The replacement text. The matched search text will be replaced with this string</string>
|
<string>The replacement text. The matched search text will be replaced with this string</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="2">
|
<item row="8" column="2">
|
||||||
<layout class="QHBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_41">
|
<widget class="QLabel" name="label_41">
|
||||||
@ -1070,7 +1072,7 @@ field is processed. In regular expression mode, only the matched text is process
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="destination_field_label">
|
<widget class="QLabel" name="destination_field_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Destination field:</string>
|
<string>&Destination field:</string>
|
||||||
@ -1080,7 +1082,7 @@ field is processed. In regular expression mode, only the matched text is process
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QComboBox" name="destination_field">
|
<widget class="QComboBox" name="destination_field">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The field that the text will be put into after all replacements.
|
<string>The field that the text will be put into after all replacements.
|
||||||
@ -1088,7 +1090,7 @@ If blank, the source field is used if the field is modifiable</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="2">
|
<item row="9" column="2">
|
||||||
<layout class="QHBoxLayout" name="verticalLayout_2">
|
<layout class="QHBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="replace_mode_label">
|
<widget class="QLabel" name="replace_mode_label">
|
||||||
@ -1137,7 +1139,7 @@ not multiple and the destination field is multiple</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="10" column="0">
|
||||||
<widget class="QLabel" name="s_r_dst_ident_label">
|
<widget class="QLabel" name="s_r_dst_ident_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Identifier type:</string>
|
<string>Identifier type:</string>
|
||||||
@ -1147,7 +1149,7 @@ not multiple and the destination field is multiple</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QLineEdit" name="s_r_dst_ident">
|
<widget class="QLineEdit" name="s_r_dst_ident">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -1163,7 +1165,7 @@ not multiple and the destination field is multiple</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1" colspan="2">
|
<item row="11" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="HSpacer_347">
|
<spacer name="HSpacer_347">
|
||||||
@ -1249,7 +1251,7 @@ not multiple and the destination field is multiple</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0" colspan="4">
|
<item row="12" column="0" colspan="4">
|
||||||
<widget class="QScrollArea" name="scrollArea11">
|
<widget class="QScrollArea" name="scrollArea11">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
@ -1434,8 +1436,8 @@ is completed. This can be slow on large libraries.</string>
|
|||||||
<tabstop>query_field</tabstop>
|
<tabstop>query_field</tabstop>
|
||||||
<tabstop>save_button</tabstop>
|
<tabstop>save_button</tabstop>
|
||||||
<tabstop>remove_button</tabstop>
|
<tabstop>remove_button</tabstop>
|
||||||
<tabstop>search_field</tabstop>
|
|
||||||
<tabstop>search_mode</tabstop>
|
<tabstop>search_mode</tabstop>
|
||||||
|
<tabstop>search_field</tabstop>
|
||||||
<tabstop>s_r_src_ident</tabstop>
|
<tabstop>s_r_src_ident</tabstop>
|
||||||
<tabstop>s_r_template</tabstop>
|
<tabstop>s_r_template</tabstop>
|
||||||
<tabstop>search_for</tabstop>
|
<tabstop>search_for</tabstop>
|
||||||
|
@ -49,7 +49,7 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
def __init__(self, parent=None, builtin_functions=None):
|
def __init__(self, parent=None, builtin_functions=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.initializeFormats()
|
self.initialize_formats()
|
||||||
self.initialize_rules(builtin_functions)
|
self.initialize_rules(builtin_functions)
|
||||||
self.regenerate_paren_positions()
|
self.regenerate_paren_positions()
|
||||||
self.highlighted_paren = False
|
self.highlighted_paren = False
|
||||||
@ -87,7 +87,7 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
a(r'\)', "rparen")
|
a(r'\)', "rparen")
|
||||||
self.Rules = tuple(r)
|
self.Rules = tuple(r)
|
||||||
|
|
||||||
def initializeFormats(self):
|
def initialize_formats(self):
|
||||||
font_name = gprefs.get('gpm_template_editor_font', None)
|
font_name = gprefs.get('gpm_template_editor_font', None)
|
||||||
size = gprefs['gpm_template_editor_font_size']
|
size = gprefs['gpm_template_editor_font_size']
|
||||||
if font_name is None:
|
if font_name is None:
|
||||||
@ -95,37 +95,37 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
font.setFixedPitch(True)
|
font.setFixedPitch(True)
|
||||||
font.setPointSize(size)
|
font.setPointSize(size)
|
||||||
font_name = font.family()
|
font_name = font.family()
|
||||||
Config = self.Config = {}
|
config = self.Config = {}
|
||||||
Config["fontfamily"] = font_name
|
config["fontfamily"] = font_name
|
||||||
pal = QApplication.instance().palette()
|
app_palette = QApplication.instance().palette()
|
||||||
for name, color, bold, italic in (
|
for name, color, bold, italic in (
|
||||||
("normal", None, False, False),
|
("normal", None, False, False),
|
||||||
("keyword", pal.color(QPalette.ColorRole.Link).name(), True, False),
|
("keyword", app_palette.color(QPalette.ColorRole.Link).name(), True, False),
|
||||||
("builtin", pal.color(QPalette.ColorRole.Link).name(), False, False),
|
("builtin", app_palette.color(QPalette.ColorRole.Link).name(), False, False),
|
||||||
("identifier", None, False, True),
|
("identifier", None, False, True),
|
||||||
("comment", "#007F00", False, True),
|
("comment", "#007F00", False, True),
|
||||||
("string", "#808000", False, False),
|
("string", "#808000", False, False),
|
||||||
("number", "#924900", False, False),
|
("number", "#924900", False, False),
|
||||||
("lparen", None, True, True),
|
("lparen", None, True, True),
|
||||||
("rparen", None, True, True)):
|
("rparen", None, True, True)):
|
||||||
Config["%sfontcolor" % name] = color
|
config["%sfontcolor" % name] = color
|
||||||
Config["%sfontbold" % name] = bold
|
config["%sfontbold" % name] = bold
|
||||||
Config["%sfontitalic" % name] = italic
|
config["%sfontitalic" % name] = italic
|
||||||
baseFormat = QTextCharFormat()
|
base_format = QTextCharFormat()
|
||||||
baseFormat.setFontFamily(Config["fontfamily"])
|
base_format.setFontFamily(config["fontfamily"])
|
||||||
Config["fontsize"] = size
|
config["fontsize"] = size
|
||||||
baseFormat.setFontPointSize(Config["fontsize"])
|
base_format.setFontPointSize(config["fontsize"])
|
||||||
self.Formats = {}
|
|
||||||
|
|
||||||
|
self.Formats = {}
|
||||||
for name in ("normal", "keyword", "builtin", "comment", "identifier",
|
for name in ("normal", "keyword", "builtin", "comment", "identifier",
|
||||||
"string", "number", "lparen", "rparen"):
|
"string", "number", "lparen", "rparen"):
|
||||||
format_ = QTextCharFormat(baseFormat)
|
format_ = QTextCharFormat(base_format)
|
||||||
col = Config["%sfontcolor" % name]
|
color = config["%sfontcolor" % name]
|
||||||
if col:
|
if color:
|
||||||
format_.setForeground(QColor(col))
|
format_.setForeground(QColor(color))
|
||||||
if Config["%sfontbold" % name]:
|
if config["%sfontbold" % name]:
|
||||||
format_.setFontWeight(QFont.Weight.Bold)
|
format_.setFontWeight(QFont.Weight.Bold)
|
||||||
format_.setFontItalic(Config["%sfontitalic" % name])
|
format_.setFontItalic(config["%sfontitalic" % name])
|
||||||
self.Formats[name] = format_
|
self.Formats[name] = format_
|
||||||
|
|
||||||
def find_paren(self, bn, pos):
|
def find_paren(self, bn, pos):
|
||||||
@ -157,17 +157,17 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
if self.generate_paren_positions:
|
if self.generate_paren_positions:
|
||||||
t = str(text)
|
t = str(text)
|
||||||
i = 0
|
i = 0
|
||||||
foundQuote = False
|
found_quote = False
|
||||||
while i < len(t):
|
while i < len(t):
|
||||||
c = t[i]
|
c = t[i]
|
||||||
if c == ':':
|
if c == ':':
|
||||||
# Deal with the funky syntax of template program mode.
|
# Deal with the funky syntax of template program mode.
|
||||||
# This won't work if there are more than one template
|
# This won't work if there are more than one template
|
||||||
# expression in the document.
|
# expression in the document.
|
||||||
if not foundQuote and i+1 < len(t) and t[i+1] == "'":
|
if not found_quote and i+1 < len(t) and t[i+1] == "'":
|
||||||
i += 2
|
i += 2
|
||||||
elif c in ["'", '"']:
|
elif c in ["'", '"']:
|
||||||
foundQuote = True
|
found_quote = True
|
||||||
i += 1
|
i += 1
|
||||||
j = t[i:].find(c)
|
j = t[i:].find(c)
|
||||||
if j < 0:
|
if j < 0:
|
||||||
@ -186,11 +186,11 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
QApplication.restoreOverrideCursor()
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
def check_cursor_pos(self, chr_, block, pos_in_block):
|
def check_cursor_pos(self, chr_, block, pos_in_block):
|
||||||
found_pp = -1
|
paren_pos = -1
|
||||||
for i, pp in enumerate(self.paren_positions):
|
for i, pp in enumerate(self.paren_positions):
|
||||||
pp.set_highlight(False)
|
pp.set_highlight(False)
|
||||||
if pp.block == block and pp.pos == pos_in_block:
|
if pp.block == block and pp.pos == pos_in_block:
|
||||||
found_pp = i
|
paren_pos = i
|
||||||
|
|
||||||
if chr_ not in ('(', ')'):
|
if chr_ not in ('(', ')'):
|
||||||
if self.highlighted_paren:
|
if self.highlighted_paren:
|
||||||
@ -198,12 +198,12 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
self.highlighted_paren = False
|
self.highlighted_paren = False
|
||||||
return
|
return
|
||||||
|
|
||||||
if found_pp >= 0:
|
if paren_pos >= 0:
|
||||||
stack = 0
|
stack = 0
|
||||||
if chr_ == '(':
|
if chr_ == '(':
|
||||||
list_ = self.paren_positions[found_pp+1:]
|
list_ = self.paren_positions[paren_pos+1:]
|
||||||
else:
|
else:
|
||||||
list_ = reversed(self.paren_positions[0:found_pp])
|
list_ = reversed(self.paren_positions[0:paren_pos])
|
||||||
for pp in list_:
|
for pp in list_:
|
||||||
if pp.paren == chr_:
|
if pp.paren == chr_:
|
||||||
stack += 1
|
stack += 1
|
||||||
@ -211,7 +211,7 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
stack -= 1
|
stack -= 1
|
||||||
else:
|
else:
|
||||||
pp.set_highlight(True)
|
pp.set_highlight(True)
|
||||||
self.paren_positions[found_pp].set_highlight(True)
|
self.paren_positions[paren_pos].set_highlight(True)
|
||||||
break
|
break
|
||||||
self.highlighted_paren = True
|
self.highlighted_paren = True
|
||||||
self.rehighlight()
|
self.rehighlight()
|
||||||
@ -544,7 +544,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
|||||||
self.textbox.setTabStopDistance(w)
|
self.textbox.setTabStopDistance(w)
|
||||||
self.source_code.setTabStopDistance(w)
|
self.source_code.setTabStopDistance(w)
|
||||||
self.textbox.setFont(font)
|
self.textbox.setFont(font)
|
||||||
self.highlighter.initializeFormats()
|
self.highlighter.initialize_formats()
|
||||||
self.highlighter.rehighlight()
|
self.highlighter.rehighlight()
|
||||||
|
|
||||||
def set_up_font_boxes(self):
|
def set_up_font_boxes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user