aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmldelegatemodel.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-08 11:01:35 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-30 07:36:05 +0000
commit816b5a667f0b5b47c3f80c2c775535310c89b727 (patch)
tree191e96ceb0aaa24bbbf17a9d2b056f641143b6ec /src/qml/types/qqmldelegatemodel.cpp
parent60d589ccddb036e84883a6c2ef63a5292c8ad022 (diff)
QQmlDelegateModel: add incubationStatus(), and use it to determine 'requestedIndex'
We used to assign the currently incubating item to 'requestedIndex' based on requested incubation mode alone. This is not sufficient, as the item can also be loaded async when the mode is AsyncIfNested. To check if the item is really loading async (and that we're not getting nullptr because of some other failure), we need to ask the incubator. Task-number: QTBUG-61537 Change-Id: Id1f458db4a7584a6b58d5bad0e7832ce4fc341dc Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/qml/types/qqmldelegatemodel.cpp')
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 4da7199d1e..9dd82494ca 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1036,6 +1036,16 @@ QObject *QQmlDelegateModel::object(int index, QQmlIncubator::IncubationMode incu
return d->object(d->m_compositorGroup, index, incubationMode);
}
+QQmlIncubator::Status QQmlDelegateModel::incubationStatus(int index)
+{
+ Q_D(QQmlDelegateModel);
+ Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index);
+ if (!it->inCache())
+ return QQmlIncubator::Null;
+
+ return d->m_cache.at(it.cacheIndex)->incubationTask->status();
+}
+
QString QQmlDelegateModelPrivate::stringValue(Compositor::Group group, int index, const QString &name)
{
Compositor::iterator it = m_compositor.find(group, index);
@@ -3203,6 +3213,16 @@ void QQmlPartsModel::setWatchedRoles(const QList<QByteArray> &roles)
m_watchedRoles = roles;
}
+QQmlIncubator::Status QQmlPartsModel::incubationStatus(int index)
+{
+ QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model);
+ Compositor::iterator it = model->m_compositor.find(model->m_compositorGroup, index);
+ if (!it->inCache())
+ return QQmlIncubator::Null;
+
+ return model->m_cache.at(it.cacheIndex)->incubationTask->status();
+}
+
int QQmlPartsModel::indexOf(QObject *item, QObject *) const
{
QHash<QObject *, QQuickPackage *>::const_iterator it = m_packaged.find(item);