Workaround for sortByColumn being partially broken in Qt 5.13.0

Fixes #1834989 [Qt 5.13 seems to break sorting the book list](https://bugs.launchpad.net/calibre/+bug/1834989)
This commit is contained in:
Kovid Goyal 2019-07-02 16:18:16 +05:30
parent a48220a182
commit 8088902fa8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 10 additions and 9 deletions

View File

@ -17,7 +17,7 @@ class MatchBookAction(InterfaceAction):
action_spec = (_('Match book to library'), 'book.png',
_('Match this book to a book in the library'),
())
dont_add_to = frozenset(['menubar', 'toolbar', 'context-menu', 'toolbar-child', 'context-menu-cover-browser'])
dont_add_to = frozenset(('menubar', 'toolbar', 'context-menu', 'toolbar-child', 'context-menu-cover-browser'))
action_type = 'current'
def genesis(self):

View File

@ -97,7 +97,6 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
self.sort_by_author.clicked.connect(self.do_sort_by_author)
self.author_order = 1
self.table.sortByColumn(1, Qt.AscendingOrder)
self.sort_by_author_sort.clicked.connect(self.do_sort_by_author_sort)
self.sort_by_author_sort.setCheckable(True)
self.sort_by_author_sort.setChecked(True)
@ -139,6 +138,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
self.table.setContextMenuPolicy(Qt.CustomContextMenu)
self.table.customContextMenuRequested .connect(self.show_context_menu)
self.do_sort_by_author_sort()
def save_state(self):
self.table_column_widths = []

View File

@ -500,7 +500,7 @@ class BooksModel(QAbstractTableModel): # {{{
self.searched.emit(True)
self.search_done.emit()
def sort(self, col, order, reset=True):
def sort(self, col, order=Qt.AscendingOrder, reset=True):
if not self.db:
return
if not isinstance(order, bool):

View File

@ -511,15 +511,16 @@ class BooksView(QTableView): # {{{
ch.blockSignals(False)
def sort_by_column_and_order(self, col, ascending):
order = Qt.AscendingOrder if ascending else Qt.DescendingOrder
self.column_header.blockSignals(True)
self.sortByColumn(col, Qt.AscendingOrder if ascending else Qt.DescendingOrder)
self.column_header.setSortIndicator(col, order)
self.column_header.blockSignals(False)
self.model().sort(col, order)
if self.is_library_view:
self.set_sort_indicator(col, ascending)
def user_sort_requested(self, col, order=Qt.AscendingOrder):
if col >= len(self.column_map) or col < 0:
return QTableView.sortByColumn(self, col)
if 0 <= col < len(self.column_map):
field = self.column_map[col]
self.intelligent_sort(field, order == Qt.AscendingOrder)

View File

@ -1055,7 +1055,7 @@ class SpellCheck(Dialog):
if self.words_model.sort_on[0] == 0:
with self:
hh = self.words_view.horizontalHeader()
self.words_view.sortByColumn(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
self.words_view.model().sort(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
def search_type_changed(self):
tprefs['spell_check_case_sensitive_search'] = bool(self.case_sensitive_search.isChecked())