From a0aefe111758b2267f1bf5fbb26991cbc6dd804d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Wed, 16 Apr 2014 18:33:24 +0200 Subject: Implement proper support for layoutChange in QQmlDelegateModel Current implementation is treating model layoutChange the same way as modelReset, which causes problems when using ListView on top of a QSortFilterProxyModel. The model emits layoutChanged whenever a data within sorting column change. Treating it as modelReset leads to poor performance on large models and caused UI issues, because the scrolling position is reset every time. This patch implements proper handling for layoutChanged signals by first handling all items moves and then simulating dataChange for all items. This fixes regression from Qt 5.1 introduced by Change I16b859d9 Task-number: QTBUG-37983 Task-number: QTBUG-34391 Change-Id: I6d3873b7b87e7f0e8fc0c1ed5dc80c6f8fdf6c22 Reviewed-by: Albert Astals Cid Reviewed-by: Michael Zanetti Reviewed-by: Alan Alpert Reviewed-by: Gunnar Sletta --- src/qml/util/qqmladaptormodel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/qml/util') diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index d38e5ac3df..c1c8bfa81d 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -467,8 +467,10 @@ public: vdm, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); QObject::disconnect(aim, SIGNAL(modelReset()), vdm, SLOT(_q_modelReset())); - QObject::disconnect(aim, SIGNAL(layoutChanged()), - vdm, SLOT(_q_layoutChanged())); + QObject::disconnect(aim, SIGNAL(layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint)), + vdm, SLOT(_q_layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint))); + QObject::disconnect(aim, SIGNAL(layoutChanged(QList,QAbstractItemModel::LayoutChangeHint)), + vdm, SLOT(_q_layoutChanged(QList,QAbstractItemModel::LayoutChangeHint))); } const_cast(this)->release(); @@ -920,8 +922,10 @@ void QQmlAdaptorModel::setModel(const QVariant &variant, QQmlDelegateModel *vdm, vdm, QQmlDelegateModel, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); qmlobject_connect(model, QAbstractItemModel, SIGNAL(modelReset()), vdm, QQmlDelegateModel, SLOT(_q_modelReset())); - qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutChanged()), - vdm, QQmlDelegateModel, SLOT(_q_layoutChanged())); + qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint)), + vdm, QQmlDelegateModel, SLOT(_q_layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint))); + qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutChanged(QList,QAbstractItemModel::LayoutChangeHint)), + vdm, QQmlDelegateModel, SLOT(_q_layoutChanged(QList,QAbstractItemModel::LayoutChangeHint))); } else { accessors = new VDMObjectDelegateDataType; } -- cgit v1.2.3