mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Enhancement #1255676: match books should update the thumbnail as well as the metadata.
This commit is contained in:
parent
9b0409ea88
commit
d225448cca
@ -36,4 +36,4 @@ class MatchBookAction(InterfaceAction):
|
|||||||
return
|
return
|
||||||
|
|
||||||
id_ = view.model().indices(rows)[0]
|
id_ = view.model().indices(rows)[0]
|
||||||
MatchBooks(self.gui, view, id_).exec_()
|
MatchBooks(self.gui, view, id_, rows[0]).exec_()
|
||||||
|
@ -1284,9 +1284,7 @@ class DeviceMixin(object): # {{{
|
|||||||
prefix = ascii_filename(prefix)
|
prefix = ascii_filename(prefix)
|
||||||
names.append('%s_%d%s'%(prefix, id,
|
names.append('%s_%d%s'%(prefix, id,
|
||||||
os.path.splitext(f)[1]))
|
os.path.splitext(f)[1]))
|
||||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
self.update_thumbnail(mi)
|
||||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
|
|
||||||
'rb').read())
|
|
||||||
dynamic.set('catalogs_to_be_synced', set([]))
|
dynamic.set('catalogs_to_be_synced', set([]))
|
||||||
if files:
|
if files:
|
||||||
remove = []
|
remove = []
|
||||||
@ -1367,9 +1365,7 @@ class DeviceMixin(object): # {{{
|
|||||||
prefix = ascii_filename(prefix)
|
prefix = ascii_filename(prefix)
|
||||||
names.append('%s_%d%s'%(prefix, id,
|
names.append('%s_%d%s'%(prefix, id,
|
||||||
os.path.splitext(f)[1]))
|
os.path.splitext(f)[1]))
|
||||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
self.update_thumbnail(mi)
|
||||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
|
|
||||||
'rb').read())
|
|
||||||
self.news_to_be_synced = set([])
|
self.news_to_be_synced = set([])
|
||||||
if config['upload_news_to_device'] and files:
|
if config['upload_news_to_device'] and files:
|
||||||
remove = ids if del_on_upload else []
|
remove = ids if del_on_upload else []
|
||||||
@ -1423,8 +1419,7 @@ class DeviceMixin(object): # {{{
|
|||||||
metadata = self.library_view.model().metadata_for(ids)
|
metadata = self.library_view.model().metadata_for(ids)
|
||||||
ids = iter(ids)
|
ids = iter(ids)
|
||||||
for mi in metadata:
|
for mi in metadata:
|
||||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
self.update_thumbnail(mi)
|
||||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover, 'rb').read())
|
|
||||||
imetadata = iter(metadata)
|
imetadata = iter(metadata)
|
||||||
|
|
||||||
bad, good, gf, names, remove_ids = [], [], [], [], []
|
bad, good, gf, names, remove_ids = [], [], [], [], []
|
||||||
@ -1665,6 +1660,13 @@ class DeviceMixin(object): # {{{
|
|||||||
loc[4] |= self.book_db_uuid_path_map[id]
|
loc[4] |= self.book_db_uuid_path_map[id]
|
||||||
return loc
|
return loc
|
||||||
|
|
||||||
|
def update_thumbnail(self, book):
|
||||||
|
if book.cover and os.access(book.cover, os.R_OK):
|
||||||
|
book.thumbnail = self.cover_to_thumbnail(open(book.cover, 'rb').read())
|
||||||
|
else:
|
||||||
|
book.thumbnail = self.default_thumbnail
|
||||||
|
|
||||||
|
|
||||||
def set_books_in_library(self, booklists, reset=False, add_as_step_to_job=None,
|
def set_books_in_library(self, booklists, reset=False, add_as_step_to_job=None,
|
||||||
force_send=False):
|
force_send=False):
|
||||||
'''
|
'''
|
||||||
@ -1738,10 +1740,7 @@ class DeviceMixin(object): # {{{
|
|||||||
mi = db.get_metadata(id_, index_is_id=True, get_cover=get_covers)
|
mi = db.get_metadata(id_, index_is_id=True, get_cover=get_covers)
|
||||||
book.smart_update(mi, replace_metadata=True)
|
book.smart_update(mi, replace_metadata=True)
|
||||||
if get_covers and desired_thumbnail_height != 0:
|
if get_covers and desired_thumbnail_height != 0:
|
||||||
if book.cover and os.access(book.cover, os.R_OK):
|
self.update_thumbnail(book)
|
||||||
book.thumbnail = self.cover_to_thumbnail(open(book.cover, 'rb').read())
|
|
||||||
else:
|
|
||||||
book.thumbnail = self.default_thumbnail
|
|
||||||
|
|
||||||
def updateq(id_, book):
|
def updateq(id_, book):
|
||||||
try:
|
try:
|
||||||
|
@ -46,7 +46,7 @@ class TableItem(QTableWidgetItem):
|
|||||||
|
|
||||||
class MatchBooks(QDialog, Ui_MatchBooks):
|
class MatchBooks(QDialog, Ui_MatchBooks):
|
||||||
|
|
||||||
def __init__(self, gui, view, id_):
|
def __init__(self, gui, view, id_, row_index):
|
||||||
QDialog.__init__(self, gui, flags=Qt.Window)
|
QDialog.__init__(self, gui, flags=Qt.Window)
|
||||||
Ui_MatchBooks.__init__(self)
|
Ui_MatchBooks.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@ -73,6 +73,7 @@ class MatchBooks(QDialog, Ui_MatchBooks):
|
|||||||
self.view = view
|
self.view = view
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
self.current_device_book_id = id_
|
self.current_device_book_id = id_
|
||||||
|
self.current_device_book_index = row_index
|
||||||
self.current_library_book_id = None
|
self.current_library_book_id = None
|
||||||
|
|
||||||
# Set up the books table columns
|
# Set up the books table columns
|
||||||
@ -194,9 +195,14 @@ class MatchBooks(QDialog, Ui_MatchBooks):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
return
|
||||||
mi = self.library_db.get_metadata(self.current_library_book_id,
|
mi = self.library_db.get_metadata(self.current_library_book_id,
|
||||||
index_is_id=True, get_user_categories=False)
|
index_is_id=True, get_user_categories=False,
|
||||||
self.device_db[self.current_device_book_id].smart_update(mi, replace_metadata=True)
|
get_cover=True)
|
||||||
self.device_db[self.current_device_book_id].in_library_waiting = True
|
book = self.device_db[self.current_device_book_id]
|
||||||
|
book.smart_update(mi, replace_metadata=True)
|
||||||
|
self.gui.update_thumbnail(book)
|
||||||
|
book.in_library_waiting = True
|
||||||
|
self.view.model().current_changed(self.current_device_book_index,
|
||||||
|
self.current_device_book_index)
|
||||||
self.save_state()
|
self.save_state()
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user