From 3d102d6ad8c188bc18621ca2f70cc35920f9f041 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 27 Dec 2010 22:55:10 +0000 Subject: [PATCH] Fix #8080 - Sort in library doesn't work after bulk metadata edit. In fact it has nothing to do with metadata edit, but instead comes from mixing int and bool flags for ascending and descending. --- src/calibre/gui2/library/models.py | 2 +- src/calibre/gui2/library/views.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 920753a77d..22a9db0fef 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -252,7 +252,7 @@ class BooksModel(QAbstractTableModel): # {{{ self.db.sort(label, ascending) if reset: self.reset() - self.sorted_on = (label, order) + self.sorted_on = (label, order == Qt.AscendingOrder) self.sort_history.insert(0, self.sorted_on) self.sorting_done.emit(self.db.index) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 8dad4c21b1..457cfaf754 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -284,15 +284,19 @@ class BooksView(QTableView): # {{{ for col, order in sort_history: if col == 'date': col = 'timestamp' - if col in self.column_map and (not history or history[0][0] != col): - history.append([col, order]) + if col in self.column_map: + if (not history or history[0][0] != col): + history.append([col, order]) + elif isinstance(order, bool) and history[0][1] != order: + history[0][1] = order return history def apply_sort_history(self, saved_history): if not saved_history: return for col, order in reversed(self.cleanup_sort_history(saved_history)[:3]): - self.sortByColumn(self.column_map.index(col), order) + self.sortByColumn(self.column_map.index(col), + Qt.AscendingOrder if order else Qt.DescendingOrder) def apply_state(self, state): h = self.column_header