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)
def _on_sort_column_changed(self, section: int, order: int) -> None:
order = bool(order)
column = self._model.column_at_section(section)
if column.sorting == Columns.SORTING_NONE:
showInfo(tr.browsing_sorting_on_this_column_is_not())
sort_key = self._state.sort_column
else:
sort_key = column.key
if self._state.sort_column != sort_key:
self._state.sort_column = sort_key
self._set_sort_indicator()
return
order = bool(order)
if self._state.sort_column != column.key:
self._state.sort_column = column.key
# default to descending for non-text fields
if column.sorting == Columns.SORTING_REVERSED:
order = not order