mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure sort indicator is correct after a column is added or removed
This commit is contained in:
parent
63e9296f3b
commit
ce023e2c56
@ -29,7 +29,7 @@ from calibre.utils.date import dt_factory, qt_to_dt, isoformat, now
|
||||
from calibre.utils.pyparsing import ParseException
|
||||
from calibre.utils.search_query_parser import SearchQueryParser
|
||||
|
||||
|
||||
# Delegates {{{
|
||||
class RatingDelegate(QStyledItemDelegate):
|
||||
COLOR = QColor("blue")
|
||||
SIZE = 16
|
||||
@ -303,7 +303,9 @@ class CcBoolDelegate(QStyledItemDelegate):
|
||||
val = 2 if val is None else 1 if not val else 0
|
||||
editor.setCurrentIndex(val)
|
||||
|
||||
class BooksModel(QAbstractTableModel):
|
||||
# }}}
|
||||
|
||||
class BooksModel(QAbstractTableModel): # {{{
|
||||
|
||||
about_to_be_sorted = pyqtSignal(object, name='aboutToBeSorted')
|
||||
sorting_done = pyqtSignal(object, name='sortingDone')
|
||||
@ -973,13 +975,13 @@ class BooksModel(QAbstractTableModel):
|
||||
self.db.set(row, column, val)
|
||||
self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), \
|
||||
index, index)
|
||||
#if column == self.sorted_on[0]:
|
||||
# self.resort()
|
||||
return True
|
||||
|
||||
def set_search_restriction(self, s):
|
||||
self.db.data.set_search_restriction(s)
|
||||
|
||||
# }}}
|
||||
|
||||
class BooksView(TableView):
|
||||
TIME_FMT = '%d %b %Y'
|
||||
wrapper = textwrap.TextWrapper(width=20)
|
||||
@ -1084,6 +1086,11 @@ class BooksView(TableView):
|
||||
if not self.restore_column_widths():
|
||||
self.resizeColumnsToContents()
|
||||
|
||||
sort_col = self._model.sorted_on[0]
|
||||
if sort_col in cm:
|
||||
idx = cm.index(sort_col)
|
||||
self.horizontalHeader().setSortIndicator(idx, self._model.sorted_on[1])
|
||||
|
||||
def set_context_menu(self, edit_metadata, send_to_device, convert, view,
|
||||
save, open_folder, book_details, delete, similar_menu=None):
|
||||
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
|
Loading…
x
Reference in New Issue
Block a user