diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2016-03-31 19:32:59 +0200 |
---|---|---|
committer | Albert Astals Cid <albert.astals@canonical.com> | 2016-04-26 08:42:44 +0000 |
commit | 84f61dd2d2b0140814b39a2c5238a6e31c49abd7 (patch) | |
tree | 46d7da8203657f7f8d1f9ff75b0ede291adf4c05 /src/qml/util | |
parent | 124e67adc201781e788aae3092a1bc1846cc4358 (diff) |
Fix performance issues when handling layout changed in Quick item views.
When the layout changes, we mark all rows as changed but do not track
where the individual rows get moved.
The only reason why one would want to track the moves is to persist
the current item selection across a layout change. But even the previous
code did not achieve that. I'll create a follow up patch to this one
that also implements this behavior as seen in Qt Widget item views.
Note that removing this code brings a tremendous performance win
on larger models. The repeated calls to _q_itemsMoved triggered O(n^2)
behavior in the number of top items in the model. Even with "only"
tens of thousands of items in the model, a layout change became very
costly and took seconds on a beefy modern desktop machine.
Calling _q_itemsMoved in a loop is bad because it:
- leads to O(N^2) behavior within QQmlChangeSet when merging the small
moves into the item view's current change set
- potentially triggers tons of binding/property updates when the cached
model indices are updated in _q_itemsMoved
Removing this slow path, I did not yet find a behavior change to the
previous code. Instead, it just does it all much faster.
Change-Id: I67fa99a1c5d8e05d17497d29391da9458bd9bdd0
Task-number: QTBUG-51638
Reviewed-by: Daniel Vrátil <daniel.vratil@kdab.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/qml/util')
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 15c547b5df..5fc2444b7c 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -470,8 +470,6 @@ public: vdm, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); QObject::disconnect(aim, SIGNAL(modelReset()), vdm, SLOT(_q_modelReset())); - 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))); } @@ -928,8 +926,6 @@ 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(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 { |