From 7a9135c8e5687d74e4418f42c1601424ebc963af Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 May 2010 11:18:31 -0600 Subject: [PATCH] Support loading of device images from paths instead of keeping them in memory --- src/calibre/devices/interface.py | 4 +++- src/calibre/gui2/library.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 356ebfc876..40cac4d615 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -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). ''' diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index d08c7d50c8..0c6f7566bd 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -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