summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-01-28 04:26:48 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-01-28 04:26:48 (GMT)
commitcfc536842a205a951457e2630b04de2262ffaa46 (patch)
treebe69c9314fa5ec7bc992d8d9fece9aee2559c374
parent56130de61b2e9e65d09ca4feef2749deea0bb4bb (diff)
downloadQt-cfc536842a205a951457e2630b04de2262ffaa46.zip
Qt-cfc536842a205a951457e2630b04de2262ffaa46.tar.gz
Qt-cfc536842a205a951457e2630b04de2262ffaa46.tar.bz2
Support builtin string converters in every context
QTBUG-6919
-rw-r--r--src/declarative/qml/qmlcompiler.cpp28
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp9
-rw-r--r--src/declarative/qml/qmlstringconverters.cpp72
-rw-r--r--src/declarative/qml/qmlstringconverters_p.h6
-rw-r--r--tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml26
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h213
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp61
7 files changed, 381 insertions, 34 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 2e18b85..bb7abf3 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -257,26 +257,30 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::Color:
{
- QColor c = QmlStringConverters::colorFromString(string);
- if (!c.isValid()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: color expected"));
+ bool ok;
+ QmlStringConverters::colorFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: color expected"));
}
break;
case QVariant::Date:
{
- QDate d = QDate::fromString(string, Qt::ISODate);
- if (!d.isValid()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: date expected"));
+ bool ok;
+ QmlStringConverters::dateFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: date expected"));
}
break;
case QVariant::Time:
{
- QTime time = QTime::fromString(string, Qt::ISODate);
- if (!time.isValid()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: time expected"));
+ bool ok;
+ QmlStringConverters::timeFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: time expected"));
}
break;
case QVariant::DateTime:
{
- QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate);
- if (!dateTime.isValid()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: datetime expected"));
+ bool ok;
+ QmlStringConverters::dateTimeFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: datetime expected"));
}
break;
case QVariant::Point:
@@ -311,7 +315,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
case QVariant::Vector3D:
{
bool ok;
- QVector3D point = QmlStringConverters::vector3DFromString(string, &ok);
+ QmlStringConverters::vector3DFromString(string, &ok);
if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: 3D vector expected"));
}
break;
@@ -417,7 +421,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::Date:
{
- QDate d = QDate::fromString(string, Qt::ISODate);
+ QDate d = QmlStringConverters::dateFromString(string);
instr.type = QmlInstruction::StoreDate;
instr.storeDate.propertyIndex = prop.propertyIndex();
instr.storeDate.value = d.toJulianDay();
@@ -425,7 +429,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::Time:
{
- QTime time = QTime::fromString(string, Qt::ISODate);
+ QTime time = QmlStringConverters::timeFromString(string);
int data[] = { time.hour(), time.minute(),
time.second(), time.msec() };
int index = output->indexForInt(data, 4);
@@ -436,7 +440,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::DateTime:
{
- QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate);
+ QDateTime dateTime = QmlStringConverters::dateTimeFromString(string);
int data[] = { dateTime.date().toJulianDay(),
dateTime.time().hour(),
dateTime.time().minute(),
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index dbf6548..0603a9c 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -51,6 +51,7 @@
#include "qmlengine.h"
#include "qmlengine_p.h"
#include "qmldeclarativedata_p.h"
+#include "qmlstringconverters_p.h"
#include <qfxperf_p_p.h>
@@ -962,6 +963,14 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data
void *a[] = { (void *)v.constData(), 0, &status, &flags};
QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
}
+ } else if (vt == QVariant::String) {
+ bool ok = false;
+ QVariant v = QmlStringConverters::variantFromString(value.toString(), t, &ok);
+ if (!ok)
+ return false;
+
+ void *a[] = { (void *)v.constData(), 0, &status, &flags};
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
} else {
return false;
}
diff --git a/src/declarative/qml/qmlstringconverters.cpp b/src/declarative/qml/qmlstringconverters.cpp
index c68654f..2963ab5 100644
--- a/src/declarative/qml/qmlstringconverters.cpp
+++ b/src/declarative/qml/qmlstringconverters.cpp
@@ -47,6 +47,7 @@
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
@@ -94,14 +95,43 @@ QVariant QmlStringConverters::variantFromString(const QString &s)
if (ok) return QVariant(p);
QSizeF sz = sizeFFromString(s, &ok);
if (ok) return QVariant(sz);
- bool b = boolFromString(s, &ok);
- if (ok) return QVariant(b);
QVector3D v = vector3DFromString(s, &ok);
if (ok) return qVariantFromValue(v);
return QVariant(s);
}
+QVariant QmlStringConverters::variantFromString(const QString &s, int preferredType, bool *ok)
+{
+ switch (preferredType) {
+ case QMetaType::QColor:
+ return QVariant::fromValue(colorFromString(s, ok));
+ case QMetaType::QDate:
+ return QVariant::fromValue(dateFromString(s, ok));
+ case QMetaType::QTime:
+ return QVariant::fromValue(timeFromString(s, ok));
+ case QMetaType::QDateTime:
+ return QVariant::fromValue(dateTimeFromString(s, ok));
+ case QMetaType::QPointF:
+ return QVariant::fromValue(pointFFromString(s, ok));
+ case QMetaType::QPoint:
+ return QVariant::fromValue(pointFFromString(s, ok).toPoint());
+ case QMetaType::QSizeF:
+ return QVariant::fromValue(sizeFFromString(s, ok));
+ case QMetaType::QSize:
+ return QVariant::fromValue(sizeFFromString(s, ok).toSize());
+ case QMetaType::QRectF:
+ return QVariant::fromValue(rectFFromString(s, ok));
+ case QMetaType::QRect:
+ return QVariant::fromValue(rectFFromString(s, ok).toRect());
+ case QMetaType::QVector3D:
+ return QVariant::fromValue(vector3DFromString(s, ok));
+ default:
+ if (ok) *ok = false;
+ return QVariant();
+ }
+}
+
QColor QmlStringConverters::colorFromString(const QString &s, bool *ok)
{
if (s.startsWith(QLatin1Char('#')) && s.length() == 9) {
@@ -120,6 +150,27 @@ QColor QmlStringConverters::colorFromString(const QString &s, bool *ok)
}
}
+QDate QmlStringConverters::dateFromString(const QString &s, bool *ok)
+{
+ QDate d = QDate::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+
+QTime QmlStringConverters::timeFromString(const QString &s, bool *ok)
+{
+ QTime t = QTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = t.isValid();
+ return t;
+}
+
+QDateTime QmlStringConverters::dateTimeFromString(const QString &s, bool *ok)
+{
+ QDateTime d = QDateTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+
//expects input of "x,y"
QPointF QmlStringConverters::pointFFromString(const QString &s, bool *ok)
{
@@ -196,23 +247,6 @@ QRectF QmlStringConverters::rectFFromString(const QString &s, bool *ok)
return QRectF(x, y, width, height);
}
-bool QmlStringConverters::boolFromString(const QString &str, bool *ok)
-{
- if (str.isEmpty() || str == QLatin1String("false") || str == QLatin1String("0")) {
- if (ok)
- *ok = true;
- return false;
- } else if (str == QLatin1String("true") || str == QLatin1String("1")) {
- if (ok)
- *ok = true;
- return true;
- }
-
- if (ok)
- *ok = false;
- return true;
-}
-
//expects input of "x,y,z"
QVector3D QmlStringConverters::vector3DFromString(const QString &s, bool *ok)
{
diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h
index 380a904..dfc59ce 100644
--- a/src/declarative/qml/qmlstringconverters_p.h
+++ b/src/declarative/qml/qmlstringconverters_p.h
@@ -70,11 +70,15 @@ QT_BEGIN_NAMESPACE
namespace QmlStringConverters
{
QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &);
+ QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0);
+
QColor Q_DECLARATIVE_EXPORT colorFromString(const QString &, bool *ok = 0);
+ QDate Q_DECLARATIVE_EXPORT dateFromString(const QString &, bool *ok = 0);
+ QTime Q_DECLARATIVE_EXPORT timeFromString(const QString &, bool *ok = 0);
+ QDateTime Q_DECLARATIVE_EXPORT dateTimeFromString(const QString &, bool *ok = 0);
QPointF Q_DECLARATIVE_EXPORT pointFFromString(const QString &, bool *ok = 0);
QSizeF Q_DECLARATIVE_EXPORT sizeFFromString(const QString &, bool *ok = 0);
QRectF Q_DECLARATIVE_EXPORT rectFFromString(const QString &, bool *ok = 0);
- bool Q_DECLARATIVE_EXPORT boolFromString(const QString &, bool *ok = 0);
QVector3D Q_DECLARATIVE_EXPORT vector3DFromString(const QString &, bool *ok = 0);
};
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml
new file mode 100644
index 0000000..db7f2b5
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml
@@ -0,0 +1,26 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ flagProperty: if(1) "FlagVal1 | FlagVal3"
+ enumProperty: if(1) "EnumVal2"
+ stringProperty: if(1) "Hello World!"
+ uintProperty: if(1) 10
+ intProperty: if(1) -19
+ realProperty: if(1) 23.2
+ doubleProperty: if(1) -19.7
+ floatProperty: if(1) 8.5
+ colorProperty: if(1) "red"
+ dateProperty: if(1) "1982-11-25"
+ timeProperty: if(1) "11:11:32"
+ dateTimeProperty: if(1) "2009-05-12T13:22:01"
+ pointProperty: if(1) "99,13"
+ pointFProperty: if(1) "-10.1,12.3"
+ sizeProperty: if(1) "99x13"
+ sizeFProperty: if(1) "0.1x0.2"
+ rectProperty: if(1) "9,7,100x200"
+ rectFProperty: if(1) "1000.1,-10.9,400x90.99"
+ boolProperty: if(1) true
+ variantProperty: if(1) "Hello World!"
+ vectorProperty: if(1) "10,1,2.2"
+ urlProperty: if(1) "main.qml"
+}
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h
index 164dd17..a800a98 100644
--- a/tests/auto/declarative/qmlecmascript/testtypes.h
+++ b/tests/auto/declarative/qmlecmascript/testtypes.h
@@ -48,7 +48,13 @@
#include <QtCore/qsize.h>
#include <QtDeclarative/qmllist.h>
#include <QtCore/qrect.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtCore/qdatetime.h>
#include <QtScript/qscriptvalue.h>
+#include <QtDeclarative/qmlscriptstring.h>
+#include <QtDeclarative/qmlcomponent.h>
class MyQmlAttachedObject : public QObject
{
@@ -278,15 +284,164 @@ QML_DECLARE_TYPE(MyExtendedObject);
class MyTypeObject : public QObject
{
Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId);
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
+ Q_PROPERTY(QmlComponent *componentProperty READ componentProperty WRITE setComponentProperty);
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty);
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty);
Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty);
Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty);
Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty);
Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty);
Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged);
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2);
Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
-
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty);
+
+ Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
+
public:
- MyTypeObject() {}
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QmlComponent *componentPropertyValue;
+ QmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
QPoint pointPropertyValue;
QPoint pointProperty() const {
@@ -326,6 +481,15 @@ public:
}
void setRectProperty(const QRect &v) {
rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
}
QRectF rectFPropertyValue;
@@ -336,7 +500,52 @@ public:
rectFPropertyValue = v;
}
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QmlScriptString scriptPropertyValue;
+ QmlScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QmlScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
QML_DECLARE_TYPE(MyTypeObject);
Q_DECLARE_METATYPE(QScriptValue);
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 82a2351..bcad045 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -76,6 +76,7 @@ public:
tst_qmlecmascript() {}
private slots:
+ void assignBasicTypes();
void idShortcutInvalidates();
void boolPropertiesEvaluateAsBool();
void methods();
@@ -125,6 +126,66 @@ private:
QmlEngine engine;
};
+void tst_qmlecmascript::assignBasicTypes()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+ {
+ QmlComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+}
+
void tst_qmlecmascript::idShortcutInvalidates()
{
{