diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-10-07 13:06:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-07 05:55:18 +0200 |
commit | cdf868033bbd7bf5a996c67fa56f8ac15e755115 (patch) | |
tree | 2e39f31248a7845fe8105e538b0a9c2b8eb55f10 /src | |
parent | d517e9c541e5869e87006faeccd60be5690bee5b (diff) |
Fix ListView components being unable to access context properties.
Where avaialable use the components creation context instead of the
views context as the root context for the new item.
Task-number: QTBUG-21865
Change-Id: I07e564548de57d58413dc0d7cd151bd8a90886e7
Reviewed-on: http://codereview.qt-project.org/6199
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qsgitemview.cpp | 4 | ||||
-rw-r--r-- | src/declarative/items/qsglistview.cpp | 4 | ||||
-rw-r--r-- | src/declarative/items/qsgvisualdatamodel.cpp | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/declarative/items/qsgitemview.cpp b/src/declarative/items/qsgitemview.cpp index b34ed8227a..9415f9eda9 100644 --- a/src/declarative/items/qsgitemview.cpp +++ b/src/declarative/items/qsgitemview.cpp @@ -1624,7 +1624,9 @@ QSGItem *QSGItemViewPrivate::createComponentItem(QDeclarativeComponent *componen QSGItem *item = 0; if (component) { - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); + QDeclarativeContext *creationContext = component->creationContext(); + QDeclarativeContext *context = new QDeclarativeContext( + creationContext ? creationContext : qmlContext(q)); QObject *nobj = component->create(context); if (nobj) { QDeclarative_setParent_noEvent(context, nobj); diff --git a/src/declarative/items/qsglistview.cpp b/src/declarative/items/qsglistview.cpp index 7f9ce3ac8b..beeeda45e9 100644 --- a/src/declarative/items/qsglistview.cpp +++ b/src/declarative/items/qsglistview.cpp @@ -832,7 +832,9 @@ QSGItem * QSGListViewPrivate::getSectionItem(const QString §ion) QDeclarativeContext *context = QDeclarativeEngine::contextForObject(sectionItem)->parentContext(); context->setContextProperty(QLatin1String("section"), section); } else { - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); + QDeclarativeContext *creationContext = sectionCriteria->delegate()->creationContext(); + QDeclarativeContext *context = new QDeclarativeContext( + creationContext ? creationContext : qmlContext(q)); context->setContextProperty(QLatin1String("section"), section); QObject *nobj = sectionCriteria->delegate()->beginCreate(context); if (nobj) { diff --git a/src/declarative/items/qsgvisualdatamodel.cpp b/src/declarative/items/qsgvisualdatamodel.cpp index f5c86b8faf..e0d353a93f 100644 --- a/src/declarative/items/qsgvisualdatamodel.cpp +++ b/src/declarative/items/qsgvisualdatamodel.cpp @@ -939,7 +939,9 @@ QObject *QSGVisualDataModelPrivate::object(Compositor::Group group, int index, b if (!cacheItem->object) { QObject *data = m_adaptorModel->data(it.modelIndex()); - QDeclarativeContext *rootContext = new QDeclarativeContext(m_context); + QDeclarativeContext *creationContext = m_delegate->creationContext(); + QDeclarativeContext *rootContext = new QDeclarativeContext( + creationContext ? creationContext : m_context.data()); QDeclarativeContext *ctxt = rootContext; if (m_adaptorModel->flags() & QSGVisualAdaptorModel::ProxiedObject) { if (QSGVisualAdaptorModelProxyInterface *proxy = qobject_cast<QSGVisualAdaptorModelProxyInterface *>(data)) { |