mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #910523 (REGEXP "replace with" field drops spaces)
This commit is contained in:
parent
b81f7d7edc
commit
e1498bfa3e
@ -43,6 +43,9 @@ class Widget(QWidget):
|
|||||||
ICON = I('config.png')
|
ICON = I('config.png')
|
||||||
HELP = ''
|
HELP = ''
|
||||||
COMMIT_NAME = None
|
COMMIT_NAME = None
|
||||||
|
# If True, leading and trailing spaces are removed from line and text edit
|
||||||
|
# fields
|
||||||
|
STRIP_TEXT_FIELDS = True
|
||||||
|
|
||||||
changed_signal = pyqtSignal()
|
changed_signal = pyqtSignal()
|
||||||
set_help = pyqtSignal(object)
|
set_help = pyqtSignal(object)
|
||||||
@ -123,7 +126,6 @@ class Widget(QWidget):
|
|||||||
if name in getattr(recs, 'disabled_options', []):
|
if name in getattr(recs, 'disabled_options', []):
|
||||||
gui_opt.setDisabled(True)
|
gui_opt.setDisabled(True)
|
||||||
|
|
||||||
|
|
||||||
def get_value(self, g):
|
def get_value(self, g):
|
||||||
from calibre.gui2.convert.xpath_wizard import XPathEdit
|
from calibre.gui2.convert.xpath_wizard import XPathEdit
|
||||||
from calibre.gui2.convert.regex_builder import RegexEdit
|
from calibre.gui2.convert.regex_builder import RegexEdit
|
||||||
@ -135,7 +137,9 @@ class Widget(QWidget):
|
|||||||
return g.value()
|
return g.value()
|
||||||
elif isinstance(g, (QLineEdit, QTextEdit)):
|
elif isinstance(g, (QLineEdit, QTextEdit)):
|
||||||
func = getattr(g, 'toPlainText', getattr(g, 'text', None))()
|
func = getattr(g, 'toPlainText', getattr(g, 'text', None))()
|
||||||
ans = unicode(func).strip()
|
ans = unicode(func)
|
||||||
|
if self.STRIP_TEXT_FIELDS:
|
||||||
|
ans = ans.strip()
|
||||||
if not ans:
|
if not ans:
|
||||||
ans = None
|
ans = None
|
||||||
return ans
|
return ans
|
||||||
|
@ -6,8 +6,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from PyQt4.Qt import QLineEdit, QTextEdit
|
|
||||||
|
|
||||||
from calibre.gui2.convert.search_and_replace_ui import Ui_Form
|
from calibre.gui2.convert.search_and_replace_ui import Ui_Form
|
||||||
from calibre.gui2.convert import Widget
|
from calibre.gui2.convert import Widget
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
@ -18,6 +16,7 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
|
|||||||
HELP = _('Modify the document text and structure using user defined patterns.')
|
HELP = _('Modify the document text and structure using user defined patterns.')
|
||||||
COMMIT_NAME = 'search_and_replace'
|
COMMIT_NAME = 'search_and_replace'
|
||||||
ICON = I('search.png')
|
ICON = I('search.png')
|
||||||
|
STRIP_TEXT_FIELDS = False
|
||||||
|
|
||||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||||
Widget.__init__(self, parent,
|
Widget.__init__(self, parent,
|
||||||
@ -74,13 +73,5 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
|
|||||||
_('Invalid regular expression: %s')%err, show=True)
|
_('Invalid regular expression: %s')%err, show=True)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_vaule(self, g):
|
|
||||||
if isinstance(g, (QLineEdit, QTextEdit)):
|
|
||||||
func = getattr(g, 'toPlainText', getattr(g, 'text', None))()
|
|
||||||
ans = unicode(func)
|
|
||||||
if not ans:
|
|
||||||
ans = None
|
|
||||||
return ans
|
|
||||||
else:
|
|
||||||
return Widget.get_value(self, g)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user