aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-07-30 15:41:10 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-07-30 15:42:09 +0200
commitc4aa4ffa21c8ce2ca7cf18085a6be17b8e704b27 (patch)
tree48ae7a7edacaa1d3c3428ec612eca7122ca751ed /src/qml
parent47ffb30a69285d6ced1287f14ff5842a298e60e0 (diff)
parent8e1b88e457cbee0000d5956f2ff5a98724c2d3e4 (diff)
Merge remote-tracking branch 'origin/stable' into 5.3
Conflicts: tests/auto/quick/qquicklistview/tst_qquicklistview.cpp Change-Id: I80584b4f7d62cd86d3449e19176118e3bed886c1
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp18
-rw-r--r--src/qml/types/qqmldelegatemodel_p.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 23bdeb55b2..aab385ceb5 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1521,6 +1521,18 @@ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelInd
_q_itemsChanged(begin.row(), end.row() - begin.row() + 1, roles);
}
+bool QQmlDelegateModel::isDescendantOf(const QPersistentModelIndex& desc, const QList< QPersistentModelIndex >& parents) const
+{
+ for (int i = 0, c = parents.count(); i < c; ++i) {
+ for (QPersistentModelIndex parent = desc; parent.isValid(); parent = parent.parent()) {
+ if (parent == parents[i])
+ return true;
+ }
+ }
+
+ return false;
+}
+
void QQmlDelegateModel::_q_layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
{
Q_D(QQmlDelegateModel);
@@ -1529,8 +1541,9 @@ void QQmlDelegateModel::_q_layoutAboutToBeChanged(const QList<QPersistentModelIn
if (hint == QAbstractItemModel::VerticalSortHint) {
d->m_storedPersistentIndexes.clear();
- if (!parents.contains(d->m_adaptorModel.rootIndex))
+ if (!parents.isEmpty() && d->m_adaptorModel.rootIndex.isValid() && !isDescendantOf(d->m_adaptorModel.rootIndex, parents)) {
return;
+ }
for (int i = 0; i < d->m_count; ++i) {
const QModelIndex index = d->m_adaptorModel.aim()->index(i, 0, d->m_adaptorModel.rootIndex);
@@ -1550,8 +1563,9 @@ void QQmlDelegateModel::_q_layoutChanged(const QList<QPersistentModelIndex> &par
return;
if (hint == QAbstractItemModel::VerticalSortHint) {
- if (!parents.contains(d->m_adaptorModel.rootIndex))
+ if (!parents.isEmpty() && d->m_adaptorModel.rootIndex.isValid() && !isDescendantOf(d->m_adaptorModel.rootIndex, parents)) {
return;
+ }
for (int i = 0, c = d->m_storedPersistentIndexes.count(); i < c; ++i) {
const QPersistentModelIndex &index = d->m_storedPersistentIndexes.at(i);
diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h
index 0b67179163..53cc94bbdf 100644
--- a/src/qml/types/qqmldelegatemodel_p.h
+++ b/src/qml/types/qqmldelegatemodel_p.h
@@ -143,6 +143,8 @@ private Q_SLOTS:
void _q_layoutChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint);
private:
+ bool isDescendantOf(const QPersistentModelIndex &desc, const QList<QPersistentModelIndex> &parents) const;
+
Q_DISABLE_COPY(QQmlDelegateModel)
};