Add the heart to the search store chooser

This commit is contained in:
Charles Haley 2011-05-28 16:57:37 +01:00
parent b244246fce
commit 66571550e9
2 changed files with 19 additions and 11 deletions

View File

@ -1417,7 +1417,7 @@ class StoreWeightlessBooksStore(StoreBase):
class StoreWHSmithUKStore(StoreBase): class StoreWHSmithUKStore(StoreBase):
name = 'WH Smith UK' name = 'WH Smith UK'
author = 'Charles Haley' author = 'Charles Haley'
description = u"With over 550 stores on the high street and 490 stores at airports, train stations, hospitals and motorway services, WHSmith is one of the UK's leading retail groups and a household name." description = u"Shop for savings on Books, discounted Magazine subscriptions and great prices on Stationery, Toys & Games"
actual_plugin = 'calibre.gui2.store.whsmith_uk_plugin:WHSmithUKStore' actual_plugin = 'calibre.gui2.store.whsmith_uk_plugin:WHSmithUKStore'
drm_free_only = False drm_free_only = False

View File

@ -9,8 +9,8 @@ __docformat__ = 'restructuredtext en'
import re import re
from random import shuffle from random import shuffle
from PyQt4.Qt import (Qt, QDialog, QDialogButtonBox, QTimer, QCheckBox, from PyQt4.Qt import (Qt, QDialog, QDialogButtonBox, QTimer, QCheckBox, QLabel,
QVBoxLayout, QIcon, QWidget, QTabWidget) QVBoxLayout, QIcon, QWidget, QTabWidget, QGridLayout)
from calibre.gui2 import JSONConfig, info_dialog from calibre.gui2 import JSONConfig, info_dialog
from calibre.gui2.progress_indicator import ProgressIndicator from calibre.gui2.progress_indicator import ProgressIndicator
@ -80,7 +80,7 @@ class SearchDialog(QDialog, Ui_Dialog):
self.progress_checker.start(100) self.progress_checker.start(100)
self.restore_state() self.restore_state()
def setup_store_checks(self): def setup_store_checks(self):
# Add check boxes for each store so the user # Add check boxes for each store so the user
# can disable searching specific stores on a # can disable searching specific stores on a
@ -88,18 +88,26 @@ class SearchDialog(QDialog, Ui_Dialog):
existing = {} existing = {}
for n in self.store_checks: for n in self.store_checks:
existing[n] = self.store_checks[n].isChecked() existing[n] = self.store_checks[n].isChecked()
self.store_checks = {} self.store_checks = {}
stores_check_widget = QWidget() stores_check_widget = QWidget()
store_list_layout = QVBoxLayout() store_list_layout = QGridLayout()
stores_check_widget.setLayout(store_list_layout) stores_check_widget.setLayout(store_list_layout)
for x in sorted(self.gui.istores.keys(), key=lambda x: x.lower()):
icon = QIcon(I('donate.png'))
i = 0 # just in case the list of stores is empty
for i, x in enumerate(sorted(self.gui.istores.keys(), key=lambda x: x.lower())):
cbox = QCheckBox(x) cbox = QCheckBox(x)
cbox.setChecked(existing.get(x, False)) cbox.setChecked(existing.get(x, False))
store_list_layout.addWidget(cbox) store_list_layout.addWidget(cbox, i, 0, 1, 1)
if self.gui.istores[x].base_plugin.affiliate:
iw = QLabel(self)
iw.setPixmap(icon.pixmap(16, 16))
store_list_layout.addWidget(iw, i, 1, 1, 1)
self.store_checks[x] = cbox self.store_checks[x] = cbox
store_list_layout.addStretch() i += 1
store_list_layout.setRowStretch(i, 10)
self.store_list.setWidget(stores_check_widget) self.store_list.setWidget(stores_check_widget)
def build_adv_search(self): def build_adv_search(self):
@ -250,14 +258,14 @@ class SearchDialog(QDialog, Ui_Dialog):
button_box.accepted.connect(d.accept) button_box.accepted.connect(d.accept)
button_box.rejected.connect(d.reject) button_box.rejected.connect(d.reject)
d.setWindowTitle(_('Customize get books search')) d.setWindowTitle(_('Customize get books search'))
tab_widget = QTabWidget(d) tab_widget = QTabWidget(d)
v.addWidget(tab_widget) v.addWidget(tab_widget)
v.addWidget(button_box) v.addWidget(button_box)
chooser_config_widget = StoreChooserWidget() chooser_config_widget = StoreChooserWidget()
search_config_widget = StoreConfigWidget(self.config) search_config_widget = StoreConfigWidget(self.config)
tab_widget.addTab(chooser_config_widget, _('Choose stores')) tab_widget.addTab(chooser_config_widget, _('Choose stores'))
tab_widget.addTab(search_config_widget, _('Configure search')) tab_widget.addTab(search_config_widget, _('Configure search'))