diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-11-24 03:50:27 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-11-24 03:52:41 (GMT) |
commit | e3da9407ad85a65abce72f8a32230ec4f2f95369 (patch) | |
tree | f0e6e8072e5960ef41382e0e049bd5fbb5201035 /src/declarative/qml/qdeclarativeworkerscript.cpp | |
parent | d32360bb33e830f8c17a6db1a31f529436c2915e (diff) | |
download | Qt-e3da9407ad85a65abce72f8a32230ec4f2f95369.zip Qt-e3da9407ad85a65abce72f8a32230ec4f2f95369.tar.gz Qt-e3da9407ad85a65abce72f8a32230ec4f2f95369.tar.bz2 |
Allow javascript date and regexp objects in WorkerScript messages
Task-number: QTBUG-14666
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/qml/qdeclarativeworkerscript.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeworkerscript.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index be7ea0e..4b78020 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -52,6 +52,7 @@ #include <QtCore/qwaitcondition.h> #include <QtScript/qscriptvalueiterator.h> #include <QtCore/qfile.h> +#include <QtCore/qdatetime.h> #include <QtNetwork/qnetworkaccessmanager.h> #include <QtDeclarative/qdeclarativeinfo.h> #include "qdeclarativenetworkaccessmanagerfactory.h" @@ -314,6 +315,12 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri return QVariant(value.toString()); } else if (value.isNumber()) { return QVariant((qreal)value.toNumber()); + } else if (value.isDate()) { + return QVariant(value.toDateTime()); +#ifndef QT_NO_REGEXP + } else if (value.isRegExp()) { + return QVariant(value.toRegExp()); +#endif } else if (value.isArray()) { QVariantList list; @@ -364,6 +371,12 @@ QScriptValue QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(const Q return QScriptValue(value.toString()); } else if (value.userType() == QMetaType::QReal) { return QScriptValue(value.toReal()); + } else if (value.userType() == QVariant::DateTime) { + return engine->newDate(value.toDateTime()); +#ifndef QT_NO_REGEXP + } else if (value.userType() == QVariant::RegExp) { + return engine->newRegExp(value.toRegExp()); +#endif } else if (value.userType() == qMetaTypeId<QDeclarativeListModelWorkerAgent::VariantRef>()) { QDeclarativeListModelWorkerAgent::VariantRef vr = qvariant_cast<QDeclarativeListModelWorkerAgent::VariantRef>(value); if (vr.a->scriptEngine() == 0) |