mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-03 14:03:06 +02:00
Fix #1182268 (Title text paste)
This commit is contained in:
parent
d4aad0f2a9
commit
830d797f7a
2 changed files with 11 additions and 8 deletions
|
|
@ -1029,7 +1029,7 @@ def _set_data(self, index, value):
|
|||
return False
|
||||
val = (int(value.toInt()[0]) if column == 'rating' else
|
||||
value.toDateTime() if column in ('timestamp', 'pubdate')
|
||||
else unicode(value.toString()).strip())
|
||||
else re.sub(ur'\s', u' ', unicode(value.toString()).strip()))
|
||||
id = self.db.id(row)
|
||||
books_to_refresh = set([id])
|
||||
if column == 'rating':
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ def save_dialog(parent, title, msg, det_msg=''):
|
|||
d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
||||
return d.exec_()
|
||||
|
||||
def clean_text(x):
|
||||
return re.sub(r'\s', ' ', x.strip())
|
||||
|
||||
'''
|
||||
The interface common to all widgets used to set basic metadata
|
||||
class BasicMetadataWidget(object):
|
||||
|
|
@ -117,7 +120,7 @@ def commit(self, db, id_):
|
|||
def current_val(self):
|
||||
|
||||
def fget(self):
|
||||
title = unicode(self.text()).strip()
|
||||
title = clean_text(unicode(self.text()))
|
||||
if not title:
|
||||
title = self.get_default()
|
||||
return title
|
||||
|
|
@ -289,7 +292,7 @@ def commit(self, db, id_):
|
|||
def current_val(self):
|
||||
|
||||
def fget(self):
|
||||
au = unicode(self.text()).strip()
|
||||
au = clean_text(unicode(self.text()))
|
||||
if not au:
|
||||
au = self.get_default()
|
||||
return string_to_authors(au)
|
||||
|
|
@ -352,7 +355,7 @@ def __init__(self, parent, authors_edit, autogen_button, db,
|
|||
def current_val(self):
|
||||
|
||||
def fget(self):
|
||||
return unicode(self.text()).strip()
|
||||
return clean_text(unicode(self.text()))
|
||||
|
||||
def fset(self, val):
|
||||
if not val:
|
||||
|
|
@ -472,7 +475,7 @@ def __init__(self, parent):
|
|||
def current_val(self):
|
||||
|
||||
def fget(self):
|
||||
return unicode(self.currentText()).strip()
|
||||
return clean_text(unicode(self.currentText()))
|
||||
|
||||
def fset(self, val):
|
||||
if not val:
|
||||
|
|
@ -1135,7 +1138,7 @@ def __init__(self, parent):
|
|||
@dynamic_property
|
||||
def current_val(self):
|
||||
def fget(self):
|
||||
return [x.strip() for x in unicode(self.text()).split(',')]
|
||||
return [clean_text(x) for x in unicode(self.text()).split(',')]
|
||||
def fset(self, val):
|
||||
if not val:
|
||||
val = []
|
||||
|
|
@ -1237,7 +1240,7 @@ def __init__(self, parent):
|
|||
def current_val(self):
|
||||
def fget(self):
|
||||
raw = unicode(self.text()).strip()
|
||||
parts = [x.strip() for x in raw.split(',')]
|
||||
parts = [clean_text(x) for x in raw.split(',')]
|
||||
ans = {}
|
||||
for x in parts:
|
||||
c = x.split(':')
|
||||
|
|
@ -1376,7 +1379,7 @@ def __init__(self, parent):
|
|||
def current_val(self):
|
||||
|
||||
def fget(self):
|
||||
return unicode(self.currentText()).strip()
|
||||
return clean_text(unicode(self.currentText()))
|
||||
|
||||
def fset(self, val):
|
||||
if not val:
|
||||
|
|
|
|||
Loading…
Reference in a new issue