diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-08 01:19:35 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-08 01:20:39 (GMT) |
commit | e74bd7d0b1a2ed47f41fba47caa542ca5b29880e (patch) | |
tree | 528602e81bc8627f04c35e20f32412d1269e6c2b | |
parent | 80cd83d3b09b2271d183a51d2e6453924c535dce (diff) | |
download | Qt-e74bd7d0b1a2ed47f41fba47caa542ca5b29880e.zip Qt-e74bd7d0b1a2ed47f41fba47caa542ca5b29880e.tar.gz Qt-e74bd7d0b1a2ed47f41fba47caa542ca5b29880e.tar.bz2 |
Revert "Support QList<QObject*> properties"
This reverts commit 9d9161446bfad883c298d54a122e822c5e273a9c.
This was a bad idea. It complicates the "property var" are not really
JavaScript var problem. Some of the patch is valid, and it will be
applied separately.
16 files changed, 70 insertions, 297 deletions
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index bed1956..71cf3cb 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -148,26 +148,8 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) idx, a); } else { - QDeclarativeEnginePrivate *ep = (data->context() && data->context()->engine)? - QDeclarativeEnginePrivate::get(data->context()->engine):0; - bool isUndefined = false; - QVariant value; - - if (data->property.propertyTypeCategory() == QDeclarativeProperty::List) { - QScriptValue scriptValue = d->scriptValue(0, &isUndefined); - value = ep->scriptValueToVariant(scriptValue, qMetaTypeId<QList<QObject *> >()); - } else { - QScriptValue scriptValue = d->scriptValue(0, &isUndefined); - value = ep->scriptValueToVariant(scriptValue); - if (value.userType() == QMetaType::QObjectStar && !qvariant_cast<QObject*>(value)) { - // If the object is null, we extract the predicted type. While this isn't - // 100% reliable, in many cases it gives us better error messages if we - // assign this null-object to an incompatible property - int type = ep->objectClass->objectType(scriptValue); - value = QVariant(type, (void *)0); - } - } + QVariant value = this->value(&isUndefined); if (isUndefined && !data->error.isValid() && data->property.isResettable()) { @@ -205,7 +187,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } if (data->error.isValid()) { - if (!data->addError(ep)) + QDeclarativeEnginePrivate *p = (data->context() && data->context()->engine)? + QDeclarativeEnginePrivate::get(data->context()->engine):0; + if (!data->addError(p)) qWarning().nospace() << qPrintable(this->error().toString()); } else { data->removeError(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 3c66efb..e8b6913 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1324,6 +1324,7 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine return qScriptValueFromValue(engine, qVariantFromValue(finalColor)); } + QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &val) { if (val.userType() == qMetaTypeId<QDeclarativeListReference>()) { @@ -1334,14 +1335,6 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v } else { return scriptEngine.nullValue(); } - } else if (val.userType() == qMetaTypeId<QList<QObject *> >()) { - const QList<QObject *> &list = *(QList<QObject *>*)val.constData(); - QScriptValue rv = scriptEngine.newArray(list.count()); - for (int ii = 0; ii < list.count(); ++ii) { - QObject *object = list.at(ii); - rv.setProperty(ii, objectClass->newQObject(object)); - } - return rv; } bool objOk; @@ -1353,31 +1346,22 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v } } -QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val, int hint) +QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val) { QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(val); if (dc == objectClass) return QVariant::fromValue(objectClass->toQObject(val)); - else if (dc == valueTypeClass) - return valueTypeClass->toVariant(val); else if (dc == contextClass) return QVariant(); - // Convert to a QList<QObject*> if val is an array and we were explicitly hinted, or - // if the first element is a QObject* - if ((hint == qMetaTypeId<QList<QObject *> >() && val.isArray()) || - (val.isArray() && QScriptDeclarativeClass::scriptClass(val.property(0)) == objectClass)) { - QList<QObject *> list; - int length = val.property(QLatin1String("length")).toInt32(); - for (int ii = 0; ii < length; ++ii) { - QScriptValue arrayItem = val.property(ii); - QObject *d = arrayItem.toQObject(); - list << d; - } - return QVariant::fromValue(list); + QScriptDeclarativeClass *sc = QScriptDeclarativeClass::scriptClass(val); + if (!sc) { + return val.toVariant(); + } else if (sc == valueTypeClass) { + return valueTypeClass->toVariant(val); + } else { + return QVariant(); } - - return val.toVariant(); } // XXX this beyonds in QUrl::toLocalFile() diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 3f22d61..45089d0 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -308,7 +308,7 @@ public: QHash<QString, QScriptValue> m_sharedScriptImports; QScriptValue scriptValueFromVariant(const QVariant &); - QVariant scriptValueToVariant(const QScriptValue &, int hint = QVariant::Invalid); + QVariant scriptValueToVariant(const QScriptValue &); void sendQuit (); diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index e0aee52..a250f21 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -351,7 +351,7 @@ void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine } } -QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool *isUndefined) +QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUndefined) { QDeclarativeExpressionData *data = this->data; QDeclarativeEngine *engine = data->context()->engine; @@ -376,7 +376,7 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool * const QString code = rewriteBinding(data->expression, &ok); if (!ok) { scriptEngine->popContext(); - return QScriptValue(); + return QVariant(); } data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line); } @@ -413,20 +413,54 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool * if (scriptEngine->hasUncaughtException()) { exceptionToError(scriptEngine, data->error); scriptEngine->clearExceptions(); - return QScriptValue(); + return QVariant(); } else { data->error = QDeclarativeError(); - return svalue; } + + QVariant rv; + + if (svalue.isArray()) { + int length = svalue.property(QLatin1String("length")).toInt32(); + if (length && svalue.property(0).isObject()) { + QList<QObject *> list; + for (int ii = 0; ii < length; ++ii) { + QScriptValue arrayItem = svalue.property(ii); + QObject *d = arrayItem.toQObject(); + list << d; + } + rv = QVariant::fromValue(list); + } + } else if (svalue.isObject() && + ep->objectClass->scriptClass(svalue) == ep->objectClass) { + QObject *o = svalue.toQObject(); + int type = QMetaType::QObjectStar; + // If the object is null, we extract the predicted type. While this isn't + // 100% reliable, in many cases it gives us better error messages if we + // assign this null-object to an incompatible property + if (!o) type = ep->objectClass->objectType(svalue); + + return QVariant(type, &o); + } + + if (rv.isNull()) + rv = svalue.toVariant(); + + return rv; } -QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, bool *isUndefined) +QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) { Q_Q(QDeclarativeExpression); - Q_ASSERT(q->engine()); + + QVariant rv; + if (!q->engine()) { + qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context"); + return rv; + } if (data->expression.isEmpty()) - return QScriptValue(); + return rv; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine()); @@ -442,7 +476,7 @@ QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, QDeclarativeExpressionData *localData = data; localData->addref(); - QScriptValue value = eval(secondaryScope, isUndefined); + rv = evalQtScript(secondaryScope, isUndefined); ep->currentExpression = lastCurrentExpression; ep->captureProperties = lastCaptureProperties; @@ -460,21 +494,7 @@ QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, lastCapturedProperties.copyAndClear(ep->capturedProperties); - return value; -} - -QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) -{ - Q_Q(QDeclarativeExpression); - - if (!q->engine()) { - qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context"); - return QVariant(); - } - - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine()); - - return ep->scriptValueToVariant(scriptValue(secondaryScope, isUndefined)); + return rv; } /*! diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index 1a0e4dd..9a90fb6 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -150,9 +150,7 @@ public: QDeclarativeExpressionData *data; QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0); - QScriptValue scriptValue(QObject *secondaryScope = 0, bool *isUndefined = 0); - - QScriptValue eval(QObject *secondaryScope, bool *isUndefined = 0); + QVariant evalQtScript(QObject *secondaryScope, bool *isUndefined = 0); void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties); void clearGuards(); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 0e230e8..10b9fab 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -222,10 +222,15 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) if (lastData->flags & QDeclarativePropertyCache::Data::IsVMEFunction) { return Value(scriptEngine, ((QDeclarativeVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex)); } else { +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) // Uncomment to use QtScript method call logic // QScriptValue sobj = scriptEngine->newQObject(obj); // return Value(scriptEngine, sobj.property(toString(name))); return Value(scriptEngine, methods.newMethod(obj, lastData)); +#else + QScriptValue sobj = scriptEngine->newQObject(obj); + return Value(scriptEngine, sobj.property(toString(name))); +#endif } } else { if (enginePriv->captureProperties && !(lastData->flags & QDeclarativePropertyCache::Data::IsConstant)) { @@ -290,6 +295,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj); return Value(scriptEngine, enginePriv->scriptValueFromVariant(var)); } + } } @@ -450,6 +456,8 @@ bool QDeclarativeObjectScriptClass::compare(Object *o1, Object *o2) return d1 == d2 || d1->object == d2->object; } +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) + struct MethodData : public QScriptDeclarativeClass::Object { MethodData(QObject *o, const QDeclarativePropertyCache::Data &d) : object(o), data(d) {} @@ -679,17 +687,7 @@ void MetaCallArgument::fromScriptValue(int callType, QDeclarativeEngine *engine, new (&data) QVariant(QDeclarativeEnginePrivate::get(engine)->scriptValueToVariant(value)); type = callType; } else if (callType == qMetaTypeId<QList<QObject*> >()) { - QList<QObject *> *list = new (&data) QList<QObject *>(); - if (value.isArray()) { - int length = value.property(QLatin1String("length")).toInt32(); - for (int ii = 0; ii < length; ++ii) { - QScriptValue arrayItem = value.property(ii); - QObject *d = arrayItem.toQObject(); - list->append(d); - } - } else if (QObject *d = value.toQObject()) { - list->append(d); - } + new (&data) QList<QObject *>(); // We don't support passing in QList<QObject*> type = callType; } else { new (&data) QVariant(); @@ -802,5 +800,7 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass:: return Value(); } +#endif + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index d33f29e..affb6b9 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1045,21 +1045,6 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope prop.append(&prop, (void *)o); } - } else if (propertyType == qMetaTypeId<QList<QObject *> >()) { - - QList<QObject *> list; - - if (value.userType() == qMetaTypeId<QList<QObject *> >()) { - list = qvariant_cast<QList<QObject *> >(value); - } else { - QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value); - if (o) - list.append(o); - } - - void *args[] = { &list, 0, &status, &flags }; - QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, args); - } else { Q_ASSERT(variantType != propertyType); diff --git a/src/declarative/util/qdeclarativelistaccessor.cpp b/src/declarative/util/qdeclarativelistaccessor.cpp index f91b2fb..4ac587f 100644 --- a/src/declarative/util/qdeclarativelistaccessor.cpp +++ b/src/declarative/util/qdeclarativelistaccessor.cpp @@ -84,8 +84,6 @@ void QDeclarativeListAccessor::setList(const QVariant &v, QDeclarativeEngine *en QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v); d = QVariant::fromValue(data); m_type = Instance; - } else if (d.userType() == qMetaTypeId<QList<QObject *> >()) { - m_type = ObjectList; } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) { m_type = ListProperty; } else { @@ -100,8 +98,6 @@ int QDeclarativeListAccessor::count() const return qvariant_cast<QStringList>(d).count(); case VariantList: return qvariant_cast<QVariantList>(d).count(); - case ObjectList: - return qvariant_cast<QList<QObject*> >(d).count(); case ListProperty: return ((QDeclarativeListReference *)d.constData())->count(); case Instance: @@ -122,8 +118,6 @@ QVariant QDeclarativeListAccessor::at(int idx) const return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx)); case VariantList: return qvariant_cast<QVariantList>(d).at(idx); - case ObjectList: - return QVariant::fromValue(qvariant_cast<QList<QObject*> >(d).at(idx)); case ListProperty: return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx)); case Instance: diff --git a/src/declarative/util/qdeclarativelistaccessor_p.h b/src/declarative/util/qdeclarativelistaccessor_p.h index 10d944a..d8bb8af 100644 --- a/src/declarative/util/qdeclarativelistaccessor_p.h +++ b/src/declarative/util/qdeclarativelistaccessor_p.h @@ -65,7 +65,7 @@ public: int count() const; QVariant at(int) const; - enum Type { Invalid, StringList, VariantList, ObjectList, ListProperty, Instance, Integer }; + enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer }; Type type() const { return m_type; } private: diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml deleted file mode 100644 index 9c289be..0000000 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.1.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt.test 1.0 -import Qt 4.6 - -MyQmlObject { - id: root - - property bool test1 - property bool test2 - - qlistProperty: root - - Component.onCompleted: { - test1 = (qlistProperty.length == 1) - test2 = (qlistProperty[0] == root) - } -} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml deleted file mode 100644 index 8041f5c..0000000 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.2.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt.test 1.0 -import Qt 4.6 - -MyQmlObject { - id: root - - property bool test1 - property bool test2 - - Component.onCompleted: { - qlistProperty = root - - test1 = (qlistProperty.length == 1) - test2 = (qlistProperty[0] == root) - } -} - diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml deleted file mode 100644 index df44e48..0000000 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.3.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt.test 1.0 -import Qt 4.6 - -MyQmlObject { - id: root - - property bool test1 - property bool test2 - property bool test3 - property bool test4 - - objectProperty: QtObject { id: obj } - qlistProperty: [ root, obj ] - - Component.onCompleted: { - test1 = (qlistProperty.length == 2) - test2 = (qlistProperty[0] == root) - test3 = (qlistProperty[1] == obj) - test4 = (qlistProperty[2] == null) - } -} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml deleted file mode 100644 index 33c3576..0000000 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.4.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt.test 1.0 -import Qt 4.6 - -MyQmlObject { - id: root - - property bool test1 - property bool test2 - property bool test3 - property bool test4 - - objectProperty: QtObject { id: obj } - - Component.onCompleted: { - qlistProperty = [ root, obj ] - - test1 = (qlistProperty.length == 2) - test2 = (qlistProperty[0] == root) - test3 = (qlistProperty[1] == obj) - test4 = (qlistProperty[2] == null) - } -} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml deleted file mode 100644 index 3fd497c..0000000 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistOfQObjects.5.qml +++ /dev/null @@ -1,35 +0,0 @@ -import Qt.test 1.0 -import Qt 4.6 - -MyQmlObject { - id: root - - property bool test1 - property bool test2 - property bool test3 - property bool test4 - property bool test5 - property bool test6 - property bool test7 - property bool test8 - - objectProperty: QtObject { id: obj } - - Component.onCompleted: { - qlistProperty = [ root, obj ] - - test1 = (qlistProperty.length == 2) - test2 = (qlistProperty[0] == root) - test3 = (qlistProperty[1] == obj) - test4 = (qlistProperty[2] == null) - - var a = qlistProperty; - a.reverse(); - qlistProperty = a - - test5 = (qlistProperty.length == 2) - test7 = (qlistProperty[0] == obj) - test6 = (qlistProperty[1] == root) - test8 = (qlistProperty[2] == null) - } -} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index d8ec452..faad8b7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -91,7 +91,6 @@ class MyQmlObject : public QObject Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp) - Q_PROPERTY(QList<QObject *> qlistProperty READ qlistProperty WRITE setQListProperty) public: MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {} @@ -143,9 +142,6 @@ public: QRegExp regExp() { return m_regExp; } void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } - QList<QObject *> qlistProperty() const { return m_objectQList2; } - void setQListProperty(const QList<QObject *> &v) { m_objectQList2 = v; } - signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -171,8 +167,6 @@ private: int m_value; int m_resetProperty; QRegExp m_regExp; - - QList<QObject *> m_objectQList2; }; QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index a2625da..77dd4b8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -130,7 +130,6 @@ private slots: void qlistqobjectMethods(); void strictlyEquals(); void compiled(); - void qlistOfQObjects(); void bug1(); void dynamicCreationCrash(); @@ -2066,80 +2065,6 @@ void tst_qdeclarativeecmascript::compiled() delete object; } -// Test manipulating QList<QObject *> properties -void tst_qdeclarativeecmascript::qlistOfQObjects() -{ - { - QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.1.qml")); - - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(object->property("test1").toBool(), true); - QCOMPARE(object->property("test2").toBool(), true); - - delete object; - } - - { - QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.2.qml")); - - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(object->property("test1").toBool(), true); - QCOMPARE(object->property("test2").toBool(), true); - - delete object; - } - - { - QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.3.qml")); - - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(object->property("test1").toBool(), true); - QCOMPARE(object->property("test2").toBool(), true); - QCOMPARE(object->property("test3").toBool(), true); - QCOMPARE(object->property("test4").toBool(), true); - - delete object; - } - - { - QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.4.qml")); - - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(object->property("test1").toBool(), true); - QCOMPARE(object->property("test2").toBool(), true); - QCOMPARE(object->property("test3").toBool(), true); - QCOMPARE(object->property("test4").toBool(), true); - - delete object; - } - - { - QDeclarativeComponent component(&engine, TEST_FILE("qlistOfQObjects.5.qml")); - - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(object->property("test1").toBool(), true); - QCOMPARE(object->property("test2").toBool(), true); - QCOMPARE(object->property("test3").toBool(), true); - QCOMPARE(object->property("test4").toBool(), true); - QCOMPARE(object->property("test5").toBool(), true); - QCOMPARE(object->property("test6").toBool(), true); - QCOMPARE(object->property("test7").toBool(), true); - QCOMPARE(object->property("test8").toBool(), true); - - delete object; - } -} - QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" |