diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-08-08 11:05:12 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-08-08 11:05:12 +0200 |
commit | b4b27168ac03d61f6dfa146c9262df44097eadfe (patch) | |
tree | 4fbfa2d3b58fa267ba8c2dbc4c7d5f077cdbc767 /src/qml | |
parent | 24581b838a5cc1dd5bd0f99cc02ed1aac9771de0 (diff) | |
parent | 9737b35ac0638dd301b670e940f4e424aab4b4f3 (diff) |
Merge "Merge branch '5.3' into dev" into refs/staging/dev
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 1 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 25 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p.h | 2 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 616f54d174..e087785901 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1542,7 +1542,6 @@ void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) callData->args[0] = QV4::Primitive::fromUInt32(s); f->call(callData); if (scope.hasException()) { - ctx->catchException(); QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); QQmlEnginePrivate::warning(QQmlEnginePrivate::get(d()->v8->engine()), error); } diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index e2f1cffb16..91ddcf57e5 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1526,6 +1526,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); @@ -1534,8 +1546,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); @@ -1555,20 +1568,16 @@ 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); if (i == index.row()) continue; - QVector<Compositor::Insert> inserts; - QVector<Compositor::Remove> removes; - d->m_compositor.listItemsMoved(&d->m_adaptorModel, i, index.row(), 1, &removes, &inserts); - if (!removes.isEmpty() || !inserts.isEmpty()) { - d->itemsMoved(removes, inserts); - } + _q_itemsMoved(i, index.row(), 1); } d->m_storedPersistentIndexes.clear(); 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) }; |