Date: Thu, 21 Apr 2011 11:43:01 -0400
Subject: [PATCH 19/23] Store: more formats for searches. Wordwrap tooltips.
---
src/calibre/gui2/store/manybooks_plugin.py | 1 +
src/calibre/gui2/store/mobileread_plugin.py | 10 +++++-----
src/calibre/gui2/store/open_library_plugin.py | 9 +++++++++
src/calibre/gui2/store/search.py | 16 ++++++++--------
src/calibre/gui2/store/smashwords_plugin.py | 8 ++++++++
5 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/calibre/gui2/store/manybooks_plugin.py b/src/calibre/gui2/store/manybooks_plugin.py
index aa5c45300a..57eb42c13e 100644
--- a/src/calibre/gui2/store/manybooks_plugin.py
+++ b/src/calibre/gui2/store/manybooks_plugin.py
@@ -90,5 +90,6 @@ class ManyBooksStore(BasicStoreConfig, StorePlugin):
s.price = price.strip()
s.detail_item = '/titles/' + id
s.drm = SearchResult.DRM_UNLOCKED
+ s.formts = 'EPUB, PDB (eReader, PalmDoc, zTXT, Plucker, iSilo), FB2, ZIP, AZW, MOBI, PRC, LIT, PKG, PDF, TXT, RB, RTF, LRF, TCR, JAR'
yield s
diff --git a/src/calibre/gui2/store/mobileread_plugin.py b/src/calibre/gui2/store/mobileread_plugin.py
index 3ac035d378..56fcb207bf 100644
--- a/src/calibre/gui2/store/mobileread_plugin.py
+++ b/src/calibre/gui2/store/mobileread_plugin.py
@@ -104,8 +104,8 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
for book_data in data.xpath('//ul/li'):
book = BookRef()
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
- book.format = ''.join(book_data.xpath('.//i/text()'))
- book.format = book.format.strip()
+ book.formats = ''.join(book_data.xpath('.//i/text()'))
+ book.formats = book.formats.strip()
text = ''.join(book_data.xpath('.//a/text()'))
if ':' in text:
@@ -222,7 +222,7 @@ class BooksModel(QAbstractItemModel):
self.books = []
if self.filter:
for b in self.all_books:
- test = '%s %s %s' % (b.title, b.author, b.format)
+ test = '%s %s %s' % (b.title, b.author, b.formats)
test = test.lower()
include = True
for item in self.filter.split(' '):
@@ -275,7 +275,7 @@ class BooksModel(QAbstractItemModel):
elif col == 1:
return QVariant(result.author)
elif col == 2:
- return QVariant(result.format)
+ return QVariant(result.formats)
return NONE
def data_as_text(self, result, col):
@@ -285,7 +285,7 @@ class BooksModel(QAbstractItemModel):
elif col == 1:
text = result.author
elif col == 2:
- text = result.format
+ text = result.formats
return text
def sort(self, col, order, reset=True):
diff --git a/src/calibre/gui2/store/open_library_plugin.py b/src/calibre/gui2/store/open_library_plugin.py
index 2bd38aae4f..0e2fa4b14f 100644
--- a/src/calibre/gui2/store/open_library_plugin.py
+++ b/src/calibre/gui2/store/open_library_plugin.py
@@ -71,3 +71,12 @@ class OpenLibraryStore(BasicStoreConfig, StorePlugin):
s.drm = SearchResult.DRM_UNKNOWN
yield s
+
+ def get_details(self, search_result, timeout):
+ url = 'http://openlibrary.org/'
+
+ br = browser()
+ with closing(br.open(url_slash_cleaner(url + search_result.detail_item), timeout=timeout)) as nf:
+ idata = html.fromstring(nf.read())
+ search_result.formats = ', '.join(list(set(idata.xpath('//a[contains(@title, "Download")]/text()'))))
+ return True
diff --git a/src/calibre/gui2/store/search.py b/src/calibre/gui2/store/search.py
index 193ebbc420..d5fbe19e93 100644
--- a/src/calibre/gui2/store/search.py
+++ b/src/calibre/gui2/store/search.py
@@ -559,22 +559,22 @@ class Matches(QAbstractItemModel):
return QVariant(self.DRM_UNKNOWN_ICON)
elif role == Qt.ToolTipRole:
if col == 1:
- return QVariant(result.title)
+ return QVariant('%s
' % result.title)
elif col == 2:
- return QVariant(result.author)
+ return QVariant('%s
' % result.author)
elif col == 3:
- return QVariant(_('Detected price as: %s. Check with the store before making a purchase to verify this price information is correct.') % result.price)
+ return QVariant('' + _('Detected price as: %s. Check with the store before making a purchase to verify this price is correct. This price often does not include promotions the store may be running.') % result.price + '
')
elif col == 4:
if result.drm == SearchResult.DRM_LOCKED:
- return QVariant(_('This book as been detected as having DRM restrictions. This book may not work with your reader and you will have limitations placed upon you as to what you can do with this book. Check with the store before making any purchases to ensure you can actually read this book.'))
+ return QVariant('' + _('This book as been detected as having DRM restrictions. This book may not work with your reader and you will have limitations placed upon you as to what you can do with this book. Check with the store before making any purchases to ensure you can actually read this book.') + '
')
elif result.drm == SearchResult.DRM_UNLOCKED:
- return QVariant(_('This book has been detected as being DRM Free. You should be able to use this book on any device provided it is in a format calibre supports for conversion. However, before making a purchase double check the DRM status with the store. The store may not be disclosing the use of DRM.'))
+ return QVariant('' + _('This book has been detected as being DRM Free. You should be able to use this book on any device provided it is in a format calibre supports for conversion. However, before making a purchase double check the DRM status with the store. The store may not be disclosing the use of DRM.') + '
')
else:
- 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.'))
+ 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 == 5:
- return QVariant(result.store_name)
+ return QVariant('%s
' % result.store_name)
elif col == 6:
- return QVariant(result.formats)
+ return QVariant('%s
' % result.formats)
elif role == Qt.SizeHintRole:
return QSize(64, 64)
return NONE
diff --git a/src/calibre/gui2/store/smashwords_plugin.py b/src/calibre/gui2/store/smashwords_plugin.py
index 43efe549cc..f91d5d09f3 100644
--- a/src/calibre/gui2/store/smashwords_plugin.py
+++ b/src/calibre/gui2/store/smashwords_plugin.py
@@ -93,3 +93,11 @@ class SmashwordsStore(BasicStoreConfig, StorePlugin):
s.drm = SearchResult.DRM_UNLOCKED
yield s
+ def get_details(self, search_result, timeout):
+ url = 'http://www.smashwords.com/'
+
+ br = browser()
+ with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
+ idata = html.fromstring(nf.read())
+ search_result.formats = ', '.join(list(set(idata.xpath('//td//b//text()'))))
+ return True
From cafd67924eccd0fc0423868e76ede59e4d782551 Mon Sep 17 00:00:00 2001
From: John Schember
Date: Thu, 21 Apr 2011 18:13:37 -0400
Subject: [PATCH 20/23] Store: Add first run disclaimer.
---
src/calibre/gui2/actions/store.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/calibre/gui2/actions/store.py b/src/calibre/gui2/actions/store.py
index 4e96960243..31c383c79d 100644
--- a/src/calibre/gui2/actions/store.py
+++ b/src/calibre/gui2/actions/store.py
@@ -10,6 +10,7 @@ from functools import partial
from PyQt4.Qt import QMenu
+from calibre.gui2 import JSONConfig
from calibre.gui2.actions import InterfaceAction
class StoreAction(InterfaceAction):
@@ -18,6 +19,8 @@ class StoreAction(InterfaceAction):
action_spec = (_('Get books'), 'store.png', None, None)
def genesis(self):
+ self.config = JSONConfig('store_action')
+
self.qaction.triggered.connect(self.search)
self.store_menu = QMenu()
self.load_menu()
@@ -31,9 +34,30 @@ class StoreAction(InterfaceAction):
self.qaction.setMenu(self.store_menu)
def search(self):
+ self.first_run_check()
from calibre.gui2.store.search import SearchDialog
sd = SearchDialog(self.gui.istores, self.gui)
sd.exec_()
def open_store(self, store_plugin):
+ self.first_run_check()
store_plugin.open(self.gui)
+
+ def first_run_check(self):
+ if self.config.get('first_run', True):
+ self.config['first_run'] = False
+ from calibre.gui2 import info_dialog
+ info_dialog(self.gui, _('Get Books Disclaimer'),
+ _('Calibre helps you find books to read by connecting you with outside stores. '
+ 'The stores are a variety of big, independent, free, and public domain sources.
'
+ 'Using the integrated search you can easily find what store has the book you\'re '
+ 'looking for. It will also give you a price, DRM status as well as a lot of '
+ 'other useful information.
'
+ 'All transaction (paid or otherwise) are handled between you and the store. '
+ 'Calibre is not part of this process and any issues related to a purchase need to '
+ 'be directed to the actual store. Be sure to double check that any books you get '
+ 'will work with you device. Double check for format and '
+ 'DRM '
+ 'restrictions.
'),
+ show=True, show_copy_button=False)
+
\ No newline at end of file
From 672fd2d6ec9ecaa27de930d65042522a1823da3c Mon Sep 17 00:00:00 2001
From: John Schember
Date: Thu, 21 Apr 2011 18:23:13 -0400
Subject: [PATCH 21/23] ...
---
src/calibre/gui2/actions/store.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/calibre/gui2/actions/store.py b/src/calibre/gui2/actions/store.py
index 31c383c79d..5f8a3efc26 100644
--- a/src/calibre/gui2/actions/store.py
+++ b/src/calibre/gui2/actions/store.py
@@ -60,4 +60,3 @@ class StoreAction(InterfaceAction):
'DRM '
'restrictions.