mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 00:03:26 +02:00
Ensure sort indicator is correct after a column is added or removed
This commit is contained in:
parent
63e9296f3b
commit
ce023e2c56
1 changed files with 11 additions and 4 deletions
|
|
@ -29,7 +29,7 @@
|
|||
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 @@ def setEditorData(self, editor, index):
|
|||
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 @@ def setData(self, index, value, role):
|
|||
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 @@ def columns_sorted(self):
|
|||
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…
Reference in a new issue