From d0f909f8dbdd8594b0d950822f0e7ab8728da513 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 26 Oct 2018 20:38:58 +0200 Subject: QTreeView/TableView: explicitly mark sortByColumn(int) as deprecated QTreeView/TableView::sortByColumn(int) was deprecated a long time ago but never got removed. Therefore mark it with QT_DEPRECATED_SINCE(5, 13) so we can remove it with Qt6. Also sync the handling of the sort order changes in QTableView with the one from QTreeView. Change-Id: I0371d9a9c21116edaa9125835827f1a200075d36 Reviewed-by: Luca Beldi Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qtreeview.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/widgets/itemviews/qtreeview.cpp') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 743832b214..e7196c9d5d 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2598,10 +2598,13 @@ void QTreeView::resizeColumnToContents(int column) d->header->resizeSection(column, qMax(contents, header)); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete \overload + This function is deprecated. Use + sortByColumn(int column, Qt::SortOrder order) instead. Sorts the model by the values in the given \a column. */ void QTreeView::sortByColumn(int column) @@ -2609,6 +2612,7 @@ void QTreeView::sortByColumn(int column) Q_D(QTreeView); sortByColumn(column, d->header->sortIndicatorOrder()); } +#endif /*! \since 4.2 @@ -2624,10 +2628,12 @@ void QTreeView::sortByColumn(int column) void QTreeView::sortByColumn(int column, Qt::SortOrder order) { Q_D(QTreeView); - - //If sorting is enabled will emit a signal connected to _q_sortIndicatorChanged, which then actually sorts + if (column < 0) + return; + // If sorting is enabled it will emit a signal connected to + // _q_sortIndicatorChanged, which then actually sorts d->header->setSortIndicator(column, order); - //If sorting is not enabled, force to sort now. + // If sorting is not enabled, force to sort now if (!d->sortingEnabled) d->model->sort(column, order); } -- cgit v1.2.3