From 2a1d4206c00e70bc9ffb2f4ddc58822efc3ced91 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 28 Apr 2020 20:09:33 +0200 Subject: HeaderView: always use headerdata from syncView model When HeaderView has a syncView, it should always use the header data of the syncView as model, and not only when that model is an QAbstractTableModel. Otherwise you cannot use headerView together width models like e.g QFileSystemModel (which is a QAbstractItemModel). If HeaderView has a syncView, but its model doesn't contain header data, then just leave the header empty. The application must either assign an model explicit to HeaderView, or provide header data to the syncView model. Just transposing the model will just duplicate the data in the syncView, which looks wrong. Change-Id: Ie48e960be8bf9fdd3ed227d90c6efb6aabfd18b5 Reviewed-by: Mitch Curtis (cherry picked from commit 4fe04f107d829434420ef44446a97938affd3420) Reviewed-by: Qt Cherry-pick Bot --- src/quicktemplates2/qquickheaderview.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp index 5c465cc7..85291bcb 100644 --- a/src/quicktemplates2/qquickheaderview.cpp +++ b/src/quicktemplates2/qquickheaderview.cpp @@ -236,16 +236,11 @@ void QQuickHeaderViewBasePrivate::setModelImpl(const QVariant &newModel) void QQuickHeaderViewBasePrivate::syncModel() { Q_Q(QQuickHeaderViewBase); + if (assignedSyncView && !m_modelExplicitlySetByUser) { auto newModel = assignedSyncView->model(); - if (auto m = newModel.value()) { + if (auto m = newModel.value()) proxyModelSetter(q, m_headerDataProxyModel, m); - } else if (orientation() == Qt::Horizontal) { - if (auto m = newModel.value()) - proxyModelSetter(q, m_transposeProxyModel, m); - } else { - QQuickTableViewPrivate::setModelImpl(newModel); - } } QQuickTableViewPrivate::syncModel(); -- cgit v1.2.3