mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Fix #1182268 (Title text paste)
This commit is contained in:
parent
d4aad0f2a9
commit
830d797f7a
@ -1029,7 +1029,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
return False
|
return False
|
||||||
val = (int(value.toInt()[0]) if column == 'rating' else
|
val = (int(value.toInt()[0]) if column == 'rating' else
|
||||||
value.toDateTime() if column in ('timestamp', 'pubdate')
|
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)
|
id = self.db.id(row)
|
||||||
books_to_refresh = set([id])
|
books_to_refresh = set([id])
|
||||||
if column == 'rating':
|
if column == 'rating':
|
||||||
|
@ -45,6 +45,9 @@ def save_dialog(parent, title, msg, det_msg=''):
|
|||||||
d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
||||||
return d.exec_()
|
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
|
The interface common to all widgets used to set basic metadata
|
||||||
class BasicMetadataWidget(object):
|
class BasicMetadataWidget(object):
|
||||||
@ -117,7 +120,7 @@ class TitleEdit(EnLineEdit):
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
title = unicode(self.text()).strip()
|
title = clean_text(unicode(self.text()))
|
||||||
if not title:
|
if not title:
|
||||||
title = self.get_default()
|
title = self.get_default()
|
||||||
return title
|
return title
|
||||||
@ -289,7 +292,7 @@ class AuthorsEdit(EditWithComplete):
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
au = unicode(self.text()).strip()
|
au = clean_text(unicode(self.text()))
|
||||||
if not au:
|
if not au:
|
||||||
au = self.get_default()
|
au = self.get_default()
|
||||||
return string_to_authors(au)
|
return string_to_authors(au)
|
||||||
@ -352,7 +355,7 @@ class AuthorSortEdit(EnLineEdit):
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return unicode(self.text()).strip()
|
return clean_text(unicode(self.text()))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
if not val:
|
if not val:
|
||||||
@ -472,7 +475,7 @@ class SeriesEdit(EditWithComplete):
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return unicode(self.currentText()).strip()
|
return clean_text(unicode(self.currentText()))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
if not val:
|
if not val:
|
||||||
@ -1135,7 +1138,7 @@ class TagsEdit(EditWithComplete): # {{{
|
|||||||
@dynamic_property
|
@dynamic_property
|
||||||
def current_val(self):
|
def current_val(self):
|
||||||
def fget(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):
|
def fset(self, val):
|
||||||
if not val:
|
if not val:
|
||||||
val = []
|
val = []
|
||||||
@ -1237,7 +1240,7 @@ class IdentifiersEdit(QLineEdit): # {{{
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
def fget(self):
|
def fget(self):
|
||||||
raw = unicode(self.text()).strip()
|
raw = unicode(self.text()).strip()
|
||||||
parts = [x.strip() for x in raw.split(',')]
|
parts = [clean_text(x) for x in raw.split(',')]
|
||||||
ans = {}
|
ans = {}
|
||||||
for x in parts:
|
for x in parts:
|
||||||
c = x.split(':')
|
c = x.split(':')
|
||||||
@ -1376,7 +1379,7 @@ class PublisherEdit(EditWithComplete): # {{{
|
|||||||
def current_val(self):
|
def current_val(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return unicode(self.currentText()).strip()
|
return clean_text(unicode(self.currentText()))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
if not val:
|
if not val:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user