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.

This commit is contained in:
Charles Haley 2010-12-27 22:55:10 +00:00
parent 2b699deac6
commit 3d102d6ad8
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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