summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-03 22:58:25 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-03 22:58:25 (GMT)
commit42b58d2b6971962c3117091c4727e71b22a41707 (patch)
treef7cc50d2b45d024ea1dda017c1952a8ef3d78df7
parent24c1173aac92e9a4e14da072b5aa62c8289d810d (diff)
parent5ac068602871b78eb4b58634d58e6b8898acbf8d (diff)
downloadQt-42b58d2b6971962c3117091c4727e71b22a41707.zip
Qt-42b58d2b6971962c3117091c4727e71b22a41707.tar.gz
Qt-42b58d2b6971962c3117091c4727e71b22a41707.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--doc/src/declarative/tutorial.qdoc6
-rw-r--r--examples/declarative/colorbrowser/colorbrowser.qml2
-rw-r--r--examples/declarative/colorbrowser/qml/ColorDelegate.qml2
-rw-r--r--examples/declarative/dynamic/qml/Sun.qml8
-rw-r--r--examples/declarative/imageprovider/imageprovider.qml2
-rw-r--r--examples/declarative/package/Delegate.qml2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp10
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp62
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp3
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp30
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp46
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp11
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp18
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp6
-rw-r--r--src/declarative/util/qdeclarativebind.cpp15
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp34
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp6
-rw-r--r--src/multimedia/base/qmediaserviceprovider.cpp14
-rw-r--r--src/multimedia/qml/qsoundeffect_qsound_p.cpp2
-rw-r--r--src/multimedia/qml/wavedecoder_p.cpp2
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp133
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h7
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp124
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/TestType.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro2
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp2
-rw-r--r--tests/auto/qmediaservice/tst_qmediaservice.cpp8
52 files changed, 527 insertions, 202 deletions
diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc
index 98efe12..310b776 100644
--- a/doc/src/declarative/tutorial.qdoc
+++ b/doc/src/declarative/tutorial.qdoc
@@ -173,10 +173,10 @@ In this case the rectangle will have the same size as its parent (see \l{anchor-
\snippet examples/declarative/tutorials/helloworld/Cell.qml 3
-In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with
+In order to change the color of the text when clicking on a cell, we create a \l MouseArea element with
the same size as its parent.
-A \l MouseRegion defines a signal called \e clicked.
+A \l MouseArea defines a signal called \e clicked.
When this signal is triggered we want to emit our own \e clicked signal with the color as parameter.
\section2 The main QML file
@@ -214,7 +214,7 @@ Here is the QML code:
\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2
First, we create a new \e down state for our text element.
-This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released.
+This state will be activated when the \l MouseArea is pressed, and deactivated when it is released.
The \e down state includes a set of property changes from our implicit \e {default state}
(the items as they were initially defined in the QML).
diff --git a/examples/declarative/colorbrowser/colorbrowser.qml b/examples/declarative/colorbrowser/colorbrowser.qml
index ebd49c6..421ae07 100644
--- a/examples/declarative/colorbrowser/colorbrowser.qml
+++ b/examples/declarative/colorbrowser/colorbrowser.qml
@@ -53,7 +53,7 @@ Rectangle {
Text { id: albumTitle; text: name; color: 'white'; font.bold: true; anchors.centerIn: parent }
}
- MouseRegion { anchors.fill: parent; onClicked: wrapper.state = 'inGrid' }
+ MouseArea { anchors.fill: parent; onClicked: wrapper.state = 'inGrid' }
states: [
State {
diff --git a/examples/declarative/colorbrowser/qml/ColorDelegate.qml b/examples/declarative/colorbrowser/qml/ColorDelegate.qml
index 605e45b..c123d12 100644
--- a/examples/declarative/colorbrowser/qml/ColorDelegate.qml
+++ b/examples/declarative/colorbrowser/qml/ColorDelegate.qml
@@ -27,7 +27,7 @@ Package {
value: hex; when: delegate.open && list.ListView.isCurrentItem
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton | Qt.LeftButton
onClicked: {
diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml
index 796a370..81b6e9b 100644
--- a/examples/declarative/dynamic/qml/Sun.qml
+++ b/examples/declarative/dynamic/qml/Sun.qml
@@ -11,14 +11,14 @@ Image {
//x and y get set when instantiated
//head offscreen
- y: NumberAnimation {
- to: parent.height;
- duration: 10000;
+ NumberAnimation on y {
+ to: window.height / 2;
running: created
+ onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen";
}
states: State {
- name: "OffScreen"; when: created && y > window.height / 2;//Below the ground
+ name: "OffScreen";
StateChangeScript { script: { sun.created = false; sun.destroy() } }
}
}
diff --git a/examples/declarative/imageprovider/imageprovider.qml b/examples/declarative/imageprovider/imageprovider.qml
index a1f2794..f899b1e 100644
--- a/examples/declarative/imageprovider/imageprovider.qml
+++ b/examples/declarative/imageprovider/imageprovider.qml
@@ -1,5 +1,5 @@
import Qt 4.6
-import ImageProviderCore 1.0
+import "ImageProviderCore"
//![0]
ListView {
width: 100
diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml
index 62198d0..f35314f 100644
--- a/examples/declarative/package/Delegate.qml
+++ b/examples/declarative/package/Delegate.qml
@@ -11,7 +11,7 @@ Package {
color: 'lightsteelblue'
Text { text: display; anchors.centerIn: parent }
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: {
if (wrapper.state == 'inList')
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 090c46d..5b313be 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -744,7 +744,7 @@ QDeclarativeGridView::~QDeclarativeGridView()
id: myDelegate
Item {
id: wrapper
- GridView.onRemove: SequentialAnimation {
+ SequentialAnimation on GridView.onRemove {
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
@@ -989,8 +989,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
id: myHighlight
Rectangle {
id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
- y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
- x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
+ SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
}
\endcode
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index a05e638..eb5315d 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1431,7 +1431,7 @@ QDeclarativeListView::~QDeclarativeListView()
id: myDelegate
Item {
id: wrapper
- ListView.onRemove: SequentialAnimation {
+ SequentialAnimation on ListView.onRemove {
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index a0aed46..55f1c89 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -144,7 +144,7 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
d->children_count, d->children_at);
}
@@ -483,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
QDeclarativeVisualDataModel *model)
-: m_index(index), m_model(model),
+: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
@@ -550,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
}
QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
-: QObject(parent), model(parent)
+: QObject(parent), model(parent)
{
new QDeclarativeVisualDataModelPartsMetaObject(this);
}
@@ -840,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Rectangle {
height: 25; width: 100
Text { text: path }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onClicked: myModel.setRoot(path)
}
@@ -969,7 +969,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
- if (!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QDeclarativeVisualDataModelParts(this);
return d->m_parts;
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index a9809c0..1eea012 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -65,6 +65,7 @@
#include "qdeclarativescriptparser_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qfxperf_p_p.h>
@@ -113,32 +114,6 @@ QList<QDeclarativeError> QDeclarativeCompiler::errors() const
}
/*!
- Returns true if \a val is a legal object id, false otherwise.
-
- Legal ids must start with a lower-case letter or underscore, and contain only
- letters, numbers and underscores.
-*/
-bool QDeclarativeCompiler::isValidId(const QString &val)
-{
- if (val.isEmpty())
- return false;
-
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
- return false;
- }
-
- QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
- if (val.at(ii) != u &&
- ((ii == 0 && !val.at(ii).isLetter()) ||
- (ii != 0 && !val.at(ii).isLetterOrNumber())) )
- return false;
-
- return true;
-}
-
-/*!
Returns true if \a name refers to an attached property, false otherwise.
Attached property names are those that start with a capital letter.
@@ -1140,10 +1115,11 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (obj->properties.count())
idProp = *obj->properties.begin();
- if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
-
if (idProp) {
+ if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
@@ -1726,8 +1702,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
QDeclarativeParser::Value *idValue = prop->values.at(0);
QString val = idValue->primitive();
- if (!isValidId(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val));
+ COMPILE_CHECK(checkValidId(idValue, val));
// We disallow id's that conflict with import prefixes and types
QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
@@ -2476,6 +2451,31 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
return true;
}
+bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val)
+{
+ if (val.isEmpty())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "Invalid empty ID"));
+
+ if (val.at(0).isLetter() && !val.at(0).isLower())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs cannot start with an uppercase letter"));
+
+ QChar u(QLatin1Char('_'));
+ for (int ii = 0; ii < val.count(); ++ii) {
+
+ if (ii == 0 && !val.at(ii).isLetter() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must start with a letter or underscore"));
+ } else if (ii != 0 && !val.at(ii).isLetterOrNumber() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must contain only letters, numbers, and underscores"));
+ }
+
+ }
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(val))
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "ID illegally masks global JavaScript property"));
+
+ return true;
+}
+
#include <qdeclarativejsparser_p.h>
static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 93a3f83..f8ada95 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -155,7 +155,6 @@ public:
bool isError() const;
QList<QDeclarativeError> errors() const;
- static bool isValidId(const QString &);
static bool isAttachedPropertyName(const QByteArray &);
static bool isSignalPropertyName(const QByteArray &);
@@ -247,6 +246,7 @@ private:
QDeclarativeParser::Object *obj,
const QDeclarativeParser::Object::DynamicProperty &);
bool completeComponentBuild();
+ bool checkValidId(QDeclarativeParser::Value *, const QString &);
void genObject(QDeclarativeParser::Object *obj);
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 57ef90c..35e7a77 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativeengine.h"
#include "qdeclarativecompiledbindings_p.h"
#include "qdeclarativeinfo.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qscriptengine.h>
#include <QtCore/qvarlengtharray.h>
@@ -74,7 +75,9 @@ void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::Scr
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
scriptContext->setActivationObject(scope);
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 7deed0b..d6305d8 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -50,10 +50,11 @@
QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ ContextData() : overrideObject(0), isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
QDeclarativeGuard<QDeclarativeContext> context;
QDeclarativeGuard<QObject> scopeObject;
+ QObject *overrideObject;
bool isSharedContext;
QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
@@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr
return data->getContext(engine);
}
+QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ QObject *rv = data->overrideObject;
+ data->overrideObject = override;
+ return rv;
+}
+
QScriptClass::QueryFlags
QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
@@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &
if (!bindContext)
return 0;
+ QObject *overrideObject = ((ContextData *)object)->overrideObject;
+ if (overrideObject) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(overrideObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject |
+ QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = overrideObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
bool includeTypes = true;
while (bindContext) {
QScriptClass::QueryFlags rv =
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
index 26086ec..4b0dca0 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -70,6 +70,7 @@ public:
QScriptValue newSharedContext();
QDeclarativeContext *contextFromValue(const QScriptValue &);
+ QObject *setOverrideObject(QScriptValue &, QObject *);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index 5b43109..cb56ead 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -374,7 +374,7 @@ QDeclarativeDomValue QDeclarativeDomProperty::value() const
QDeclarativeDomValue rv;
if (d->property) {
rv.d->property = d->property;
- if (d->property->values.count())
+ if (d->property->values.count())
rv.d->value = d->property->values.at(0);
else
rv.d->value = d->property->onValues.at(0);
@@ -508,7 +508,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
{
- if (isValid())
+ if (isValid())
return d->property.customType;
return QByteArray();
@@ -1184,7 +1184,7 @@ QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1228,7 +1228,7 @@ QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::oper
returned.
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index ae1e790..e528e9e 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -46,6 +46,7 @@
#include "qdeclarativecontext_p.h"
#include "qdeclarativerewrite_p.h"
#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <QtCore/qdebug.h>
#include <QtScript/qscriptprogram.h>
@@ -135,6 +136,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
+ scriptContext->pushScope(ep->globalClass->globalObject());
dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
scriptEngine->popContext();
}
@@ -151,9 +153,11 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
new QScriptProgram(data->expression, data->url, data->line);
}
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
+ data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
+ &data->expressionContext);
#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
+ data->expressionFunction = evalInObjectScope(ctxt, me, data->expression,
+ &data->expressionContext);
#endif
data->expressionFunctionValid = true;
@@ -164,22 +168,34 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QString &program)
+ const QString &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QScriptProgram &program)
+ const QScriptProgram &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
@@ -326,15 +342,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeEngine *engine = data->context()->engine();
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- if (secondaryScope)
- ctxtPriv->defaultObjects.append(secondaryScope);
-
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
if (!data->expressionFunctionValid) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
+ data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
+ scriptContext->pushScope(data->expressionContext);
+ scriptContext->pushScope(ep->globalClass->globalObject());
if (data->expressionRewritten) {
data->expressionFunction = scriptEngine->evaluate(data->expression,
@@ -357,11 +372,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeContext *oldSharedContext = 0;
QObject *oldSharedScope = 0;
+ QObject *oldOverride = 0;
if (data->isShared) {
oldSharedContext = ep->sharedContext;
oldSharedScope = ep->sharedScope;
ep->sharedContext = data->context();
ep->sharedScope = data->me;
+ } else {
+ oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope);
}
QScriptValue svalue = data->expressionFunction.call();
@@ -369,6 +387,8 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
if (data->isShared) {
ep->sharedContext = oldSharedContext;
ep->sharedScope = oldSharedScope;
+ } else {
+ ep->contextClass->setOverrideObject(data->expressionContext, oldOverride);
}
if (isUndefined)
@@ -383,12 +403,6 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
data->error = QDeclarativeError();
}
- if (secondaryScope) {
- QObject *last = ctxtPriv->defaultObjects.takeLast();
- Q_ASSERT(last == secondaryScope);
- Q_UNUSED(last);
- }
-
QVariant rv;
if (svalue.isArray()) {
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 91ac4c0..cd1729d 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -119,6 +119,7 @@ public:
bool expressionFunctionValid:1;
bool expressionRewritten:1;
QScriptValue expressionFunction;
+ QScriptValue expressionContext;
QObject *me;
bool trackChange;
@@ -180,8 +181,8 @@ public:
virtual void emitValueChanged();
static void exceptionToError(QScriptEngine *, QDeclarativeError &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &, QScriptValue * = 0);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &, QScriptValue * = 0);
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 5b06b42..9ee2fe5 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE
QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine)
: QScriptClass(engine)
{
- QScriptValue v = engine->newObject();
- globalObject = engine->globalObject();
+ QScriptValue globalObject = engine->globalObject();
+ m_globalObject = engine->newObject();
QScriptValueIterator iter(globalObject);
while (iter.hasNext()) {
iter.next();
- v.setProperty(iter.scriptName(), iter.value());
+ m_globalObject.setProperty(iter.scriptName(), iter.value());
+ m_illegalNames.insert(iter.name());
}
+ QScriptValue v = engine->newObject();
v.setScriptClass(this);
engine->setGlobalObject(v);
}
@@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
engine()->currentContext()->throwError(error);
}
+/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
{
+ QScriptValue globalObject = engine()->globalObject();
+
QScriptValue v = engine()->newObject();
- globalObject = engine()->globalObject();
- QScriptValueIterator iter(globalObject);
+ QScriptValueIterator iter(v);
while (iter.hasNext()) {
iter.next();
v.setProperty(iter.scriptName(), iter.value());
@@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(name, value);
v.setScriptClass(this);
+
engine()->setGlobalObject(v);
}
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index a33cf5e..1b34aee 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -54,6 +54,7 @@
//
#include <QtScript/qscriptclass.h>
+#include <QtCore/qset.h>
QT_BEGIN_NAMESPACE
@@ -74,8 +75,12 @@ public:
void explicitSetProperty(const QString &, const QScriptValue &);
+ const QScriptValue &globalObject() const { return m_globalObject; }
+ const QSet<QString> &illegalNames() const { return m_illegalNames; }
+
private:
- QScriptValue globalObject;
+ QSet<QString> m_illegalNames;
+ QScriptValue m_globalObject;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index e1ec2cd..521c241 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -793,7 +793,7 @@ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDecla
QVariant QDeclarativePropertyPrivate::readValueProperty()
{
- if(isValueType()) {
+ if (isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -809,13 +809,20 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
if (!ep) delete valueType;
return rv;
- } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) {
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) {
QDeclarativeListProperty<QObject> prop;
void *args[] = { &prop, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(rv);
+
} else {
return object->metaObject()->property(core.coreIndex).read(object.data());
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 7f4f1c0..b14de19 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -110,7 +110,7 @@ QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstrac
\code
Rectangle {
width: 100; height: 100
- x: NumberAnimation {
+ NumberAnimation on x {
running: myMouse.pressed
from: 0; to: 100
}
@@ -310,7 +310,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
\code
Rectangle {
- rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
+ NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 }
}
\endcode
*/
@@ -412,7 +412,7 @@ void QDeclarativeAbstractAnimation::resume()
no further influence on property values. In this example animation
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
was stopped at time 250ms, the \c x property will have a value of 50.
@@ -450,7 +450,7 @@ void QDeclarativeAbstractAnimation::restart()
its end. In the following example,
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
calling \c stop() at time 250ms will result in the \c x property having
@@ -1292,7 +1292,7 @@ QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
Q_D(QDeclarativePropertyAnimation);
d->interpolatorType = QMetaType::QVector3D;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
+ d->defaultToInterpolatorType = true;
}
QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
@@ -1741,7 +1741,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Animate all changes to a rectangle's x property.
\qml
Rectangle {
- x: Behavior { PropertyAnimation {} }
+ Behavior on x { PropertyAnimation {} }
}
\endqml
\o As a property value source
@@ -1749,7 +1749,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Repeatedly animate the rectangle's x property.
\qml
Rectangle {
- x: SequentialAnimation {
+ SequentialAnimation on x {
repeat: true
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
@@ -2140,8 +2140,8 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
id: theRect
width: 100; height: 100
color: Qt.rgba(0,0,1)
- x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
- y: Behavior { NumberAnimation {} } //animate theRect's y property
+ NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property
+ Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
\row
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index 5352341..dea2c02 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -75,13 +75,13 @@ public:
Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
- In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
+ In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property:
\code
Rectangle {
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
+ y: 200 // initial value
+ Behavior on y {
NumberAnimation {
easing: "easeOutBounce(amplitude:100)"
duration: 200
diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp
index e95a03e..26baa38 100644
--- a/src/declarative/util/qdeclarativebind.cpp
+++ b/src/declarative/util/qdeclarativebind.cpp
@@ -72,7 +72,7 @@ public:
/*!
\qmlclass Binding QDeclarativeBind
- \since 4.7
+ \since 4.7
\brief The Binding element allows arbitrary property bindings to be created.
Sometimes it is necessary to bind to a property of an object that wasn't
@@ -114,6 +114,19 @@ QDeclarativeBind::~QDeclarativeBind()
{
}
+/*!
+ \qmlproperty bool Binding::when
+
+ This property holds when the binding is active.
+ This should be set to an expression that evaluates to true when you want the binding to be active.
+
+ \code
+ Binding {
+ target: contactName; property: 'text'
+ value: name; when: list.ListView.isCurrentItem
+ }
+ \endcode
+*/
bool QDeclarativeBind::when() const
{
Q_D(const QDeclarativeBind);
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
index 3fa9866..ee181dd 100644
--- a/src/declarative/util/qdeclarativeeasefollow.cpp
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -59,10 +59,10 @@ class QDeclarativeEaseFollowPrivate : public QObjectPrivate
public:
QDeclarativeEaseFollowPrivate()
: source(0), velocity(200), duration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
+ reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
- {}
+ {}
qreal source;
qreal velocity;
@@ -173,7 +173,7 @@ bool QDeclarativeEaseFollowPrivate::recalc()
}
/*
- qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
+ qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
<< vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
*/
return true;
@@ -254,19 +254,19 @@ void QDeclarativeEaseFollowPrivate::tick(int t)
\since 4.7
\brief The EaseFollow element allows a property to smoothly track a value.
- The EaseFollow smoothly animates a property's value to a set target value
+ The EaseFollow smoothly animates a property's value to a set target value
using an ease in/out quad easing curve. If the target value changes while
- the animation is in progress, the easing curves used to animate to the old
+ the animation is in progress, the easing curves used to animate to the old
and the new target values are spliced together to avoid any obvious visual
glitches.
The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
+ animation should occur, or the duration that the animation should take.
If both a velocity and a duration are specified, the one that results in
the quickest animation is chosen for each change in the target value.
For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
take 4 seconds with both a velocity of 200 and a duration of 8000 set.
Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
will take 8 seconds with a duration of 8000 set, and will take 8 seconds
@@ -283,8 +283,8 @@ Rectangle {
color: "green"
width: 60; height: 60;
x: -5; y: -5;
- x: EaseFollow { source: rect1.x - 5; velocity: 200 }
- y: EaseFollow { source: rect1.y - 5; velocity: 200 }
+ EaseFollow on x { source: rect1.x - 5; velocity: 200 }
+ EaseFollow on y { source: rect1.y - 5; velocity: 200 }
}
Rectangle {
@@ -338,8 +338,8 @@ qreal QDeclarativeEaseFollow::sourceValue() const
Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c Immediate, the
- animation will immediately begin accelerating in the reverse direction,
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
begining with a velocity of 0. If the reversing mode is \c Sync, the
property is immediately set to the target value.
*/
@@ -373,7 +373,7 @@ void QDeclarativeEaseFollowPrivate::restart()
return;
}
- bool hasReversed = trackVelocity != 0. &&
+ bool hasReversed = trackVelocity != 0. &&
((trackVelocity > 0) == ((initialValue - source) > 0));
if (hasReversed) {
@@ -440,7 +440,7 @@ void QDeclarativeEaseFollow::setDuration(qreal v)
d->duration = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit durationChanged();
@@ -470,7 +470,7 @@ void QDeclarativeEaseFollow::setVelocity(qreal v)
d->velocity = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit velocityChanged();
@@ -511,8 +511,8 @@ void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t)
\qmlproperty qreal EaseFollow::maximumEasingTime
This property specifies the maximum time an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
+Setting this property causes the velocity to "level out" after at a time. Setting
+a negative value reverts to the normal mode of easing over the entire animation
duration.
The default value is -1.
@@ -528,7 +528,7 @@ void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v)
Q_D(QDeclarativeEaseFollow);
d->maximumEasingTime = v;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit maximumEasingTimeChanged();
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 6205ab9..1d69dd3 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -222,8 +222,8 @@ void QDeclarativeSpringFollowPrivate::stop()
id: rect1
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: SequentialAnimation {
+ y: 200 // initial value
+ SequentialAnimation on y {
running: true
repeat: true
NumberAnimation {
@@ -239,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop()
x: rect1.width
width: 20; height: 20
color: "#ff0000"
- y: SpringFollow { source: rect1.y; velocity: 200 }
+ SpringFollow on y { source: rect1.y; velocity: 200 }
}
\endcode
diff --git a/src/multimedia/base/qmediaserviceprovider.cpp b/src/multimedia/base/qmediaserviceprovider.cpp
index eb6505c..d51d682 100644
--- a/src/multimedia/base/qmediaserviceprovider.cpp
+++ b/src/multimedia/base/qmediaserviceprovider.cpp
@@ -268,7 +268,7 @@ class QPluginServiceProvider : public QMediaServiceProvider
public:
QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint)
{
- QString key(type);
+ QString key(QString::fromLatin1(type.constData(),type.length()));
QList<QMediaServiceProviderPlugin *>plugins;
foreach (QObject *obj, loader()->instances(key)) {
@@ -383,7 +383,8 @@ public:
const QStringList& codecs,
int flags) const
{
- QList<QObject*> instances = loader()->instances(serviceType);
+ QList<QObject*> instances = loader()->instances(
+ QString::fromLatin1(serviceType.constData(),serviceType.length()));
if (instances.isEmpty())
return QtMultimedia::NotSupported;
@@ -424,7 +425,8 @@ public:
QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const
{
- QList<QObject*> instances = loader()->instances(serviceType);
+ QList<QObject*> instances = loader()->instances(
+ QString::fromLatin1(serviceType.constData(),serviceType.length()));
QStringList supportedTypes;
@@ -457,7 +459,8 @@ public:
{
QList<QByteArray> res;
- foreach(QObject *obj, loader()->instances(serviceType)) {
+ foreach(QObject *obj, loader()->instances(
+ QString::fromLatin1(serviceType.constData(),serviceType.length()))) {
QMediaServiceSupportedDevicesInterface *iface =
qobject_cast<QMediaServiceSupportedDevicesInterface*>(obj);
@@ -471,7 +474,8 @@ public:
QString deviceDescription(const QByteArray &serviceType, const QByteArray &device)
{
- foreach(QObject *obj, loader()->instances(serviceType)) {
+ foreach(QObject *obj, loader()->instances(
+ QString::fromLatin1(serviceType.constData(),serviceType.length()))) {
QMediaServiceSupportedDevicesInterface *iface =
qobject_cast<QMediaServiceSupportedDevicesInterface*>(obj);
diff --git a/src/multimedia/qml/qsoundeffect_qsound_p.cpp b/src/multimedia/qml/qsoundeffect_qsound_p.cpp
index 0292d26..df160a9 100644
--- a/src/multimedia/qml/qsoundeffect_qsound_p.cpp
+++ b/src/multimedia/qml/qsoundeffect_qsound_p.cpp
@@ -157,7 +157,7 @@ void QSoundEffectPrivate::setMedia(const QMediaContent &media)
{
m_queued = false;
- if (media.isNull() || media.canonicalUrl().scheme() != "file") {
+ if (media.isNull() || media.canonicalUrl().scheme() != QLatin1String("file")) {
m_media = QMediaContent();
return;
}
diff --git a/src/multimedia/qml/wavedecoder_p.cpp b/src/multimedia/qml/wavedecoder_p.cpp
index b7d6101..f2277ae 100644
--- a/src/multimedia/qml/wavedecoder_p.cpp
+++ b/src/multimedia/qml/wavedecoder_p.cpp
@@ -122,7 +122,7 @@ void WaveDecoder::handleData()
else {
int bps = qFromLittleEndian<quint16>(header.wave.bitsPerSample);
- format.setCodec("audio/pcm");
+ format.setCodec(QLatin1String("audio/pcm"));
format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setFrequency(qFromLittleEndian<quint32>(header.wave.sampleRate));
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
index 2d7aaa8..e646693 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
@@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE
QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent)
: QMediaPlayerControl(parent)
, m_session(session)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_mediaStatus(QMediaPlayer::NoMedia)
+ , m_bufferProgress(-1)
, m_stream(0)
, m_fifoNotifier(0)
, m_fifoCanWrite(false)
@@ -77,11 +80,11 @@ QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *sessio
connect(m_session, SIGNAL(volumeChanged(int)),
this, SIGNAL(volumeChanged(int)));
connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
- this, SIGNAL(stateChanged(QMediaPlayer::State)));
- connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
- this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
+ this, SLOT(updateState(QMediaPlayer::State)));
connect(m_session,SIGNAL(bufferingProgressChanged(int)),
- this, SIGNAL(bufferStatusChanged(int)));
+ this, SLOT(setBufferProgress(int)));
+ connect(m_session, SIGNAL(playbackFinished()),
+ this, SLOT(processEOS()));
connect(m_session, SIGNAL(audioAvailableChanged(bool)),
this, SIGNAL(audioAvailableChanged(bool)));
connect(m_session, SIGNAL(videoAvailableChanged(bool)),
@@ -114,17 +117,20 @@ qint64 QGstreamerPlayerControl::duration() const
QMediaPlayer::State QGstreamerPlayerControl::state() const
{
- return m_session->state();
+ return m_state;
}
QMediaPlayer::MediaStatus QGstreamerPlayerControl::mediaStatus() const
{
- return m_session->mediaStatus();
+ return m_mediaStatus;
}
int QGstreamerPlayerControl::bufferStatus() const
{
- return 100;
+ if (m_bufferProgress == -1) {
+ return m_session->state() == QMediaPlayer::StoppedState ? 0 : 100;
+ } else
+ return m_bufferProgress;
}
int QGstreamerPlayerControl::volume() const
@@ -169,23 +175,33 @@ void QGstreamerPlayerControl::setPosition(qint64 pos)
void QGstreamerPlayerControl::play()
{
- m_session->play();
-
- if (m_fifoFd[1] >= 0) {
- m_fifoCanWrite = true;
-
- writeFifo();
+ if (m_session->play()) {
+ if (m_state != QMediaPlayer::PlayingState)
+ emit stateChanged(m_state = QMediaPlayer::PlayingState);
}
}
void QGstreamerPlayerControl::pause()
{
- m_session->pause();
+ if (m_session->pause()) {
+ if (m_state != QMediaPlayer::PausedState)
+ emit stateChanged(m_state = QMediaPlayer::PausedState);
+ }
}
void QGstreamerPlayerControl::stop()
{
- m_session->stop();
+ if (m_state != QMediaPlayer::StoppedState) {
+ m_session->pause();
+ if (!m_session->seek(0)) {
+ m_bufferProgress = -1;
+ m_session->stop();
+ m_session->pause();
+ }
+ emit positionChanged(0);
+ if (m_state != QMediaPlayer::StoppedState)
+ emit stateChanged(m_state = QMediaPlayer::StoppedState);
+ }
}
void QGstreamerPlayerControl::setVolume(int volume)
@@ -210,8 +226,15 @@ const QIODevice *QGstreamerPlayerControl::mediaStream() const
void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice *stream)
{
+ QMediaPlayer::State oldState = m_state;
+ m_state = QMediaPlayer::StoppedState;
m_session->stop();
+ if (m_bufferProgress != -1) {
+ m_bufferProgress = -1;
+ emit bufferStatusChanged(0);
+ }
+
if (m_stream) {
closeFifo();
@@ -234,7 +257,25 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice *
m_session->load(url);
+ if (m_fifoFd[1] >= 0) {
+ m_fifoCanWrite = true;
+
+ writeFifo();
+ }
+
+ if (!url.isEmpty()) {
+ if (m_mediaStatus != QMediaPlayer::LoadingMedia)
+ emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::LoadingMedia);
+ m_session->pause();
+ } else {
+ if (m_mediaStatus != QMediaPlayer::NoMedia)
+ emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::NoMedia);
+ setBufferProgress(0);
+ }
+
emit mediaChanged(m_currentResource);
+ if (m_state != oldState)
+ emit stateChanged(m_state);
}
void QGstreamerPlayerControl::setVideoOutput(QObject *output)
@@ -252,6 +293,68 @@ bool QGstreamerPlayerControl::isVideoAvailable() const
return m_session->isVideoAvailable();
}
+void QGstreamerPlayerControl::updateState(QMediaPlayer::State state)
+{
+ QMediaPlayer::MediaStatus oldStatus = m_mediaStatus;
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ if (m_state != QMediaPlayer::StoppedState)
+ emit stateChanged(m_state = QMediaPlayer::StoppedState);
+ break;
+
+ case QMediaPlayer::PlayingState:
+ case QMediaPlayer::PausedState:
+ if (m_state == QMediaPlayer::StoppedState)
+ m_mediaStatus = QMediaPlayer::LoadedMedia;
+ else {
+ if (m_bufferProgress == -1)
+ m_mediaStatus = QMediaPlayer::BufferedMedia;
+ }
+ break;
+ }
+
+ if (m_mediaStatus != oldStatus)
+ emit mediaStatusChanged(m_mediaStatus);
+}
+
+void QGstreamerPlayerControl::processEOS()
+{
+ m_mediaStatus = QMediaPlayer::EndOfMedia;
+ m_state = QMediaPlayer::StoppedState;
+
+ emit stateChanged(m_state);
+ emit mediaStatusChanged(m_mediaStatus);
+}
+
+void QGstreamerPlayerControl::setBufferProgress(int progress)
+{
+ if (m_bufferProgress == progress || m_mediaStatus == QMediaPlayer::NoMedia)
+ return;
+
+ QMediaPlayer::MediaStatus oldStatus = m_mediaStatus;
+
+ m_bufferProgress = progress;
+
+ if (m_state == QMediaPlayer::StoppedState) {
+ m_mediaStatus = QMediaPlayer::LoadedMedia;
+ } else {
+ if (m_bufferProgress < 100) {
+ m_mediaStatus = QMediaPlayer::StalledMedia;
+ m_session->pause();
+ } else {
+ m_mediaStatus = QMediaPlayer::BufferedMedia;
+ if (m_state == QMediaPlayer::PlayingState)
+ m_session->play();
+ }
+ }
+
+ if (m_mediaStatus != oldStatus)
+ emit mediaStatusChanged(m_mediaStatus);
+
+ emit bufferStatusChanged(m_bufferProgress);
+}
+
void QGstreamerPlayerControl::writeFifo()
{
if (m_fifoCanWrite) {
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h
index ae0f8b6..0c53945 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h
@@ -107,11 +107,18 @@ private Q_SLOTS:
void writeFifo();
void fifoReadyWrite(int socket);
+ void updateState(QMediaPlayer::State);
+ void processEOS();
+ void setBufferProgress(int progress);
+
private:
bool openFifo();
void closeFifo();
QGstreamerPlayerSession *m_session;
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_mediaStatus;
+ int m_bufferProgress;
QMediaContent m_currentResource;
QIODevice *m_stream;
QSocketNotifier *m_fifoNotifier;
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
index 600621e..392a7a8 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
@@ -57,7 +57,6 @@ QT_BEGIN_NAMESPACE
QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
:QObject(parent),
m_state(QMediaPlayer::StoppedState),
- m_mediaStatus(QMediaPlayer::UnknownMediaStatus),
m_busHelper(0),
m_playbin(0),
m_nullVideoOutput(0),
@@ -92,6 +91,7 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
m_busHelper->installSyncEventFilter(this);
m_nullVideoOutput = gst_element_factory_make("fakesink", NULL);
+ gst_object_ref(GST_OBJECT(m_nullVideoOutput));
g_object_set(G_OBJECT(m_playbin), "video-sink", m_nullVideoOutput, NULL);
// Initial volume
@@ -109,12 +109,14 @@ QGstreamerPlayerSession::~QGstreamerPlayerSession()
delete m_busHelper;
gst_object_unref(GST_OBJECT(m_bus));
gst_object_unref(GST_OBJECT(m_playbin));
+ gst_object_unref(GST_OBJECT(m_nullVideoOutput));
}
}
void QGstreamerPlayerSession::load(const QUrl &url)
{
m_url = url;
+
if (m_playbin) {
m_tags.clear();
emit tagsChanged();
@@ -259,26 +261,36 @@ bool QGstreamerPlayerSession::isSeekable() const
return m_seekable;
}
-void QGstreamerPlayerSession::play()
+bool QGstreamerPlayerSession::play()
{
if (m_playbin) {
if (gst_element_set_state(m_playbin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
qWarning() << "GStreamer; Unable to play -" << m_url.toString();
- m_state = QMediaPlayer::StoppedState;
- m_mediaStatus = QMediaPlayer::InvalidMedia;
+ m_state = QMediaPlayer::StoppedState;
emit stateChanged(m_state);
- emit mediaStatusChanged(m_mediaStatus);
-
emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path()));
- }
+ } else
+ return true;
}
+
+ return false;
}
-void QGstreamerPlayerSession::pause()
+bool QGstreamerPlayerSession::pause()
{
- if (m_playbin)
- gst_element_set_state(m_playbin, GST_STATE_PAUSED);
+ if (m_playbin) {
+ if (gst_element_set_state(m_playbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
+ qWarning() << "GStreamer; Unable to play -" << m_url.toString();
+ m_state = QMediaPlayer::StoppedState;
+
+ emit stateChanged(m_state);
+ emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path()));
+ } else
+ return true;
+ }
+
+ return false;
}
void QGstreamerPlayerSession::stop()
@@ -292,31 +304,45 @@ void QGstreamerPlayerSession::stop()
}
}
-void QGstreamerPlayerSession::seek(qint64 ms)
+bool QGstreamerPlayerSession::seek(qint64 ms)
{
if (m_playbin && m_state != QMediaPlayer::StoppedState) {
gint64 position = (gint64)ms * 1000000;
- gst_element_seek_simple(m_playbin, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, position);
+ return gst_element_seek_simple(m_playbin, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, position);
}
+
+ return false;
}
void QGstreamerPlayerSession::setVolume(int volume)
{
- m_volume = volume;
- emit volumeChanged(m_volume);
+ if (m_volume != volume) {
+ m_volume = volume;
- if (!m_muted && m_playbin)
- g_object_set(G_OBJECT(m_playbin), "volume", m_volume/100.0, NULL);
+ if (m_playbin) {
+#ifndef USE_PLAYBIN2
+ if(!m_muted)
+#endif
+ g_object_set(G_OBJECT(m_playbin), "volume", m_volume/100.0, NULL);
+ }
+
+ emit volumeChanged(m_volume);
+ }
}
void QGstreamerPlayerSession::setMuted(bool muted)
{
- m_muted = muted;
-
- g_object_set(G_OBJECT(m_playbin), "volume", (m_muted ? 0 : m_volume/100.0), NULL);
+ if (m_muted != muted) {
+ m_muted = muted;
- emit mutedStateChanged(m_muted);
+#ifdef USE_PLAYBIN2
+ g_object_set(G_OBJECT(m_playbin), "mute", m_muted, NULL);
+#else
+ g_object_set(G_OBJECT(m_playbin), "volume", (m_muted ? 0 : m_volume/100.0), NULL);
+#endif
+ emit mutedStateChanged(m_muted);
+ }
}
static void addTagToMap(const GstTagList *list,
@@ -388,14 +414,6 @@ void QGstreamerPlayerSession::setSeekable(bool seekable)
}
}
-void QGstreamerPlayerSession::setMediaStatus(QMediaPlayer::MediaStatus status)
-{
- if (m_mediaStatus != status) {
- m_mediaStatus = status;
- emit mediaStatusChanged(status);
- }
-}
-
bool QGstreamerPlayerSession::processSyncMessage(const QGstreamerMessage &message)
{
GstMessage* gm = message.rawMessage();
@@ -440,9 +458,6 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_playbin)) {
switch (GST_MESSAGE_TYPE(gm)) {
- case GST_MESSAGE_DURATION:
- break;
-
case GST_MESSAGE_STATE_CHANGED:
{
GstState oldState;
@@ -462,24 +477,19 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
switch (newState) {
case GST_STATE_VOID_PENDING:
case GST_STATE_NULL:
- setMediaStatus(QMediaPlayer::UnknownMediaStatus);
setSeekable(false);
if (m_state != QMediaPlayer::StoppedState)
emit stateChanged(m_state = QMediaPlayer::StoppedState);
break;
case GST_STATE_READY:
- setMediaStatus(QMediaPlayer::LoadedMedia);
setSeekable(false);
if (m_state != QMediaPlayer::StoppedState)
emit stateChanged(m_state = QMediaPlayer::StoppedState);
break;
case GST_STATE_PAUSED:
- //don't emit state changes for intermediate states
- if (m_state != QMediaPlayer::PausedState && pending == GST_STATE_VOID_PENDING)
+ if (m_state != QMediaPlayer::PausedState)
emit stateChanged(m_state = QMediaPlayer::PausedState);
- setMediaStatus(QMediaPlayer::LoadedMedia);
-
//check for seekable
if (oldState == GST_STATE_READY) {
/*
@@ -513,17 +523,13 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
if (m_state != QMediaPlayer::PlayingState)
emit stateChanged(m_state = QMediaPlayer::PlayingState);
+
break;
}
}
break;
case GST_MESSAGE_EOS:
- if (m_state != QMediaPlayer::StoppedState)
- emit stateChanged(m_state = QMediaPlayer::StoppedState);
-
- setMediaStatus(QMediaPlayer::EndOfMedia);
-
emit playbackFinished();
break;
@@ -546,7 +552,11 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
case GST_MESSAGE_INFO:
break;
case GST_MESSAGE_BUFFERING:
- setMediaStatus(QMediaPlayer::BufferingMedia);
+ {
+ int progress = 0;
+ gst_message_parse_buffering(gm, &progress);
+ emit bufferingProgressChanged(progress);
+ }
break;
case GST_MESSAGE_STATE_DIRTY:
case GST_MESSAGE_STEP_DONE:
@@ -556,8 +566,32 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
case GST_MESSAGE_STRUCTURE_CHANGE:
case GST_MESSAGE_APPLICATION:
case GST_MESSAGE_ELEMENT:
+ break;
case GST_MESSAGE_SEGMENT_START:
+ {
+ const GstStructure *structure = gst_message_get_structure(gm);
+ qint64 position = g_value_get_int64(gst_structure_get_value(structure, "position"));
+ position /= 1000000;
+ m_lastPosition = position;
+ emit positionChanged(position);
+ }
+ break;
case GST_MESSAGE_SEGMENT_DONE:
+ break;
+ case GST_MESSAGE_DURATION:
+ {
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 duration = 0;
+
+ if (gst_element_query_duration(m_playbin, &format, &duration)) {
+ int newDuration = duration / 1000000;
+ if (m_duration != newDuration) {
+ m_duration = newDuration;
+ emit durationChanged(m_duration);
+ }
+ }
+ }
+ break;
case GST_MESSAGE_LATENCY:
#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 13)
case GST_MESSAGE_ASYNC_START:
@@ -604,7 +638,7 @@ void QGstreamerPlayerSession::getStreamsInfo()
haveAudio = audioStreamsCount > 0;
haveVideo = videoStreamsCount > 0;
- m_playbin2StreamOffset[QMediaStreamsControl::AudioStream] = 0;
+ /*m_playbin2StreamOffset[QMediaStreamsControl::AudioStream] = 0;
m_playbin2StreamOffset[QMediaStreamsControl::VideoStream] = audioStreamsCount;
m_playbin2StreamOffset[QMediaStreamsControl::SubPictureStream] = audioStreamsCount+videoStreamsCount;
@@ -648,7 +682,9 @@ void QGstreamerPlayerSession::getStreamsInfo()
}
m_streamProperties.append(streamProperties);
+
}
+ */
#else
enum {
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
index d650ec7..edfec5b 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
@@ -71,7 +71,6 @@ public:
QUrl url() const;
QMediaPlayer::State state() const { return m_state; }
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
qint64 duration() const;
qint64 position() const;
@@ -105,11 +104,11 @@ public:
public slots:
void load(const QUrl &url);
- void play();
- void pause();
+ bool play();
+ bool pause();
void stop();
- void seek(qint64 pos);
+ bool seek(qint64 pos);
void setVolume(int volume);
void setMuted(bool muted);
@@ -118,7 +117,6 @@ signals:
void durationChanged(qint64 duration);
void positionChanged(qint64 position);
void stateChanged(QMediaPlayer::State state);
- void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus);
void volumeChanged(int volume);
void mutedStateChanged(bool muted);
void audioAvailableChanged(bool audioAvailable);
@@ -137,11 +135,8 @@ private slots:
void setSeekable(bool);
private:
- void setMediaStatus(QMediaPlayer::MediaStatus);
-
QUrl m_url;
QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
QGstreamerBusHelper* m_busHelper;
GstElement* m_playbin;
GstElement* m_nullVideoOutput;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
new file mode 100644
index 0000000..4ad7f34
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+Item {
+ id: root
+
+ property int foo: 12
+ property int console: 11
+
+ property bool test1: foo == 12
+ property bool test2: console != 11
+ property bool test3: root.console == 11
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 85a3ef3..75ee7ce 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -729,6 +729,16 @@ void tst_qdeclarativeecmascript::scope()
QCOMPARE(object->property("test5").toInt(), 24);
QCOMPARE(object->property("test6").toInt(), 24);
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scope.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);
+ }
}
/*
@@ -1666,8 +1676,7 @@ void tst_qdeclarativeecmascript::scriptScope()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
emit object->argumentSignal(19, "Hello world!", 10.3);
- QEXPECT_FAIL("", "QTBUG-8641", Continue);
- QCOMPARE(object->property("result").toString(), QLatin1String("undefined"));
+ QCOMPARE(object->property("result").toString(), QString());
delete object;
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
index 56e3eeb..2c6b8bf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
@@ -1,2 +1,2 @@
-3:5:"" is not a valid object id
+3:9:Invalid empty ID
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
index 160e8b5..7251de1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
@@ -1 +1 @@
-3:5:"StartsWithUpperCase" is not a valid object id
+3:9:IDs cannot start with an uppercase letter
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt
new file mode 100644
index 0000000..e4fd1db
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt
@@ -0,0 +1 @@
+3:9:ID illegally masks global JavaScript property
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml
new file mode 100644
index 0000000..d4bc539
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+MyQmlObject {
+ id: gc
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt
new file mode 100644
index 0000000..b03ec6c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt
@@ -0,0 +1 @@
+3:9:IDs must contain only letters, numbers, and underscores
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml
new file mode 100644
index 0000000..1ea615c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+MyQmlObject {
+ id: hello.world
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt
new file mode 100644
index 0000000..c010e79
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt
@@ -0,0 +1 @@
+3:9:IDs must start with a letter or underscore
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml
new file mode 100644
index 0000000..57474b7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+MyQmlObject {
+ id: "3hello"
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
index 1ca678c..c010e79 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
@@ -1 +1 @@
-3:5:"1" is not a valid object id
+3:9:IDs must start with a letter or underscore
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index 08d6d96..df93dc8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -62,7 +62,10 @@ public:
MyInterface() : id(913) {}
int id;
};
+
+QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+QT_END_NAMESPACE
QML_DECLARE_INTERFACE(MyInterface);
struct MyCustomVariantType
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 870f3fe..5d480fa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -232,6 +232,9 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
+ QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false;
+ QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false;
+ QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false;
QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
@@ -327,9 +330,6 @@ void tst_qdeclarativelanguage::errors()
QFETCH(QString, errorFile);
QFETCH(bool, create);
- if (file == "invalidID.6.qml")
- QTest::ignoreMessage(QtWarningMsg, "id \"StartsWithUpperCase\" is invalid: ids cannot start with uppercase letters");
-
QDeclarativeComponent component(&engine, TEST_FILE(file));
if(create) {
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml
new file mode 100644
index 0000000..1dfb3e1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+QtObject {
+ property int a: 10
+}
+
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml
new file mode 100644
index 0000000..8085db2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+QtObject {
+ property TestType test
+
+ test: TestType {
+ property int b: 19
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
index 22e50cc..af1e1b6 100644
--- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
+++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
@@ -3,3 +3,5 @@ contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeproperty.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
index 0333d98..9b8a643 100644
--- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
+++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
@@ -46,6 +46,14 @@
#include <private/qguard_p.h>
#include <private/qdeclarativebinding_p.h>
#include <QtGui/QLineEdit>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename));
+}
class MyQmlObject : public QObject
{
@@ -181,6 +189,7 @@ class PropertyObject : public QObject
Q_PROPERTY(QUrl url READ url WRITE setUrl);
Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty);
Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+ Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject);
Q_CLASSINFO("DefaultProperty", "defaultProperty");
public:
@@ -202,6 +211,7 @@ public:
int propertyWithNotify() const { return m_propertyWithNotify; }
void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+ MyQmlObject *qmlObject() { return &m_qmlObject; }
signals:
void clicked();
void oddlyNamedNotifySignal();
@@ -211,6 +221,7 @@ private:
QRect m_rect;
QUrl m_url;
int m_propertyWithNotify;
+ MyQmlObject m_qmlObject;
};
QML_DECLARE_TYPE(PropertyObject);
@@ -953,6 +964,32 @@ void tst_qdeclarativeproperty::read()
QCOMPARE(p.read(), QVariant());
}
+ // Object property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "qmlObject");
+ QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
+ QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>());
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "test", &engine);
+
+ QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
+ QVERIFY(p.propertyType() != QMetaType::QObjectStar);
+
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
+ }
+
// Attached property
{
QDeclarativeComponent component(&engine);
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index dea88c4..b1935df 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -671,9 +671,9 @@ void tst_qdeclarativetextedit::delegateLoading()
QTRY_VERIFY(view->status()==QDeclarativeView::Error);
view->setFocus();
QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- //ErrorB should get a component which is ready but component.create() returns null
+ //A test should be added here with a component which is ready but component.create() returns null
//Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate
- //###This could be a case of overzealous defensive programming
+ //###This was only needed for code coverage, and could be a case of overzealous defensive programming
//delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateErrorB");
//QVERIFY(!delegate);
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 841a0ee..de11fe2 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -103,7 +103,7 @@ void tst_QDeclarativeWorkerScript::source_data()
QTest::addColumn<bool>("valid");
QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/worker.qml") << true;
- QTest::newRow("invalid") << QUrl("file:///asdjfk.js") << false;
+ QTest::newRow("invalid") << QUrl::fromLocalFile("asdjfk.js") << false;
}
void tst_QDeclarativeWorkerScript::messaging()
diff --git a/tests/auto/qmediaservice/tst_qmediaservice.cpp b/tests/auto/qmediaservice/tst_qmediaservice.cpp
index 35f661d..a0cb69d 100644
--- a/tests/auto/qmediaservice/tst_qmediaservice.cpp
+++ b/tests/auto/qmediaservice/tst_qmediaservice.cpp
@@ -69,7 +69,9 @@ class QtTestMediaControlA : public QMediaControl
#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA"
+QT_BEGIN_NAMESPACE
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid)
+QT_END_NAMESPACE
class QtTestMediaControlB : public QMediaControl
@@ -78,7 +80,9 @@ class QtTestMediaControlB : public QMediaControl
};
#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB"
+QT_BEGIN_NAMESPACE
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid)
+QT_END_NAMESPACE
class QtTestMediaControlC : public QMediaControl
@@ -87,7 +91,9 @@ class QtTestMediaControlC : public QMediaControl
};
#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC"
+QT_BEGIN_NAMESPACE
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A.
+QT_END_NAMESPACE
class QtTestMediaControlD : public QMediaControl
{
@@ -95,7 +101,9 @@ class QtTestMediaControlD : public QMediaControl
};
#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
+QT_BEGIN_NAMESPACE
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
+QT_END_NAMESPACE
class QtTestMediaControlE : public QMediaControl
{