Sync to trunk.

This commit is contained in:
John Schember 2010-01-01 13:34:38 -05:00
commit 530426977d
3 changed files with 10 additions and 7 deletions

View File

@ -275,7 +275,7 @@ class DevicePlugin(Plugin):
:metadata: If not None, it is a list of :class:`MetaInformation` objects. :metadata: If not None, it is a list of :class:`MetaInformation` objects.
The idea is to use the metadata to determine where on the device to The idea is to use the metadata to determine where on the device to
put the book. len(metadata) == len(files). Apart from the regular put the book. len(metadata) == len(files). Apart from the regular
cover_data, there may also be a thumbnail attribute, which should cover (path to cover), there may also be a thumbnail attribute, which should
be used in preference. The thumbnail attribute is of the form be used in preference. The thumbnail attribute is of the form
(width, height, cover_data as jpeg). In addition the MetaInformation (width, height, cover_data as jpeg). In addition the MetaInformation
objects can have a tag_order attribute. objects can have a tag_order attribute.

View File

@ -715,8 +715,9 @@ class DeviceGUI(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.name)[1])) os.path.splitext(f.name)[1]))
if mi.cover_data and mi.cover_data[1]: if mi.cover and os.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(mi.cover_data[1]) mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
dynamic.set('news_to_be_synced', set([])) dynamic.set('news_to_be_synced', set([]))
if config['upload_news_to_device'] and files: if config['upload_news_to_device'] and files:
remove = ids if \ remove = ids if \
@ -751,8 +752,9 @@ class DeviceGUI(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_data and mi.cover_data[1]: if mi.cover and os.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(mi.cover_data[1]) mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
imetadata = iter(metadata) imetadata = iter(metadata)
files = [getattr(f, 'name', None) for f in _files] files = [getattr(f, 'name', None) for f in _files]

View File

@ -402,9 +402,10 @@ class BooksModel(QAbstractTableModel):
def metadata_for(self, ids): def metadata_for(self, ids):
ans = [] ans = []
for id in ids: for id in ids:
mi = self.db.get_metadata(id, index_is_id=True) mi = self.db.get_metadata(id, index_is_id=True, get_cover=True)
if mi.series is not None: if mi.series is not None:
mi.tag_order = self.db.books_in_series_of(id, index_is_id=True) mi.tag_order = { mi.series: self.db.books_in_series_of(id,
index_is_id=True)}
ans.append(mi) ans.append(mi)
return ans return ans