Enhancement #1255676: match books should update the thumbnail as well as the metadata.

This commit is contained in:
Charles Haley 2013-11-28 13:39:20 +01:00
parent 9b0409ea88
commit d225448cca
3 changed files with 22 additions and 17 deletions

View File

@ -36,4 +36,4 @@ class MatchBookAction(InterfaceAction):
return
id_ = view.model().indices(rows)[0]
MatchBooks(self.gui, view, id_).exec_()
MatchBooks(self.gui, view, id_, rows[0]).exec_()

View File

@ -1284,9 +1284,7 @@ class DeviceMixin(object): # {{{
prefix = ascii_filename(prefix)
names.append('%s_%d%s'%(prefix, id,
os.path.splitext(f)[1]))
if mi.cover and os.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
self.update_thumbnail(mi)
dynamic.set('catalogs_to_be_synced', set([]))
if files:
remove = []
@ -1367,9 +1365,7 @@ class DeviceMixin(object): # {{{
prefix = ascii_filename(prefix)
names.append('%s_%d%s'%(prefix, id,
os.path.splitext(f)[1]))
if mi.cover and os.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
self.update_thumbnail(mi)
self.news_to_be_synced = set([])
if config['upload_news_to_device'] and files:
remove = ids if del_on_upload else []
@ -1423,8 +1419,7 @@ class DeviceMixin(object): # {{{
metadata = self.library_view.model().metadata_for(ids)
ids = iter(ids)
for mi in metadata:
if mi.cover and os.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover, 'rb').read())
self.update_thumbnail(mi)
imetadata = iter(metadata)
bad, good, gf, names, remove_ids = [], [], [], [], []
@ -1665,6 +1660,13 @@ class DeviceMixin(object): # {{{
loc[4] |= self.book_db_uuid_path_map[id]
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,
force_send=False):
'''
@ -1738,10 +1740,7 @@ class DeviceMixin(object): # {{{
mi = db.get_metadata(id_, index_is_id=True, get_cover=get_covers)
book.smart_update(mi, replace_metadata=True)
if get_covers and desired_thumbnail_height != 0:
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
self.update_thumbnail(book)
def updateq(id_, book):
try:

View File

@ -46,7 +46,7 @@ class TableItem(QTableWidgetItem):
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)
Ui_MatchBooks.__init__(self)
self.setupUi(self)
@ -73,6 +73,7 @@ class MatchBooks(QDialog, Ui_MatchBooks):
self.view = view
self.gui = gui
self.current_device_book_id = id_
self.current_device_book_index = row_index
self.current_library_book_id = None
# Set up the books table columns
@ -194,9 +195,14 @@ class MatchBooks(QDialog, Ui_MatchBooks):
d.exec_()
return
mi = self.library_db.get_metadata(self.current_library_book_id,
index_is_id=True, get_user_categories=False)
self.device_db[self.current_device_book_id].smart_update(mi, replace_metadata=True)
self.device_db[self.current_device_book_id].in_library_waiting = True
index_is_id=True, get_user_categories=False,
get_cover=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()
QDialog.accept(self)