mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Speed up edit single metadata dialog
This commit is contained in:
commit
41db672c83
@ -41,7 +41,8 @@ class Base(object):
|
|||||||
val = self.gui_val
|
val = self.gui_val
|
||||||
val = self.normalize_ui_val(val)
|
val = self.normalize_ui_val(val)
|
||||||
if val != self.initial_val:
|
if val != self.initial_val:
|
||||||
self.db.set_custom(book_id, val, num=self.col_id, notify=notify)
|
self.db.set_custom(book_id, val, num=self.col_id, notify=notify,
|
||||||
|
commit=False)
|
||||||
|
|
||||||
def normalize_db_val(self, val):
|
def normalize_db_val(self, val):
|
||||||
return val
|
return val
|
||||||
@ -305,7 +306,7 @@ class Series(Base):
|
|||||||
else:
|
else:
|
||||||
s_index = None
|
s_index = None
|
||||||
self.db.set_custom(book_id, val, extra=s_index,
|
self.db.set_custom(book_id, val, extra=s_index,
|
||||||
num=self.col_id, notify=notify)
|
num=self.col_id, notify=notify, commit=False)
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
'bool' : Bool,
|
'bool' : Bool,
|
||||||
|
@ -719,24 +719,31 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.db.set_authors(self.id, string_to_authors(au), notify=False)
|
self.db.set_authors(self.id, string_to_authors(au), notify=False)
|
||||||
aus = unicode(self.author_sort.text())
|
aus = unicode(self.author_sort.text())
|
||||||
if aus:
|
if aus:
|
||||||
self.db.set_author_sort(self.id, aus, notify=False)
|
self.db.set_author_sort(self.id, aus, notify=False, commit=False)
|
||||||
self.db.set_isbn(self.id,
|
self.db.set_isbn(self.id,
|
||||||
re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text())), notify=False)
|
re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text())),
|
||||||
self.db.set_rating(self.id, 2*self.rating.value(), notify=False)
|
notify=False, commit=False)
|
||||||
self.db.set_publisher(self.id, unicode(self.publisher.currentText()), notify=False)
|
self.db.set_rating(self.id, 2*self.rating.value(), notify=False,
|
||||||
|
commit=False)
|
||||||
|
self.db.set_publisher(self.id, unicode(self.publisher.currentText()),
|
||||||
|
notify=False, commit=False)
|
||||||
self.db.set_tags(self.id, [x.strip() for x in
|
self.db.set_tags(self.id, [x.strip() for x in
|
||||||
unicode(self.tags.text()).split(',')], notify=False)
|
unicode(self.tags.text()).split(',')], notify=False, commit=False)
|
||||||
self.db.set_series(self.id,
|
self.db.set_series(self.id,
|
||||||
unicode(self.series.currentText()).strip(), notify=False)
|
unicode(self.series.currentText()).strip(), notify=False,
|
||||||
self.db.set_series_index(self.id, self.series_index.value(), notify=False)
|
commit=False)
|
||||||
self.db.set_comment(self.id, unicode(self.comments.toPlainText()), notify=False)
|
self.db.set_series_index(self.id, self.series_index.value(),
|
||||||
|
notify=False, commit=False)
|
||||||
|
self.db.set_comment(self.id, unicode(self.comments.toPlainText()),
|
||||||
|
notify=False, commit=False)
|
||||||
d = self.pubdate.date()
|
d = self.pubdate.date()
|
||||||
d = qt_to_dt(d)
|
d = qt_to_dt(d)
|
||||||
self.db.set_pubdate(self.id, d, notify=False)
|
self.db.set_pubdate(self.id, d, notify=False, commit=False)
|
||||||
d = self.date.date()
|
d = self.date.date()
|
||||||
d = qt_to_dt(d)
|
d = qt_to_dt(d)
|
||||||
if d.date() != self.orig_timestamp.date():
|
if d.date() != self.orig_timestamp.date():
|
||||||
self.db.set_timestamp(self.id, d, notify=False)
|
self.db.set_timestamp(self.id, d, notify=False, commit=False)
|
||||||
|
self.db.commit()
|
||||||
|
|
||||||
if self.cover_changed:
|
if self.cover_changed:
|
||||||
if self.cover_data is not None:
|
if self.cover_data is not None:
|
||||||
@ -745,6 +752,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.db.remove_cover(self.id)
|
self.db.remove_cover(self.id)
|
||||||
for w in getattr(self, 'custom_column_widgets', []):
|
for w in getattr(self, 'custom_column_widgets', []):
|
||||||
w.commit(self.id)
|
w.commit(self.id)
|
||||||
|
self.db.commit()
|
||||||
except IOError, err:
|
except IOError, err:
|
||||||
if err.errno == 13: # Permission denied
|
if err.errno == 13: # Permission denied
|
||||||
fname = err.filename if err.filename else 'file'
|
fname = err.filename if err.filename else 'file'
|
||||||
|
@ -412,9 +412,10 @@ class CustomColumns(object):
|
|||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def set_custom(self, id, val, label=None, num=None,
|
def set_custom(self, id, val, label=None, num=None,
|
||||||
append=False, notify=True, extra=None):
|
append=False, notify=True, extra=None, commit=True):
|
||||||
self._set_custom(id, val, label=label, num=num, append=append,
|
self._set_custom(id, val, label=label, num=num, append=append,
|
||||||
notify=notify, extra=extra)
|
notify=notify, extra=extra)
|
||||||
|
if commit:
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def _set_custom(self, id_, val, label=None, num=None,
|
def _set_custom(self, id_, val, label=None, num=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user