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')
|
||||
HELP = ''
|
||||
COMMIT_NAME = None
|
||||
# If True, leading and trailing spaces are removed from line and text edit
|
||||
# fields
|
||||
STRIP_TEXT_FIELDS = True
|
||||
|
||||
changed_signal = pyqtSignal()
|
||||
set_help = pyqtSignal(object)
|
||||
@ -123,7 +126,6 @@ class Widget(QWidget):
|
||||
if name in getattr(recs, 'disabled_options', []):
|
||||
gui_opt.setDisabled(True)
|
||||
|
||||
|
||||
def get_value(self, g):
|
||||
from calibre.gui2.convert.xpath_wizard import XPathEdit
|
||||
from calibre.gui2.convert.regex_builder import RegexEdit
|
||||
@ -135,7 +137,9 @@ class Widget(QWidget):
|
||||
return g.value()
|
||||
elif isinstance(g, (QLineEdit, QTextEdit)):
|
||||
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:
|
||||
ans = None
|
||||
return ans
|
||||
|
@ -6,8 +6,6 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
|
||||
from PyQt4.Qt import QLineEdit, QTextEdit
|
||||
|
||||
from calibre.gui2.convert.search_and_replace_ui import Ui_Form
|
||||
from calibre.gui2.convert import Widget
|
||||
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.')
|
||||
COMMIT_NAME = 'search_and_replace'
|
||||
ICON = I('search.png')
|
||||
STRIP_TEXT_FIELDS = False
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent,
|
||||
@ -74,13 +73,5 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
|
||||
_('Invalid regular expression: %s')%err, show=True)
|
||||
return False
|
||||
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