From ec8b8bbe69161623d43eaf6202df8f8d31701e92 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 22 Apr 2011 07:56:45 -0600 Subject: [PATCH] ... --- src/calibre/gui2/store/search/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/store/search/models.py b/src/calibre/gui2/store/search/models.py index eadbd36a9b..73b7bcc90a 100644 --- a/src/calibre/gui2/store/search/models.py +++ b/src/calibre/gui2/store/search/models.py @@ -55,7 +55,7 @@ class Matches(QAbstractItemModel): self.cover_pool.start_threads() self.details_pool = DetailsThreadPool(DetailsThread, 4) self.details_pool.start_threads() - + self.sort_col = 2 self.sort_order = Qt.AscendingOrder @@ -95,7 +95,7 @@ class Matches(QAbstractItemModel): return self.matches[row] else: return None - + def has_results(self): return len(self.matches) > 0 @@ -221,7 +221,12 @@ class Matches(QAbstractItemModel): self.reset() def reorder_matches(self): - self.matches = sorted(self.matches, key=lambda x: self.all_matches.index(x)) + def keygen(x): + try: + return self.all_matches.index(x) + except: + return 100000 + self.matches = sorted(self.matches, key=keygen) class SearchFilter(SearchQueryParser): @@ -327,5 +332,6 @@ class SearchFilter(SearchQueryParser): matches.add(sr) break except ValueError: # Unicode errors + import traceback traceback.print_exc() return matches