summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/globalobject.qdoc4
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc4
-rw-r--r--examples/declarative/effects/effects.qml65
-rw-r--r--examples/declarative/effects/effects.qmlproject16
-rw-r--r--examples/declarative/effects/pic.pngbin12933 -> 0 bytes
-rw-r--r--examples/declarative/tic-tac-toe/content/pics/board.pngbin1423 -> 12258 bytes
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects.cpp174
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects_p.h67
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp14
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp19
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp78
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp32
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp63
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h12
-rw-r--r--src/declarative/util/qdeclarativepropertymap.cpp2
-rw-r--r--src/declarative/util/qdeclarativepropertymap.h2
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp86
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/atob.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/btoa.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp83
26 files changed, 315 insertions, 439 deletions
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index d729d4f..6709ab4 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -190,10 +190,10 @@ This function attempts to open the specified \c target url in an external applic
This function returns a hex string of the md5 hash of \c data.
\section3 Qt.btoa(data)
-This function returns a base64 encoding of \c data.
+Binary to ASCII - this function returns a base64 encoding of \c data.
\section3 Qt.atob(data)
-This function returns a base64 decoding of \c data.
+ASCII to binary - this function returns a base64 decoding of \c data.
\section3 Qt.quit()
This function causes the QML engine to emit the quit signal, which in
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 5d1e18f..670a218 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -91,6 +91,10 @@
qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
\endcode
+ Note that it's perfectly reasonable for a library to register types to older versions
+ than the actual version of the library. Indeed, it is normal for the new library to allow
+ QML written to previous versions to continue to work, even if more advanced versions of
+ some of its types are available.
*/
/*!
diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml
deleted file mode 100644
index feb7c69..0000000
--- a/examples/declarative/effects/effects.qml
+++ /dev/null
@@ -1,65 +0,0 @@
-import Qt 4.7
-
-Rectangle {
- width: 400; height: 200
-
- Image {
- id: blur
- x: 5
- source: "pic.png"
-
- effect: Blur {
- NumberAnimation on blurRadius {
- id: blurEffect
- running: false
- from: 0; to: 10
- duration: 1000
- loops: Animation.Infinite
- }
- }
-
- MouseArea { anchors.fill: parent; onClicked: blurEffect.running = !blurEffect.running }
- }
-
- Text { text: "Blur"; anchors.top: blur.bottom; anchors.horizontalCenter: blur.horizontalCenter }
-
- Image {
- id: dropShadow
- source: "pic.png"
- x: 135
-
- effect: DropShadow {
- blurRadius: 3
- offset.x: 3
-
- NumberAnimation on offset.y {
- id: dropShadowEffect
- from: 0; to: 10
- duration: 1000
- running: false
- loops: Animation.Infinite
- }
- }
-
- MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running }
- }
-
- Image {
- id: colorize
- source: "pic.png"
- x: 265
-
- effect: Colorize { color: "blue" }
- }
-
- Text { text: "Colorize"; anchors.top: colorize.bottom; anchors.horizontalCenter: colorize.horizontalCenter }
-
- Text { text: "Drop Shadow"; anchors.top: dropShadow.bottom; anchors.horizontalCenter: dropShadow.horizontalCenter }
-
- Text {
- y: 155; anchors.horizontalCenter: parent.horizontalCenter
- text: "Clicking Blur or Drop Shadow will \ntoggle animation."
- color: "black"
- }
-
-}
diff --git a/examples/declarative/effects/effects.qmlproject b/examples/declarative/effects/effects.qmlproject
deleted file mode 100644
index d4909f8..0000000
--- a/examples/declarative/effects/effects.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.0
-
-Project {
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
- /* List of plugin directories passed to QML runtime */
- // importPaths: [ " ../exampleplugin " ]
-}
diff --git a/examples/declarative/effects/pic.png b/examples/declarative/effects/pic.png
deleted file mode 100644
index 051e738..0000000
--- a/examples/declarative/effects/pic.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png
index 29118a9..7e5b7ba 100644
--- a/examples/declarative/tic-tac-toe/content/pics/board.png
+++ b/examples/declarative/tic-tac-toe/content/pics/board.png
Binary files differ
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index ad7ccb5..d420595 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -5,7 +5,6 @@ HEADERS += \
$$PWD/qdeclarativeanchors_p.h \
$$PWD/qdeclarativeanchors_p_p.h \
$$PWD/qdeclarativeevents_p_p.h \
- $$PWD/qdeclarativeeffects_p.h \
$$PWD/qdeclarativeflickable_p.h \
$$PWD/qdeclarativeflickable_p_p.h \
$$PWD/qdeclarativeflipable_p.h \
@@ -50,7 +49,6 @@ HEADERS += \
$$PWD/qdeclarativelistview_p.h \
$$PWD/qdeclarativelayoutitem_p.h \
$$PWD/qdeclarativeitemchangelistener_p.h \
- $$PWD/qdeclarativeeffects.cpp \
$$PWD/qdeclarativegraphicswidget_p.h
SOURCES += \
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects.cpp b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
deleted file mode 100644
index ea1f9cc..0000000
--- a/src/declarative/graphicsitems/qdeclarativeeffects.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdeclarative.h>
-
-#include <QtGui/qgraphicseffect.h>
-
-/*!
- \qmlclass Blur QGraphicsBlurEffect
- \since 4.7
- \brief The Blur object provides a blur effect.
-
- A blur effect blurs the source item. This effect is useful for reducing details;
- for example, when the a source loses focus and attention should be drawn to other
- elements. Use blurRadius to control the level of detail and blurHint to control
- the quality of the blur.
-
- By default, the blur radius is 5 pixels.
-
- \img graphicseffect-blur.png
-*/
-
-/*!
- \qmlproperty real Blur::blurRadius
-
- This controls how blurry an item will appear.
-
- A smaller radius produces a sharper appearance, and a larger radius produces
- a more blurred appearance.
-
- The default radius is 5 pixels.
-*/
-/*!
- \qmlproperty enumeration Blur::blurHint
-
- Use Qt.PerformanceHint to specify a faster blur or Qt.QualityHint hint
- to specify a higher quality blur.
-
- If the blur radius is animated, it is recommended you use Qt.PerformanceHint.
-
- The default hint is Qt.PerformanceHint.
-*/
-
-/*!
- \qmlclass Colorize QGraphicsColorizeEffect
- \since 4.7
- \brief The Colorize object provides a colorize effect.
-
- A colorize effect renders the source item with a tint of its color.
-
- By default, the color is light blue.
-
- \img graphicseffect-colorize.png
-*/
-
-/*!
- \qmlproperty color Colorize::color
- The color of the effect.
-
- By default, the color is light blue.
-*/
-
-/*!
- \qmlproperty real Colorize::strength
-
- To what extent the source item is "colored". A strength of 0.0 is equal to no effect,
- while 1.0 means full colorization. By default, the strength is 1.0.
-*/
-
-
-/*!
- \qmlclass DropShadow QGraphicsDropShadowEffect
- \since 4.7
- \brief The DropShadow object provides a drop shadow effect.
-
- A drop shadow effect renders the source item with a drop shadow. The color of
- the drop shadow can be modified using the color property. The drop
- shadow offset can be modified using the xOffset and yOffset properties and the blur
- radius of the drop shadow can be changed with the blurRadius property.
-
- By default, the drop shadow is a semi-transparent dark gray shadow,
- blurred with a radius of 1 at an offset of 8 pixels towards the lower right.
-
- \img graphicseffect-drop-shadow.png
-*/
-
-/*!
- \qmlproperty real DropShadow::xOffset
- \qmlproperty real DropShadow::yOffset
- The shadow offset in pixels.
-
- By default, xOffset and yOffset are 8 pixels.
-*/
-
-/*!
- \qmlproperty real DropShadow::blurRadius
- The blur radius in pixels of the drop shadow.
-
- Using a smaller radius results in a sharper shadow, whereas using a bigger
- radius results in a more blurred shadow.
-
- By default, the blur radius is 1 pixel.
-*/
-
-/*!
- \qmlproperty color DropShadow::color
- The color of the drop shadow.
-
- By default, the drop color is a semi-transparent dark gray.
-*/
-
-
-/*!
- \qmlclass Opacity QGraphicsOpacityEffect
- \since 4.7
- \brief The Opacity object provides an opacity effect.
-
- An opacity effect renders the source with an opacity. This effect is useful
- for making the source semi-transparent, similar to a fade-in/fade-out
- sequence. The opacity can be modified using the opacity property.
-
- By default, the opacity is 0.7.
-
- \img graphicseffect-opacity.png
-*/
-
-/*!
- \qmlproperty real Opacity::opacity
- This property specifies how opaque an item should appear.
-
- The value should be in the range of 0.0 to 1.0, where 0.0 is
- fully transparent and 1.0 is fully opaque.
-
- By default, the opacity is 0.7.
-*/
-
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects_p.h b/src/declarative/graphicsitems/qdeclarativeeffects_p.h
deleted file mode 100644
index 0de5854..0000000
--- a/src/declarative/graphicsitems/qdeclarativeeffects_p.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEEFFECTS_P_H
-#define QDECLARATIVEEFFECTS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qdeclarative.h>
-#include <QtGui/qgraphicseffect.h>
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QML_DECLARE_TYPE(QGraphicsEffect)
-QML_DECLARE_TYPE(QGraphicsBlurEffect)
-QML_DECLARE_TYPE(QGraphicsColorizeEffect)
-QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
-QML_DECLARE_TYPE(QGraphicsOpacityEffect)
-#endif
-
-#endif // QDECLARATIVEEFFECTS_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index bdd24b6..bc0c65e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -61,7 +61,6 @@
#include <QtCore/qnumeric.h>
#include <QtScript/qscriptengine.h>
#include <QtGui/qgraphicstransform.h>
-#include <QtGui/qgraphicseffect.h>
#include <qlistmodelinterface_p.h>
QT_BEGIN_NAMESPACE
@@ -70,8 +69,6 @@ QT_BEGIN_NAMESPACE
#define FLT_MAX 1E+37
#endif
-#include "qdeclarativeeffects.cpp"
-
/*!
\qmlclass Transform QGraphicsTransform
\since 4.7
@@ -234,11 +231,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \group group_effects
- \title Effects
-*/
-
-/*!
\group group_layouts
\title Layouts
*/
@@ -2154,8 +2146,8 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
Opacity is an \e inherited attribute. That is, the opacity is
also applied individually to child items. In almost all cases this
- is what you want. If you can spot the issue in the following
- example, you might need to use an \l Opacity effect instead.
+ is what you want, but in some cases (like the following example)
+ it may produce undesired results.
\table
\row
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 8e34472..4238c53 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -46,7 +46,6 @@
#include <QtGui/qgraphicseffect.h>
#include "private/qdeclarativeevents_p_p.h"
-#include "private/qdeclarativeeffects_p.h"
#include "private/qdeclarativescalegrid_p_p.h"
#include "private/qdeclarativeanimatedimage_p.h"
#include "private/qdeclarativeborderimage_p.h"
@@ -144,19 +143,6 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QAction>();
qmlRegisterType<QDeclarativePen>();
qmlRegisterType<QDeclarativeFlickableVisibleArea>();
-#ifdef QT_NO_GRAPHICSEFFECT
- QString no_graphicseffect = qApp->translate("QGraphicsBlurEffect","Qt was built without support for graphicseffects");
- qmlRegisterTypeNotAvailable("Qt",4,7,"Blur",no_graphicseffect);
- qmlRegisterTypeNotAvailable("Qt",4,7,"Colorize",no_graphicseffect);
- qmlRegisterTypeNotAvailable("Qt",4,7,"DropShadow",no_graphicseffect);
- qmlRegisterTypeNotAvailable("Qt",4,7,"Opacity",no_graphicseffect);
-#else
- qmlRegisterType<QGraphicsEffect>();
- qmlRegisterType<QGraphicsBlurEffect>("Qt",4,7,"Blur");
- qmlRegisterType<QGraphicsColorizeEffect>("Qt",4,7,"Colorize");
- qmlRegisterType<QGraphicsDropShadowEffect>("Qt",4,7,"DropShadow");
- qmlRegisterType<QGraphicsOpacityEffect>("Qt",4,7,"Opacity");
-#endif
qmlRegisterUncreatableType<QDeclarativeKeyNavigationAttached>("Qt",4,7,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
qmlRegisterUncreatableType<QDeclarativeKeysAttached>("Qt",4,7,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties"));
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index edafe59..1727687 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -2809,25 +2809,6 @@ bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeParser::Object *from)
return false;
}
-/*!
- Returns true if from can be assigned to a (QObject) property of type
- to.
-*/
-bool QDeclarativeCompiler::canCoerce(int to, int from)
-{
- const QMetaObject *toMo =
- QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(to);
- const QMetaObject *fromMo =
- QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(from);
-
- while (fromMo) {
- if (QDeclarativePropertyPrivate::equal(fromMo, toMo))
- return true;
- fromMo = fromMo->superClass();
- }
- return false;
-}
-
QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeParser::Object *from)
{
// ### Optimize
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index cdc514d..fefab7a 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -274,7 +274,6 @@ private:
static QDeclarativeType *toQmlType(QDeclarativeParser::Object *from);
bool canCoerce(int to, QDeclarativeParser::Object *from);
- bool canCoerce(int to, int from);
QStringList deferredProperties(QDeclarativeParser::Object *);
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 6d64f63..8eae120 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -767,6 +767,9 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex
*/
void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
{
+ if (!object)
+ return;
+
QDeclarativeData *ddata = QDeclarativeData::get(object, true);
if (!ddata)
return;
@@ -780,6 +783,9 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own
*/
QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object)
{
+ if (!object)
+ return CppOwnership;
+
QDeclarativeData *ddata = QDeclarativeData::get(object, false);
if (!ddata)
return CppOwnership;
@@ -980,7 +986,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
Q_ASSERT(context);
if(ctxt->argumentCount() != 1) {
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter"));
+ return ctxt->throwError("Qt.createComponent(): Invalid arguments");
}else{
QString arg = ctxt->argument(0).toString();
if (arg.isEmpty())
@@ -1000,7 +1006,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 2 or 3 parameters"));
+ return ctxt->throwError("Qt.createQmlObject(): Invalid arguments");
QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
Q_ASSERT(context);
@@ -1020,7 +1026,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
if(!parentArg)
- return ctxt->throwError(QDeclarativeEngine::tr("parent object not found"));
+ return ctxt->throwError("Qt.createQmlObject(): Missing parent object");
QDeclarativeComponent component(activeEngine);
component.setData(qml.toUtf8(), url);
@@ -1045,7 +1051,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
}
if (!component.isReady())
- return ctxt->throwError(QDeclarativeEngine::tr("Qt.createQmlObject(): component is not ready"));
+ return ctxt->throwError("Qt.createQmlObject(): Component is not ready");
QObject *obj = component.create(context->asQDeclarativeContext());
@@ -1091,7 +1097,7 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript
QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 3)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 3 parameters"));
+ return ctxt->throwError("Qt.vector(): Invalid arguments");
qsreal x = ctxt->argument(0).toNumber();
qsreal y = ctxt->argument(1).toNumber();
qsreal z = ctxt->argument(2).toNumber();
@@ -1102,7 +1108,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
{
int argCount = ctxt->argumentCount();
if(argCount == 0 || argCount > 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters"));
+ return ctxt->throwError("Qt.formatDate(): Invalid arguments");
QDate date = ctxt->argument(0).toDateTime().date();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
@@ -1112,8 +1118,9 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
return engine->newVariant(qVariantFromValue(date.toString(format)));
} else if (ctxt->argument(1).isNumber()) {
enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
- } else
- return ctxt->throwError(QDeclarativeEngine::tr("invalid date format"));
+ } else {
+ return ctxt->throwError("Qt.formatDate(): Invalid date format");
+ }
}
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
@@ -1122,7 +1129,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
{
int argCount = ctxt->argumentCount();
if(argCount == 0 || argCount > 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters"));
+ return ctxt->throwError("Qt.formatTime(): Invalid arguments");
QTime date = ctxt->argument(0).toDateTime().time();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
@@ -1132,8 +1139,9 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
return engine->newVariant(qVariantFromValue(date.toString(format)));
} else if (ctxt->argument(1).isNumber()) {
enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
- } else
- return ctxt->throwError(QDeclarativeEngine::tr("invalid time format"));
+ } else {
+ return ctxt->throwError("Qt.formatTime(): Invalid time format");
+ }
}
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
@@ -1142,7 +1150,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
{
int argCount = ctxt->argumentCount();
if(argCount == 0 || argCount > 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters"));
+ return ctxt->throwError("Qt.formatDateTime(): Invalid arguments");
QDateTime date = ctxt->argument(0).toDateTime();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
@@ -1152,8 +1160,9 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
return engine->newVariant(qVariantFromValue(date.toString(format)));
} else if (ctxt->argument(1).isNumber()) {
enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
- } else
- return ctxt->throwError(QDeclarativeEngine::tr("invalid datetiem format"));
+ } else {
+ return ctxt->throwError("Qt.formatDateTime(): Invalid datetime formate");
+ }
}
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
@@ -1162,7 +1171,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine
{
int argCount = ctxt->argumentCount();
if(argCount < 3 || argCount > 4)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters"));
+ return ctxt->throwError("Qt.rgba(): Invalid arguments");
qsreal r = ctxt->argument(0).toNumber();
qsreal g = ctxt->argument(1).toNumber();
qsreal b = ctxt->argument(2).toNumber();
@@ -1184,7 +1193,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
{
int argCount = ctxt->argumentCount();
if(argCount < 3 || argCount > 4)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters"));
+ return ctxt->throwError("Qt.hsla(): Invalid arguments");
qsreal h = ctxt->argument(0).toNumber();
qsreal s = ctxt->argument(1).toNumber();
qsreal l = ctxt->argument(2).toNumber();
@@ -1205,7 +1214,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 4)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 4 parameters"));
+ return ctxt->throwError("Qt.rect(): Invalid arguments");
qsreal x = ctxt->argument(0).toNumber();
qsreal y = ctxt->argument(1).toNumber();
@@ -1221,7 +1230,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters"));
+ return ctxt->throwError("Qt.point(): Invalid arguments");
qsreal x = ctxt->argument(0).toNumber();
qsreal y = ctxt->argument(1).toNumber();
return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y)));
@@ -1230,7 +1239,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin
QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters"));
+ return ctxt->throwError("Qt.size(): Invalid arguments");
qsreal w = ctxt->argument(0).toNumber();
qsreal h = ctxt->argument(1).toNumber();
return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h)));
@@ -1239,7 +1248,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine
QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 1)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter"));
+ return ctxt->throwError("Qt.lighter(): Invalid arguments");
QVariant v = ctxt->argument(0).toVariant();
QColor color;
if (v.userType() == QVariant::Color)
@@ -1258,7 +1267,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng
QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 1)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter"));
+ return ctxt->throwError("Qt.darker(): Invalid arguments");
QVariant v = ctxt->argument(0).toVariant();
QColor color;
if (v.userType() == QVariant::Color)
@@ -1277,21 +1286,20 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() < 1)
- return e->newVariant(QVariant(false));
+ return QScriptValue(e, false);
bool ret = false;
#ifndef QT_NO_DESKTOPSERVICES
ret = QDesktopServices::openUrl(QUrl(ctxt->argument(0).toString()));
#endif
- return e->newVariant(QVariant(ret));
+ return QScriptValue(e, ret);
}
QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
{
- QByteArray data;
-
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
+ if (ctxt->argumentCount() != 1)
+ return ctxt->throwError("Qt.md5(): Invalid arguments");
+ QByteArray data = ctxt->argument(0).toString().toUtf8();
QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
return QScriptValue(QLatin1String(result.toHex()));
@@ -1299,20 +1307,20 @@ QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine
QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *)
{
- QByteArray data;
+ if (ctxt->argumentCount() != 1)
+ return ctxt->throwError("Qt.btoa(): Invalid arguments");
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
+ QByteArray data = ctxt->argument(0).toString().toUtf8();
return QScriptValue(QLatin1String(data.toBase64()));
}
QScriptValue QDeclarativeEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *)
{
- QByteArray data;
+ if (ctxt->argumentCount() != 1)
+ return ctxt->throwError("Qt.atob(): Invalid arguments");
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
+ QByteArray data = ctxt->argument(0).toString().toUtf8();
return QScriptValue(QLatin1String(QByteArray::fromBase64(data)));
}
@@ -1411,7 +1419,7 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE
QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
- return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters"));
+ return ctxt->throwError("Qt.tint(): Invalid arguments");
//get color
QVariant v = ctxt->argument(0).toVariant();
QColor color;
@@ -1730,7 +1738,7 @@ public:
found = QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin);
if (!found) {
if (errorString) {
- bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), 0, 0);
+ bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1);
if (anyversion)
*errorString = QDeclarativeEngine::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin);
else
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index 8fee8a7..d9ea8dc 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -99,8 +99,12 @@ struct QDeclarativeMetaTypeData
StringConverters stringConverters;
struct ModuleInfo {
- ModuleInfo(int maj, int min) : vmajor(maj), vminor(min) {}
- int vmajor, vminor;
+ ModuleInfo(int major, int minor)
+ : vmajor_min(major), vminor_min(minor), vmajor_max(major), vminor_max(minor) {}
+ ModuleInfo(int major_min, int minor_min, int major_max, int minor_max)
+ : vmajor_min(major_min), vminor_min(minor_min), vmajor_max(major_max), vminor_max(minor_max) {}
+ int vmajor_min, vminor_min;
+ int vmajor_max, vminor_max;
};
typedef QHash<QByteArray, ModuleInfo> ModuleInfoHash;
ModuleInfoHash modules;
@@ -544,9 +548,15 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
if (type.uri) {
QByteArray mod(type.uri);
QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(mod);
- if (it == data->modules.end()
- || ((*it).vmajor < type.versionMajor || ((*it).vmajor == type.versionMajor && (*it).vminor < type.versionMinor))) {
+ if (it == data->modules.end()) {
+ // New module
data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor,type.versionMinor));
+ } else if ((*it).vmajor_max < type.versionMajor || ((*it).vmajor_max == type.versionMajor && (*it).vminor_max < type.versionMinor)) {
+ // Newer module
+ data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor_min, (*it).vminor_min, type.versionMajor, type.versionMinor));
+ } else if ((*it).vmajor_min > type.versionMajor || ((*it).vmajor_min == type.versionMajor && (*it).vminor_min > type.versionMinor)) {
+ // Older module
+ data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor, type.versionMinor, (*it).vmajor_min, (*it).vminor_min));
}
}
@@ -554,15 +564,23 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
}
/*
- Have any types been registered for \a module with at least versionMajor.versionMinor.
+ Have any types been registered for \a module with at least versionMajor.versionMinor, and types
+ for \a module with at most versionMajor.versionMinor.
+
+ So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
+
+ Passing -1 for both \a versionMajor \a versionMinor will return true if any version is installed.
*/
bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, int versionMinor)
{
QDeclarativeMetaTypeData *data = metaTypeData();
QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(module);
return it != data->modules.end()
- && ((*it).vmajor > versionMajor ||
- ((*it).vmajor == versionMajor && (*it).vminor >= versionMinor));
+ && ((versionMajor<0 && versionMinor<0) ||
+ (((*it).vmajor_max > versionMajor ||
+ ((*it).vmajor_max == versionMajor && (*it).vminor_max >= versionMinor))
+ && ((*it).vmajor_min < versionMajor ||
+ ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor))));
}
QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok)
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 27f37df..4f7719b 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -1674,7 +1674,7 @@ void QDeclarativePropertyAnimationPrivate::init()
/*!
\qmlproperty int PropertyAnimation::duration
- This property holds the duration of the transition, in milliseconds.
+ This property holds the duration of the animation, in milliseconds.
The default value is 250.
*/
@@ -2690,6 +2690,67 @@ QDeclarativeListProperty<QDeclarativeItem> QDeclarativeAnchorAnimation::targets(
return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets);
}
+/*!
+ \qmlproperty int AnchorAnimation::duration
+ This property holds the duration of the animation, in milliseconds.
+
+ The default value is 250.
+*/
+int QDeclarativeAnchorAnimation::duration() const
+{
+ Q_D(const QDeclarativeAnchorAnimation);
+ return d->va->duration();
+}
+
+void QDeclarativeAnchorAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QDeclarativeAnchorAnimation);
+ if (d->va->duration() == duration)
+ return;
+ d->va->setDuration(duration);
+ emit durationChanged(duration);
+}
+
+/*!
+ \qmlproperty enumeration AnchorAnimation::easing.type
+ \qmlproperty real AnchorAnimation::easing.amplitude
+ \qmlproperty real AnchorAnimation::easing.overshoot
+ \qmlproperty real AnchorAnimation::easing.period
+ \brief the easing curve used for the animation.
+
+ To specify an easing curve you need to specify at least the type. For some curves you can also specify
+ amplitude, period and/or overshoot. The default easing curve is
+ Linear.
+
+ \qml
+ AnchorAnimation { easing.type: "InOutQuad" }
+ \endqml
+
+ See the \l{PropertyAnimation::easing.type} documentation for information
+ about the different types of easing curves.
+*/
+
+QEasingCurve QDeclarativeAnchorAnimation::easing() const
+{
+ Q_D(const QDeclarativeAnchorAnimation);
+ return d->va->easingCurve();
+}
+
+void QDeclarativeAnchorAnimation::setEasing(const QEasingCurve &e)
+{
+ Q_D(QDeclarativeAnchorAnimation);
+ if (d->va->easingCurve() == e)
+ return;
+
+ d->va->setEasingCurve(e);
+ emit easingChanged(e);
+}
+
void QDeclarativeAnchorAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeProperties &modified,
TransitionDirection direction)
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index c839c2c..40c893c 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -475,6 +475,8 @@ class QDeclarativeAnchorAnimation : public QDeclarativeAbstractAnimation
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeAnchorAnimation)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> targets READ targets)
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
public:
QDeclarativeAnchorAnimation(QObject *parent=0);
@@ -482,6 +484,16 @@ public:
QDeclarativeListProperty<QDeclarativeItem> targets();
+ int duration() const;
+ void setDuration(int);
+
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
+
+Q_SIGNALS:
+ void durationChanged(int);
+ void easingChanged(const QEasingCurve&);
+
protected:
virtual void transition(QDeclarativeStateActions &actions,
QDeclarativeProperties &modified,
diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp
index c8161a7..919727f 100644
--- a/src/declarative/util/qdeclarativepropertymap.cpp
+++ b/src/declarative/util/qdeclarativepropertymap.cpp
@@ -265,7 +265,7 @@ QVariant &QDeclarativePropertyMap::operator[](const QString &key)
Same as value().
*/
-const QVariant QDeclarativePropertyMap::operator[](const QString &key) const
+QVariant QDeclarativePropertyMap::operator[](const QString &key) const
{
return value(key);
}
diff --git a/src/declarative/util/qdeclarativepropertymap.h b/src/declarative/util/qdeclarativepropertymap.h
index e0b7ce3..1b6594b 100644
--- a/src/declarative/util/qdeclarativepropertymap.h
+++ b/src/declarative/util/qdeclarativepropertymap.h
@@ -73,7 +73,7 @@ public:
bool contains(const QString &key) const;
QVariant &operator[](const QString &key);
- const QVariant operator[](const QString &key) const;
+ QVariant operator[](const QString &key) const;
Q_SIGNALS:
void valueChanged(const QString &key, const QVariant &value);
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
index 5d8a52d..ee320aa 100644
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -63,6 +63,8 @@ private slots:
void contextForObject();
void offlineStoragePath();
void clearComponentCache();
+ void outputWarningsToStandardError();
+ void objectOwnership();
};
void tst_qdeclarativeengine::rootContext()
@@ -101,6 +103,7 @@ void tst_qdeclarativeengine::networkAccessManager()
engine = new QDeclarativeEngine;
NetworkAccessManagerFactory factory;
engine->setNetworkAccessManagerFactory(&factory);
+ QVERIFY(engine->networkAccessManagerFactory() == &factory);
QVERIFY(engine->networkAccessManager() == factory.manager);
delete engine;
}
@@ -235,6 +238,89 @@ void tst_qdeclarativeengine::clearComponentCache()
}
}
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qdeclarativeengine::outputWarningsToStandardError()
+{
+ QDeclarativeEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ QDeclarativeComponent c(&engine);
+ c.setData("import Qt 4.7; QtObject { property int a: undefined }", QUrl());
+
+ QVERIFY(c.isReady() == true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QObject *o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 1);
+ QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
+ warnings.clear();
+
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+
+ old = qInstallMsgHandler(msgHandler);
+
+ o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 0);
+}
+
+void tst_qdeclarativeengine::objectOwnership()
+{
+ {
+ QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
+ QDeclarativeEngine::setObjectOwnership(0, QDeclarativeEngine::JavaScriptOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
+ }
+
+ {
+ QObject o;
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
+ QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
+ QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine);
+ c.setData("import Qt 4.7; QtObject { property QtObject object: QtObject {} }", QUrl());
+
+ QObject *o = c.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(QDeclarativeEngine::objectOwnership(o), QDeclarativeEngine::CppOwnership);
+
+ QObject *o2 = qvariant_cast<QObject *>(o->property("object"));
+ QCOMPARE(QDeclarativeEngine::objectOwnership(o2), QDeclarativeEngine::JavaScriptOwnership);
+
+ delete o;
+ }
+
+}
+
QTEST_MAIN(tst_qdeclarativeengine)
#include "tst_qdeclarativeengine.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt
new file mode 100644
index 0000000..dfa7a36
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt
@@ -0,0 +1 @@
+1:1:module "Test" version 0.1 is not installed
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml b/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml
new file mode 100644
index 0000000..18514b1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml
@@ -0,0 +1,3 @@
+import Test 0.1
+
+MyTypeObject { }
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index c1397de..c39e6f7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -277,6 +277,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false;
+ QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false;
QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false;
QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
diff --git a/tests/auto/declarative/qdeclarativeqt/data/atob.qml b/tests/auto/declarative/qdeclarativeqt/data/atob.qml
new file mode 100644
index 0000000..8355fa5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/atob.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+QtObject {
+ property string test1: Qt.atob()
+ property string test2: Qt.atob("SGVsbG8gd29ybGQh")
+}
+
diff --git a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml
new file mode 100644
index 0000000..c2993ff
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+QtObject {
+ property string test1: Qt.btoa()
+ property string test2: Qt.btoa("Hello world!")
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 727d74c..f5d5926 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -74,6 +74,8 @@ private slots:
void consoleLog();
void formatting();
void isQtObject();
+ void btoa();
+ void atob();
private:
QDeclarativeEngine engine;
@@ -102,8 +104,8 @@ void tst_qdeclarativeqt::rgba()
{
QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml"));
- QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters";
- QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters";
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -125,8 +127,8 @@ void tst_qdeclarativeqt::hsla()
{
QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml"));
- QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters";
- QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters";
+ QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -147,8 +149,8 @@ void tst_qdeclarativeqt::rect()
{
QDeclarativeComponent component(&engine, TEST_FILE("rect.qml"));
- QString warning1 = component.url().toString() + ":6: Error: expected 4 parameters";
- QString warning2 = component.url().toString() + ":7: Error: expected 4 parameters";
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -168,8 +170,8 @@ void tst_qdeclarativeqt::point()
{
QDeclarativeComponent component(&engine, TEST_FILE("point.qml"));
- QString warning1 = component.url().toString() + ":6: Error: expected 2 parameters";
- QString warning2 = component.url().toString() + ":7: Error: expected 2 parameters";
+ QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -188,8 +190,8 @@ void tst_qdeclarativeqt::size()
{
QDeclarativeComponent component(&engine, TEST_FILE("size.qml"));
- QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters";
- QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters";
+ QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -209,8 +211,8 @@ void tst_qdeclarativeqt::vector()
{
QDeclarativeComponent component(&engine, TEST_FILE("vector.qml"));
- QString warning1 = component.url().toString() + ":6: Error: expected 3 parameters";
- QString warning2 = component.url().toString() + ":7: Error: expected 3 parameters";
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -229,8 +231,8 @@ void tst_qdeclarativeqt::lighter()
{
QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
- QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter";
- QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter";
+ QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":6: Error: Qt.lighter(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -251,8 +253,8 @@ void tst_qdeclarativeqt::darker()
{
QDeclarativeComponent component(&engine, TEST_FILE("darker.qml"));
- QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter";
- QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter";
+ QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":6: Error: Qt.darker(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -273,8 +275,8 @@ void tst_qdeclarativeqt::tint()
{
QDeclarativeComponent component(&engine, TEST_FILE("tint.qml"));
- QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters";
- QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters";
+ QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -322,10 +324,13 @@ void tst_qdeclarativeqt::openUrlExternally()
void tst_qdeclarativeqt::md5()
{
QDeclarativeComponent component(&engine, TEST_FILE("md5.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
QObject *object = component.create();
QVERIFY(object != 0);
- QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex()));
QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
delete object;
@@ -335,8 +340,8 @@ void tst_qdeclarativeqt::createComponent()
{
QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml"));
- QString warning1 = component.url().toString() + ":9: Error: expected 1 parameter";
- QString warning2 = component.url().toString() + ":10: Error: expected 1 parameter";
+ QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -353,11 +358,11 @@ void tst_qdeclarativeqt::createQmlObject()
{
QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml"));
- QString warning1 = component.url().toString() + ":7: Error: expected 2 or 3 parameters";
+ QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n";
QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n";
- QString warning4 = component.url().toString()+ ":9: Error: parent object not found";
- QString warning5 = component.url().toString()+ ":8: Error: expected 2 or 3 parameters";
+ QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
+ QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
QString warning6 = "RunTimeError: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
@@ -433,6 +438,36 @@ void tst_qdeclarativeqt::isQtObject()
delete object;
}
+void tst_qdeclarativeqt::btoa()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("btoa.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh"));
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::atob()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("atob.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("Hello world!"));
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeqt)
#include "tst_qdeclarativeqt.moc"