From 8c74aae44a6734dff51790cd0504212a5fe74c32 Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 21 Apr 2011 21:31:10 -0400 Subject: [PATCH] Store: Don't add duplicate results to results. --- src/calibre/gui2/store/search.py | 23 ++++++++++++----------- src/calibre/gui2/store/search_result.py | 3 +++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/store/search.py b/src/calibre/gui2/store/search.py index 716cb1612a..bba6756974 100644 --- a/src/calibre/gui2/store/search.py +++ b/src/calibre/gui2/store/search.py @@ -463,17 +463,18 @@ class Matches(QAbstractItemModel): self.reset() def add_result(self, result, store_plugin): - self.layoutAboutToBeChanged.emit() - self.all_matches.append(result) - self.search_filter.add_search_result(result) - if result.cover_url: - result.cover_queued = True - self.cover_pool.add_task(result, self.filter_results) - else: - result.cover_queued = False - self.details_pool.add_task(result, store_plugin, self.got_result_details) - self.filter_results() - self.layoutChanged.emit() + if result not in self.all_matches: + self.layoutAboutToBeChanged.emit() + self.all_matches.append(result) + self.search_filter.add_search_result(result) + if result.cover_url: + result.cover_queued = True + self.cover_pool.add_task(result, self.filter_results) + else: + result.cover_queued = False + self.details_pool.add_task(result, store_plugin, self.got_result_details) + self.filter_results() + self.layoutChanged.emit() def get_result(self, index): row = index.row() diff --git a/src/calibre/gui2/store/search_result.py b/src/calibre/gui2/store/search_result.py index b817b68a77..7bf361157e 100644 --- a/src/calibre/gui2/store/search_result.py +++ b/src/calibre/gui2/store/search_result.py @@ -22,3 +22,6 @@ class SearchResult(object): self.detail_item = '' self.drm = None self.formats = '' + + def __eq__(self, other): + return self.title == other.title and self.author == other.author and self.store_name == other.store_name