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);
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) {
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)) {
--- /dev/null
+import QtQuick 2.0
+
+GridView {
+ id: view
+
+ property string title
+
+ width: 100; height: 100;
+
+ model: 1
+ delegate: Text { objectName: "listItem"; text: view.title }
+ header: Text { objectName: "header"; text: view.title }
+ footer: Text { objectName: "footer"; text: view.title }
+}
--- /dev/null
+import QtQuick 2.0
+
+ComponentView {
+ title: "Hello!"
+}
public:
tst_QSGGridView();
-private slots:
+//private slots:
void initTestCase();
void cleanupTestCase();
void items();
void testQtQuick11Attributes_data();
void columnCount();
void margins();
+private slots:
+ void creationContext();
private:
QSGView *createView();
}
}
+void tst_QSGGridView::creationContext()
+{
+ QSGView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/creationContext.qml"));
+ qApp->processEvents();
+
+ QSGItem *rootItem = qobject_cast<QSGItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QSGItem *item;
+ QVERIFY(item = rootItem->findChild<QSGItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
QSGView *tst_QSGGridView::createView()
{
QSGView *canvas = new QSGView(0);
--- /dev/null
+import QtQuick 2.0
+
+ListView {
+ id: view
+
+ property string title
+
+ width: 100; height: 100;
+
+ model: 1
+ delegate: Text { objectName: "listItem"; text: view.title }
+ header: Text { objectName: "header"; text: view.title }
+ footer: Text { objectName: "footer"; text: view.title }
+ section.delegate: Text { objectName: "section"; text: view.title }
+ section.property: "modelData"
+}
--- /dev/null
+import QtQuick 2.0
+
+ComponentView {
+ title: "Hello!"
+}
void rightToLeft();
void test_mirroring();
void margins();
+ void creationContext();
private:
template <class T> void items();
clear<TestModel2>();
}
+void tst_QSGListView::creationContext()
+{
+ QSGView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/creationContext.qml"));
+ qApp->processEvents();
+
+ QSGItem *rootItem = qobject_cast<QSGItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QSGItem *item;
+ QVERIFY(item = rootItem->findChild<QSGItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QSGItem *>("section"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
QSGView *tst_QSGListView::createView()
{
QSGView *canvas = new QSGView(0);
}
}
-
QTEST_MAIN(tst_QSGListView)
#include "tst_qsglistview.moc"
--- /dev/null
+import QtQuick 2.0
+
+PathView {
+ id: view
+
+ property string title
+
+ width: 100; height: 100;
+
+ model: 1
+ delegate: Text { objectName: "listItem"; text: view.title }
+
+ path: Path {
+ startX: 25; startY: 25;
+ PathLine { x: 75; y: 75 }
+ }
+}
--- /dev/null
+import QtQuick 2.0
+
+ComponentView {
+ title: "Hello!"
+}
void treeModel();
void changePreferredHighlight();
void missingPercent();
+ void creationContext();
private:
QSGView *createView();
delete canvas;
}
+void tst_QSGPathView::creationContext()
+{
+ QSGView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/creationContext.qml"));
+
+ QSGItem *rootItem = qobject_cast<QSGItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QSGItem *item;
+ QVERIFY(item = findItem<QSGItem>(rootItem, "listItem", 0));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
QSGView *tst_QSGPathView::createView()
{
QSGView *canvas = new QSGView(0);