diff options
author | Peter Yard <peter.yard@nokia.com> | 2010-05-14 00:17:40 (GMT) |
---|---|---|
committer | Peter Yard <peter.yard@nokia.com> | 2010-05-14 00:17:40 (GMT) |
commit | 124e9a761b3cab7414d3ddeaa8e8f2455b6598ad (patch) | |
tree | 518c22b7317c5646d2ce0adc5deb5818b2ea0af6 /src/declarative/util | |
parent | dcc9a7e72fe4c283df59378d08d75aecfa3b3b05 (diff) | |
parent | ac519ee416e06f4ab471f102da306f94de21c90d (diff) | |
download | Qt-124e9a761b3cab7414d3ddeaa8e8f2455b6598ad.zip Qt-124e9a761b3cab7414d3ddeaa8e8f2455b6598ad.tar.gz Qt-124e9a761b3cab7414d3ddeaa8e8f2455b6598ad.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Conflicts:
examples/declarative/dial/dial-example.qml
Diffstat (limited to 'src/declarative/util')
25 files changed, 381 insertions, 199 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 4059522..0f7c946 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -55,6 +55,7 @@ #include <qdeclarativemetatype_p.h> #include <qdeclarativevaluetype_p.h> #include <qdeclarativeproperty_p.h> +#include <qdeclarativeengine_p.h> #include <qvariant.h> #include <qcolor.h> @@ -178,6 +179,10 @@ void QDeclarativeAbstractAnimation::setRunning(bool r) d->running = r; if (r == false) d->avoidPropertyValueSourceStart = true; + else { + QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); + engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()")); + } return; } @@ -268,6 +273,11 @@ void QDeclarativeAbstractAnimation::componentComplete() { Q_D(QDeclarativeAbstractAnimation); d->componentComplete = true; +} + +void QDeclarativeAbstractAnimation::componentFinalized() +{ + Q_D(QDeclarativeAbstractAnimation); if (d->running) { d->running = false; setRunning(true); @@ -745,7 +755,7 @@ void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script) } /*! - \qmlproperty QString ScriptAction::scriptName + \qmlproperty string ScriptAction::scriptName This property holds the the name of the StateChangeScript to run. This property is only valid when ScriptAction is used as part of a transition. @@ -781,7 +791,7 @@ void QDeclarativeScriptActionPrivate::execute() if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.evaluate(); - if (expr.hasError()) + if (expr.hasError()) qmlInfo(q) << expr.error(); } } @@ -834,7 +844,7 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation() The PropertyAction is immediate - the target property is not animated to the selected value in any way. - + \sa QtDeclarative */ /*! @@ -864,7 +874,7 @@ void QDeclarativePropertyActionPrivate::init() This property holds an explicit target object to animate. The exact effect of the \c target property depends on how the animation - is being used. Refer to the \l animation documentation for details. + is being used. Refer to the \l {QML Animation} documentation for details. */ QObject *QDeclarativePropertyAction::target() const @@ -1320,27 +1330,27 @@ void QDeclarativeRotationAnimation::setTo(qreal t) /*! \qmlproperty enumeration RotationAnimation::direction The direction in which to rotate. - Possible values are Numerical, Clockwise, Counterclockwise, - or Shortest. + + Possible values are: \table \row - \o Numerical + \o RotationAnimation.Numerical \o Rotate by linearly interpolating between the two numbers. A rotation from 10 to 350 will rotate 340 degrees clockwise. \row - \o Clockwise + \o RotationAnimation.Clockwise \o Rotate clockwise between the two values \row - \o Counterclockwise + \o RotationAnimation.Counterclockwise \o Rotate counterclockwise between the two values \row - \o Shortest + \o RotationAnimation.Shortest \o Rotate in the direction that produces the shortest animation path. A rotation from 10 to 350 will rotate 20 degrees counterclockwise. \endtable - The default direction is Numerical. + The default direction is RotationAnimation.Numerical. */ QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const { @@ -1605,7 +1615,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int Animate any objects that have changed their x or y properties in the target state using an InOutQuad easing curve: \qml - Transition { PropertyAnimation { properties: "x,y"; easing.type: "InOutQuad" } } + Transition { PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } } \endqml \o In a Behavior @@ -1754,189 +1764,189 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) Linear. \qml - PropertyAnimation { properties: "y"; easing.type: "InOutElastic"; easing.amplitude: 2.0; easing.period: 1.5 } + PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 } \endqml Available types are: \table \row - \o \c Linear + \o \c Easing.Linear \o Easing curve for a linear (t) function: velocity is constant. \o \inlineimage qeasingcurve-linear.png \row - \o \c InQuad + \o \c Easing.InQuad \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquad.png \row - \o \c OutQuad + \o \c Easing.OutQuad \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity. \o \inlineimage qeasingcurve-outquad.png \row - \o \c InOutQuad + \o \c Easing.InOutQuad \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquad.png \row - \o \c OutInQuad + \o \c Easing.OutInQuad \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquad.png \row - \o \c InCubic + \o \c Easing.InCubic \o Easing curve for a cubic (t^3) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-incubic.png \row - \o \c OutCubic + \o \c Easing.OutCubic \o Easing curve for a cubic (t^3) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outcubic.png \row - \o \c InOutCubic + \o \c Easing.InOutCubic \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutcubic.png \row - \o \c OutInCubic + \o \c Easing.OutInCubic \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outincubic.png \row - \o \c InQuart + \o \c Easing.InQuart \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquart.png \row - \o \c OutQuart + \o \c Easing.OutQuart \o Easing curve for a cubic (t^4) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquart.png \row - \o \c InOutQuart + \o \c Easing.InOutQuart \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquart.png \row - \o \c OutInQuart + \o \c Easing.OutInQuart \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquart.png \row - \o \c InQuint + \o \c Easing.InQuint \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquint.png \row - \o \c OutQuint + \o \c Easing.OutQuint \o Easing curve for a cubic (t^5) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquint.png \row - \o \c InOutQuint + \o \c Easing.InOutQuint \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquint.png \row - \o \c OutInQuint + \o \c Easing.OutInQuint \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquint.png \row - \o \c InSine + \o \c Easing.InSine \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-insine.png \row - \o \c OutSine + \o \c Easing.OutSine \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outsine.png \row - \o \c InOutSine + \o \c Easing.InOutSine \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutsine.png \row - \o \c OutInSine + \o \c Easing.OutInSine \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinsine.png \row - \o \c InExpo + \o \c Easing.InExpo \o Easing curve for an exponential (2^t) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inexpo.png \row - \o \c OutExpo + \o \c Easing.OutExpo \o Easing curve for an exponential (2^t) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outexpo.png \row - \o \c InOutExpo + \o \c Easing.InOutExpo \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutexpo.png \row - \o \c OutInExpo + \o \c Easing.OutInExpo \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinexpo.png \row - \o \c InCirc + \o \c Easing.InCirc \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-incirc.png \row - \o \c OutCirc + \o \c Easing.OutCirc \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outcirc.png \row - \o \c InOutCirc + \o \c Easing.InOutCirc \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutcirc.png \row - \o \c OutInCirc + \o \c Easing.OutInCirc \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outincirc.png \row - \o \c InElastic + \o \c Easing.InElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity. \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \o \inlineimage qeasingcurve-inelastic.png \row - \o \c OutElastic + \o \c Easing.OutElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity. \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \o \inlineimage qeasingcurve-outelastic.png \row - \o \c InOutElastic + \o \c Easing.InOutElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutelastic.png \row - \o \c OutInElastic + \o \c Easing.OutInElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinelastic.png \row - \o \c InBack + \o \c Easing.InBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. \o \inlineimage qeasingcurve-inback.png \row - \o \c OutBack + \o \c Easing.OutBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity. \o \inlineimage qeasingcurve-outback.png \row - \o \c InOutBack + \o \c Easing.InOutBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutback.png \row - \o \c OutInBack + \o \c Easing.OutInBack \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinback.png \row - \o \c InBounce + \o \c Easing.InBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inbounce.png \row - \o \c OutBounce + \o \c Easing.OutBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outbounce.png \row - \o \c InOutBounce + \o \c Easing.InOutBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutbounce.png \row - \o \c OutInBounce + \o \c Easing.OutInBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinbounce.png \endtable - easing.amplitude is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type - QEasingCurve::InBounce, QEasingCurve::OutBounce, QEasingCurve::InOutBounce, QEasingCurve::OutInBounce, QEasingCurve::InElastic, - QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic). + easing.amplitude is only applicable for bounce and elastic curves (curves of type + Easing.InBounce, Easing.OutBounce, Easing.InOutBounce, Easing.OutInBounce, Easing.InElastic, + Easing.OutElastic, Easing.InOutElastic or Easing.OutInElastic). - easing.overshoot is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InBack, QEasingCurve::OutBack, - QEasingCurve::InOutBack or QEasingCurve::OutInBack. + easing.overshoot is only applicable if type is: Easing.InBack, Easing.OutBack, + Easing.InOutBack or Easing.OutInBack. - easing.period is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InElastic, QEasingCurve::OutElastic, - QEasingCurve::InOutElastic or QEasingCurve::OutInElastic. + easing.period is only applicable if type is: Easing.InElastic, Easing.OutElastic, + Easing.InOutElastic or Easing.OutInElastic. */ QEasingCurve QDeclarativePropertyAnimation::easing() const { @@ -2337,7 +2347,7 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation() } /*! - \qmlproperty item ParentAnimation::target + \qmlproperty Item ParentAnimation::target The item to reparent. When used in a transition, if no target is specified all @@ -2360,7 +2370,7 @@ void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target) } /*! - \qmlproperty item ParentAnimation::newParent + \qmlproperty Item ParentAnimation::newParent The new parent to animate to. If not set, then the parent defined in the end state of the transition. @@ -2382,7 +2392,7 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent) } /*! - \qmlproperty item ParentAnimation::via + \qmlproperty Item ParentAnimation::via The item to reparent via. This provides a way to do an unclipped animation when both the old parent and new parent are clipped @@ -2730,7 +2740,7 @@ void QDeclarativeAnchorAnimation::setDuration(int duration) Linear. \qml - AnchorAnimation { easing.type: "InOutQuad" } + AnchorAnimation { easing.type: Easing.InOutQuad } \endqml See the \l{PropertyAnimation::easing.type} documentation for information diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 40c893c..e7cd8a8 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -133,6 +133,7 @@ public: private Q_SLOTS: void timelineComplete(); + void componentFinalized(); private: virtual void setTarget(const QDeclarativeProperty &); diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 1089d31..90e0ca3 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -48,6 +48,7 @@ #include <qdeclarativeinfo.h> #include <qdeclarativeproperty_p.h> #include <qdeclarativeguard_p.h> +#include <qdeclarativeengine_p.h> #include <private/qobject_p.h> @@ -57,12 +58,14 @@ class QDeclarativeBehaviorPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QDeclarativeBehavior) public: - QDeclarativeBehaviorPrivate() : animation(0), enabled(true) {} + QDeclarativeBehaviorPrivate() : animation(0), enabled(true), finalized(false) {} QDeclarativeProperty property; QVariant currentValue; + QVariant targetValue; QDeclarativeGuard<QDeclarativeAbstractAnimation> animation; bool enabled; + bool finalized; }; /*! @@ -80,7 +83,7 @@ public: y: 200 // initial value Behavior on y { NumberAnimation { - easing.type: "OutBounce" + easing.type: Easing.OutBounce easing.amplitude: 100 duration: 200 } @@ -158,12 +161,17 @@ void QDeclarativeBehavior::write(const QVariant &value) { Q_D(QDeclarativeBehavior); qmlExecuteDeferred(this); - if (!d->animation || !d->enabled) { + if (!d->animation || !d->enabled || !d->finalized) { QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + d->targetValue = value; return; } + if (value == d->targetValue) + return; + d->currentValue = d->property.read(); + d->targetValue = value; if (d->animation->qtAnimation()->duration() != -1) d->animation->qtAnimation()->stop(); @@ -189,6 +197,15 @@ void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property) d->currentValue = property.read(); if (d->animation) d->animation->setDefaultTarget(property); + + QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); + engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()")); +} + +void QDeclarativeBehavior::componentFinalized() +{ + Q_D(QDeclarativeBehavior); + d->finalized = true; } QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h index e8a809f..6c10eec 100644 --- a/src/declarative/util/qdeclarativebehavior_p.h +++ b/src/declarative/util/qdeclarativebehavior_p.h @@ -82,6 +82,9 @@ public: Q_SIGNALS: void enabledChanged(); + +private Q_SLOTS: + void componentFinalized(); }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp index 5516628..5fab631 100644 --- a/src/declarative/util/qdeclarativebind.cpp +++ b/src/declarative/util/qdeclarativebind.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeBindPrivate : public QObjectPrivate { public: - QDeclarativeBindPrivate() : when(true), componentComplete(false), obj(0) {} + QDeclarativeBindPrivate() : when(true), componentComplete(true), obj(0) {} bool when : 1; bool componentComplete : 1; @@ -98,7 +98,6 @@ public: /*! \internal \class QDeclarativeBind - \ingroup group_utility \brief The QDeclarativeBind class allows arbitrary property bindings to be created. Simple bindings are usually earier to do in-place rather than creating a @@ -198,6 +197,12 @@ void QDeclarativeBind::setValue(const QVariant &v) eval(); } +void QDeclarativeBind::classBegin() +{ + Q_D(QDeclarativeBind); + d->componentComplete = false; +} + void QDeclarativeBind::componentComplete() { Q_D(QDeclarativeBind); diff --git a/src/declarative/util/qdeclarativebind_p.h b/src/declarative/util/qdeclarativebind_p.h index f756e80..f89c2eb 100644 --- a/src/declarative/util/qdeclarativebind_p.h +++ b/src/declarative/util/qdeclarativebind_p.h @@ -80,6 +80,7 @@ public: void setValue(const QVariant &); protected: + virtual void classBegin(); virtual void componentComplete(); private: diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp index 20d878b..ffa160f 100644 --- a/src/declarative/util/qdeclarativeconnections.cpp +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -57,11 +57,13 @@ QT_BEGIN_NAMESPACE class QDeclarativeConnectionsPrivate : public QObjectPrivate { public: - QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {} + QDeclarativeConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} QList<QDeclarativeBoundSignal*> boundsignals; QObject *target; + bool targetSet; + bool ignoreUnknownSignals; bool componentcomplete; QByteArray data; @@ -139,17 +141,21 @@ QDeclarativeConnections::~QDeclarativeConnections() \qmlproperty Object Connections::target This property holds the object that sends the signal. - By default, the target is assumed to be the parent of the Connections. + If not set at all, the target defaults to be the parent of the Connections. + + If set to null, no connection is made and any signal handlers are ignored + until the target is not null. */ QObject *QDeclarativeConnections::target() const { Q_D(const QDeclarativeConnections); - return d->target ? d->target : parent(); + return d->targetSet ? d->target : parent(); } void QDeclarativeConnections::setTarget(QObject *obj) { Q_D(QDeclarativeConnections); + d->targetSet = true; // even if setting to 0, it is *set* if (d->target == obj) return; foreach (QDeclarativeBoundSignal *s, d->boundsignals) { @@ -166,6 +172,29 @@ void QDeclarativeConnections::setTarget(QObject *obj) emit targetChanged(); } +/*! + \qmlproperty bool Connections::ignoreUnknownSignals + + Normally, you will get a runtime error if you try to connect + to signals on an object which the object does not have. + + By setting this flag to true, such errors are ignored. This is + useful if you intend to connect to different types of object, handling + a different set of signals for each. +*/ +bool QDeclarativeConnections::ignoreUnknownSignals() const +{ + Q_D(const QDeclarativeConnections); + return d->ignoreUnknownSignals; +} + +void QDeclarativeConnections::setIgnoreUnknownSignals(bool ignore) +{ + Q_D(QDeclarativeConnections); + d->ignoreUnknownSignals = ignore; +} + + QByteArray QDeclarativeConnectionsParser::compile(const QList<QDeclarativeCustomParserProperty> &props) @@ -220,7 +249,7 @@ void QDeclarativeConnectionsParser::setCustomData(QObject *object, void QDeclarativeConnections::connectSignals() { Q_D(QDeclarativeConnections); - if (!d->componentcomplete) + if (!d->componentcomplete || (d->targetSet && !target())) return; QDataStream ds(d->data); @@ -230,19 +259,24 @@ void QDeclarativeConnections::connectSignals() QString script; ds >> script; QDeclarativeProperty prop(target(), propName); - if (!prop.isValid()) { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } else if (prop.type() & QDeclarativeProperty::SignalProperty) { + if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) { QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(target(), prop.method(), this); signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0)); d->boundsignals += signal; } else { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); + if (!d->ignoreUnknownSignals) + qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); } } } +void QDeclarativeConnections::classBegin() +{ + Q_D(QDeclarativeConnections); + d->componentcomplete=false; +} + void QDeclarativeConnections::componentComplete() { Q_D(QDeclarativeConnections); diff --git a/src/declarative/util/qdeclarativeconnections_p.h b/src/declarative/util/qdeclarativeconnections_p.h index 3eacf12..a914166 100644 --- a/src/declarative/util/qdeclarativeconnections_p.h +++ b/src/declarative/util/qdeclarativeconnections_p.h @@ -65,6 +65,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDec Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) public: QDeclarativeConnections(QObject *parent=0); @@ -73,11 +74,15 @@ public: QObject *target() const; void setTarget(QObject *); + bool ignoreUnknownSignals() const; + void setIgnoreUnknownSignals(bool ignore); + Q_SIGNALS: void targetChanged(); private: void connectSignals(); + void classBegin(); void componentComplete(); }; diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 4115193..adfcd62 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -78,7 +78,6 @@ public: /*! \qmlclass FontLoader QDeclarativeFontLoader \since 4.7 - \ingroup group_utility \brief This item allows using fonts by name or url. Example: @@ -186,10 +185,10 @@ void QDeclarativeFontLoader::setName(const QString &name) This property holds the status of font loading. It can be one of: \list - \o Null - no font has been set - \o Ready - the font has been loaded - \o Loading - the font is currently being loaded - \o Error - an error occurred while loading the font + \o FontLoader.Null - no font has been set + \o FontLoader.Ready - the font has been loaded + \o FontLoader.Loading - the font is currently being loaded + \o FontLoader.Error - an error occurred while loading the font \endlist Note that a change in the status property does not cause anything to happen diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3810256..0985a6b 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -591,7 +591,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap) Changes the \a property of the item at \a index in the list model to \a value. \code - fruitModel.set(3, "cost", 5.95) + fruitModel.setProperty(3, "cost", 5.95) \endcode The \a index must be an element in the list. diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp index 0e5aaa6..ba5d534 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject.cpp +++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp @@ -305,7 +305,7 @@ void QDeclarativeOpenMetaObject::setCached(bool c) QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true); if (d->cacheProperties) { if (!d->type->d->cache) - d->type->d->cache = QDeclarativePropertyCache::create(d->type->d->engine, this); + d->type->d->cache = new QDeclarativePropertyCache(d->type->d->engine, this); qmldata->propertyCache = d->type->d->cache; d->type->d->cache->addref(); } else { diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index dbca326..d9ce42c 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -55,6 +55,7 @@ #include <QFile> #include <QThread> #include <QMutex> +#include <QBuffer> #include <QWaitCondition> #include <QtCore/qdebug.h> #include <private/qobject_p.h> @@ -342,7 +343,10 @@ void QDeclarativeImageRequestHandler::networkRequestDone() errorString = reply->errorString(); } else { QSize read_impsize; - if (readImage(reply->url(), reply, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) { + QByteArray all = reply->readAll(); + QBuffer buff(&all); + buff.open(QIODevice::ReadOnly); + if (readImage(reply->url(), &buff, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) { qmlOriginalSizes()->insert(reply->url(), read_impsize); error = QDeclarativeImageReaderEvent::NoError; } else { diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index 4b2d5a0..a22c756 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -51,6 +51,7 @@ #include <qdeclarativecontext.h> #include <qdeclarativeguard_p.h> #include <qdeclarativeproperty_p.h> +#include <qdeclarativecontext_p.h> #include <QtCore/qdebug.h> @@ -162,11 +163,15 @@ public: virtual void execute(Reason) { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression); + if (ownedExpression == expression) + ownedExpression = 0; } virtual bool isReversable() { return true; } virtual void reverse(Reason) { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); + if (ownedExpression == reverseExpression) + ownedExpression = 0; } virtual void saveOriginals() { @@ -174,11 +179,26 @@ public: reverseExpression = rewindExpression; } + virtual void copyOriginals(QDeclarativeActionEvent *other) + { + QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other); + saveCurrentValues(); + if (rsh == this) + return; + reverseExpression = rsh->reverseExpression; + if (rsh->ownedExpression == reverseExpression) { + ownedExpression = rsh->ownedExpression; + rsh->ownedExpression = 0; + } + } + virtual void rewind() { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); + if (ownedExpression == rewindExpression) + ownedExpression = 0; } virtual void saveCurrentValues() { - rewindExpression = QDeclarativePropertyPrivate::signalExpression(property); + rewindExpression = QDeclarativePropertyPrivate::signalExpression(property); } virtual bool override(QDeclarativeActionEvent*other) { @@ -302,12 +322,18 @@ void QDeclarativePropertyChangesPrivate::decode() QDeclarativeProperty prop = property(name); //### better way to check for signal property? if (prop.type() & QDeclarativeProperty::SignalProperty) { QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); QDeclarativeReplaceSignalHandler *handler = new QDeclarativeReplaceSignalHandler; handler->property = prop; handler->expression = expression; signalReplacements << handler; } else if (isScript) { QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expressions << qMakePair(name, expression); } else { properties << qMakePair(name, data); @@ -437,9 +463,11 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions() if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->evaluate(); } else { + QDeclarativeExpression *e = d->expressions.at(ii).second; QDeclarativeBinding *newBinding = - new QDeclarativeBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + new QDeclarativeBinding(e->expression(), object(), qmlContext(this)); newBinding->setTarget(prop); + newBinding->setSourceLocation(e->sourceFile(), e->lineNumber()); a.toBinding = newBinding; a.deletableToBinding = true; } diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 19a00ee..bd48ef0 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -388,10 +388,10 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions Sets how the SmoothedAnimation 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 + If reversing mode is \c SmoothedAnimation.Eased, the animation will smoothly decelerate, and + then reverse direction. If the reversing mode is \c SmoothedAnimation.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 + begining with a velocity of 0. If the reversing mode is \c SmoothedAnimation.Sync, the property is immediately set to the target value. */ QDeclarativeSmoothedAnimation::ReversingMode QDeclarativeSmoothedAnimation::reversingMode() const diff --git a/src/declarative/util/qdeclarativesmoothedfollow.cpp b/src/declarative/util/qdeclarativesmoothedfollow.cpp index 3ed9257..f70df9d 100644 --- a/src/declarative/util/qdeclarativesmoothedfollow.cpp +++ b/src/declarative/util/qdeclarativesmoothedfollow.cpp @@ -143,10 +143,10 @@ QDeclarativeSmoothedFollowPrivate::QDeclarativeSmoothedFollowPrivate() Sets how the SmoothedFollow 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 + If reversing mode is \c SmoothedFollow.Eased, the animation will smoothly decelerate, and + then reverse direction. If the reversing mode is \c SmoothedFollow.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 + begining with a velocity of 0. If the reversing mode is \c SmoothedFollow.Sync, the property is immediately set to the target value. */ QDeclarativeSmoothedFollow::ReversingMode QDeclarativeSmoothedFollow::reversingMode() const diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp index 70077f3..aae66ac 100644 --- a/src/declarative/util/qdeclarativespringfollow.cpp +++ b/src/declarative/util/qdeclarativespringfollow.cpp @@ -227,7 +227,7 @@ void QDeclarativeSpringFollowPrivate::stop() loops: Animation.Infinite NumberAnimation { to: 200 - easing.type: "OutBounce" + easing.type: Easing.OutBounce easing.amplitude: 100 duration: 2000 } diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 861cbc8..ea209aa 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -149,7 +149,6 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje \class QDeclarativeState \brief The QDeclarativeState class allows you to define configurations of objects and properties. - \ingroup group_states QDeclarativeState allows you to specify a state as a set of batched changes from the default configuration. diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 5b51495..9b042d7 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -47,6 +47,7 @@ #include <qdeclarativebinding_p.h> #include <qdeclarativeglobal_p.h> +#include <QtCore/qstringbuilder.h> #include <QtCore/qdebug.h> #include <private/qobject_p.h> @@ -62,7 +63,7 @@ class QDeclarativeStateGroupPrivate : public QObjectPrivate public: QDeclarativeStateGroupPrivate() : nullState(0), componentComplete(true), - ignoreTrans(false), applyingState(false) {} + ignoreTrans(false), applyingState(false), unnamedCount(0) {} QString currentState; QDeclarativeState *nullState; @@ -78,6 +79,7 @@ public: bool componentComplete; bool ignoreTrans; bool applyingState; + int unnamedCount; QDeclarativeTransition *findTransition(const QString &from, const QString &to); void setCurrentStateInternal(const QString &state, bool = false); @@ -259,6 +261,12 @@ void QDeclarativeStateGroup::componentComplete() Q_D(QDeclarativeStateGroup); d->componentComplete = true; + for (int ii = 0; ii < d->states.count(); ++ii) { + QDeclarativeState *state = d->states.at(ii); + if (state->name().isEmpty()) + state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); + } + if (d->updateAutoState()) { return; } else if (!d->currentState.isEmpty()) { diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 689f53c..a93a25d 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1056,40 +1056,41 @@ void QDeclarativeAnchorChanges::execute(Reason reason) if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //incorporate any needed "reverts" if (d->applyOrigLeft) { if (!d->origLeftBinding) - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); } if (d->applyOrigRight) { if (!d->origRightBinding) - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); } if (d->applyOrigHCenter) { if (!d->origHCenterBinding) - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); } if (d->applyOrigTop) { if (!d->origTopBinding) - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); } if (d->applyOrigBottom) { if (!d->origBottomBinding) - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); } if (d->applyOrigVCenter) { if (!d->origVCenterBinding) - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); } if (d->applyOrigBaseline) { if (!d->origBaselineBinding) - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); } @@ -1105,31 +1106,31 @@ void QDeclarativeAnchorChanges::execute(Reason reason) //reset any anchors that have been specified as "undefined" if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); } @@ -1161,51 +1162,52 @@ void QDeclarativeAnchorChanges::reverse(Reason reason) if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //reset any anchors set by the state if (d->leftBinding) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0); if (reason == ActualChange) { d->leftBinding->destroy(); d->leftBinding = 0; } } if (d->rightBinding) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0); if (reason == ActualChange) { d->rightBinding->destroy(); d->rightBinding = 0; } } if (d->hCenterBinding) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0); if (reason == ActualChange) { d->hCenterBinding->destroy(); d->hCenterBinding = 0; } } if (d->topBinding) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0); if (reason == ActualChange) { d->topBinding->destroy(); d->topBinding = 0; } } if (d->bottomBinding) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0); if (reason == ActualChange) { d->bottomBinding->destroy(); d->bottomBinding = 0; } } if (d->vCenterBinding) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0); if (reason == ActualChange) { d->vCenterBinding->destroy(); d->vCenterBinding = 0; } } if (d->baselineBinding) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0); if (reason == ActualChange) { d->baselineBinding->destroy(); d->baselineBinding = 0; @@ -1335,37 +1337,38 @@ void QDeclarativeAnchorChanges::clearBindings() d->fromWidth = d->target->width(); d->fromHeight = d->target->height(); + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //reset any anchors with corresponding reverts //reset any anchors that have been specified as "undefined" //reset any anchors that we'll be setting in the state QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | d->anchorSet->d_func()->usedAnchors; if (d->applyOrigLeft || (combined & QDeclarativeAnchors::LeftAnchor)) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); } if (d->applyOrigRight || (combined & QDeclarativeAnchors::RightAnchor)) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); } if (d->applyOrigHCenter || (combined & QDeclarativeAnchors::HCenterAnchor)) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); } if (d->applyOrigTop || (combined & QDeclarativeAnchors::TopAnchor)) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, 0); } if (d->applyOrigBottom || (combined & QDeclarativeAnchors::BottomAnchor)) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); } if (d->applyOrigVCenter || (combined & QDeclarativeAnchors::VCenterAnchor)) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); } if (d->applyOrigBaseline || (combined & QDeclarativeAnchors::BaselineAnchor)) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); } } @@ -1387,21 +1390,22 @@ void QDeclarativeAnchorChanges::rewind() if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //restore previous anchors if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setLeft(d->rewindLeft); + targetPrivate->anchors()->setLeft(d->rewindLeft); if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setRight(d->rewindRight); + targetPrivate->anchors()->setRight(d->rewindRight); if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setHorizontalCenter(d->rewindHCenter); + targetPrivate->anchors()->setHorizontalCenter(d->rewindHCenter); if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setTop(d->rewindTop); + targetPrivate->anchors()->setTop(d->rewindTop); if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBottom(d->rewindBottom); + targetPrivate->anchors()->setBottom(d->rewindBottom); if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setVerticalCenter(d->rewindVCenter); + targetPrivate->anchors()->setVerticalCenter(d->rewindVCenter); if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBaseline(d->rewindBaseline); + targetPrivate->anchors()->setBaseline(d->rewindBaseline); d->target->setX(d->rewindX); d->target->setY(d->rewindY); @@ -1415,13 +1419,14 @@ void QDeclarativeAnchorChanges::saveCurrentValues() if (!d->target) return; - d->rewindLeft = d->target->anchors()->left(); - d->rewindRight = d->target->anchors()->right(); - d->rewindHCenter = d->target->anchors()->horizontalCenter(); - d->rewindTop = d->target->anchors()->top(); - d->rewindBottom = d->target->anchors()->bottom(); - d->rewindVCenter = d->target->anchors()->verticalCenter(); - d->rewindBaseline = d->target->anchors()->baseline(); + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + d->rewindLeft = targetPrivate->anchors()->left(); + d->rewindRight = targetPrivate->anchors()->right(); + d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); + d->rewindTop = targetPrivate->anchors()->top(); + d->rewindBottom = targetPrivate->anchors()->bottom(); + d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); + d->rewindBaseline = targetPrivate->anchors()->baseline(); d->rewindX = d->target->x(); d->rewindY = d->target->y(); diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp index 9bb3f69..6c62446 100644 --- a/src/declarative/util/qdeclarativesystempalette.cpp +++ b/src/declarative/util/qdeclarativesystempalette.cpp @@ -59,7 +59,6 @@ public: /*! \qmlclass SystemPalette QDeclarativeSystemPalette \since 4.7 - \ingroup group_utility \brief The SystemPalette item gives access to the Qt palettes. \sa QPalette diff --git a/src/declarative/util/qdeclarativetimeline.cpp b/src/declarative/util/qdeclarativetimeline.cpp index 656c62b..0258b3c 100644 --- a/src/declarative/util/qdeclarativetimeline.cpp +++ b/src/declarative/util/qdeclarativetimeline.cpp @@ -255,7 +255,6 @@ qreal QDeclarativeTimeLinePrivate::value(const Op &op, int time, qreal base, boo /*! \internal \class QDeclarativeTimeLine - \ingroup group_animation \brief The QDeclarativeTimeLine class provides a timeline for controlling animations. QDeclarativeTimeLine is similar to QTimeLine except: @@ -387,7 +386,10 @@ void QDeclarativeTimeLine::set(QDeclarativeTimeLineValue &timeLineValue, qreal v */ int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration) { - if ((velocity > 0.0f) == (acceleration > 0.0f)) + if (acceleration == 0.0f) + return -1; + + if ((velocity > 0.0f) == (acceleration > 0.0f)) acceleration = acceleration * -1.0f; int time = static_cast<int>(-1000 * velocity / acceleration); @@ -410,13 +412,16 @@ int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal */ int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) { - Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f); + if (maxDistance == 0.0f || acceleration == 0.0f) + return -1; + + Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f); qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance); if (maxAccel > acceleration) acceleration = maxAccel; - if ((velocity > 0.0f) == (acceleration > 0.0f)) + if ((velocity > 0.0f) == (acceleration > 0.0f)) acceleration = acceleration * -1.0f; int time = static_cast<int>(-1000 * velocity / acceleration); @@ -438,6 +443,7 @@ int QDeclarativeTimeLine::accelDistance(QDeclarativeTimeLineValue &timeLineValue { if (distance == 0.0f || velocity == 0.0f) return -1; + Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f)); int time = static_cast<int>(1000 * (2.0f * distance) / velocity); @@ -868,7 +874,6 @@ void QDeclarativeTimeLine::remove(QDeclarativeTimeLineObject *v) /*! \internal \class QDeclarativeTimeLineValue - \ingroup group_animation \brief The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine. */ diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index f284156..ab8b116 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Transition QDeclarativeTransition - \since 4.7 + \since 4.7 \brief The Transition element defines animated transitions that occur on state changes. \sa {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} @@ -63,8 +63,6 @@ QT_BEGIN_NAMESPACE \internal \class QDeclarativeTransition \brief The QDeclarativeTransition class allows you to define animated transitions that occur on state changes. - - \ingroup group_states */ //ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 62d913c..e68ef94 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -128,19 +128,18 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QDeclarativeViewPrivate : public QDeclarativeItemChangeListener +class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener { + Q_DECLARE_PUBLIC(QDeclarativeView) public: - QDeclarativeViewPrivate(QDeclarativeView *view) - : q(view), root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} + QDeclarativeViewPrivate() + : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} ~QDeclarativeViewPrivate() { delete root; } void execute(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); void initResize(); void updateSize(); - inline QSize rootObjectSize(); - - QDeclarativeView *q; + inline QSize rootObjectSize() const; QDeclarativeGuard<QGraphicsObject> root; QDeclarativeGuard<QDeclarativeItem> declarativeItemRoot; @@ -162,6 +161,7 @@ public: void QDeclarativeViewPrivate::execute() { + Q_Q(QDeclarativeView); if (root) { delete root; root = 0; @@ -182,6 +182,7 @@ void QDeclarativeViewPrivate::execute() void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) { + Q_Q(QDeclarativeView); if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) { // wait for both width and height to be changed resizetimer.start(0,q); @@ -250,8 +251,9 @@ void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, Constructs a QDeclarativeView with the given \a parent. */ QDeclarativeView::QDeclarativeView(QWidget *parent) -: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) + : QGraphicsView(*(new QDeclarativeViewPrivate), parent) { + Q_D(QDeclarativeView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); } @@ -262,8 +264,9 @@ QDeclarativeView::QDeclarativeView(QWidget *parent) Constructs a QDeclarativeView with the given QML \a source and \a parent. */ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) -: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) + : QGraphicsView(*(new QDeclarativeViewPrivate), parent) { + Q_D(QDeclarativeView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); setSource(source); @@ -271,6 +274,7 @@ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) void QDeclarativeViewPrivate::init() { + Q_Q(QDeclarativeView); q->setScene(&scene); q->setOptimizationFlags(QGraphicsView::DontSavePainterState); @@ -288,12 +292,10 @@ void QDeclarativeViewPrivate::init() } /*! - The destructor clears the view's \l {QGraphicsObject} {items} and - deletes the internal representation. + Destroys the view. */ QDeclarativeView::~QDeclarativeView() { - delete d; } /*! \property QDeclarativeView::source @@ -316,6 +318,7 @@ QDeclarativeView::~QDeclarativeView() */ void QDeclarativeView::setSource(const QUrl& url) { + Q_D(QDeclarativeView); d->source = url; d->execute(); } @@ -327,6 +330,7 @@ void QDeclarativeView::setSource(const QUrl& url) */ QUrl QDeclarativeView::source() const { + Q_D(const QDeclarativeView); return d->source; } @@ -336,6 +340,7 @@ QUrl QDeclarativeView::source() const */ QDeclarativeEngine* QDeclarativeView::engine() { + Q_D(QDeclarativeView); return &d->engine; } @@ -348,6 +353,7 @@ QDeclarativeEngine* QDeclarativeView::engine() */ QDeclarativeContext* QDeclarativeView::rootContext() { + Q_D(QDeclarativeView); return d->engine.rootContext(); } @@ -376,6 +382,7 @@ QDeclarativeContext* QDeclarativeView::rootContext() QDeclarativeView::Status QDeclarativeView::status() const { + Q_D(const QDeclarativeView); if (!d->component) return QDeclarativeView::Null; @@ -388,6 +395,7 @@ QDeclarativeView::Status QDeclarativeView::status() const */ QList<QDeclarativeError> QDeclarativeView::errors() const { + Q_D(const QDeclarativeView); if (d->component) return d->component->errors(); return QList<QDeclarativeError>(); @@ -410,6 +418,7 @@ QList<QDeclarativeError> QDeclarativeView::errors() const void QDeclarativeView::setResizeMode(ResizeMode mode) { + Q_D(QDeclarativeView); if (d->resizeMode == mode) return; @@ -433,6 +442,7 @@ void QDeclarativeView::setResizeMode(ResizeMode mode) void QDeclarativeViewPrivate::initResize() { + Q_Q(QDeclarativeView); if (declarativeItemRoot) { if (resizeMode == QDeclarativeView::SizeViewToRootObject) { QDeclarativeItemPrivate *p = @@ -449,6 +459,7 @@ void QDeclarativeViewPrivate::initResize() void QDeclarativeViewPrivate::updateSize() { + Q_Q(QDeclarativeView); if (!root) return; if (declarativeItemRoot) { @@ -479,15 +490,12 @@ void QDeclarativeViewPrivate::updateSize() q->updateGeometry(); } -QSize QDeclarativeViewPrivate::rootObjectSize() +QSize QDeclarativeViewPrivate::rootObjectSize() const { QSize rootObjectSize(0,0); int widthCandidate = -1; int heightCandidate = -1; - if (declarativeItemRoot) { - widthCandidate = declarativeItemRoot->width(); - heightCandidate = declarativeItemRoot->height(); - } else if (root) { + if (root) { QSizeF size = root->boundingRect().size(); widthCandidate = size.width(); heightCandidate = size.height(); @@ -503,6 +511,7 @@ QSize QDeclarativeViewPrivate::rootObjectSize() QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const { + Q_D(const QDeclarativeView); return d->resizeMode; } @@ -511,7 +520,7 @@ QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const */ void QDeclarativeView::continueExecute() { - + Q_D(QDeclarativeView); disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute())); if (d->component->isError()) { @@ -544,6 +553,7 @@ void QDeclarativeView::continueExecute() */ void QDeclarativeView::setRootObject(QObject *obj) { + Q_D(QDeclarativeView); if (d->root == obj) return; if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem *>(obj)) { @@ -593,6 +603,7 @@ void QDeclarativeView::setRootObject(QObject *obj) */ void QDeclarativeView::timerEvent(QTimerEvent* e) { + Q_D(QDeclarativeView); if (!e || e->timerId() == d->resizetimer.timerId()) { d->updateSize(); d->resizetimer.stop(); @@ -602,6 +613,7 @@ void QDeclarativeView::timerEvent(QTimerEvent* e) /*! \reimp */ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) { + Q_D(QDeclarativeView); if (watched == d->root && d->resizeMode == SizeViewToRootObject) { if (d->graphicsWidgetRoot) { if (e->type() == QEvent::GraphicsSceneResize) { @@ -614,16 +626,16 @@ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) /*! \internal - Preferred size follows the root object in - resize mode SizeViewToRootObject and - the view in resize mode SizeRootObjectToView. + Preferred size follows the root object geometry. */ QSize QDeclarativeView::sizeHint() const { - if (d->resizeMode == SizeRootObjectToView) { + Q_D(const QDeclarativeView); + QSize rootObjectSize = d->rootObjectSize(); + if (rootObjectSize.isEmpty()) { return size(); - } else { // d->resizeMode == SizeViewToRootObject - return d->rootObjectSize(); + } else { + return rootObjectSize; } } @@ -632,6 +644,7 @@ QSize QDeclarativeView::sizeHint() const */ QGraphicsObject *QDeclarativeView::rootObject() const { + Q_D(const QDeclarativeView); return d->root; } @@ -642,6 +655,7 @@ QGraphicsObject *QDeclarativeView::rootObject() const */ void QDeclarativeView::resizeEvent(QResizeEvent *e) { + Q_D(QDeclarativeView); if (d->resizeMode == SizeRootObjectToView) { d->updateSize(); } @@ -661,6 +675,7 @@ void QDeclarativeView::resizeEvent(QResizeEvent *e) */ void QDeclarativeView::paintEvent(QPaintEvent *event) { + Q_D(QDeclarativeView); int time = 0; if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled()) time = d->frameTimer.restart(); diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index 3513c04..e9cff32 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -106,9 +106,8 @@ protected: virtual bool eventFilter(QObject *watched, QEvent *e); private: - friend class QDeclarativeViewPrivate; - QDeclarativeViewPrivate *d; Q_DISABLE_COPY(QDeclarativeView) + Q_DECLARE_PRIVATE(QDeclarativeView) }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index bdebadf..f1a00989 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -472,40 +472,71 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla \since 4.7 \brief The XmlListModel element is used to specify a model using XPath expressions. - XmlListModel is used to create a model from XML data that can be used as a data source + XmlListModel is used to create a model from XML data. XmlListModel can be used as a data source for the view classes (such as ListView, PathView, GridView) and other classes that interact with model - data (such as Repeater). + data (such as \l Repeater). + + For example, if there is a XML document at http://www.mysite.com/feed.xml like this: + + \code + <?xml version="1.0" encoding="utf-8"?> + <rss version="2.0"> + ... + <channel> + <item> + <title>Item A</title> + <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate> + </item> + <item> + <title>Item B</title> + <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate> + </item> + </channel> + </rss> + \endcode + + Then it could be used to create the following model: - Here is an example of a model containing news from a Yahoo RSS feed: \qml XmlListModel { - id: feedModel - source: "http://rss.news.yahoo.com/rss/oceania" + source: "http://www.mysite.com/feed.xml" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "pubDate"; query: "pubDate/string()" } - XmlRole { name: "description"; query: "description/string()" } } \endqml - You can also define certain roles as "keys" so that the model only adds data - that contains new values for these keys when reload() is called. + The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate + a model item for each \c <item> in the XML document. The XmlRole objects define the + model item attributes; here, each model item will have \c title and \c pubDate + attributes that match the \c title and \c pubDate values of its corresponding \c <item>. - For example, if the roles above were defined like this: + + \section2 Using key XML roles + + You can define certain roles as "keys" so that when reload() is called, + the model will only add and refresh data that contains new values for + these keys. + + For example, if above role for "pubDate" was defined like this instead: \qml - XmlRole { name: "title"; query: "title/string()"; isKey: true } XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true } \endqml - Then when reload() is called, the model will only add new items with a - "title" and "pubDate" value combination that is not already present in - the model. + Then when reload() is called, the model will only add and reload + items with a "pubDate" value that is not already + present in the model. - This is useful to provide incremental updates and avoid repainting an - entire model in a view. + This is useful when displaying the contents of XML documents that + are incrementally updated (such as RSS feeds) to avoid repainting the + entire contents of a model in a view. - \sa {QtDeclarative} + If multiple key roles are specified, the model only adds and reload items + with a combined value of all key roles that is not already present in + the model. + + \sa {declarative/xmldata}{XML data example} */ QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) @@ -626,8 +657,8 @@ void QDeclarativeXmlListModel::setXml(const QString &xml) /*! \qmlproperty string XmlListModel::query - An absolute XPath query representing the base query for the model items. The query should start with - '/' or '//'. + An absolute XPath query representing the base query for creating model items + from this model's XmlRole objects. The query should start with '/' or '//'. */ QString QDeclarativeXmlListModel::query() const { @@ -652,7 +683,20 @@ void QDeclarativeXmlListModel::setQuery(const QString &query) /*! \qmlproperty string XmlListModel::namespaceDeclarations - A set of declarations for the namespaces used in the query. + The namespace declarations to be used in the XPath queries. + + The namespaces should be declared as in XQuery. For example, if a requested document + at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom", + this can be declared as the default namespace: + + \qml + XmlListModel { + source: "http://mysite.com/feed.xml" + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + XmlRole { name: "title"; query: "title/string()" } + } + \endqml */ QString QDeclarativeXmlListModel::namespaceDeclarations() const { @@ -675,10 +719,10 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati Specifies the model loading status, which can be one of the following: \list - \o Null - No XML data has been set for this model. - \o Ready - The XML data has been loaded into the model. - \o Loading - The model is in the process of reading and loading XML data. - \o Error - An error occurred while the model was loading. + \o XmlListModel.Null - No XML data has been set for this model. + \o XmlListModel.Ready - The XML data has been loaded into the model. + \o XmlListModel.Loading - The model is in the process of reading and loading XML data. + \o XmlListModel.Error - An error occurred while the model was loading. \endlist \sa progress @@ -735,7 +779,7 @@ void QDeclarativeXmlListModel::componentComplete() Otherwise, items are only added if the model does not already contain items with matching key role values. - \sa XmlRole::isKey + \sa {Using key XML roles}, XmlRole::isKey */ void QDeclarativeXmlListModel::reload() { @@ -752,8 +796,11 @@ void QDeclarativeXmlListModel::reload() if (d->reply) { d->reply->abort(); - d->reply->deleteLater(); - d->reply = 0; + if (d->reply) { + // abort will generally have already done this (and more) + d->reply->deleteLater(); + d->reply = 0; + } } if (!d->xml.isEmpty()) { |