Support loading of device images from paths instead of keeping them in memory

This commit is contained in:
Kovid Goyal 2010-05-17 11:18:31 -06:00
parent 7aee85def8
commit 7a9135c8e5
2 changed files with 8 additions and 3 deletions

View File

@ -380,7 +380,9 @@ class BookList(list):
3. size (file size of the book)
4. datetime (a UTC time tuple)
5. path (path on the device to the book)
6. thumbnail (can be None)
6. thumbnail (can be None) thumbnail is either a str/bytes object with the
image data or it should have an attribute image_path that stores an
absolute (platform native) path to the image
7. tags (a list of strings, can be empty).
'''

View File

@ -1418,9 +1418,12 @@ class DeviceBooksModel(BooksModel):
data = {}
item = self.db[self.map[current.row()]]
cdata = item.thumbnail
if cdata:
if cdata is not None:
img = QImage()
img.loadFromData(cdata)
if hasattr(cdata, 'image_path'):
img.load(cdata.image_path)
else:
img.loadFromData(cdata)
if img.isNull():
img = self.default_image
data['cover'] = img