Make failed sort column change a no-op

The previous behaviour when a non-sortable column was clicked was to
trigger the sorting routine, which was usually a no-op, but would
reorder rows if the configured sort column was hidden.
This commit is contained in:
RumovZ 2021-05-17 18:33:59 +02:00
parent 10bfb95f1b
commit 02f86ec352

View file

@ -358,15 +358,14 @@ class Table:
self._scroll_to_column(self._model.len_columns() - 1) self._scroll_to_column(self._model.len_columns() - 1)
def _on_sort_column_changed(self, section: int, order: int) -> None: def _on_sort_column_changed(self, section: int, order: int) -> None:
order = bool(order)
column = self._model.column_at_section(section) column = self._model.column_at_section(section)
if column.sorting == Columns.SORTING_NONE: if column.sorting == Columns.SORTING_NONE:
showInfo(tr.browsing_sorting_on_this_column_is_not()) showInfo(tr.browsing_sorting_on_this_column_is_not())
sort_key = self._state.sort_column self._set_sort_indicator()
else: return
sort_key = column.key order = bool(order)
if self._state.sort_column != sort_key: if self._state.sort_column != column.key:
self._state.sort_column = sort_key self._state.sort_column = column.key
# default to descending for non-text fields # default to descending for non-text fields
if column.sorting == Columns.SORTING_REVERSED: if column.sorting == Columns.SORTING_REVERSED:
order = not order order = not order