diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-04-28 20:09:33 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-05-05 13:05:07 +0200 |
commit | 4fe04f107d829434420ef44446a97938affd3420 (patch) | |
tree | 7ff6304b5b24864986277745e8425221101505ee /src | |
parent | 885d065902422f82d474e6a8cae43e1b3e4d94d0 (diff) |
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.
Pick-to: 5.15
Change-Id: Ie48e960be8bf9fdd3ed227d90c6efb6aabfd18b5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickheaderview.cpp | 9 |
1 files 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<QAbstractTableModel *>()) { + if (auto m = newModel.value<QAbstractItemModel *>()) proxyModelSetter(q, m_headerDataProxyModel, m); - } else if (orientation() == Qt::Horizontal) { - if (auto m = newModel.value<QAbstractItemModel *>()) - proxyModelSetter(q, m_transposeProxyModel, m); - } else { - QQuickTableViewPrivate::setModelImpl(newModel); - } } QQuickTableViewPrivate::syncModel(); |