Store: Show number of results.

This commit is contained in:
John Schember 2011-05-21 19:09:14 -04:00
parent 4610ea2e72
commit 44366b2c97
3 changed files with 16 additions and 4 deletions

View file

@ -9,7 +9,8 @@
import re
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)
from calibre.gui2 import NONE
from calibre.gui2.store.search_result import SearchResult
@ -30,6 +31,8 @@ def comparable_price(text):
class Matches(QAbstractItemModel):
total_changed = pyqtSignal(int)
HEADERS = [_('Cover'), _('Title'), _('Price'), _('DRM'), _('Store')]
HTML_COLS = (1, 4)
@ -69,6 +72,7 @@ def clear_results(self):
self.query = ''
self.cover_pool.abort()
self.details_pool.abort()
self.total_changed.emit(self.rowCount())
self.reset()
def add_result(self, result, store_plugin):
@ -101,6 +105,7 @@ def filter_results(self):
self.matches = list(self.search_filter.parse(self.query))
else:
self.matches = list(self.search_filter.universal_set())
self.total_changed.emit(self.rowCount())
self.sort(self.sort_col, self.sort_order, False)
self.layoutChanged.emit()

View file

@ -78,9 +78,11 @@ def __init__(self, istores, parent=None, query=''):
self.checker.timeout.connect(self.get_results)
self.progress_checker.timeout.connect(self.check_progress)
self.results_view.activated.connect(self.open_store)
self.results_view.model().total_changed.connect(self.update_book_total)
self.select_all_stores.clicked.connect(self.stores_select_all)
self.select_invert_stores.clicked.connect(self.stores_select_invert)
self.select_none_stores.clicked.connect(self.stores_select_none)
self.configure.clicked.connect(self.do_config)
self.finished.connect(self.dialog_closed)
self.progress_checker.start(100)
@ -221,6 +223,9 @@ def load_settings(self):
self.cover_thread_count = self.config.get('cover_thread_count', 2)
self.details_thread_count = self.config.get('details_thread_count', 4)
def do_config(self):
pass
def config_finished(self):
self.load_settings()
@ -249,6 +254,8 @@ def get_results(self):
if not self.search_pool.threads_running() and not self.results_view.model().has_results():
info_dialog(self, _('No matches'), _('Couldn\'t find any books matching your query.'), show=True, show_copy_button=False)
def update_book_total(self, total):
self.total.setText('%s' % total)
def open_store(self, index):
result = self.results_view.model().get_result(index)

View file

@ -82,8 +82,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>207</width>
<height>130</height>
<width>102</width>
<height>129</height>
</rect>
</property>
</widget>
@ -209,7 +209,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="book_count">
<widget class="QLabel" name="total">
<property name="text">
<string>0</string>
</property>