diff options
author | Daniel Vrátil <dan@progdan.cz> | 2014-04-16 18:33:24 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-12 19:21:29 +0200 |
commit | a0aefe111758b2267f1bf5fbb26991cbc6dd804d (patch) | |
tree | 93e0559d268de94ef4e76de8bb9aeba357b7df2e /src/qml/util | |
parent | 261e6aa88ce42c4dfbc14c4c5bc2748202a8d7ab (diff) |
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 <albert.astals@canonical.com>
Reviewed-by: Michael Zanetti <michael.zanetti@canonical.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/qml/util')
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), + vdm, SLOT(_q_layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); + QObject::disconnect(aim, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), + vdm, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); } const_cast<VDMAbstractItemModelDataType *>(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<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), + vdm, QQmlDelegateModel, SLOT(_q_layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); + qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), + vdm, QQmlDelegateModel, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); } else { accessors = new VDMObjectDelegateDataType; } |