diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index ad587baf39..ba88d766dc 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1111,6 +1111,7 @@ class StoreAmazonKindleStore(StoreBase): drm_free_only = False headquarters = 'US' formats = ['KINDLE'] + affiliate = True class StoreAmazonDEKindleStore(StoreBase): name = 'Amazon DE Kindle' @@ -1121,6 +1122,7 @@ class StoreAmazonDEKindleStore(StoreBase): drm_free_only = False headquarters = 'DE' formats = ['KINDLE'] + affiliate = True class StoreAmazonUKKindleStore(StoreBase): name = 'Amazon UK Kindle' @@ -1131,6 +1133,7 @@ class StoreAmazonUKKindleStore(StoreBase): drm_free_only = False headquarters = 'UK' formats = ['KINDLE'] + affiliate = True class StoreArchiveOrgStore(StoreBase): name = 'Archive.org' @@ -1168,6 +1171,7 @@ class StoreBeamEBooksDEStore(StoreBase): drm_free_only = True headquarters = 'DE' formats = ['EPUB', 'MOBI', 'PDF'] + affiliate = True class StoreBeWriteStore(StoreBase): name = 'BeWrite Books' @@ -1233,6 +1237,7 @@ class StoreFoylesUKStore(StoreBase): drm_free_only = False headquarters = 'UK' formats = ['EPUB', 'PDF'] + affiliate = True class StoreGandalfStore(StoreBase): name = 'Gandalf' @@ -1402,6 +1407,7 @@ class StoreEBookShoppeUKStore(StoreBase): drm_free_only = False headquarters = 'UK' formats = ['EPUB', 'PDF'] + affiliate = True plugins += [ StoreArchiveOrgStore, @@ -1432,7 +1438,7 @@ plugins += [ StorePragmaticBookshelfStore, StoreSmashwordsStore, StoreVirtualoStore, - #StoreWaterstonesUKStore, + StoreWaterstonesUKStore, StoreWeightlessBooksStore, StoreWizardsTowerBooksStore, StoreWoblinkStore diff --git a/src/calibre/gui2/store/search/models.py b/src/calibre/gui2/store/search/models.py index 64724be6aa..797195e202 100644 --- a/src/calibre/gui2/store/search/models.py +++ b/src/calibre/gui2/store/search/models.py @@ -10,7 +10,7 @@ import re from operator import attrgetter from PyQt4.Qt import (Qt, QAbstractItemModel, QVariant, QPixmap, QModelIndex, QSize, - pyqtSignal) + pyqtSignal, QIcon) from calibre.gui2 import NONE from calibre.gui2.store.search_result import SearchResult @@ -33,7 +33,7 @@ class Matches(QAbstractItemModel): total_changed = pyqtSignal(int) - HEADERS = [_('Cover'), _('Title'), _('Price'), _('DRM'), _('Store')] + HEADERS = [_('Cover'), _('Title'), _('Price'), _('DRM'), _('Store'), _('')] HTML_COLS = (1, 4) def __init__(self, cover_thread_count=2, detail_thread_count=4): @@ -76,6 +76,7 @@ class Matches(QAbstractItemModel): self.reset() def add_result(self, result, store_plugin): + result.plugin = store_plugin if result not in self.all_matches: self.layoutAboutToBeChanged.emit() self.all_matches.append(result) @@ -175,6 +176,12 @@ class Matches(QAbstractItemModel): return QVariant(self.DRM_UNLOCKED_ICON) elif result.drm == SearchResult.DRM_UNKNOWN: return QVariant(self.DRM_UNKNOWN_ICON) + if col == 5: + if getattr(result.plugin.base_plugin, 'affiliate', False): + icon = QIcon() + icon.addFile(I('donate.png'), QSize(16, 16)) + return QVariant(icon) + return NONE elif role == Qt.ToolTipRole: if col == 1: return QVariant('
%s
' % result.title) @@ -189,6 +196,8 @@ class Matches(QAbstractItemModel): return QVariant('' + _('The DRM status of this book could not be determined. There is a very high likelihood that this book is actually DRM restricted.') + '
') elif col == 4: return QVariant('%s
' % result.formats) + elif col == 5: + return QVariant(_('Buying from this store supports a calibre developer')) elif role == Qt.SizeHintRole: return QSize(64, 64) return NONE @@ -208,6 +217,11 @@ class Matches(QAbstractItemModel): text = 'c' elif col == 4: text = result.store_name + elif col == 5: + if getattr(result.plugin.base_plugin, 'affiliate', False): + text = 'y' + else: + text = 'n' return text def sort(self, col, order, reset=True): diff --git a/src/calibre/gui2/store/search_result.py b/src/calibre/gui2/store/search_result.py index 7bf361157e..a3c6a5601e 100644 --- a/src/calibre/gui2/store/search_result.py +++ b/src/calibre/gui2/store/search_result.py @@ -7,11 +7,11 @@ __copyright__ = '2011, John Schember