Store: Fix threading issue. Fix Manybooks cover download.

This commit is contained in:
John Schember 2011-05-27 20:07:48 -04:00
parent 615d5722a7
commit ca6e74f762
2 changed files with 9 additions and 5 deletions

View File

@ -78,7 +78,8 @@ class ManyBooksStore(BasicStoreConfig, StorePlugin):
cover_name = mo.group() cover_name = mo.group()
cover_name = cover_name.replace('etext', '') cover_name = cover_name.replace('etext', '')
cover_id = id.split('.')[0] cover_id = id.split('.')[0]
cover_url = 'http://manybooks_images.s3.amazonaws.com/original_covers/' + id[0] + '/' + cover_name + '/' + cover_id + '-thumb.jpg' cover_url = 'http://www.manybooks.net/images/' + id[0] + '/' + cover_name + '/' + cover_id + '-thumb.jpg'
print(cover_url)
counter -= 1 counter -= 1

View File

@ -12,7 +12,7 @@ from operator import attrgetter
from PyQt4.Qt import (Qt, QAbstractItemModel, QVariant, QPixmap, QModelIndex, QSize, from PyQt4.Qt import (Qt, QAbstractItemModel, QVariant, QPixmap, QModelIndex, QSize,
pyqtSignal) pyqtSignal)
from calibre.gui2 import NONE from calibre.gui2 import NONE, FunctionDispatcher
from calibre.gui2.store.search_result import SearchResult from calibre.gui2.store.search_result import SearchResult
from calibre.gui2.store.search.download_thread import DetailsThreadPool, \ from calibre.gui2.store.search.download_thread import DetailsThreadPool, \
CoverThreadPool CoverThreadPool
@ -56,6 +56,9 @@ class Matches(QAbstractItemModel):
self.search_filter = SearchFilter() self.search_filter = SearchFilter()
self.cover_pool = CoverThreadPool(cover_thread_count) self.cover_pool = CoverThreadPool(cover_thread_count)
self.details_pool = DetailsThreadPool(detail_thread_count) self.details_pool = DetailsThreadPool(detail_thread_count)
self.filter_results_dispatcher = FunctionDispatcher(self.filter_results)
self.got_result_details_dispatcher = FunctionDispatcher(self.got_result_details)
self.sort_col = 2 self.sort_col = 2
self.sort_order = Qt.AscendingOrder self.sort_order = Qt.AscendingOrder
@ -82,10 +85,10 @@ class Matches(QAbstractItemModel):
self.search_filter.add_search_result(result) self.search_filter.add_search_result(result)
if result.cover_url: if result.cover_url:
result.cover_queued = True result.cover_queued = True
self.cover_pool.add_task(result, self.filter_results) self.cover_pool.add_task(result, self.filter_results_dispatcher)
else: else:
result.cover_queued = False result.cover_queued = False
self.details_pool.add_task(result, store_plugin, self.got_result_details) self.details_pool.add_task(result, store_plugin, self.got_result_details_dispatcher)
self.filter_results() self.filter_results()
self.layoutChanged.emit() self.layoutChanged.emit()
@ -112,7 +115,7 @@ class Matches(QAbstractItemModel):
def got_result_details(self, result): def got_result_details(self, result):
if not result.cover_queued and result.cover_url: if not result.cover_queued and result.cover_url:
result.cover_queued = True result.cover_queued = True
self.cover_pool.add_task(result, self.filter_results) self.cover_pool.add_task(result, self.filter_results_dispatcher)
if result in self.matches: if result in self.matches:
row = self.matches.index(result) row = self.matches.index(result)
self.dataChanged.emit(self.index(row, 0), self.index(row, self.columnCount() - 1)) self.dataChanged.emit(self.index(row, 0), self.index(row, self.columnCount() - 1))