From 2729df73c54eebcd4b981eaf1487d604e467c4d5 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 23 Jun 2009 10:13:58 +0200 Subject: Changed SetProperty to SetProperties to anticipate deprecation of SetProperty. --- examples/declarative/states/states.qml | 12 +++++++++--- examples/declarative/states/transitions.qml | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml index bcde20c..c7ee172 100644 --- a/examples/declarative/states/states.qml +++ b/examples/declarative/states/states.qml @@ -26,15 +26,21 @@ Rect { // In state 'Position1', change the 'myrect' item x, y to 150, 50. State { name: "Position1" - SetProperty { target: myrect; property: "x"; value: 150 } - SetProperty { target: myrect; property: "y"; value: 50 } + SetProperties { + target: myrect + x: 150 + y: 50 + } }, // In state 'Position2', change y to 100. We do not specify 'x' here - // it will therefore be restored to its default value of 0, if it // had been changed. State { name: "Position2" - SetProperty { target: myrect; property: "y"; value: 200 } + SetProperties { + target: myrect + y: 200 + } } ] } diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 4c1dceb..736cc87 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -26,15 +26,21 @@ Rect { // In state 'Position1', change the 'myrect' item x, y to 150, 50. State { name: "Position1" - SetProperty { target: myrect; property: "x"; value: 150 } - SetProperty { target: myrect; property: "y"; value: 50 } + SetProperties { + target: myrect + x: 150 + y: 50 + } }, // In state 'Position2', change y to 100. We do not specify 'x' here - // it will therefore be restored to its default value of 0, if it // had been changed. State { name: "Position2" - SetProperty { target: myrect; property: "y"; value: 200 } + SetProperties { + target: myrect + y: 200 + } } ] -- cgit v0.12 From 2020c692803a8a7839d85860d05174a193d9a848 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 23 Jun 2009 10:16:18 +0200 Subject: Changed SetProperty to SetProperties to anticipate deprecation of SetProperty. --- examples/declarative/tutorials/helloworld/t3/tutorial3.qml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index bd89ecf..127d99e 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -14,15 +14,10 @@ Rect { State { name: "down" when: MouseRegion.pressed == true - SetProperty { + SetProperties { target: HelloText - property: "y" - value: 160 - } - SetProperty { - target: HelloText - property: "color" - value: "red" + y: 160 + color: "red" } } ] -- cgit v0.12 From 969f15aa35863bf5bd3d3d2cfa087cf67d5ddc81 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 25 Jun 2009 09:40:13 +1000 Subject: Add support for setting/getting animation time. --- src/declarative/util/qmlanimation.cpp | 10 ++++++++++ src/declarative/util/qmlanimation.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 2a6cad9..4776391 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -371,6 +371,16 @@ void QmlAbstractAnimation::setRepeat(bool r) emit repeatChanged(r); } +int QmlAbstractAnimation::currentTime() +{ + qtAnimation()->currentTime(); +} + +void QmlAbstractAnimation::setCurrentTime(int time) +{ + qtAnimation()->setCurrentTime(time); +} + QmlAnimationGroup *QmlAbstractAnimation::group() const { Q_D(const QmlAbstractAnimation); diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 0452159..b0dd261 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -86,6 +86,9 @@ public: bool repeat() const; void setRepeat(bool); + int currentTime(); + void setCurrentTime(int); + QmlAnimationGroup *group() const; void setGroup(QmlAnimationGroup *); -- cgit v0.12 From 9f020f8a737ee27cf5b7ce4a41e579a6872d9954 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Jun 2009 15:03:26 +1000 Subject: A little cleanup --- src/declarative/util/qmlstate.cpp | 102 ++++++++++++++++++++++++-------------- src/declarative/util/qmlstate.h | 23 --------- src/declarative/util/qmlstate_p.h | 29 ++++++++++- 3 files changed, 92 insertions(+), 62 deletions(-) diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index abe8301..0574224 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -234,19 +234,6 @@ QmlState &QmlState::operator<<(QmlStateOperation *op) return *this; } -#if 0 -static void dump(const QmlStateOperation::ActionList &list) -{ - if (!QString(getenv("STATE_DEBUG")).isEmpty()) - return; - - for (int ii = 0; ii < list.count(); ++ii) { - const Action &action = list.at(ii); - qWarning() << action.property.object << action.property.name << action.toValue; - } -} -#endif - void QmlStatePrivate::applyBindings() { foreach(const Action &action, bindingsList) { @@ -282,12 +269,16 @@ void QmlStatePrivate::complete() emit q->completed(); } -QmlStateOperation::ActionList QmlStatePrivate::generateActionList(QmlStateGroup *group) const +// Generate a list of actions for this state. This includes coelescing state +// actions that this state "extends" +QmlStateOperation::ActionList +QmlStatePrivate::generateActionList(QmlStateGroup *group) const { QmlStateOperation::ActionList applyList; if (inState) return applyList; + // Prevent "extends" recursion inState = true; if (!extends.isEmpty()) { @@ -336,12 +327,19 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->reverting.clear(); d->bindingsList.clear(); - if (revert) - d->revertList = static_cast(revert->d_ptr)->revertList; - QmlStateOperation::RevertActionList additionalReverts; + if (revert) { + QmlStatePrivate *revertPrivate = + static_cast(revert->d_ptr); + d->revertList = revertPrivate->revertList; + revertPrivate->revertList.clear(); + } + // List of actions caused by this state QmlStateOperation::ActionList applyList = d->generateActionList(group); + // List of actions that need to be reverted to roll back (just) this state + QmlStatePrivate::SimpleActionList additionalReverts; + // First add the reverse of all the applyList actions for (int ii = 0; ii < applyList.count(); ++ii) { const Action &action = applyList.at(ii); if (action.event || !action.restore) @@ -353,10 +351,15 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever found = true; } if (!found) { - RevertAction r(action); + // Only need to revert the applyList action if the previous + // state doesn't have a higher priority revert already + SimpleAction r(action); additionalReverts << r; } } + + // Any reverts from a previous state that aren't carried forth + // into this state need to be translated into apply actions for (int ii = 0; ii < d->revertList.count(); ++ii) { bool found = false; for (int jj = 0; !found && jj < applyList.count(); ++jj) { @@ -376,26 +379,41 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever a.bv = d->revertList.at(ii).bv; } applyList << a; + // Store these special reverts in the reverting list d->reverting << d->revertList.at(ii).property; } } + // All the local reverts now become part of the ongoing revertList d->revertList << additionalReverts; - //apply all changes, and work out any ending positions for bindings - //then rewind all changes and proceed as normal - //### 4 foreach loops! - //////////////////////////////////////////////////////////////////// - foreach(const Action &action, applyList) { - if (stateChangeDebug()) - qWarning() << " Action:" << action.property.object() << action.property.name() << action.toValue; + // Output for debugging + if (stateChangeDebug()) { + foreach(const Action &action, applyList) { + qWarning() << " Action:" << action.property.object() + << action.property.name() << action.toValue; + } + } + // Determine which actions are binding changes. + foreach(const Action &action, applyList) { if (action.bv && !action.toBinding.isEmpty()) { d->bindingsList << action; action.bv->clearExpression(); } } + // Animated transitions need both the start and the end value for + // each property change. In the presence of bindings, the end values + // are non-trivial to calculate. As a "best effort" attempt, we first + // apply all the property and binding changes, then read all the actual + // final values, then roll back the changes and proceed as normal. + // + // This doesn't catch everything, and it might be a little fragile in + // some cases - but whatcha going to do? + if (!d->bindingsList.isEmpty()) { + + // Apply all the property and binding changes foreach(const Action &action, applyList) { if (action.bv && !action.toBinding.isEmpty()) { action.bv->setExpression(action.toBinding); @@ -404,6 +422,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } } + // Read all the end values for binding changes for (int ii = 0; ii < applyList.size(); ++ii) { Action *action = &applyList[ii]; if (action->event) @@ -415,6 +434,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } } + // Revert back to the original values foreach(const Action &action, applyList) { if (action.event) continue; @@ -424,36 +444,44 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever action.property.write(action.fromValue); } } - //////////////////////////////////////////////////////////////////// - QmlStateOperation::ActionList modList = applyList; - QList touched; + d->completeList.clear(); + if (trans) { + QList touched; d->transition = trans; - trans->prepare(modList, touched, this); - for (int ii = 0; ii < modList.count(); ++ii) { - const Action &action = modList.at(ii); + trans->prepare(applyList, touched, this); + + // Modify the action list to remove actions handled in the transition + for (int ii = 0; ii < applyList.count(); ++ii) { + const Action &action = applyList.at(ii); if (action.event) { + if (action.actionDone) { - modList.removeAt(ii); + applyList.removeAt(ii); --ii; } + } else { - if (action.toValue != action.fromValue) { - d->completeList << RevertAction(action, false); - } if (touched.contains(action.property)) { - modList.removeAt(ii); + if (action.toValue != action.fromValue) + d->completeList << SimpleAction(action, + SimpleAction::EndState); + + applyList.removeAt(ii); --ii; } + } } } - foreach(const Action &action, modList) { + // Any actions remaining have not been handled by the transition and should + // be applied immediately + foreach(const Action &action, applyList) { if (action.event) action.event->execute(); else diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 0b8d82a..59ef812 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -79,28 +79,6 @@ public: virtual void execute(); }; -class RevertAction -{ -public: - RevertAction(const Action &a, bool from = true) : bv(0) - { - property = a.property; - if (from) { - value = a.fromValue; - binding = a.fromBinding; - } else { - value = a.toValue; - binding = a.toBinding; - } - bv = a.bv; - } - - QmlMetaProperty property; - QVariant value; - QString binding; - QmlBindableValue *bv; -}; - class QmlStateGroup; class Q_DECLARATIVE_EXPORT QmlStateOperation : public QObject { @@ -109,7 +87,6 @@ public: QmlStateOperation(QObject *parent = 0) : QObject(parent) {} typedef QList ActionList; - typedef QList RevertActionList; virtual ActionList actions(); diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index da8fdcd..7fcbcd7 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -48,6 +48,29 @@ QT_BEGIN_NAMESPACE +class SimpleAction +{ +public: + enum State { StartState, EndState }; + SimpleAction(const Action &a, State state = StartState) : bv(0) + { + property = a.property; + if (state == StartState) { + value = a.fromValue; + binding = a.fromBinding; + } else { + value = a.toValue; + binding = a.toBinding; + } + bv = a.bv; + } + + QmlMetaProperty property; + QVariant value; + QString binding; + QmlBindableValue *bv; +}; + class QmlStatePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlState) @@ -56,13 +79,15 @@ public: QmlStatePrivate() : when(0), transition(0), inState(false), group(0) {} + typedef QList SimpleActionList; + QString name; QmlBindableValue *when; QmlConcreteList operations; QmlTransition *transition; - QmlStateOperation::RevertActionList revertList; + SimpleActionList revertList; QList reverting; - QmlStateOperation::RevertActionList completeList; + SimpleActionList completeList; QmlStateOperation::ActionList bindingsList; QString extends; mutable bool inState; -- cgit v0.12 From 128a0c387801194a690f646cde6579bbf804b7de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 25 Jun 2009 15:07:21 +1000 Subject: Refactoring animation code. Greatly simplify the NumericAnimation and ColorAnimation classes. Still need to optimize. --- src/declarative/util/qmlanimation.cpp | 651 +++++----------------------------- src/declarative/util/qmlanimation.h | 167 +++------ src/declarative/util/qmlanimation_p.h | 60 ---- 3 files changed, 131 insertions(+), 747 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4776391..f2a91eb 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -373,7 +373,7 @@ void QmlAbstractAnimation::setRepeat(bool r) int QmlAbstractAnimation::currentTime() { - qtAnimation()->currentTime(); + return qtAnimation()->currentTime(); } void QmlAbstractAnimation::setCurrentTime(int time) @@ -716,9 +716,9 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() */ QmlColorAnimation::QmlColorAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlColorAnimationPrivate), parent) +: QmlVariantAnimation(parent) { - Q_D(QmlColorAnimation); + Q_D(QmlVariantAnimation); d->init(); } @@ -726,46 +726,6 @@ QmlColorAnimation::~QmlColorAnimation() { } -void QmlColorAnimationPrivate::init() -{ - Q_Q(QmlColorAnimation); - ca = new QmlTimeLineValueAnimator(q); - ca->setStartValue(QVariant(0.0f)); - ca->setEndValue(QVariant(1.0f)); -} - -/*! - \qmlproperty int ColorAnimation::duration - This property holds the duration of the color transition, in milliseconds. - - The default value is 250. -*/ -/*! - \property QmlColorAnimation::duration - \brief the duration of the transition, in milliseconds. - - The default value is 250. -*/ -int QmlColorAnimation::duration() const -{ - Q_D(const QmlColorAnimation); - return d->ca->duration(); -} - -void QmlColorAnimation::setDuration(int duration) -{ - if (duration < 0) { - qWarning("QmlColorAnimation: Cannot set a duration of < 0"); - return; - } - - Q_D(QmlColorAnimation); - if (d->ca->duration() == duration) - return; - d->ca->setDuration(duration); - emit durationChanged(duration); -} - /*! \qmlproperty color ColorAnimation::from This property holds the starting color. @@ -776,18 +736,13 @@ void QmlColorAnimation::setDuration(int duration) */ QColor QmlColorAnimation::from() const { - Q_D(const QmlColorAnimation); - return d->fromValue; + Q_D(const QmlVariantAnimation); + return d->from.value(); } void QmlColorAnimation::setFrom(const QColor &f) { - Q_D(QmlColorAnimation); - if (d->fromIsDefined && f == d->fromValue) - return; - d->fromValue = f; - d->fromIsDefined = f.isValid(); - emit fromChanged(f); + QmlVariantAnimation::setFrom(f); } /*! @@ -800,202 +755,15 @@ void QmlColorAnimation::setFrom(const QColor &f) */ QColor QmlColorAnimation::to() const { - Q_D(const QmlColorAnimation); - return d->toValue; + Q_D(const QmlVariantAnimation); + return d->to.value(); } void QmlColorAnimation::setTo(const QColor &t) { - Q_D(QmlColorAnimation); - if (d->toIsDefined && t == d->toValue) - return; - d->toValue = t; - d->toIsDefined = t.isValid(); - emit toChanged(t); -} - -/*! - \qmlproperty string ColorAnimation::easing - This property holds the easing curve used for the transition. - - Each channel of the color is eased using the same easing curve. - See NumericAnimation::easing for a full discussion of easing, - and a list of available curves. -*/ -QString QmlColorAnimation::easing() const -{ - Q_D(const QmlColorAnimation); - return d->easing; -} - -void QmlColorAnimation::setEasing(const QString &e) -{ - Q_D(QmlColorAnimation); - if (d->easing == e) - return; - - d->easing = e; - d->ca->setEasingCurve(stringToCurve(d->easing)); - emit easingChanged(e); -} - -/*! - \qmlproperty list ColorAnimation::filter - This property holds the items selected to be affected by this animation (all if not set). - \sa exclude -*/ -QList *QmlColorAnimation::filter() -{ - Q_D(QmlColorAnimation); - return &d->filter; -} - -/*! - \qmlproperty list ColorAnimation::exclude - This property holds the items not to be affected by this animation. - \sa filter -*/ -QList *QmlColorAnimation::exclude() -{ - Q_D(QmlColorAnimation); - return &d->exclude; -} - -void QmlColorAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlColorAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->ca->setFromSourcedValue(&d->fromSourced); -} - -QAbstractAnimation *QmlColorAnimation::qtAnimation() -{ - Q_D(QmlColorAnimation); - return d->ca; -} - -void QmlColorAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction) -{ - Q_D(QmlColorAnimation); - Q_UNUSED(direction); - - struct NTransitionData : public QmlTimeLineValue - { - QmlStateActions actions; - void write(QmlMetaProperty &property, const QVariant &color) - { - if (property.propertyType() == QVariant::Color) { - property.write(color); - } - } - - void setValue(qreal v) - { - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QColor to(action.toValue.value()); - - if (v == 1.) { - write(action.property, to); - } else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (action.fromValue.isNull()) - action.fromValue = QVariant(QColor()); - } - - QColor from(action.fromValue.value()); - - QVariant newColor = QmlColorAnimationPrivate::colorInterpolator(&from, &to, v); - write(action.property, newColor); - } - } - } - }; - - //XXX should we get rid of this? - QStringList props; - props << QLatin1String("color"); - if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) - props.append(d->propertyName); - - NTransitionData *data = new NTransitionData; - - QSet objs; - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { - objs.insert(obj); - Action myAction = action; - - if (d->fromIsDefined) { - myAction.fromValue = QVariant(d->fromValue); - } else { - myAction.fromValue = QVariant(); - } - if (d->toIsDefined) - myAction.toValue = QVariant(d->toValue); - - modified << action.property; - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (d->toValue.isValid() && target() && !objs.contains(target())) { - QObject *obj = target(); - for (int jj = 0; jj < props.count(); ++jj) { - Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); - - if (d->fromIsDefined) - myAction.fromValue = QVariant(d->fromValue); - - myAction.toValue = QVariant(d->toValue); - myAction.bv = 0; - myAction.event = 0; - data->actions << myAction; - } - } - - if (data->actions.count()) - d->ca->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - else - delete data; + QmlVariantAnimation::setTo(t); } -QVariantAnimation::Interpolator QmlColorAnimationPrivate::colorInterpolator = 0; - -void QmlColorAnimationPrivate::valueChanged(qreal v) -{ - if (!fromSourced) { - if (!fromIsDefined) { - fromValue = qvariant_cast(property.read()); - } - fromSourced = true; - } - - if (property.propertyType() == QVariant::Color) { - QVariant newColor = colorInterpolator(&fromValue, &toValue, v); - property.write(newColor); - } -} QML_DEFINE_TYPE(QmlColorAnimation,ColorAnimation) /*! @@ -1428,9 +1196,9 @@ QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction) */ QmlNumericAnimation::QmlNumericAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlNumericAnimationPrivate), parent) +: QmlVariantAnimation(parent) { - Q_D(QmlNumericAnimation); + Q_D(QmlVariantAnimation); d->init(); } @@ -1438,46 +1206,6 @@ QmlNumericAnimation::~QmlNumericAnimation() { } -void QmlNumericAnimationPrivate::init() -{ - Q_Q(QmlNumericAnimation); - na = new QmlTimeLineValueAnimator(q); - na->setStartValue(QVariant(0.0f)); - na->setEndValue(QVariant(1.0f)); -} - -/*! - \qmlproperty int NumericAnimation::duration - This property holds the duration of the transition, in milliseconds. - - The default value is 250. -*/ -/*! - \property QmlNumericAnimation::duration - \brief the duration of the transition, in milliseconds. - - The default value is 250. -*/ -int QmlNumericAnimation::duration() const -{ - Q_D(const QmlNumericAnimation); - return d->na->duration(); -} - -void QmlNumericAnimation::setDuration(int duration) -{ - if (duration < 0) { - qWarning("QmlNumericAnimation: Cannot set a duration of < 0"); - return; - } - - Q_D(QmlNumericAnimation); - if (d->na->duration() == duration) - return; - d->na->setDuration(duration); - emit durationChanged(duration); -} - /*! \qmlproperty real NumericAnimation::from This property holds the starting value. @@ -1489,17 +1217,13 @@ void QmlNumericAnimation::setDuration(int duration) */ qreal QmlNumericAnimation::from() const { - Q_D(const QmlNumericAnimation); - return d->from; + Q_D(const QmlVariantAnimation); + return d->from.toDouble(); //### toFloat? } void QmlNumericAnimation::setFrom(qreal f) { - Q_D(QmlNumericAnimation); - if (!d->from.isNull && f == d->from) - return; - d->from = f; - emit fromChanged(f); + QmlVariantAnimation::setFrom(f); } /*! @@ -1513,280 +1237,13 @@ void QmlNumericAnimation::setFrom(qreal f) */ qreal QmlNumericAnimation::to() const { - Q_D(const QmlNumericAnimation); - return d->to; + Q_D(const QmlVariantAnimation); + return d->to.toDouble(); //### toFloat? } void QmlNumericAnimation::setTo(qreal t) { - Q_D(QmlNumericAnimation); - if (!d->to.isNull && t == d->to) - return; - d->to = t; - emit toChanged(t); -} - -/*! - \qmlproperty string NumericAnimation::easing - \brief the easing curve used for the transition. - - Available values are: - - \list - \i \e easeNone - Easing equation function for a simple linear tweening, with no easing. - \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity. - \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity. - \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity. - \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity. - \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity. - \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity. - \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity. - \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity. - \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity. - \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. - \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity. - \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity. - \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity. - \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity. - \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. - \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity. - \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. - \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity. - \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. - \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration. - \endlist -*/ - -/*! - \property QmlNumericAnimation::easing - This property holds the easing curve to use. - - \sa QEasingCurve -*/ -QString QmlNumericAnimation::easing() const -{ - Q_D(const QmlNumericAnimation); - return d->easing; -} - -void QmlNumericAnimation::setEasing(const QString &e) -{ - Q_D(QmlNumericAnimation); - if (d->easing == e) - return; - - d->easing = e; - d->na->setEasingCurve(stringToCurve(d->easing)); - emit easingChanged(e); -} - -/*! - \qmlproperty string NumericAnimation::properties - This property holds the properties this animation should be applied to. - - This is a comma-separated list of properties that should use - this animation when they change. -*/ -/*! - \property QmlNumericAnimation::properties - \brief the properties this animation should be applied to. - - properties holds a comma-separated list of properties that should use - this animation when they change. -*/ -QString QmlNumericAnimation::properties() const -{ - Q_D(const QmlNumericAnimation); - return d->properties; -} - -void QmlNumericAnimation::setProperties(const QString &prop) -{ - Q_D(QmlNumericAnimation); - if (d->properties == prop) - return; - - d->properties = prop; - emit propertiesChanged(prop); -} - -/*! - \qmlproperty list NumericAnimation::filter - This property holds the items selected to be affected by this animation (all if not set). - \sa exclude -*/ -QList *QmlNumericAnimation::filter() -{ - Q_D(QmlNumericAnimation); - return &d->filter; -} - -/*! - \qmlproperty list NumericAnimation::exclude - This property holds the items not to be affected by this animation. - \sa filter -*/ -QList *QmlNumericAnimation::exclude() -{ - Q_D(QmlNumericAnimation); - return &d->exclude; -} - -void QmlNumericAnimationPrivate::valueChanged(qreal r) -{ - if (!fromSourced) { - if (from.isNull) { - fromValue = qvariant_cast(property.read()); - } else { - fromValue = from; - } - fromSourced = true; - } - - if (r == 1.) { - property.write(to.value); - } else { - qreal val = fromValue + (to-fromValue) * r; - property.write(val); - } -} - -void QmlNumericAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlNumericAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->na->setFromSourcedValue(&d->fromSourced); -} - -QAbstractAnimation *QmlNumericAnimation::qtAnimation() -{ - Q_D(QmlNumericAnimation); - return d->na; -} - -void QmlNumericAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction) -{ - Q_D(QmlNumericAnimation); - Q_UNUSED(direction); - - struct NTransitionData : public QmlTimeLineValue - { - QmlStateActions actions; - void setValue(qreal v) - { - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QmlBehaviour::_ignore = true; - if (v == 1.) - action.property.write(action.toValue.toDouble()); - else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (action.fromValue.isNull()) { - action.fromValue = QVariant(0.); - } - } - qreal start = action.fromValue.toDouble(); - qreal end = action.toValue.toDouble(); - qreal val = start + (end-start) * v; - action.property.write(val); - } - QmlBehaviour::_ignore = false; - } - } - }; - - QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); - for (int ii = 0; ii < props.count(); ++ii) - props[ii] = props.at(ii).trimmed(); - if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) - props.append(d->propertyName); - - if (d->userProperty.isValid() && props.isEmpty() && !target()) { - props.append(d->userProperty.value.name()); - d->target = d->userProperty.value.object(); - } - - NTransitionData *data = new NTransitionData; - - QSet objs; - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { - objs.insert(obj); - Action myAction = action; - if (d->from.isValid()) { - myAction.fromValue = QVariant(d->from); - } else { - myAction.fromValue = QVariant(); - } - if (d->to.isValid()) - myAction.toValue = QVariant(d->to); - - modified << action.property; - - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (d->to.isValid() && target() && !objs.contains(target())) { - QObject *obj = target(); - for (int jj = 0; jj < props.count(); ++jj) { - Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); - - if (d->from.isValid()) - myAction.fromValue = QVariant(d->from); - - myAction.toValue = QVariant(d->to); - myAction.bv = 0; - myAction.event = 0; - data->actions << myAction; - } - } - - if (data->actions.count()) { - d->na->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - } else { - delete data; - } + QmlVariantAnimation::setTo(t); } QML_DEFINE_TYPE(QmlNumericAnimation,NumericAnimation) @@ -1971,6 +1428,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, QML_DEFINE_TYPE(QmlParallelAnimation,ParallelAnimation) +//### profile and optimize QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, const QVariant &to, qreal progress) { if (from.userType() != to.userType()) @@ -1981,6 +1439,8 @@ QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, co } //convert a variant from string type to another animatable type +//### should use any registered string convertor +//### profile and optimize void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Type type) { if (variant.type() != QVariant::String) { @@ -2137,10 +1597,53 @@ void QmlVariantAnimation::setTo(const QVariant &t) /*! \qmlproperty string VariantAnimation::easing - This property holds the easing curve used for the transition. + \brief the easing curve used for the transition. + + Available values are: - See NumericAnimation::easing for a full discussion of easing, - and a list of available curves. + \list + \i \e easeNone - Easing equation function for a simple linear tweening, with no easing. + \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity. + \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity. + \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity. + \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity. + \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity. + \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity. + \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity. + \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity. + \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity. + \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. + \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity. + \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity. + \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity. + \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity. + \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. + \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity. + \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. + \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity. + \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. + \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration. + \endlist */ /*! @@ -2230,8 +1733,7 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r) if (r == 1.) { property.write(to); } else { - QVariant val = interpolateVariant(from, to, r); - property.write(val); + property.write(interpolateVariant(from, to, r)); } } @@ -2266,7 +1768,7 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, Q_D(QmlVariantAnimation); Q_UNUSED(direction); - struct NTransitionData : public QmlTimeLineValue + struct PropertyUpdater : public QmlTimeLineValue { QmlStateActions actions; void setValue(qreal v) @@ -2275,28 +1777,38 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, for (int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; + QmlBehaviour::_ignore = true; if (v == 1.) action.property.write(action.toValue); else { if (action.fromValue.isNull()) { action.fromValue = action.property.read(); /*if (action.fromValue.isNull()) - action.fromValue = QVariant(0.);*/ //XXX can we give a default value for any type? + action.fromValue = QVariant(0.);*/ //### can/should we give a default value for any type? } QVariant val = QmlVariantAnimationPrivate::interpolateVariant(action.fromValue, action.toValue, v); action.property.write(val); } + QmlBehaviour::_ignore = false; } } }; - QStringList props = d->properties.split(QLatin1Char(',')); + QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) props.append(d->propertyName); - NTransitionData *data = new NTransitionData; + /* ### we used to select properties of name 'color' by default for color animations + props << QLatin1String("color");*/ + + if (d->userProperty.isValid() && props.isEmpty() && !target()) { + props.append(d->userProperty.value.name()); + d->target = d->userProperty.value.object(); + } + + PropertyUpdater *data = new PropertyUpdater; QSet objs; for (int ii = 0; ii < actions.count(); ++ii) { @@ -2339,7 +1851,6 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType()); myAction.fromValue = d->from; } - d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType()); myAction.toValue = d->to; myAction.bv = 0; diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index b0dd261..00ff3d7 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -160,53 +160,6 @@ protected: }; QML_DECLARE_TYPE(QmlPauseAnimation) -class QmlColorAnimationPrivate; -class QmlColorAnimation : public QmlAbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlColorAnimation) - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QList* filter READ filter) - Q_PROPERTY(QList* exclude READ exclude) - -public: - QmlColorAnimation(QObject *parent=0); - virtual ~QmlColorAnimation(); - - int duration() const; - void setDuration(int); - - QColor from() const; - void setFrom(const QColor &); - - QColor to() const; - void setTo(const QColor &); - - QString easing() const; - void setEasing(const QString &); - - QList *filter(); - - QList *exclude(); - -protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); - -Q_SIGNALS: - void durationChanged(int); - void fromChanged(const QColor &); - void toChanged(const QColor &); - void easingChanged(const QString &); -}; -QML_DECLARE_TYPE(QmlColorAnimation) - class QmlRunScriptActionPrivate; class QmlRunScriptAction : public QmlAbstractAnimation { @@ -293,32 +246,32 @@ protected: }; QML_DECLARE_TYPE(QmlParentChangeAction) -class QmlNumericAnimationPrivate; -class QmlNumericAnimation : public QmlAbstractAnimation +class QmlVariantAnimationPrivate; +class QmlVariantAnimation : public QmlAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlNumericAnimation) + Q_DECLARE_PRIVATE(QmlVariantAnimation) Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY(QList* filter READ filter) Q_PROPERTY(QList* exclude READ exclude) public: - QmlNumericAnimation(QObject *parent=0); - virtual ~QmlNumericAnimation(); + QmlVariantAnimation(QObject *parent=0); + virtual ~QmlVariantAnimation(); int duration() const; void setDuration(int); - qreal from() const; - void setFrom(qreal); + QVariant from() const; + void setFrom(const QVariant &); - qreal to() const; - void setTo(qreal); + QVariant to() const; + void setTo(const QVariant &); QString easing() const; void setEasing(const QString &); @@ -338,19 +291,51 @@ protected: Q_SIGNALS: void durationChanged(int); - void fromChanged(qreal); - void toChanged(qreal); + void fromChanged(QVariant); + void toChanged(QVariant); void easingChanged(const QString &); void propertiesChanged(const QString &); }; -QML_DECLARE_TYPE(QmlNumericAnimation) +QML_DECLARE_TYPE(QmlVariantAnimation) -#if 0 -class QmlDiscreteAnimation : public QmlAbstractAnimation +class QmlColorAnimation : public QmlVariantAnimation { -Q_OBJECT + Q_OBJECT + Q_DECLARE_PRIVATE(QmlVariantAnimation) + Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) + +public: + QmlColorAnimation(QObject *parent=0); + virtual ~QmlColorAnimation(); + + QColor from() const; + void setFrom(const QColor &); + + QColor to() const; + void setTo(const QColor &); +}; +QML_DECLARE_TYPE(QmlColorAnimation) + +class QmlNumericAnimation : public QmlVariantAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlVariantAnimation) + + Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + +public: + QmlNumericAnimation(QObject *parent=0); + virtual ~QmlNumericAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); }; -#endif +QML_DECLARE_TYPE(QmlNumericAnimation) class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation @@ -404,58 +389,6 @@ protected: }; QML_DECLARE_TYPE(QmlParallelAnimation) -class QmlVariantAnimationPrivate; -class QmlVariantAnimation : public QmlAbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlVariantAnimation) - - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* filter READ filter) - Q_PROPERTY(QList* exclude READ exclude) - -public: - QmlVariantAnimation(QObject *parent=0); - virtual ~QmlVariantAnimation(); - - int duration() const; - void setDuration(int); - - QVariant from() const; - void setFrom(const QVariant &); - - QVariant to() const; - void setTo(const QVariant &); - - QString easing() const; - void setEasing(const QString &); - - QString properties() const; - void setProperties(const QString &); - - QList *filter(); - QList *exclude(); - -protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); - -Q_SIGNALS: - void durationChanged(int); - void fromChanged(QVariant); - void toChanged(QVariant); - void easingChanged(const QString &); - void propertiesChanged(const QString &); -}; -QML_DECLARE_TYPE(QmlVariantAnimation) - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index f09ab88..ff31895 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -207,40 +207,6 @@ public: QPauseAnimation *pa; }; -class QmlColorAnimationPrivate : public QmlAbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QmlColorAnimation) -public: - QmlColorAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - ca(0), value(this, &QmlColorAnimationPrivate::valueChanged) - { - if (!colorInterpolator) - colorInterpolator = QVariantAnimationPrivate::getInterpolator(QVariant::Color); - } - - void init(); - - QString easing; - - QColor fromValue; - QColor toValue; - - QList filter; - QList exclude; - - bool fromSourced; - bool fromIsDefined; - bool toIsDefined; - - QmlTimeLineValueAnimator *ca; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy value; - - static QVariantAnimation::Interpolator colorInterpolator; -}; - class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate { Q_DECLARE_PUBLIC(QmlRunScriptAction) @@ -295,32 +261,6 @@ public: QActionAnimation *cpa; }; -class QmlNumericAnimationPrivate : public QmlAbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QmlNumericAnimation) -public: - QmlNumericAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), na(0), value(this, &QmlNumericAnimationPrivate::valueChanged) {} - - void init(); - - QmlNullableValue from; - QmlNullableValue to; - - QString easing; - - QString properties; - QList filter; - QList exclude; - - bool fromSourced; - qreal fromValue; - QmlTimeLineValueAnimator *na; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy value; -}; - class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate { Q_DECLARE_PUBLIC(QmlAnimationGroup) -- cgit v0.12 From 4b3933bc4d6c5e2ae4507e5df92c6f877e3f621e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Jun 2009 17:07:10 +1000 Subject: Expose extended type URLs through the QML DOM API --- src/declarative/qml/qmlcompiler.cpp | 5 ++++- src/declarative/qml/qmlcomponent.cpp | 1 + src/declarative/qml/qmldom.cpp | 10 ++++++++++ src/declarative/qml/qmldom.h | 1 + src/declarative/qml/qmlparser_p.h | 2 ++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 8297ac4..cb0c571 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -570,7 +570,10 @@ void QmlCompiler::compileTree(Object *tree) bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) { Q_ASSERT (obj->type != -1); - obj->metatype = output->types.at(obj->type).metaObject(); + const QmlCompiledData::TypeReference &tr = output->types.at(obj->type); + obj->metatype = tr.metaObject(); + if (tr.component) + obj->url = tr.component->url(); if (output->types.at(obj->type).className == "Component") { COMPILE_CHECK(compileComponent(obj, ctxt)); diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index f90af4a..3429813 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -296,6 +296,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int star cc->addref(); d->start = start; d->count = count; + d->url = cc->url; } /*! diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index d2608c8..42b40b6 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -791,6 +791,16 @@ int QmlDomObject::length() const return 0; } +// Returns the URL of the type, if it is an external type, or an empty URL if +// not +QUrl QmlDomObject::url() const +{ + if (d && d->object) + return d->object->url; + else + return QUrl(); +} + QmlDomBasicValuePrivate::QmlDomBasicValuePrivate() : value(0) { diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index fde35a8..ab3e39f 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -143,6 +143,7 @@ public: int position() const; int length() const; + QUrl url() const; private: friend class QmlDomDocument; friend class QmlDomComponent; diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index a38ce69..78040da 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -102,6 +102,8 @@ namespace QmlParser // QmlCompiledData::types array, or -1 if the object is a fetched // object. int type; + // The url of this object if it is an external type. Used by the DOM + QUrl url; // The name of this type QByteArray typeName; // The id assigned to the object (if any). -- cgit v0.12 From 91a7af3f44dc941929e0f93b98b2f2074f26086d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 09:25:19 +1000 Subject: Optimize refactored animation classes. --- src/declarative/util/qmlanimation.cpp | 42 ++++++++++++++++++++++++++--------- src/declarative/util/qmlanimation_p.h | 4 +++- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index f2a91eb..4e637d5 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -720,6 +720,8 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent) { Q_D(QmlVariantAnimation); d->init(); + d->interpolatorType = QMetaType::QColor; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } QmlColorAnimation::~QmlColorAnimation() @@ -1200,6 +1202,8 @@ QmlNumericAnimation::QmlNumericAnimation(QObject *parent) { Q_D(QmlVariantAnimation); d->init(); + d->interpolatorType = QMetaType::QReal; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } QmlNumericAnimation::~QmlNumericAnimation() @@ -1726,6 +1730,7 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r) if (!fromSourced) { if (!fromIsDefined) { from = property.read(); + convertVariant(from, (QVariant::Type)(interpolatorType ? interpolatorType : property.propertyType())); } fromSourced = true; } @@ -1733,7 +1738,10 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r) if (r == 1.) { property.write(to); } else { - property.write(interpolateVariant(from, to, r)); + if (interpolator) + property.write(interpolator(from.constData(), to.constData(), r)); + else + property.write(interpolateVariant(from, to, r)); //### optimize } } @@ -1751,9 +1759,9 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) else d->property = d->userProperty; - d->convertVariant(d->to, (QVariant::Type)d->property.propertyType()); + d->convertVariant(d->to, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); if (d->fromIsDefined) - d->convertVariant(d->from, (QVariant::Type)d->property.propertyType()); + d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); d->fromSourced = false; d->value.QmlTimeLineValue::setValue(0.); @@ -1771,6 +1779,9 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, struct PropertyUpdater : public QmlTimeLineValue { QmlStateActions actions; + int interpolatorType; //for Numeric/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; void setValue(qreal v) { QmlTimeLineValue::setValue(v); @@ -1783,11 +1794,18 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, else { if (action.fromValue.isNull()) { action.fromValue = action.property.read(); - /*if (action.fromValue.isNull()) - action.fromValue = QVariant(0.);*/ //### can/should we give a default value for any type? + if (interpolatorType) + QmlVariantAnimationPrivate::convertVariant(action.fromValue, (QVariant::Type)interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); + } } - QVariant val = QmlVariantAnimationPrivate::interpolateVariant(action.fromValue, action.toValue, v); - action.property.write(val); + if (interpolator) + action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v)); } QmlBehaviour::_ignore = false; } @@ -1809,6 +1827,8 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, } PropertyUpdater *data = new PropertyUpdater; + data->interpolatorType = d->interpolatorType; + data->interpolator = d->interpolator; QSet objs; for (int ii = 0; ii < actions.count(); ++ii) { @@ -1831,8 +1851,8 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, if (d->toIsDefined) myAction.toValue = d->to; - d->convertVariant(myAction.fromValue, (QVariant::Type)myAction.property.propertyType()); - d->convertVariant(myAction.toValue, (QVariant::Type)myAction.property.propertyType()); + d->convertVariant(myAction.fromValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); + d->convertVariant(myAction.toValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); modified << action.property; @@ -1848,10 +1868,10 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, myAction.property = QmlMetaProperty(obj, props.at(jj)); if (d->fromIsDefined) { - d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType()); + d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); myAction.fromValue = d->from; } - d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType()); + d->convertVariant(d->to, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); myAction.toValue = d->to; myAction.bv = 0; myAction.event = 0; diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index ff31895..7b0649a 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -306,7 +306,7 @@ class QmlVariantAnimationPrivate : public QmlAbstractAnimationPrivate public: QmlVariantAnimationPrivate() : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} + interpolatorType(0), interpolator(0), va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} void init(); @@ -322,6 +322,8 @@ public: bool fromSourced; bool fromIsDefined; bool toIsDefined; + int interpolatorType; + QVariantAnimation::Interpolator interpolator; QmlTimeLineValueAnimator *va; virtual void valueChanged(qreal); -- cgit v0.12 From baff8c7e3bba56c3d9c53300ed4524c4b3546c15 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 09:40:42 +1000 Subject: Rename VariantAnimation -> PropertyAnimation. --- doc/src/declarative/elements.qdoc | 2 +- src/declarative/util/qmlanimation.cpp | 143 +++++++++++++++++----------------- src/declarative/util/qmlanimation.h | 20 ++--- src/declarative/util/qmlanimation_p.h | 10 +-- 4 files changed, 87 insertions(+), 88 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 35d746b..daf34c4 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -26,9 +26,9 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list +\o \l PropertyAnimation \o \l NumericAnimation \o \l ColorAnimation -\o \l VariantAnimation \o \l PauseAnimation \o \l SequentialAnimation \o \l ParallelAnimation diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4e637d5..e42672d 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -60,7 +60,7 @@ /* TODO: Check for any memory leaks easing should be a QEasingCurve-type property - All other XXXs + All other XXXs and ###s */ QT_BEGIN_NAMESPACE @@ -693,7 +693,7 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() /*! \qmlclass ColorAnimation QmlColorAnimation - \inherits Animation + \inherits PropertyAnimation \brief The ColorAnimation allows you to animate color changes. \code @@ -716,9 +716,9 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() */ QmlColorAnimation::QmlColorAnimation(QObject *parent) -: QmlVariantAnimation(parent) +: QmlPropertyAnimation(parent) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); d->init(); d->interpolatorType = QMetaType::QColor; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); @@ -738,13 +738,13 @@ QmlColorAnimation::~QmlColorAnimation() */ QColor QmlColorAnimation::from() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->from.value(); } void QmlColorAnimation::setFrom(const QColor &f) { - QmlVariantAnimation::setFrom(f); + QmlPropertyAnimation::setFrom(f); } /*! @@ -757,13 +757,13 @@ void QmlColorAnimation::setFrom(const QColor &f) */ QColor QmlColorAnimation::to() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->to.value(); } void QmlColorAnimation::setTo(const QColor &t) { - QmlVariantAnimation::setTo(t); + QmlPropertyAnimation::setTo(t); } QML_DEFINE_TYPE(QmlColorAnimation,ColorAnimation) @@ -1176,7 +1176,7 @@ QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction) /*! \qmlclass NumericAnimation QmlNumericAnimation - \inherits Animation + \inherits PropertyAnimation \brief The NumericAnimation allows you to animate changes in properties of type qreal. Animate a set of properties over 200ms, from their values in the start state to @@ -1198,9 +1198,9 @@ QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction) */ QmlNumericAnimation::QmlNumericAnimation(QObject *parent) -: QmlVariantAnimation(parent) +: QmlPropertyAnimation(parent) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); d->init(); d->interpolatorType = QMetaType::QReal; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); @@ -1221,13 +1221,13 @@ QmlNumericAnimation::~QmlNumericAnimation() */ qreal QmlNumericAnimation::from() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->from.toDouble(); //### toFloat? } void QmlNumericAnimation::setFrom(qreal f) { - QmlVariantAnimation::setFrom(f); + QmlPropertyAnimation::setFrom(f); } /*! @@ -1241,13 +1241,13 @@ void QmlNumericAnimation::setFrom(qreal f) */ qreal QmlNumericAnimation::to() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->to.toDouble(); //### toFloat? } void QmlNumericAnimation::setTo(qreal t) { - QmlVariantAnimation::setTo(t); + QmlPropertyAnimation::setTo(t); } QML_DEFINE_TYPE(QmlNumericAnimation,NumericAnimation) @@ -1433,7 +1433,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, QML_DEFINE_TYPE(QmlParallelAnimation,ParallelAnimation) //### profile and optimize -QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, const QVariant &to, qreal progress) +QVariant QmlPropertyAnimationPrivate::interpolateVariant(const QVariant &from, const QVariant &to, qreal progress) { if (from.userType() != to.userType()) return QVariant(); @@ -1445,7 +1445,7 @@ QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, co //convert a variant from string type to another animatable type //### should use any registered string convertor //### profile and optimize -void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Type type) +void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, QVariant::Type type) { if (variant.type() != QVariant::String) { variant.convert(type); @@ -1488,9 +1488,9 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ } /*! - \qmlclass VariantAnimation QmlVariantAnimation + \qmlclass PropertyAnimation QmlPropertyAnimation \inherits Animation - \brief The VariantAnimation allows you to animate changes in properties of type QVariant. + \brief The PropertyAnimation allows you to animate property changes. Animate a size property over 200ms, from its current size to 20-by-20: \code @@ -1498,51 +1498,51 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ \endcode */ -QmlVariantAnimation::QmlVariantAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlVariantAnimationPrivate), parent) +QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) +: QmlAbstractAnimation(*(new QmlPropertyAnimationPrivate), parent) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); d->init(); } -QmlVariantAnimation::~QmlVariantAnimation() +QmlPropertyAnimation::~QmlPropertyAnimation() { } -void QmlVariantAnimationPrivate::init() +void QmlPropertyAnimationPrivate::init() { - Q_Q(QmlVariantAnimation); + Q_Q(QmlPropertyAnimation); va = new QmlTimeLineValueAnimator(q); va->setStartValue(QVariant(0.0f)); va->setEndValue(QVariant(1.0f)); } /*! - \qmlproperty int VariantAnimation::duration + \qmlproperty int PropertyAnimation::duration This property holds the duration of the transition, in milliseconds. The default value is 250. */ /*! - \property QmlVariantAnimation::duration + \property QmlPropertyAnimation::duration \brief the duration of the transition, in milliseconds. The default value is 250. */ -int QmlVariantAnimation::duration() const +int QmlPropertyAnimation::duration() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->va->duration(); } -void QmlVariantAnimation::setDuration(int duration) +void QmlPropertyAnimation::setDuration(int duration) { if (duration < 0) { - qWarning("QmlVariantAnimation: Cannot set a duration of < 0"); + qWarning("QmlPropertyAnimation: Cannot set a duration of < 0"); return; } - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->va->duration() == duration) return; d->va->setDuration(duration); @@ -1550,23 +1550,23 @@ void QmlVariantAnimation::setDuration(int duration) } /*! - \qmlproperty real VariantAnimation::from + \qmlproperty real PropertyAnimation::from This property holds the starting value. If not set, then the value defined in the start state of the transition. */ /*! - \property QmlVariantAnimation::from + \property QmlPropertyAnimation::from \brief the starting value. */ -QVariant QmlVariantAnimation::from() const +QVariant QmlPropertyAnimation::from() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->from; } -void QmlVariantAnimation::setFrom(const QVariant &f) +void QmlPropertyAnimation::setFrom(const QVariant &f) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->fromIsDefined && f == d->from) return; d->from = f; @@ -1575,23 +1575,23 @@ void QmlVariantAnimation::setFrom(const QVariant &f) } /*! - \qmlproperty real VariantAnimation::to + \qmlproperty real PropertyAnimation::to This property holds the ending value. If not set, then the value defined in the end state of the transition. */ /*! - \property QmlVariantAnimation::to + \property QmlPropertyAnimation::to \brief the ending value. */ -QVariant QmlVariantAnimation::to() const +QVariant QmlPropertyAnimation::to() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->to; } -void QmlVariantAnimation::setTo(const QVariant &t) +void QmlPropertyAnimation::setTo(const QVariant &t) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->toIsDefined && t == d->to) return; d->to = t; @@ -1600,7 +1600,7 @@ void QmlVariantAnimation::setTo(const QVariant &t) } /*! - \qmlproperty string VariantAnimation::easing + \qmlproperty string PropertyAnimation::easing \brief the easing curve used for the transition. Available values are: @@ -1651,20 +1651,20 @@ void QmlVariantAnimation::setTo(const QVariant &t) */ /*! - \property QmlVariantAnimation::easing + \property QmlPropertyAnimation::easing \brief the easing curve to use. \sa QEasingCurve */ -QString QmlVariantAnimation::easing() const +QString QmlPropertyAnimation::easing() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->easing; } -void QmlVariantAnimation::setEasing(const QString &e) +void QmlPropertyAnimation::setEasing(const QString &e) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->easing == e) return; @@ -1674,28 +1674,28 @@ void QmlVariantAnimation::setEasing(const QString &e) } /*! - \qmlproperty string VariantAnimation::properties + \qmlproperty string PropertyAnimation::properties This property holds the properties this animation should be applied to. This is a comma-separated list of properties that should use this animation when they change. */ /*! - \property QmlVariantAnimation::properties + \property QmlPropertyAnimation::properties \brief the properties this animation should be applied to properties holds a copy separated list of properties that should use this animation when they change. */ -QString QmlVariantAnimation::properties() const +QString QmlPropertyAnimation::properties() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->properties; } -void QmlVariantAnimation::setProperties(const QString &prop) +void QmlPropertyAnimation::setProperties(const QString &prop) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->properties == prop) return; @@ -1704,28 +1704,28 @@ void QmlVariantAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list VariantAnimation::filter + \qmlproperty list PropertyAnimation::filter This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList *QmlVariantAnimation::filter() +QList *QmlPropertyAnimation::filter() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return &d->filter; } /*! - \qmlproperty list VariantAnimation::exclude + \qmlproperty list PropertyAnimation::exclude This property holds the items not to be affected by this animation. \sa filter */ -QList *QmlVariantAnimation::exclude() +QList *QmlPropertyAnimation::exclude() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return &d->exclude; } -void QmlVariantAnimationPrivate::valueChanged(qreal r) +void QmlPropertyAnimationPrivate::valueChanged(qreal r) { if (!fromSourced) { if (!fromIsDefined) { @@ -1745,15 +1745,15 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r) } } -QAbstractAnimation *QmlVariantAnimation::qtAnimation() +QAbstractAnimation *QmlPropertyAnimation::qtAnimation() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return d->va; } -void QmlVariantAnimation::prepare(QmlMetaProperty &p) +void QmlPropertyAnimation::prepare(QmlMetaProperty &p) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->userProperty.isNull) d->property = p; else @@ -1769,11 +1769,11 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) d->va->setFromSourcedValue(&d->fromSourced); } -void QmlVariantAnimation::transition(QmlStateActions &actions, +void QmlPropertyAnimation::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); Q_UNUSED(direction); struct PropertyUpdater : public QmlTimeLineValue @@ -1795,7 +1795,7 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, if (action.fromValue.isNull()) { action.fromValue = action.property.read(); if (interpolatorType) - QmlVariantAnimationPrivate::convertVariant(action.fromValue, (QVariant::Type)interpolatorType); + QmlPropertyAnimationPrivate::convertVariant(action.fromValue, (QVariant::Type)interpolatorType); } if (!interpolatorType) { int propType = action.property.propertyType(); @@ -1886,7 +1886,6 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, } } -//XXX whats the best name for this? (just Animation?) -QML_DEFINE_TYPE(QmlVariantAnimation,VariantAnimation) +QML_DEFINE_TYPE(QmlPropertyAnimation,PropertyAnimation) QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 00ff3d7..a91394d 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -246,11 +246,11 @@ protected: }; QML_DECLARE_TYPE(QmlParentChangeAction) -class QmlVariantAnimationPrivate; -class QmlVariantAnimation : public QmlAbstractAnimation +class QmlPropertyAnimationPrivate; +class QmlPropertyAnimation : public QmlAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlVariantAnimation) + Q_DECLARE_PRIVATE(QmlPropertyAnimation) Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) @@ -261,8 +261,8 @@ class QmlVariantAnimation : public QmlAbstractAnimation Q_PROPERTY(QList* exclude READ exclude) public: - QmlVariantAnimation(QObject *parent=0); - virtual ~QmlVariantAnimation(); + QmlPropertyAnimation(QObject *parent=0); + virtual ~QmlPropertyAnimation(); int duration() const; void setDuration(int); @@ -296,12 +296,12 @@ Q_SIGNALS: void easingChanged(const QString &); void propertiesChanged(const QString &); }; -QML_DECLARE_TYPE(QmlVariantAnimation) +QML_DECLARE_TYPE(QmlPropertyAnimation) -class QmlColorAnimation : public QmlVariantAnimation +class QmlColorAnimation : public QmlPropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlVariantAnimation) + Q_DECLARE_PRIVATE(QmlPropertyAnimation) Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) @@ -317,10 +317,10 @@ public: }; QML_DECLARE_TYPE(QmlColorAnimation) -class QmlNumericAnimation : public QmlVariantAnimation +class QmlNumericAnimation : public QmlPropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlVariantAnimation) + Q_DECLARE_PRIVATE(QmlPropertyAnimation) Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 7b0649a..da5ed97 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -300,13 +300,13 @@ public: QAnimationGroup *ag; }; -class QmlVariantAnimationPrivate : public QmlAbstractAnimationPrivate +class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlVariantAnimation) + Q_DECLARE_PUBLIC(QmlPropertyAnimation) public: - QmlVariantAnimationPrivate() + QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - interpolatorType(0), interpolator(0), va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} + interpolatorType(0), interpolator(0), va(0), value(this, &QmlPropertyAnimationPrivate::valueChanged) {} void init(); @@ -328,7 +328,7 @@ public: QmlTimeLineValueAnimator *va; virtual void valueChanged(qreal); - QmlTimeLineValueProxy value; + QmlTimeLineValueProxy value; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, QVariant::Type type); -- cgit v0.12 From 662488175fb9c6a44e9641867177b5396c507891 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 11:10:56 +1000 Subject: Fix animation bugs, and add autotest. --- src/declarative/util/qmlanimation.cpp | 13 ++-- tests/auto/declarative/animations/animations.pro | 5 ++ .../auto/declarative/animations/data/badtype1.qml | 10 +++ .../auto/declarative/animations/data/badtype2.qml | 10 +++ .../auto/declarative/animations/data/badtype3.qml | 10 +++ .../auto/declarative/animations/data/badtype4.qml | 23 ++++++ tests/auto/declarative/animations/data/color.qml | 10 +++ .../declarative/animations/data/mixedtype1.qml | 22 ++++++ .../declarative/animations/data/mixedtype2.qml | 22 ++++++ tests/auto/declarative/animations/data/number.qml | 10 +++ .../auto/declarative/animations/tst_animations.cpp | 82 ++++++++++++++++++++++ 11 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 tests/auto/declarative/animations/animations.pro create mode 100644 tests/auto/declarative/animations/data/badtype1.qml create mode 100644 tests/auto/declarative/animations/data/badtype2.qml create mode 100644 tests/auto/declarative/animations/data/badtype3.qml create mode 100644 tests/auto/declarative/animations/data/badtype4.qml create mode 100644 tests/auto/declarative/animations/data/color.qml create mode 100644 tests/auto/declarative/animations/data/mixedtype1.qml create mode 100644 tests/auto/declarative/animations/data/mixedtype2.qml create mode 100644 tests/auto/declarative/animations/data/number.qml create mode 100644 tests/auto/declarative/animations/tst_animations.cpp diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index e42672d..42ed40b 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1439,7 +1439,10 @@ QVariant QmlPropertyAnimationPrivate::interpolateVariant(const QVariant &from, c return QVariant(); QVariantAnimation::Interpolator interpolator = QVariantAnimationPrivate::getInterpolator(from.userType()); - return interpolator(from.constData(), to.constData(), progress); + if (interpolator) + return interpolator(from.constData(), to.constData(), progress); + else + return QVariant(); } //convert a variant from string type to another animatable type @@ -1851,8 +1854,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, if (d->toIsDefined) myAction.toValue = d->to; - d->convertVariant(myAction.fromValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); - d->convertVariant(myAction.toValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); + d->convertVariant(myAction.fromValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); + d->convertVariant(myAction.toValue, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); modified << action.property; @@ -1868,10 +1871,10 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, myAction.property = QmlMetaProperty(obj, props.at(jj)); if (d->fromIsDefined) { - d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); + d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); myAction.fromValue = d->from; } - d->convertVariant(d->to, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : d->property.propertyType())); + d->convertVariant(d->to, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); myAction.toValue = d->to; myAction.bv = 0; myAction.event = 0; diff --git a/tests/auto/declarative/animations/animations.pro b/tests/auto/declarative/animations/animations.pro new file mode 100644 index 0000000..419da4e --- /dev/null +++ b/tests/auto/declarative/animations/animations.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_animations.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/animations/data/badtype1.qml b/tests/auto/declarative/animations/data/badtype1.qml new file mode 100644 index 0000000..691d2b3 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype1.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: PropertyAnimation { from: "blue"; to: "green"; running: true; } + } +} diff --git a/tests/auto/declarative/animations/data/badtype2.qml b/tests/auto/declarative/animations/data/badtype2.qml new file mode 100644 index 0000000..18d9079 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype2.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumericAnimation { from: "blue"; to: "green"; running: true; } + } +} diff --git a/tests/auto/declarative/animations/data/badtype3.qml b/tests/auto/declarative/animations/data/badtype3.qml new file mode 100644 index 0000000..f1a89b6 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype3.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + color: ColorAnimation { from: 10; to: 15; running: true; } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml new file mode 100644 index 0000000..e3d312e --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype4.qml @@ -0,0 +1,23 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; color: "blue" } + } + transitions: Transition { + ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + //NumericAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/animations/data/color.qml b/tests/auto/declarative/animations/data/color.qml new file mode 100644 index 0000000..051e0e1 --- /dev/null +++ b/tests/auto/declarative/animations/data/color.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + color: PropertyAnimation { to: "green"; running: true } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/declarative/animations/data/mixedtype1.qml b/tests/auto/declarative/animations/data/mixedtype1.qml new file mode 100644 index 0000000..415bbfb --- /dev/null +++ b/tests/auto/declarative/animations/data/mixedtype1.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; width: 40 } + } + transitions: Transition { + PropertyAnimation { properties: "x,width"; duration: 1000 } //x is real, width is int + } +} diff --git a/tests/auto/declarative/animations/data/mixedtype2.qml b/tests/auto/declarative/animations/data/mixedtype2.qml new file mode 100644 index 0000000..0e9fb8d --- /dev/null +++ b/tests/auto/declarative/animations/data/mixedtype2.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; color: "blue" } + } + transitions: Transition { + PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/animations/data/number.qml b/tests/auto/declarative/animations/data/number.qml new file mode 100644 index 0000000..feb551b --- /dev/null +++ b/tests/auto/declarative/animations/data/number.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: PropertyAnimation { from: 0; to: 200; duration: 1000; running: true } + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp new file mode 100644 index 0000000..1895cef2 --- /dev/null +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include + +class tst_animations : public QObject +{ + Q_OBJECT +public: + tst_animations() {} + +private slots: + void badTypes(); + //void mixedTypes(); +}; + +void tst_animations::badTypes() +{ + //don't crash + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/badtype1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } + + //make sure we get a compiler error + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype2.qml")); + QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"blue\" to double number")); + } + + //make sure we get a compiler error + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype3.qml")); + QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"10\" to color")); + } +} + +/*//test animating mixed types with property animation + //for example, int + real; color + real; etc +void tst_animations::mixedTypes() +{ + //### this one isn't real robust because width will likely change to real as well + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } + + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype2.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } +}*/ + +QTEST_MAIN(tst_animations) + +#include "tst_animations.moc" -- cgit v0.12 From ffc9e62cbf7e24cd04a1202de1b3e618f9e12642 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 11:16:57 +1000 Subject: Rename NumericAnimation -> NumberAnimation --- demos/declarative/calculator/calculator.qml | 4 +- demos/declarative/contacts/Button.qml | 2 +- demos/declarative/contacts/ContactField.qml | 2 +- demos/declarative/contacts/FieldText.qml | 4 +- demos/declarative/contacts/RemoveButton.qml | 4 +- demos/declarative/contacts/contacts.qml | 8 +-- demos/declarative/flickr/content/ImageDetails.qml | 2 +- demos/declarative/flickr/content/Loading.qml | 2 +- demos/declarative/flickr/content/MediaLineEdit.qml | 2 +- demos/declarative/flickr/content/ScrollBar.qml | 2 +- demos/declarative/flickr/content/Star.qml | 2 +- demos/declarative/flickr/flickr.qml | 6 +-- demos/declarative/flickr/flickr2.qml | 12 ++--- demos/declarative/webbrowser/webbrowser.qml | 10 ++-- doc/src/declarative/animation.qdoc | 12 ++--- doc/src/declarative/elements.qdoc | 2 +- doc/src/declarative/qmlforcpp.qdoc | 6 +-- doc/src/declarative/tutorial3.qdoc | 4 +- examples/declarative/animation/animation.qml | 4 +- examples/declarative/behaviours/test.qml | 10 ++-- examples/declarative/easing/easing.qml | 4 +- examples/declarative/flowview/flowview.qml | 8 +-- examples/declarative/follow/follow.qml | 4 +- examples/declarative/follow/pong.qml | 4 +- examples/declarative/listview/highlight.qml | 2 +- examples/declarative/listview/recipes.qml | 2 +- examples/declarative/minehunt/minehunt.qml | 4 +- examples/declarative/scrollbar/display.qml | 2 +- examples/declarative/slideswitch/Switch.qml | 2 +- examples/declarative/states/transitions.qml | 6 +-- .../1_Drawing_and_Animation/5/RemoveButton.qml | 2 +- .../contacts/1_Drawing_and_Animation/GroupBox.qml | 2 +- .../tutorials/contacts/2_Reuse/1/RemoveButton.qml | 2 +- .../tutorials/contacts/2_Reuse/1a/RemoveButton.qml | 2 +- .../contacts/2_Reuse/1b/lib/RemoveButton.qml | 2 +- .../tutorials/contacts/2_Reuse/2/RemoveButton.qml | 2 +- .../tutorials/contacts/2_Reuse/3/ContactField.qml | 2 +- .../tutorials/contacts/2_Reuse/3/FieldText.qml | 4 +- .../tutorials/contacts/2_Reuse/3/RemoveButton.qml | 2 +- .../tutorials/contacts/2_Reuse/4/ContactField.qml | 2 +- .../tutorials/contacts/2_Reuse/4/FieldText.qml | 4 +- .../tutorials/contacts/2_Reuse/4/RemoveButton.qml | 2 +- .../tutorials/contacts/2_Reuse/GroupBox.qml | 2 +- .../contacts/3_Collections/2/ContactView.qml | 2 +- .../contacts/3_Collections/3/ContactView.qml | 2 +- .../tutorials/contacts/3_Collections/GroupBox.qml | 2 +- .../contacts/3_Collections/lib/Button.qml | 2 +- .../contacts/3_Collections/lib/ContactField.qml | 2 +- .../contacts/3_Collections/lib/FieldText.qml | 4 +- .../contacts/3_Collections/lib/RemoveButton.qml | 2 +- .../tutorials/helloworld/t3/tutorial3.qml | 2 +- examples/declarative/velocity/Day.qml | 2 +- .../declarative/webview/content/SpinSquare.qml | 2 +- examples/declarative/xmldata/yahoonews.qml | 4 +- src/declarative/fx/qfxflipable.cpp | 2 +- src/declarative/fx/qfxhighlightfilter.cpp | 2 +- src/declarative/fx/qfxlayouts.cpp | 24 ++++----- src/declarative/qml/qmldom.cpp | 10 ++-- src/declarative/util/qmlanimation.cpp | 60 +++++++++++----------- src/declarative/util/qmlanimation.h | 8 +-- src/declarative/util/qmlbehaviour.cpp | 2 +- src/declarative/util/qmlfollow.cpp | 2 +- .../auto/declarative/animations/data/badtype2.qml | 2 +- .../auto/declarative/animations/data/badtype4.qml | 2 +- .../visual/bindinganimation/bindinganimation.qml | 2 +- tests/auto/declarative/visual/easing/easing.qml | 2 +- .../auto/declarative/visual/flipable/flipable.xml | 10 ++-- .../visual/pauseAnimation/pauseAnimation.qml | 4 +- 68 files changed, 163 insertions(+), 163 deletions(-) diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 145435b..2a297ef 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -120,8 +120,8 @@ Rect { transitions: [ Transition { - NumericAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } - NumericAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 } + NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } + NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 } } ] } diff --git a/demos/declarative/contacts/Button.qml b/demos/declarative/contacts/Button.qml index 3b76a13..295e6cd 100644 --- a/demos/declarative/contacts/Button.qml +++ b/demos/declarative/contacts/Button.qml @@ -49,7 +49,7 @@ Item { ] } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } diff --git a/demos/declarative/contacts/ContactField.qml b/demos/declarative/contacts/ContactField.qml index 003e723..156c00d 100644 --- a/demos/declarative/contacts/ContactField.qml +++ b/demos/declarative/contacts/ContactField.qml @@ -51,7 +51,7 @@ Item { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "width,rightMargin" duration: 200 } diff --git a/demos/declarative/contacts/FieldText.qml b/demos/declarative/contacts/FieldText.qml index 39e45d4..333a5f6 100644 --- a/demos/declarative/contacts/FieldText.qml +++ b/demos/declarative/contacts/FieldText.qml @@ -74,7 +74,7 @@ Rect { text: fieldText.label opacity: textEdit.text == '' ? 1 : 0 opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -148,7 +148,7 @@ Rect { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,leftMargin,rightMargin" duration: 200 } diff --git a/demos/declarative/contacts/RemoveButton.qml b/demos/declarative/contacts/RemoveButton.qml index 8f46fcb..514c978 100644 --- a/demos/declarative/contacts/RemoveButton.qml +++ b/demos/declarative/contacts/RemoveButton.qml @@ -77,7 +77,7 @@ Rect { opacity: 0 } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -117,7 +117,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index 0ce9948..c52ef6d 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -123,7 +123,7 @@ Rect { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { duration: 500 properties: "yPosition,height,opacity" } @@ -221,7 +221,7 @@ Rect { color: 'white' opacity: contacts.mode == 'list' ? 1 : 0 opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -288,7 +288,7 @@ Rect { Transition { fromState: "*" toState: "*" - NumericAnimation { + NumberAnimation { property: "bottomMargin" duration: 250 } @@ -319,7 +319,7 @@ Rect { Transition { fromState: "*" toState: "*" - NumericAnimation { + NumberAnimation { property: "opacity" duration: 500 } diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index ccc91cb..a413726 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -135,7 +135,7 @@ Flipable { transitions: [ Transition { - NumericAnimation { easing: "easeInOutQuad"; properties: "rotation"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "rotation"; duration: 500 } } ] } diff --git a/demos/declarative/flickr/content/Loading.qml b/demos/declarative/flickr/content/Loading.qml index 7488a66..0a8a51a 100644 --- a/demos/declarative/flickr/content/Loading.qml +++ b/demos/declarative/flickr/content/Loading.qml @@ -1,6 +1,6 @@ Image { id: Loading; source: "pics/loading.png"; transformOrigin: "Center" - rotation: NumericAnimation { + rotation: NumberAnimation { id: "RotationAnimation"; from: 0; to: 360; running: Loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml index 691bb5b..b9a5775 100644 --- a/demos/declarative/flickr/content/MediaLineEdit.qml +++ b/demos/declarative/flickr/content/MediaLineEdit.qml @@ -41,7 +41,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" } } ] diff --git a/demos/declarative/flickr/content/ScrollBar.qml b/demos/declarative/flickr/content/ScrollBar.qml index 2c4ff54..551f0ea 100644 --- a/demos/declarative/flickr/content/ScrollBar.qml +++ b/demos/declarative/flickr/content/ScrollBar.qml @@ -28,7 +28,7 @@ Item { Transition { fromState: "*" toState: "*" - NumericAnimation { + NumberAnimation { target: Container properties: "opacity" duration: 400 diff --git a/demos/declarative/flickr/content/Star.qml b/demos/declarative/flickr/content/Star.qml index 22fc138..437450d 100644 --- a/demos/declarative/flickr/content/Star.qml +++ b/demos/declarative/flickr/content/Star.qml @@ -35,7 +35,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "opacity,scale,x,y" easing: "easeOutBounce" } diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 83448ee..3ce442e 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -99,13 +99,13 @@ Item { Transition { fromState: "*"; toState: "Details" ParentChangeAction { } - NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } }, Transition { fromState: "Details"; toState: "*" SequentialAnimation { ParentChangeAction { } - NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } SetPropertyAction { filter: Wrapper; properties: "z" } } } @@ -194,7 +194,7 @@ Item { transitions: [ Transition { fromState: "*"; toState: "*" - NumericAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } + NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } } ] } diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 79f7a32..807a0ca 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -100,13 +100,13 @@ Item { Transition { fromState: "*"; toState: "Details" ParentChangeAction { } - NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } }, Transition { fromState: "Details"; toState: "*" SequentialAnimation { ParentChangeAction { } - NumericAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } SetPropertyAction { filter: Wrapper; properties: "z" } } } @@ -146,14 +146,14 @@ Item { SequentialAnimation { SetPropertyAction { target: Wrapper; property: "moveToParent" } ParallelAnimation { - NumericAnimation { + NumberAnimation { target: Wrapper properties: "x,y" to: 0 easing: "easeOutQuad" duration: 350 } - NumericAnimation { target: Wrapper; properties: "scale,angle"; duration: 350 } + NumberAnimation { target: Wrapper; properties: "scale,angle"; duration: 350 } } } }, @@ -163,14 +163,14 @@ Item { PauseAnimation { duration: Math.floor(index/7)*100 } SetPropertyAction { target: Wrapper; property: "moveToParent" } ParallelAnimation { - NumericAnimation { + NumberAnimation { target: Wrapper properties: "x,y" to: 0 easing: "easeOutQuad" duration: 250 } - NumericAnimation { target: Wrapper; properties: "scale,angle"; duration: 250 } + NumberAnimation { target: Wrapper; properties: "scale,angle"; duration: 250 } } } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 889ab87..c8fa832 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -169,7 +169,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { target: Header properties: "progressOff" easing: "easeInOutQuad" @@ -283,7 +283,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "opacity" easing: "easeInOutQuad" duration: 300 @@ -355,7 +355,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "opacity" easing: "easeInOutQuad" duration: 320 @@ -406,13 +406,13 @@ Item { value: false } ParallelAnimation { - NumericAnimation { + NumberAnimation { target: WebView properties: "zoomedOut" easing: "easeInOutQuad" duration: 200 } - NumericAnimation { + NumberAnimation { target: Flick properties: "xPosition,yPosition" easing: "easeInOutQuad" diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index f17f5c9..0517009 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -25,7 +25,7 @@ Other Features: \o Animation synchronization \endlist -The simplest form of animation is using \l NumericAnimation +The simplest form of animation is using \l NumberAnimation The following example creates a bouncing effect: \code @@ -40,9 +40,9 @@ Rect { y: SequentialAnimation { running: true repeat: true - NumericAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 } + NumberAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 } PauseAnimation { duration: 1000 } - NumericAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 } + NumberAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 } } } } @@ -113,7 +113,7 @@ For the previous example, a transition could describe how \c myrect moved from i \code transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "x,y" easing: "easeOutBounce" duration: 200 @@ -147,13 +147,13 @@ Transition { duration: 1000 } ParallelAnimation { - NumericAnimation { + NumberAnimation { duration: 1000 easing: "easeOutBounce" target: box1 properties: "x,y" } - NumericAnimation { + NumberAnimation { duration: 1000 target: box2 properties: "x,y" diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index daf34c4..192dfa1 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -27,7 +27,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list \o \l PropertyAnimation -\o \l NumericAnimation +\o \l NumberAnimation \o \l ColorAnimation \o \l PauseAnimation \o \l SequentialAnimation diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc index 4095071..c95cb71 100644 --- a/doc/src/declarative/qmlforcpp.qdoc +++ b/doc/src/declarative/qmlforcpp.qdoc @@ -438,7 +438,7 @@ \code Button { id: MyButton - onClicked: NumericAnimation { + onClicked: NumberAnimation { target: MyButton property: "x" to: 100 @@ -555,12 +555,12 @@ \code Rect { - x: NumericAnimation { running: true; repeat; true; from: 0; to: 100; } + x: NumberAnimation { running: true; repeat; true; from: 0; to: 100; } } \endcode Here the \c x property of the rectangle will be animated from 0 to 100. - To support this, the NumericAnimation class inherits the + To support this, the NumberAnimation class inherits the QmlPropertyValueSource class. If a type inherits this class and is assigned to a property for which type assignment would otherwise fail (ie. the property itself doesn't have a type of QmlPropertyValueSource *), the QML diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 0b97e63..e9f861e 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -46,7 +46,7 @@ Rect { toState: "down" reversible: true ParallelAnimation { - NumericAnimation { + NumberAnimation { properties: "y" duration: 500 easing: "easeOutBounce" @@ -114,7 +114,7 @@ Because we want the same transition to be run in reverse when changing back from \code ParallelAnimation { - NumericAnimation { + NumberAnimation { properties: "y" duration: 500 easing: "easeOutBounce" diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml index 5cb471e..272aeec 100644 --- a/examples/declarative/animation/animation.qml +++ b/examples/declarative/animation/animation.qml @@ -14,7 +14,7 @@ Rect { running: true repeat: true // Move from 0 to 360 in 500ms, using the easeInOutQuad easing function - NumericAnimation { + NumberAnimation { from: 0 to: 360 easing: "easeInOutQuad" @@ -25,7 +25,7 @@ Rect { duration: 200 } // Then move back to 0 in 2 seconds, using the easeInOutElastic easing function - NumericAnimation { + NumberAnimation { from: 360 to: 0 easing: "easeInOutElastic" diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml index e6a50cd..4c092bf 100644 --- a/examples/declarative/behaviours/test.qml +++ b/examples/declarative/behaviours/test.qml @@ -56,7 +56,7 @@ Rect { id: bluerect x: Behavior { SequentialAnimation { - NumericAnimation { + NumberAnimation { target: bluerect properties: "y" from: 0 @@ -64,7 +64,7 @@ Rect { easing: "easeOutBounce(amplitude:30)" duration: 250 } - NumericAnimation { + NumberAnimation { target: bluerect properties: "y" from: 10 @@ -73,18 +73,18 @@ Rect { duration: 250 } } - NumericAnimation { duration: 500 } + NumberAnimation { duration: 500 } } parent: Behavior { SequentialAnimation { - NumericAnimation { + NumberAnimation { target: bluerect properties: "opacity" to: 0 duration: 150 } SetPropertyAction {} - NumericAnimation { + NumberAnimation { target: bluerect properties: "opacity" to: 1 diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml index af675d1..4fdf512 100644 --- a/examples/declarative/easing/easing.qml +++ b/examples/declarative/easing/easing.qml @@ -63,7 +63,7 @@ Rect { font.italic: true x: SequentialAnimation { id: Anim - NumericAnimation { + NumberAnimation { from: 0 to: Window.width / 2 easing: type @@ -72,7 +72,7 @@ Rect { PauseAnimation { duration: 300 } - NumericAnimation { + NumberAnimation { to: 0 from: Window.width / 2 easing: type diff --git a/examples/declarative/flowview/flowview.qml b/examples/declarative/flowview/flowview.qml index 4c9aecc..61b8794 100644 --- a/examples/declarative/flowview/flowview.qml +++ b/examples/declarative/flowview/flowview.qml @@ -23,8 +23,8 @@ Rect { fromState: "" ; toState: "rotated" reversible: true SequentialAnimation { - NumericAnimation { filter: [TopBar, BottomBar]; properties: "x,y"; easing: "easeInOutQuad" } - NumericAnimation { filter: [LeftBar, RightBar]; properties: "x,y"; easing: "easeInOutQuad"} + NumberAnimation { filter: [TopBar, BottomBar]; properties: "x,y"; easing: "easeInOutQuad" } + NumberAnimation { filter: [LeftBar, RightBar]; properties: "x,y"; easing: "easeInOutQuad"} } } @@ -66,7 +66,7 @@ Rect { SequentialAnimation { ParentChangeAction{} PauseAnimation { duration: 50 * List.FlowView.column } - NumericAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" } } }, Transition { @@ -74,7 +74,7 @@ Rect { SequentialAnimation { ParentChangeAction{} PauseAnimation { duration: 50 * (Grid.FlowView.row * 2 + Grid.FlowView.column) } - NumericAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" } } } ] diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml index 3258ea6..21a0309 100644 --- a/examples/declarative/follow/follow.qml +++ b/examples/declarative/follow/follow.qml @@ -7,11 +7,11 @@ Rect { y: 200; width: 60; height: 20 y: SequentialAnimation { running: true; repeat: true - NumericAnimation { + NumberAnimation { to: 20; duration: 500 easing: "easeInOutQuad" } - NumericAnimation { + NumberAnimation { to: 200; duration: 2000 easing: "easeOutBounce" } diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml index 582b04c..93ee6a7 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/pong.qml @@ -16,9 +16,9 @@ Rect { // Move the ball to the right and back to the left repeatedly x: SequentialAnimation { running: true; repeat: true - NumericAnimation { to: Page.width-40; duration: 2000 } + NumberAnimation { to: Page.width-40; duration: 2000 } SetPropertyAction { target: Ball; property: "direction"; value: "left" } - NumericAnimation { to: 20; duration: 2000 } + NumberAnimation { to: 20; duration: 2000 } SetPropertyAction { target: Ball; property: "direction"; value: "right" } } diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 9a672d9..d0a6e30 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -30,7 +30,7 @@ Rect { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "x"; duration: 200 } } diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index ae9756c..b012c5a 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -115,7 +115,7 @@ Rect { // Make the state changes smooth ParallelAnimation { ColorAnimation { duration: 500 } - NumericAnimation { + NumberAnimation { duration: 300; properties: "detailsOpacity,x,yPosition,height,width" } } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index db826a3..17fc177 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -29,7 +29,7 @@ Item { source: "pics/flag.png" opacity: modelData.hasFlag opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -77,7 +77,7 @@ Item { PauseAnimation { duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} } - NumericAnimation { + NumberAnimation { easing: "easeInOutQuad" properties: "rotation" } diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 42e8f25..49f66cc 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -32,7 +32,7 @@ Rect { Transition { fromState: "*" toState: "*" - NumericAnimation { + NumberAnimation { properties: "opacity" duration: 400 } diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml index 8bc88e4..69633e3 100644 --- a/examples/declarative/slideswitch/Switch.qml +++ b/examples/declarative/slideswitch/Switch.qml @@ -50,7 +50,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 } + NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 } } ] } diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 4c1dceb..214f6e2 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -44,17 +44,17 @@ Rect { // with easeOutBounce easing function. Transition { fromState: "*"; toState: "Position1" - NumericAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 } + NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 } }, // When transitioning to 'Position2' move x,y over a duration of 2 seconds, // with easeInOutQuad easing function. Transition { fromState: "*"; toState: "Position2" - NumericAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } + NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } }, // For any other state changes move x,y linearly over duration of 200ms. Transition { - NumericAnimation { properties: "x,y"; duration: 200 } + NumberAnimation { properties: "x,y"; duration: 200 } } ] } diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml index 29d464b..280553e 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml @@ -107,7 +107,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml index 0d607a9..064aaa2 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml @@ -48,7 +48,7 @@ FocusRealm { onClicked: { parent.parent.focus=true } } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml index 3142c45..c8df678 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml @@ -106,7 +106,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml index 3142c45..c8df678 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml @@ -106,7 +106,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml index bf6e82d..afbb039 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml @@ -108,7 +108,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml index 99a521d..6e6a6e5 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml @@ -114,7 +114,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml index 890d781..ba7f676 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml @@ -51,7 +51,7 @@ Item { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "width,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml index 8bf5317..5afcac3 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml @@ -71,7 +71,7 @@ Rect { text: fieldText.label opacity: textEdit.text == '' ? 1 : 0 opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -136,7 +136,7 @@ Rect { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,leftMargin,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml index 2f27a69..8f3604a 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml @@ -109,7 +109,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml index e9927e9..6499293 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml @@ -49,7 +49,7 @@ Item { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "width,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml index d4fbc20..dee15c6 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml @@ -73,7 +73,7 @@ Rect { text: fieldText.label opacity: textEdit.text == '' ? 1 : 0 opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -137,7 +137,7 @@ Rect { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,leftMargin,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml index bfe496e..f7e2f22 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml @@ -114,7 +114,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml index 0d607a9..064aaa2 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml @@ -48,7 +48,7 @@ FocusRealm { onClicked: { parent.parent.focus=true } } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml index 0a293f5..b1e4721 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml @@ -102,7 +102,7 @@ Item { //! [transitions] transitions: [ Transition { - NumericAnimation { + NumberAnimation { duration: 500 properties: "yPosition,height,opacity" } diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml index 7a44a3f..e4a145f 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml @@ -118,7 +118,7 @@ Item { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { duration: 500 properties: "yPosition,height,opacity" } diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml index 0d607a9..064aaa2 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml @@ -48,7 +48,7 @@ FocusRealm { onClicked: { parent.parent.focus=true } } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml index 3b76a13..295e6cd 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml @@ -49,7 +49,7 @@ Item { ] } opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml index e9927e9..6499293 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml @@ -49,7 +49,7 @@ Item { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "width,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml index 111d9c5..4e699c3 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml @@ -73,7 +73,7 @@ Rect { text: fieldText.label opacity: textEdit.text == '' ? 1 : 0 opacity: Behavior { - NumericAnimation { + NumberAnimation { property: "opacity" duration: 250 } @@ -137,7 +137,7 @@ Rect { fromState: "" toState: "*" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,leftMargin,rightMargin" duration: 200 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml index c0ea79d..a403be7 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml @@ -112,7 +112,7 @@ Rect { fromState: "*" toState: "opened" reversible: true - NumericAnimation { + NumberAnimation { properties: "opacity,x,width" duration: 200 } diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index bd89ecf..5ea0dd6 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -32,7 +32,7 @@ Rect { toState: "down" reversible: true ParallelAnimation { - NumericAnimation { + NumberAnimation { properties: "y" duration: 500 easing: "easeOutBounce" diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index c70a211..8f78822 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -100,7 +100,7 @@ Rect { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "rotation,scale" duration: 200 } diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml index 5e4735e..640416f 100644 --- a/examples/declarative/webview/content/SpinSquare.qml +++ b/examples/declarative/webview/content/SpinSquare.qml @@ -13,7 +13,7 @@ Item { width: Root.width height: width } - rotation: NumericAnimation { + rotation: NumberAnimation { from: 0 to: 360 repeat: true diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index b465ef1..c2a0e34 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -82,12 +82,12 @@ Rect { toState: "Details" reversible: true SequentialAnimation { - NumericAnimation { + NumberAnimation { duration: 200 properties: "height" easing: "easeOutQuad" } - NumericAnimation { + NumberAnimation { duration: 200 properties: "opacity" } diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 4c02e74..9595724 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -94,7 +94,7 @@ Flipable { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { easing: "easeInOutQuad" properties: "rotation" } diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp index 1671fc6..78a91af 100644 --- a/src/declarative/fx/qfxhighlightfilter.cpp +++ b/src/declarative/fx/qfxhighlightfilter.cpp @@ -80,7 +80,7 @@ Text { text: "Highlight" filter: Highlight { source: "pics/highlight.png" - xOffset: NumericAnimation { + xOffset: NumberAnimation { running: true repeat: true from: 320 diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp index a975778..e27135c 100644 --- a/src/declarative/fx/qfxlayouts.cpp +++ b/src/declarative/fx/qfxlayouts.cpp @@ -132,7 +132,7 @@ BaseLayout { id: layout y: 0 move: Transition { - NumericAnimation { + NumberAnimation { properties: "y" ease: "easeOutBounce" } @@ -161,7 +161,7 @@ BaseLayout { id: layout y: 0 add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -196,7 +196,7 @@ BaseLayout { id: layout y: 0 remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -512,7 +512,7 @@ VerticalLayout { VerticalLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -539,7 +539,7 @@ VerticalLayout { VerticalLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -566,7 +566,7 @@ VerticalLayout { VerticalLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "y" ease: "easeOutBounce" } @@ -683,7 +683,7 @@ HorizontalLayout { HorizontalLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -705,7 +705,7 @@ HorizontalLayout { HorizontalLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -727,7 +727,7 @@ HorizontalLayout { HorizontalLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "x" ease: "easeOutBounce" } @@ -875,7 +875,7 @@ GridLayout { GridLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -900,7 +900,7 @@ GridLayout { GridLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -923,7 +923,7 @@ GridLayout { GridLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "x,y" ease: "easeOutBounce" } diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index d2608c8..be58071 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -959,11 +959,11 @@ void QmlDomValueBinding::setBinding(const QString &expression) In QML, value sources are special value generating types that may be assigned to properties. Value sources inherit the QmlPropertyValueSource class. In the example below, the "x" property is being assigned the - NumericAnimation value source. + NumberAnimation value source. \qml Rect { - x: NumericAnimation { + x: NumberAnimation { from: 0 to: 100 repeat: true @@ -1008,11 +1008,11 @@ QmlDomValueValueSource &QmlDomValueValueSource::operator=(const QmlDomValueValue /*! Return the value source object. - In the example below, an object representing the NumericAnimation will be + In the example below, an object representing the NumberAnimation will be returned. \qml Rect { - x: NumericAnimation { + x: NumberAnimation { from: 0 to: 100 repeat: true @@ -1357,7 +1357,7 @@ Item { \qml Item { x: 10 - x: NumericAnimation { + x: NumberAnimation { running: false from: 0 to: 100 diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 42ed40b..b2a3356 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -179,7 +179,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj \code Rect { width: 100; height: 100 - x: NumericAnimation { + x: NumberAnimation { running: MyMouse.pressed from: 0; to: 100 } @@ -192,7 +192,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj or not the animation is running. \code - NumericAnimation { id: MyAnimation } + NumberAnimation { id: MyAnimation } Text { text: MyAnimation.running ? "Animation is running" : "Animation is not running" } \endcode @@ -349,7 +349,7 @@ void QmlAbstractAnimation::setFinishPlaying(bool f) \code Rect { - rotation: NumericAnimation { running: true; repeat: true; from: 0 to: 360 } + rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 } } \endcode */ @@ -512,7 +512,7 @@ void QmlAbstractAnimation::resume() no further influence on property values. In this example animation \code Rect { - x: NumericAnimation { from: 0; to: 100; duration: 500 } + x: NumberAnimation { from: 0; to: 100; duration: 500 } } \endcode was stopped at time 250ms, the \c x property will have a value of 50. @@ -550,7 +550,7 @@ void QmlAbstractAnimation::restart() its end. In the following example, \code Rect { - x: NumericAnimation { from: 0; to: 100; duration: 500 } + x: NumberAnimation { from: 0; to: 100; duration: 500 } } \endcode calling \c stop() at time 250ms will result in the \c x property having @@ -606,9 +606,9 @@ void QmlAbstractAnimation::timelineComplete() A 500ms animation sequence, with a 100ms pause between two animations: \code SequentialAnimation { - NumericAnimation { ... duration: 200 } + NumberAnimation { ... duration: 200 } PauseAnimation { duration: 100 } - NumericAnimation { ... duration: 200 } + NumberAnimation { ... duration: 200 } } \endcode */ @@ -1175,29 +1175,29 @@ void QmlParentChangeAction::transition(QmlStateActions &actions, QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction) /*! - \qmlclass NumericAnimation QmlNumericAnimation + \qmlclass NumberAnimation QmlNumberAnimation \inherits PropertyAnimation - \brief The NumericAnimation allows you to animate changes in properties of type qreal. + \brief The NumberAnimation allows you to animate changes in properties of type qreal. Animate a set of properties over 200ms, from their values in the start state to their values in the end state of the transition: \code - NumericAnimation { properties: "x,y,scale"; duration: 200 } + NumberAnimation { properties: "x,y,scale"; duration: 200 } \endcode */ /*! \internal - \class QmlNumericAnimation + \class QmlNumberAnimation \ingroup group_animation \ingroup group_states - \brief The QmlNumericAnimation class allows you to animate changes in properties of type qreal. + \brief The QmlNumberAnimation class allows you to animate changes in properties of type qreal. - A QmlNumericAnimation object can be instantiated in Qml using the tag - \l{xmlNumericAnimation} {<NumericAnimation>}. + A QmlNumberAnimation object can be instantiated in Qml using the tag + \l{xmlNumberAnimation} {<NumberAnimation>}. */ -QmlNumericAnimation::QmlNumericAnimation(QObject *parent) +QmlNumberAnimation::QmlNumberAnimation(QObject *parent) : QmlPropertyAnimation(parent) { Q_D(QmlPropertyAnimation); @@ -1206,51 +1206,51 @@ QmlNumericAnimation::QmlNumericAnimation(QObject *parent) d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } -QmlNumericAnimation::~QmlNumericAnimation() +QmlNumberAnimation::~QmlNumberAnimation() { } /*! - \qmlproperty real NumericAnimation::from + \qmlproperty real NumberAnimation::from This property holds the starting value. If not set, then the value defined in the start state of the transition. */ /*! - \property QmlNumericAnimation::from + \property QmlNumberAnimation::from \brief the starting value. */ -qreal QmlNumericAnimation::from() const +qreal QmlNumberAnimation::from() const { Q_D(const QmlPropertyAnimation); return d->from.toDouble(); //### toFloat? } -void QmlNumericAnimation::setFrom(qreal f) +void QmlNumberAnimation::setFrom(qreal f) { QmlPropertyAnimation::setFrom(f); } /*! - \qmlproperty real NumericAnimation::to + \qmlproperty real NumberAnimation::to This property holds the ending value. If not set, then the value defined in the end state of the transition. */ /*! - \property QmlNumericAnimation::to + \property QmlNumberAnimation::to \brief the ending value. */ -qreal QmlNumericAnimation::to() const +qreal QmlNumberAnimation::to() const { Q_D(const QmlPropertyAnimation); return d->to.toDouble(); //### toFloat? } -void QmlNumericAnimation::setTo(qreal t) +void QmlNumberAnimation::setTo(qreal t) { QmlPropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(QmlNumericAnimation,NumericAnimation) +QML_DEFINE_TYPE(QmlNumberAnimation,NumberAnimation) QmlAnimationGroup::QmlAnimationGroup(QObject *parent) : QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) @@ -1279,8 +1279,8 @@ QmlList *QmlAnimationGroup::animations() \code SequentialAnimation { - NumericAnimation { target: MyItem; property: "x"; to: 100 } - NumericAnimation { target: MyItem; property: "x"; to: 0 } + NumberAnimation { target: MyItem; property: "x"; to: 100 } + NumberAnimation { target: MyItem; property: "x"; to: 0 } } \endcode @@ -1362,8 +1362,8 @@ QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation) \code ParallelAnimation { - NumericAnimation { target: MyItem; property: "x"; to: 100 } - NumericAnimation { target: MyItem; property: "y"; to: 100 } + NumberAnimation { target: MyItem; property: "x"; to: 100 } + NumberAnimation { target: MyItem; property: "y"; to: 100 } } \endcode @@ -1782,7 +1782,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, struct PropertyUpdater : public QmlTimeLineValue { QmlStateActions actions; - int interpolatorType; //for Numeric/ColorAnimation + int interpolatorType; //for Number/ColorAnimation int prevInterpolatorType; //for generic QVariantAnimation::Interpolator interpolator; void setValue(qreal v) diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index a91394d..110c43e 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -317,7 +317,7 @@ public: }; QML_DECLARE_TYPE(QmlColorAnimation) -class QmlNumericAnimation : public QmlPropertyAnimation +class QmlNumberAnimation : public QmlPropertyAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QmlPropertyAnimation) @@ -326,8 +326,8 @@ class QmlNumericAnimation : public QmlPropertyAnimation Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) public: - QmlNumericAnimation(QObject *parent=0); - virtual ~QmlNumericAnimation(); + QmlNumberAnimation(QObject *parent=0); + virtual ~QmlNumberAnimation(); qreal from() const; void setFrom(qreal); @@ -335,7 +335,7 @@ public: qreal to() const; void setTo(qreal); }; -QML_DECLARE_TYPE(QmlNumericAnimation) +QML_DECLARE_TYPE(QmlNumberAnimation) class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp index 3617541..4beca5e 100644 --- a/src/declarative/util/qmlbehaviour.cpp +++ b/src/declarative/util/qmlbehaviour.cpp @@ -115,7 +115,7 @@ public: color: "#00ff00" y: 200 //initial value y: Behavior { - NumericAnimation { + NumberAnimation { easing: "easeOutBounce(amplitude:100)" duration: 200 } diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index d1ecac4..95e7792 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -183,7 +183,7 @@ void QmlFollowPrivate::stop() y: SequentialAnimation { running: true repeat: true - NumericAnimation { + NumberAnimation { to: 200 easing: "easeOutBounce(amplitude:100)" duration: 2000 diff --git a/tests/auto/declarative/animations/data/badtype2.qml b/tests/auto/declarative/animations/data/badtype2.qml index 18d9079..aa248a6 100644 --- a/tests/auto/declarative/animations/data/badtype2.qml +++ b/tests/auto/declarative/animations/data/badtype2.qml @@ -5,6 +5,6 @@ Rect { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumericAnimation { from: "blue"; to: "green"; running: true; } + x: NumberAnimation { from: "blue"; to: "green"; running: true; } } } diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml index e3d312e..fa4eebe 100644 --- a/tests/auto/declarative/animations/data/badtype4.qml +++ b/tests/auto/declarative/animations/data/badtype4.qml @@ -18,6 +18,6 @@ Rect { } transitions: Transition { ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color - //NumericAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + //NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color } } diff --git a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml index 61cedc2..b06314f 100644 --- a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml @@ -27,7 +27,7 @@ Rect { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "x" } } diff --git a/tests/auto/declarative/visual/easing/easing.qml b/tests/auto/declarative/visual/easing/easing.qml index 4a0ed14..59dd25c 100644 --- a/tests/auto/declarative/visual/easing/easing.qml +++ b/tests/auto/declarative/visual/easing/easing.qml @@ -169,7 +169,7 @@ Rect { fromState: "*" toState: "to" reversible: true - NumericAnimation { + NumberAnimation { properties: "x" easing: type } diff --git a/tests/auto/declarative/visual/flipable/flipable.xml b/tests/auto/declarative/visual/flipable/flipable.xml index d769e55..9288acc 100644 --- a/tests/auto/declarative/visual/flipable/flipable.xml +++ b/tests/auto/declarative/visual/flipable/flipable.xml @@ -104,17 +104,17 @@ - + - - + + - - + + diff --git a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml index 5c00f58..e0880f0 100644 --- a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml +++ b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml @@ -11,11 +11,11 @@ Rect { y: SequentialAnimation { running: true repeat: true - NumericAnimation { + NumberAnimation { to: 0; duration: 500 easing: "easeInOutQuad" } - NumericAnimation { + NumberAnimation { to: 200-img.height easing: "easeOutBounce" duration: 2000 -- cgit v0.12 From 98286fd1ac3bb7940618d5a170c7b98b0e2a4dae Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 12:53:17 +1000 Subject: Color property is required to be explicity set (at least for now). --- demos/declarative/contacts/Button.qml | 2 ++ demos/declarative/contacts/FieldText.qml | 1 + doc/src/declarative/animation.qdoc | 3 ++- doc/src/declarative/tutorial3.qdoc | 4 ++-- examples/declarative/animation/animation.qml | 2 ++ examples/declarative/listview/recipes.qml | 2 +- examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml | 1 + examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml | 1 + examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml | 2 ++ .../declarative/tutorials/contacts/3_Collections/lib/FieldText.qml | 1 + examples/declarative/tutorials/helloworld/t3/tutorial3.qml | 2 +- src/declarative/util/qmlanimation.cpp | 4 ---- 12 files changed, 16 insertions(+), 9 deletions(-) diff --git a/demos/declarative/contacts/Button.qml b/demos/declarative/contacts/Button.qml index 295e6cd..842825f 100644 --- a/demos/declarative/contacts/Button.qml +++ b/demos/declarative/contacts/Button.qml @@ -36,6 +36,7 @@ Item { fromState: "*" toState: "pressed" ColorAnimation { + property: "color" duration: 200 } }, @@ -43,6 +44,7 @@ Item { fromState: "pressed" toState: "*" ColorAnimation { + property: "color" duration: 1000 } } diff --git a/demos/declarative/contacts/FieldText.qml b/demos/declarative/contacts/FieldText.qml index 333a5f6..ddeed11 100644 --- a/demos/declarative/contacts/FieldText.qml +++ b/demos/declarative/contacts/FieldText.qml @@ -153,6 +153,7 @@ Rect { duration: 200 } ColorAnimation { + property: "color" duration: 150 } } diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 0517009..9f3f4f6 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -132,7 +132,7 @@ Transition { } \endcode -Transitions can happen in parallel, in sequence, or in any combination of the two:; +Transitions can happen in parallel, in sequence, or in any combination of the two: \code Transition { @@ -141,6 +141,7 @@ Transition { reversible: true SequentialAnimation { ColorAnimation { + property: "color" duration: 1000 } PauseAnimation { diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index e9f861e..d8bed78 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -51,7 +51,7 @@ Rect { duration: 500 easing: "easeOutBounce" } - ColorAnimation { duration: 500 } + ColorAnimation { property: "color"; duration: 500 } } } ] @@ -119,7 +119,7 @@ ParallelAnimation { duration: 500 easing: "easeOutBounce" } - ColorAnimation { duration: 500 } + ColorAnimation { property: "color"; duration: 500 } } \endcode diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml index 272aeec..37e68d6 100644 --- a/examples/declarative/animation/animation.qml +++ b/examples/declarative/animation/animation.qml @@ -37,11 +37,13 @@ Rect { running: true repeat: true ColorAnimation { + property: "color" from: "#FF0000" to: "#00FF00" duration: 5000 } ColorAnimation { + property: "color" from: "#00FF00" to: "#FF0000" duration: 5000 diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index b012c5a..e5cb8ff 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -114,7 +114,7 @@ Rect { Transition { // Make the state changes smooth ParallelAnimation { - ColorAnimation { duration: 500 } + ColorAnimation { property: "color"; duration: 500 } NumberAnimation { duration: 300; properties: "detailsOpacity,x,yPosition,height,width" } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml index 5afcac3..6ebcfda 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml @@ -141,6 +141,7 @@ Rect { duration: 200 } ColorAnimation { + property: "color" duration: 150 } } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml index dee15c6..d3bca29 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml @@ -142,6 +142,7 @@ Rect { duration: 200 } ColorAnimation { + property: "color" duration: 150 } } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml index 295e6cd..842825f 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml @@ -36,6 +36,7 @@ Item { fromState: "*" toState: "pressed" ColorAnimation { + property: "color" duration: 200 } }, @@ -43,6 +44,7 @@ Item { fromState: "pressed" toState: "*" ColorAnimation { + property: "color" duration: 1000 } } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml index 4e699c3..a094040 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml @@ -142,6 +142,7 @@ Rect { duration: 200 } ColorAnimation { + property: "color" duration: 150 } } diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index f4bce32..664bf45 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -32,7 +32,7 @@ Rect { duration: 500 easing: "easeOutBounce" } - ColorAnimation { duration: 500 } + ColorAnimation { property: "color"; duration: 500 } } } ] diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index b2a3356..921c578 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -699,10 +699,6 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() \code ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 } \endcode - - The default property animated is \c color, but like other animations, - this can be changed by setting \c property. The \c color property will - still animate. XXX is this a bug? */ /*! \internal -- cgit v0.12 From 0ee01c42afb203d60ff0cd543ced124e0c100b8e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 13:36:53 +1000 Subject: Make ease prefix optional. --- src/declarative/util/qmlanimation.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 921c578..c5f2a25 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -85,11 +85,17 @@ QEasingCurve stringToCurve(const QString &curve) QString prop_str = easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); normalizedCurve = easeName.left(idx); + if (!normalizedCurve.startsWith(QLatin1String("ease"))) { + qWarning("QEasingCurve: Easing function '%s' must start with 'ease'", + curve.toLatin1().constData()); + } props = prop_str.split(QLatin1Char(',')); } - normalizedCurve = normalizedCurve.mid(4); + if (normalizedCurve.startsWith(QLatin1String("ease"))) + normalizedCurve = normalizedCurve.mid(4); + //XXX optimize? int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); -- cgit v0.12 From 40a59d973c324e45954481f608e1bfc2b9579300 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Jun 2009 14:31:54 +1000 Subject: Make sure we update when anchor margins/offsets change. --- src/declarative/fx/qfxanchors.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 3da58a2..feac96e 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -772,6 +772,7 @@ void QFxAnchors::setLeftMargin(int offset) if (d->leftMargin == offset) return; d->leftMargin = offset; + d->updateHorizontalAnchors(); emit leftMarginChanged(); } @@ -787,6 +788,7 @@ void QFxAnchors::setRightMargin(int offset) if (d->rightMargin == offset) return; d->rightMargin = offset; + d->updateHorizontalAnchors(); emit rightMarginChanged(); } @@ -802,6 +804,7 @@ void QFxAnchors::setHorizontalCenterOffset(int offset) if (d->hCenterOffset == offset) return; d->hCenterOffset = offset; + d->updateHorizontalAnchors(); emit horizontalCenterOffsetChanged(); } @@ -817,6 +820,7 @@ void QFxAnchors::setTopMargin(int offset) if (d->topMargin == offset) return; d->topMargin = offset; + d->updateVerticalAnchors(); emit topMarginChanged(); } @@ -832,6 +836,7 @@ void QFxAnchors::setBottomMargin(int offset) if (d->bottomMargin == offset) return; d->bottomMargin = offset; + d->updateVerticalAnchors(); emit bottomMarginChanged(); } @@ -847,6 +852,7 @@ void QFxAnchors::setVerticalCenterOffset(int offset) if (d->vCenterOffset == offset) return; d->vCenterOffset = offset; + d->updateVerticalAnchors(); emit verticalCenterOffsetChanged(); } -- cgit v0.12 From 3c45c081ce33f05ae200d252ebb5e9e1484bcc6d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 26 Jun 2009 14:52:07 +1000 Subject: Update SetProperties to handle changing bindings Also removed all uses of SetProperty --- demos/declarative/contacts/Button.qml | 5 +- demos/declarative/contacts/ContactField.qml | 10 ++- demos/declarative/contacts/FieldText.qml | 45 +++++------- demos/declarative/contacts/RemoveButton.qml | 25 +++---- demos/declarative/contacts/contacts.qml | 45 +++++------- demos/declarative/flickr/content/ImageDetails.qml | 2 +- demos/declarative/flickr/content/MediaLineEdit.qml | 5 +- demos/declarative/flickr/flickr2.qml | 10 +-- demos/declarative/webbrowser/webbrowser.qml | 84 ++++------------------ doc/src/declarative/animation.qdoc | 10 ++- doc/src/declarative/elements.qdoc | 1 - doc/src/declarative/tutorial3.qdoc | 24 ++----- examples/declarative/listview/highlight.qml | 4 +- examples/declarative/listview/recipes.qml | 13 ++-- examples/declarative/minehunt/minehunt.qml | 6 +- examples/declarative/scrollbar/display.qml | 12 +--- examples/declarative/slideswitch/Switch.qml | 8 +-- examples/declarative/states/states.qml | 6 +- examples/declarative/states/transitions.qml | 6 +- .../1_Drawing_and_Animation/4/RemoveButton.qml | 25 +++---- .../1_Drawing_and_Animation/4a/RemoveButton.qml | 25 +++---- .../1_Drawing_and_Animation/5/RemoveButton.qml | 25 +++---- .../tutorials/contacts/2_Reuse/1/RemoveButton.qml | 25 +++---- .../tutorials/contacts/2_Reuse/1a/RemoveButton.qml | 25 +++---- .../contacts/2_Reuse/1b/lib/RemoveButton.qml | 25 +++---- .../tutorials/contacts/2_Reuse/2/RemoveButton.qml | 25 +++---- .../tutorials/contacts/2_Reuse/3/ContactField.qml | 10 ++- .../tutorials/contacts/2_Reuse/3/FieldText.qml | 35 ++++----- .../tutorials/contacts/2_Reuse/3/RemoveButton.qml | 25 +++---- .../tutorials/contacts/2_Reuse/4/ContactField.qml | 10 ++- .../tutorials/contacts/2_Reuse/4/FieldText.qml | 35 ++++----- .../tutorials/contacts/2_Reuse/4/RemoveButton.qml | 25 +++---- .../contacts/3_Collections/2/ContactView.qml | 26 +++---- .../contacts/3_Collections/3/ContactView.qml | 26 +++---- .../contacts/3_Collections/lib/Button.qml | 5 +- .../contacts/3_Collections/lib/ContactField.qml | 10 ++- .../contacts/3_Collections/lib/FieldText.qml | 35 ++++----- .../contacts/3_Collections/lib/RemoveButton.qml | 26 +++---- .../tutorials/helloworld/t3/tutorial3.qml | 12 +--- examples/declarative/xmldata/yahoonews.qml | 12 +--- src/declarative/qml/qmlbindablevalue.cpp | 35 +++++++-- src/declarative/qml/qmlbindablevalue.h | 10 ++- src/declarative/qml/qmlbindablevalue_p.h | 6 +- src/declarative/qml/qmlmetaproperty.cpp | 47 +++++++++++- src/declarative/qml/qmlmetaproperty.h | 4 +- src/declarative/qml/qmlvme.cpp | 4 +- src/declarative/util/qmlanimation.cpp | 6 -- src/declarative/util/qmlsetproperties.cpp | 28 +++++++- src/declarative/util/qmlsetproperties.h | 4 ++ src/declarative/util/qmlstate.cpp | 84 +++++++++++++++------- src/declarative/util/qmlstate.h | 13 ++-- src/declarative/util/qmlstate_p.h | 8 +-- src/declarative/util/qmlstateoperations.cpp | 10 +-- .../visual/bindinganimation/bindinganimation.qml | 10 ++- .../visual/colorAnimation/colorAnimation.qml | 10 ++- tests/auto/declarative/visual/easing/easing.qml | 10 ++- 56 files changed, 485 insertions(+), 592 deletions(-) diff --git a/demos/declarative/contacts/Button.qml b/demos/declarative/contacts/Button.qml index 3b76a13..5623b26 100644 --- a/demos/declarative/contacts/Button.qml +++ b/demos/declarative/contacts/Button.qml @@ -24,10 +24,9 @@ Item { State { name: "pressed" when: buttonMouseRegion.pressed == true - SetProperty { + SetProperties { target: buttonRect - property: "color" - value: "green" + color: "green" } } ] diff --git a/demos/declarative/contacts/ContactField.qml b/demos/declarative/contacts/ContactField.qml index 003e723..60a4cc5 100644 --- a/demos/declarative/contacts/ContactField.qml +++ b/demos/declarative/contacts/ContactField.qml @@ -34,15 +34,13 @@ Item { State { name: "editingText" when: fieldText.state == 'editing' - SetProperty { + SetProperties { target: removeButton.anchors - property: "rightMargin" - value: -35 + rightMargin: -35 } - SetProperty { + SetProperties { target: fieldText - property: "width" - value: contactField.width + width: contactField.width } } ] diff --git a/demos/declarative/contacts/FieldText.qml b/demos/declarative/contacts/FieldText.qml index 39e45d4..ae84d44 100644 --- a/demos/declarative/contacts/FieldText.qml +++ b/demos/declarative/contacts/FieldText.qml @@ -96,50 +96,41 @@ Rect { states: [ State { name: "editing" - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: fieldText - property: "color" - value: "white" + color: "white" } - SetProperty { + SetProperties { target: textEdit - property: "color" - value: "black" + color: "black" } - SetProperty { + SetProperties { target: textEdit - property: "readOnly" - value: false + readOnly: false } - SetProperty { + SetProperties { target: textEdit - property: "focus" - value: true + focus: true } - SetProperty { + SetProperties { target: editRegion - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "leftMargin" - value: 34 + leftMargin: 34 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "rightMargin" - value: 34 + rightMargin: 34 } } ] diff --git a/demos/declarative/contacts/RemoveButton.qml b/demos/declarative/contacts/RemoveButton.qml index 8f46fcb..c1cc816 100644 --- a/demos/declarative/contacts/RemoveButton.qml +++ b/demos/declarative/contacts/RemoveButton.qml @@ -85,30 +85,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: removeButton.expandedWidth + width: removeButton.expandedWidth } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index 0ce9948..fd49041 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -50,10 +50,9 @@ Rect { State { name: "currentItem" when: wrapper.ListView.isCurrentItem - SetProperty { + SetProperties { target: label - property: "color" - value: "black" + color: "black" } } ] @@ -94,30 +93,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: wrapper - property: "height" - value: contactListView.height + height: contactListView.height } - SetProperty { + SetProperties { target: contactListView - property: "yPosition" - value: wrapper.y + yPosition: wrapper.y } - SetProperty { + SetProperties { target: contactListView - property: "locked" - value: 1 + locked: 1 } - SetProperty { + SetProperties { target: label - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: Details - property: "opacity" - value: 1 + opacity: 1 } } ] @@ -277,10 +271,9 @@ Rect { State { name: "searchHidden" when: searchBar.text == '' || contacts.mode != 'list' - SetProperty { + SetProperties { target: searchBarWrapper.anchors - property: "bottomMargin" - value: -30 + bottomMargin: -30 } } ] @@ -303,15 +296,13 @@ Rect { State { name: "editNewState" when: contacts.mode == 'new' - SetProperty { + SetProperties { target: contactListView - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: newContactWrapper - property: "opacity" - value: 1 + opacity: 1 } } ] diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index ccc91cb..d17e323 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -129,7 +129,7 @@ Flipable { states: [ State { name: "Back" - SetProperty { target: Container; property: "rotation"; value: 180 } + SetProperties { target: Container; rotation: 180 } } ] diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml index 691bb5b..65c2b38 100644 --- a/demos/declarative/flickr/content/MediaLineEdit.qml +++ b/demos/declarative/flickr/content/MediaLineEdit.qml @@ -14,10 +14,9 @@ Item { target: Label text: Container.label + ": " } - SetProperty { + SetProperties { target: Label - property: "x" - binding: 10 + x: 10 } SetProperties { target: Editor diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 79f7a32..2f4c823 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -48,7 +48,6 @@ Item { Script { function photoClicked() { Background.imageDetails.photoTitle = title; - Background.imageDetails.flickableArea.yPosition = 0; Background.imageDetails.photoDescription = description; Background.imageDetails.photoTags = tags; Background.imageDetails.photoWidth = photoWidth; @@ -129,15 +128,12 @@ Item { states: [ State { name: "gridView" - SetProperty { target: Wrapper; property: "moveToParent"; value: GridViewPackage } + SetProperties { target: Wrapper; explicit: true; property: "moveToParent"; value: GridViewPackage } }, State { name: "pathView" - SetProperty { target: Wrapper; property: "scale"; value: PathViewPackage.PathView.scale } - SetProperty { target: Wrapper; property: "scale"; binding: "PathViewPackage.PathView.scale" } - SetProperty { target: Wrapper; property: "angle"; value: PathViewPackage.PathView.angle } - SetProperty { target: Wrapper; property: "angle"; binding: "PathViewPackage.PathView.angle" } - SetProperty { target: Wrapper; property: "moveToParent"; value: PathViewPackage } + SetProperties { target: Wrapper; scale: PathViewPackage.PathView.scale; angle: PathViewPackage.PathView.angle; } + SetProperties { target: Wrapper; explicit: true; moveToParent: PathViewPackage } } ] transitions: [ diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 889ab87..3dcc20d 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -151,20 +151,12 @@ Item { State { name: "Normal" when: WebView.progress == 1.0 - SetProperty { - target: Header - property: "progressOff" - value: 1 - } + SetProperties { target: Header; progressOff: 1 } }, State { name: "ProgressShown" when: WebView.progress < 1.0 - SetProperty { - target: Header - property: "progressOff" - value: 0 - } + SetProperties { target: Header; progressOff: 0; } } ] transitions: [ @@ -255,30 +247,14 @@ Item { State { name: "Enabled" when: WebView.back.enabled==true - SetProperty { - target: back_e - property: "opacity" - value: 1 - } - SetProperty { - target: back_d - property: "opacity" - value: 0 - } + SetProperties { target: back_e; opacity: 1 } + SetProperties { target: back_d; opacity: 0 } }, State { name: "Disabled" when: WebView.back.enabled==false - SetProperty { - target: back_e - property: "opacity" - value: 0 - } - SetProperty { - target: back_d - property: "opacity" - value: 1 - } + SetProperties { target: back_e; opacity: 0 } + SetProperties { target: back_d; opacity: 1 } } ] transitions: [ @@ -327,30 +303,14 @@ Item { State { name: "Enabled" when: WebView.forward.enabled==true - SetProperty { - target: forward_e - property: "opacity" - value: 1 - } - SetProperty { - target: forward_d - property: "opacity" - value: 0 - } + SetProperties { target: forward_e; opacity: 1 } + SetProperties { target: forward_d; opacity: 0 } }, State { name: "Disabled" when: WebView.forward.enabled==false - SetProperty { - target: forward_e - property: "opacity" - value: 0 - } - SetProperty { - target: forward_d - property: "opacity" - value: 1 - } + SetProperties { target: forward_e; opacity: 0 } + SetProperties { target: forward_d; opacity: 1 } } ] transitions: [ @@ -372,29 +332,13 @@ Item { states: [ State { name: "Normal" - SetProperty { - target: WebView - property: "zoomedOut" - value: 0 - } - SetProperty { - target: Flick - property: "xPosition" - value: Math.min(WebView.width-Flick.width,Math.max(0,Flick.centerX-Flick.width/2)) - } - SetProperty { - target: Flick - property: "yPosition" - value: Math.min(WebView.height-Flick.height,Math.max(0,Flick.centerY-Flick.height/2)) - } + SetProperties { target: WebView; zoomedOut: 0 } + SetProperties { target: Flick; explicit: true; xPosition: Math.min(WebView.width-Flick.width,Math.max(0,Flick.centerX-Flick.width/2)) } + SetProperties { target: Flick; explicit: true; yPosition: Math.min(WebView.height-Flick.height,Math.max(0,Flick.centerY-Flick.height/2)) } }, State { name: "ZoomedOut" - SetProperty { - target: WebView - property: "zoomedOut" - value: 1 - } + SetProperties { target: WebView; zoomedOut: 1 } } ] transitions: [ diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index f17f5c9..9edb54d 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -89,15 +89,13 @@ Item { states: [ State { name: "moved" - SetProperty { + SetProperties { target: myrect - property: "x" - value: 50 + x: 50 } - SetProperty { + SetProperties { target: myrect - property: "y" - value: 50 + y: 50 } } ] diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 35d746b..d078da0 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -18,7 +18,6 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list \o \l State -\o \l SetProperty \o \l SetProperties \o \l ParentChange \o \l RunScript diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 0b97e63..e52e353 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -28,16 +28,8 @@ Rect { State { name: "down" when: MouseRegion.pressed == true - SetProperty { - target: HelloText - property: "y" - value: 160 - } - SetProperty { - target: HelloText - property: "color" - value: "red" - } + SetProperties { target: HelloText; y: 160 } + SetProperties { target: HelloText color: "red" } } ] transitions: [ @@ -80,16 +72,8 @@ states: [ State { name: "down" when: MouseRegion.pressed == true - SetProperty { - target: HelloText - property: "y" - value: 160 - } - SetProperty { - target: HelloText - property: "color" - value: "red" - } + SetProperties { target: HelloText; y: 160 } + SetProperties { target: HelloText; color: "red" } } ] \endcode diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 9a672d9..b9d56b2 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -23,9 +23,7 @@ Rect { State { name: "Current" when: Wrapper.ListView.isCurrentItem - SetProperty { - target: Wrapper; property: "x"; value: 10 - } + SetProperties { target: Wrapper; x: 10 } } ] transitions: [ diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index ae9756c..829f074 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -14,7 +14,7 @@ Rect { width: List.width // Create a property to contain the visibility of the details. // We can bind multiple element's opacity to this one property, - // rather than having a "SetProperty" line for each element we + // rather than having a "SetProperties" line for each element we // want to fade. property real detailsOpacity : 0 @@ -94,20 +94,17 @@ Rect { states: [ State { name: "Details" - SetProperty { target: background; property: "color"; value: "white" } + SetProperties { target: background; color: "white" } // Make the picture bigger SetProperties { target: recipePic; width: 128; height: 128 } // Make details visible SetProperties { target: wrapper; detailsOpacity: 1; x: 0 } // Make the detailed view fill the entire list area - SetProperty { target: wrapper; property: "height"; value: List.height } + SetProperties { target: wrapper; height: List.height } // Move the list so that this item is at the top. - SetProperty { - target: wrapper.ListView.view - property: "yPosition"; value: wrapper.y - } + SetProperties { target: wrapper.ListView.view; explicit: true; yPosition: wrapper.y } // Disallow flicking while we're in detailed view - SetProperty { target: wrapper.ListView.view; property: "locked"; value: 1 } + SetProperties { target: wrapper.ListView.view; locked: 1 } } ] transitions: [ diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index db826a3..df8660f 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -64,11 +64,7 @@ Item { State { name: "back" when: modelData.flipped == true - SetProperty { - target: flipable - property: "rotation" - value: 180 - } + SetProperties { target: flipable; rotation: 180 } } ] transitions: [ diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 42e8f25..bf40d2d 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -16,16 +16,8 @@ Rect { State { name: "ShowBars" when: View.moving - SetProperty { - target: SBV - property: "opacity" - value: 1 - } - SetProperty { - target: SBH - property: "opacity" - value: 1 - } + SetProperties { target: SBV; opacity: 1 } + SetProperties { target: SBH; opacity: 1 } } ] transitions: [ diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml index 8bc88e4..cd93ec9 100644 --- a/examples/declarative/slideswitch/Switch.qml +++ b/examples/declarative/slideswitch/Switch.qml @@ -39,13 +39,13 @@ Item { states: [ State { name: "On" - SetProperty { target: Knob; property: "x"; value: 78 } - SetProperty { target: Switch; property: "on"; value: true } + SetProperties { target: Knob; x: 78 } + SetProperties { target: Switch; on: true } }, State { name: "Off" - SetProperty { target: Knob; property: "x"; value: 1 } - SetProperty { target: Switch; property: "on"; value: false } + SetProperties { target: Knob; x: 1 } + SetProperties { target: Switch; on: false } } ] transitions: [ diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml index bcde20c..6bd9813 100644 --- a/examples/declarative/states/states.qml +++ b/examples/declarative/states/states.qml @@ -26,15 +26,15 @@ Rect { // In state 'Position1', change the 'myrect' item x, y to 150, 50. State { name: "Position1" - SetProperty { target: myrect; property: "x"; value: 150 } - SetProperty { target: myrect; property: "y"; value: 50 } + SetProperties { target: myrect; x: 150 } + SetProperties { target: myrect; y: 50 } }, // In state 'Position2', change y to 100. We do not specify 'x' here - // it will therefore be restored to its default value of 0, if it // had been changed. State { name: "Position2" - SetProperty { target: myrect; property: "y"; value: 200 } + SetProperties { target: myrect; y: 200 } } ] } diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 4c1dceb..d01fea8 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -26,15 +26,15 @@ Rect { // In state 'Position1', change the 'myrect' item x, y to 150, 50. State { name: "Position1" - SetProperty { target: myrect; property: "x"; value: 150 } - SetProperty { target: myrect; property: "y"; value: 50 } + SetProperties { target: myrect; x: 150; } + SetProperties { target: myrect; y: 50; } }, // In state 'Position2', change y to 100. We do not specify 'x' here - // it will therefore be restored to its default value of 0, if it // had been changed. State { name: "Position2" - SetProperty { target: myrect; property: "y"; value: 200 } + SetProperties { target: myrect; y: 200 } } ] diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml index a359aaf..135a519 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml @@ -79,30 +79,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml index 4db49ea..5ee56ce 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml @@ -86,30 +86,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml index 29d464b..00dec9e 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml @@ -74,30 +74,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml index 3142c45..3a9f318 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml @@ -74,30 +74,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml index 3142c45..3a9f318 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml @@ -74,30 +74,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml index bf6e82d..362591e 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml @@ -76,30 +76,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: 230 + width: 230 } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml index 99a521d..5595414 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml @@ -81,31 +81,26 @@ Rect { State { name: "opened" //! [use width] - SetProperty { + SetProperties { target: removeButton - property: "width" - value: removeButton.expandedWidth + width: removeButton.expandedWidth } //! [use width] - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml index 890d781..8ae4d7d 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml @@ -34,15 +34,13 @@ Item { State { name: "editingText" when: fieldText.state == 'editing' - SetProperty { + SetProperties { target: removeButton.anchors - property: "rightMargin" - value: -35 + rightMargin: -35 } - SetProperty { + SetProperties { target: fieldText - property: "width" - value: contactField.width + width: contactField.width } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml index 8bf5317..b55aab8 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml @@ -94,40 +94,33 @@ Rect { states: [ State { name: "editing" - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: textEdit - property: "readOnly" - value: false + readOnly: false } - SetProperty { + SetProperties { target: textEdit - property: "focus" - value: true + focus: true } - SetProperty { + SetProperties { target: editRegion - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "leftMargin" - value: 39 + leftMargin: 39 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "rightMargin" - value: 39 + rightMargin: 39 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml index 2f27a69..6b4cd99 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml @@ -77,30 +77,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: removeButton.expandedWidth + width: removeButton.expandedWidth } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml index e9927e9..06a959d 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml @@ -32,15 +32,13 @@ Item { State { name: "editingText" when: fieldText.state == 'editing' - SetProperty { + SetProperties { target: removeButton.anchors - property: "rightMargin" - value: -35 + rightMargin: -35 } - SetProperty { + SetProperties { target: fieldText - property: "width" - value: contactField.width + width: contactField.width } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml index d4fbc20..1a5b77b 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml @@ -95,40 +95,33 @@ Rect { states: [ State { name: "editing" - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: textEdit - property: "readOnly" - value: false + readOnly: false } - SetProperty { + SetProperties { target: textEdit - property: "focus" - value: true + focus: true } - SetProperty { + SetProperties { target: editRegion - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "leftMargin" - value: 39 + leftMargin: 39 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "rightMargin" - value: 39 + rightMargin: 39 } } ] diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml index bfe496e..4398ac1 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml @@ -82,30 +82,25 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: removeButton.expandedWidth + width: removeButton.expandedWidth } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml index 0a293f5..1be4b99 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml @@ -71,30 +71,26 @@ Item { states: [ State { name: "opened" - SetProperty { + SetProperties { target: wrapper - property: "height" - value: contactListView.height + height: contactListView.height } - SetProperty { + SetProperties { target: contactListView - property: "yPosition" - value: wrapper.y + explicit: true + yPosition: wrapper.y } - SetProperty { + SetProperties { target: contactListView - property: "locked" - value: 1 + locked: 1 } - SetProperty { + SetProperties { target: label - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: Details - property: "opacity" - value: 1 + opacity: 1 } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml index 7a44a3f..a3b3e18 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml @@ -89,30 +89,26 @@ Item { states: [ State { name: "opened" - SetProperty { + SetProperties { target: wrapper - property: "height" - value: contactListView.height + height: contactListView.height } - SetProperty { + SetProperties { target: contactListView - property: "yPosition" - value: wrapper.y + explicit: true + yPosition: wrapper.y } - SetProperty { + SetProperties { target: contactListView - property: "locked" - value: 1 + locked: 1 } - SetProperty { + SetProperties { target: label - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: Details - property: "opacity" - value: 1 + opacity: 1 } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml index 3b76a13..5623b26 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml @@ -24,10 +24,9 @@ Item { State { name: "pressed" when: buttonMouseRegion.pressed == true - SetProperty { + SetProperties { target: buttonRect - property: "color" - value: "green" + color: "green" } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml index e9927e9..06a959d 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml @@ -32,15 +32,13 @@ Item { State { name: "editingText" when: fieldText.state == 'editing' - SetProperty { + SetProperties { target: removeButton.anchors - property: "rightMargin" - value: -35 + rightMargin: -35 } - SetProperty { + SetProperties { target: fieldText - property: "width" - value: contactField.width + width: contactField.width } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml index 111d9c5..b4dc559 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml @@ -95,40 +95,33 @@ Rect { states: [ State { name: "editing" - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: textEdit - property: "readOnly" - value: false + readOnly: false } - SetProperty { + SetProperties { target: textEdit - property: "focus" - value: true + focus: true } - SetProperty { + SetProperties { target: editRegion - property: "opacity" - value: 0 + opacity: 0 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "leftMargin" - value: 39 + leftMargin: 39 } - SetProperty { + SetProperties { target: textEdit.anchors - property: "rightMargin" - value: 39 + rightMargin: 39 } } ] diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml index c0ea79d..95ca062 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml @@ -80,30 +80,26 @@ Rect { states: [ State { name: "opened" - SetProperty { + SetProperties { target: removeButton - property: "width" - value: removeButton.expandedWidth + explicit: true + width: removeButton.expandedWidth } - SetProperty { + SetProperties { target: text - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: confirmIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: cancelIcon - property: "opacity" - value: 1 + opacity: 1 } - SetProperty { + SetProperties { target: trashIcon - property: "opacity" - value: 0 + opacity: 0 } } ] diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index bd89ecf..e0515ec 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -14,16 +14,8 @@ Rect { State { name: "down" when: MouseRegion.pressed == true - SetProperty { - target: HelloText - property: "y" - value: 160 - } - SetProperty { - target: HelloText - property: "color" - value: "red" - } + SetProperties { target: HelloText; y: 160 } + SetProperties { target: HelloText; color: "red" } } ] transitions: [ diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index b465ef1..a5bb2f1 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -64,16 +64,8 @@ Rect { states: [ State { name: "Details" - SetProperty { - target: Wrapper - property: "height" - binding: "contents.height + 10" - } - SetProperty { - target: Description - property: "opacity" - value: 1 - } + SetProperties { target: Wrapper; height: contents.height + 10 } + SetProperties { target: Description; opacity: 1 } } ] transitions: [ diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index d1835cf..222ea87 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -53,18 +53,18 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); QmlBindableValuePrivate::QmlBindableValuePrivate() -: inited(false), updating(false), mePtr(0) +: inited(false), updating(false), enabled(true), mePtr(0) { } QML_DEFINE_NOCREATE_TYPE(QmlBindableValue); -QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), data, rc, obj) +QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, data, rc, obj) { } -QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), str, obj) +QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, str, obj) { } @@ -105,6 +105,15 @@ void QmlBindableValue::setExpression(const QString &expr) update(); } +void QmlBindableValue::forceUpdate() +{ + Q_D(QmlBindableValue); + if (!d->inited) + init(); + else + update(); +} + Q_DECLARE_METATYPE(QList); void QmlBindableValue::update() { @@ -113,7 +122,7 @@ void QmlBindableValue::update() #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer bu; #endif - if (!d->inited) + if (!d->inited || !d->enabled) return; if (!d->updating) { @@ -159,4 +168,18 @@ void QmlBindableValue::valueChanged() update(); } +void QmlBindableValue::setEnabled(bool e) +{ + Q_D(QmlBindableValue); + d->enabled = e; + setTrackChange(e); +} + +bool QmlBindableValue::enabled() const +{ + Q_D(const QmlBindableValue); + + return d->enabled; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index f54481a..50bbf36 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -62,8 +62,8 @@ class Q_DECLARATIVE_EXPORT QmlBindableValue : public QmlPropertyValueSource, { Q_OBJECT public: - QmlBindableValue(const QString &, QObject *, QObject *parent=0); - QmlBindableValue(void *, QmlRefCount *, QObject *, QObject *parent); + QmlBindableValue(const QString &, QObject *, QmlContext *, QObject *parent=0); + QmlBindableValue(void *, QmlRefCount *, QObject *, QmlContext *, QObject *parent); ~QmlBindableValue(); virtual void setTarget(const QmlMetaProperty &); @@ -74,8 +74,12 @@ public: virtual void setExpression(const QString &); void init(); + void forceUpdate(); -private Q_SLOTS: + void setEnabled(bool); + bool enabled() const; + +public Q_SLOTS: void update(); protected: diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h index 9476b80..b55a314 100644 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -54,8 +54,10 @@ class QmlBindableValuePrivate : public QObjectPrivate public: QmlBindableValuePrivate(); - bool inited; - bool updating; + bool inited:1; + bool updating:1; + bool enabled:1; + QmlMetaProperty property; QmlBindableValue **mePtr; diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 52036c2..30e818b 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -519,7 +519,7 @@ QMetaProperty QmlMetaProperty::property() const Returns the binding associated with this property, or 0 if no binding exists. */ -QmlBindableValue *QmlMetaProperty::binding() +QmlBindableValue *QmlMetaProperty::binding() const { if (!isProperty() || type() & Attached) return 0; @@ -537,6 +537,51 @@ QmlBindableValue *QmlMetaProperty::binding() return 0; } +/*! + Set the binding associated with this property to \a binding. Returns + the existing binding (if any), otherwise 0. + + \a binding will be enabled, and the returned binding (if any) will be + disabled. +*/ +QmlBindableValue *QmlMetaProperty::setBinding(QmlBindableValue *binding) const +{ + if (!isProperty() || type() & Attached) + return 0; + + const QObjectList &children = object()->children(); + for (QObjectList::ConstIterator iter = children.begin(); + iter != children.end(); ++iter) { + QObject *child = *iter; + if (child->metaObject() == &QmlBindableValue::staticMetaObject) { + QmlBindableValue *v = static_cast(child); + if (v->property() == *this && v->enabled()) { + + v->setEnabled(false); + + if (binding) { + binding->setParent(object()); + binding->setTarget(*this); + binding->setEnabled(true); + binding->forceUpdate(); + } + + return v; + + } + } + } + + if (binding) { + binding->setParent(object()); + binding->setTarget(*this); + binding->setEnabled(true); + binding->forceUpdate(); + } + + return 0; +} + /*! \internal */ int QmlMetaProperty::findSignal(const QObject *obj, const char *name) { diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index 9daef59..ce2fbcf 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -123,7 +123,9 @@ public: QMetaProperty property() const; - QmlBindableValue *binding(); + QmlBindableValue *binding() const; + QmlBindableValue *setBinding(QmlBindableValue *) const; + static int findSignal(const QObject *, const char *); int coreIndex() const; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index a3ee4e5..962d917 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -564,7 +564,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledComp QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, 0); + QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, QmlContext::activeContext(), 0); bindValues.append(bind); QmlBindableValuePrivate *p = static_cast(QObjectPrivate::get(bind)); @@ -584,7 +584,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledComp QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, false); + QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, QmlContext::activeContext()); bindValues.append(bind); QmlBindableValuePrivate *p = static_cast(QObjectPrivate::get(bind)); diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 2a6cad9..e5f1138 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -958,8 +958,6 @@ void QmlColorAnimation::transition(QmlStateActions &actions, myAction.fromValue = QVariant(d->fromValue); myAction.toValue = QVariant(d->toValue); - myAction.bv = 0; - myAction.event = 0; data->actions << myAction; } } @@ -1766,8 +1764,6 @@ void QmlNumericAnimation::transition(QmlStateActions &actions, myAction.fromValue = QVariant(d->from); myAction.toValue = QVariant(d->to); - myAction.bv = 0; - myAction.event = 0; data->actions << myAction; } } @@ -2332,8 +2328,6 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType()); myAction.toValue = d->to; - myAction.bv = 0; - myAction.event = 0; data->actions << myAction; } } diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index cb97ed9..240e37b 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -113,7 +114,8 @@ class QmlSetPropertiesPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlSetProperties) public: - QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true) {} + QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true), + isExplicit(false) {} QObject *object; QByteArray data; @@ -121,6 +123,7 @@ public: void decode(); bool restore; + bool isExplicit; QList > properties; QList > expressions; @@ -205,6 +208,7 @@ QmlSetPropertiesParser::compile(const QList &props, void QmlSetPropertiesPrivate::decode() { + Q_Q(QmlSetProperties); if (decoded) return; @@ -221,7 +225,7 @@ void QmlSetPropertiesPrivate::decode() ds >> data; if (isScript) { - QmlExpression *expression = new QmlExpression(qmlContext(object), data.toString(), object); + QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object); expression->setTrackChange(false); expressions << qMakePair(name, expression); } else { @@ -347,7 +351,13 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); - a.toValue = d->expressions.at(ii).second->value(); + + if (d->isExplicit) { + a.toValue = d->expressions.at(ii).second->value(); + } else { + a.toBinding = new QmlBindableValue(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + a.toBinding->setTarget(prop); + } list << a; } @@ -357,6 +367,18 @@ QmlSetProperties::ActionList QmlSetProperties::actions() return list; } +bool QmlSetProperties::isExplicit() const +{ + Q_D(const QmlSetProperties); + return d->isExplicit; +} + +void QmlSetProperties::setIsExplicit(bool e) +{ + Q_D(QmlSetProperties); + d->isExplicit = e; +} + QML_DEFINE_CUSTOM_TYPE(QmlSetProperties,SetProperties,QmlSetPropertiesParser) QT_END_NAMESPACE diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index da5fcf2..fe98900 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QmlSetProperties : public QmlStateOperation Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) + Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit); public: QmlSetProperties(); ~QmlSetProperties(); @@ -69,6 +70,9 @@ public: bool restoreEntryValues() const; void setRestoreEntryValues(bool); + bool isExplicit() const; + void setIsExplicit(bool); + virtual ActionList actions(); }; QML_DECLARE_TYPE(QmlSetProperties) diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index 0574224..fe215e7 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() : restore(true), bv(0), event(0), actionDone(false) +Action::Action() : restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0) { } @@ -237,8 +237,9 @@ QmlState &QmlState::operator<<(QmlStateOperation *op) void QmlStatePrivate::applyBindings() { foreach(const Action &action, bindingsList) { - if (action.bv && !action.toBinding.isEmpty()) { - action.bv->setExpression(action.toBinding); + if (action.toBinding) { + action.property.setBinding(action.toBinding); + action.toBinding->forceUpdate(); } } } @@ -246,6 +247,7 @@ void QmlStatePrivate::applyBindings() void QmlStatePrivate::complete() { Q_Q(QmlState); + //apply bindings (now that all transitions are complete) applyBindings(); @@ -316,6 +318,15 @@ void QmlState::cancel() } } +void Action::deleteFromBinding() +{ + if (fromBinding) { + property.setBinding(0); + delete fromBinding; + fromBinding = 0; + } +} + void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *revert) { Q_D(QmlState); @@ -341,20 +352,36 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever QmlStatePrivate::SimpleActionList additionalReverts; // First add the reverse of all the applyList actions for (int ii = 0; ii < applyList.count(); ++ii) { - const Action &action = applyList.at(ii); - if (action.event || !action.restore) + Action &action = applyList[ii]; + + if (action.event) continue; + action.fromBinding = action.property.binding(); + bool found = false; - for (int jj = 0; !found && jj < d->revertList.count(); ++jj) { - if (d->revertList.at(jj).property == action.property) + int jj; + for (jj = 0; jj < d->revertList.count(); ++jj) { + if (d->revertList.at(jj).property == action.property) { found = true; + break; + } } + if (!found) { - // Only need to revert the applyList action if the previous - // state doesn't have a higher priority revert already - SimpleAction r(action); - additionalReverts << r; + if (!action.restore) { + action.deleteFromBinding(); + } else { + // Only need to revert the applyList action if the previous + // state doesn't have a higher priority revert already + SimpleAction r(action); + additionalReverts << r; + } + } else { + + if (!found || d->revertList.at(jj).binding != action.fromBinding) { + action.deleteFromBinding(); + } } } @@ -369,15 +396,13 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } if (!found) { QVariant cur = d->revertList.at(ii).property.read(); + delete d->revertList.at(ii).property.setBinding(0); + Action a; a.property = d->revertList.at(ii).property; a.fromValue = cur; a.toValue = d->revertList.at(ii).value; a.toBinding = d->revertList.at(ii).binding; - if (!a.toBinding.isEmpty()) { - a.fromBinding = d->revertList.at(ii).bv->expression(); - a.bv = d->revertList.at(ii).bv; - } applyList << a; // Store these special reverts in the reverting list d->reverting << d->revertList.at(ii).property; @@ -396,9 +421,12 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever // Determine which actions are binding changes. foreach(const Action &action, applyList) { - if (action.bv && !action.toBinding.isEmpty()) { + if (action.toBinding) { d->bindingsList << action; - action.bv->clearExpression(); + if (action.fromBinding) + action.property.setBinding(0); // Disable current binding + } else if (action.fromBinding) { + action.property.setBinding(0); // Disable current binding } } @@ -415,8 +443,9 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever // Apply all the property and binding changes foreach(const Action &action, applyList) { - if (action.bv && !action.toBinding.isEmpty()) { - action.bv->setExpression(action.toBinding); + if (action.toBinding) { + action.property.setBinding(action.toBinding); + action.toBinding->forceUpdate(); } else if (!action.event) { action.property.write(action.toValue); } @@ -429,9 +458,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever continue; const QmlMetaProperty &prop = action->property; - if (action->bv && !action->toBinding.isEmpty()) { + if (action->toBinding) action->toValue = prop.read(); - } } // Revert back to the original values @@ -439,8 +467,9 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever if (action.event) continue; - if (action.bv && !action.toBinding.isEmpty()) - action.bv->clearExpression(); + if (action.toBinding) + action.property.setBinding(0); + action.property.write(action.fromValue); } } @@ -480,12 +509,15 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } // Any actions remaining have not been handled by the transition and should - // be applied immediately + // be applied immediately. We skip applying transitions, as they are all + // applied at the end in applyBindings() to avoid any nastiness mid + // transition foreach(const Action &action, applyList) { - if (action.event) + if (action.event) { action.event->execute(); - else + } else { action.property.write(action.toValue); + } } if (!trans) d->applyBindings(); //### merge into above foreach? diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 59ef812..e9a173c 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -60,15 +60,18 @@ class Action public: Action(); + bool restore:1; + bool actionDone:1; + QmlMetaProperty property; - bool restore; QVariant fromValue; QVariant toValue; - QString fromBinding; - QString toBinding; - QmlBindableValue *bv; + + QmlBindableValue *fromBinding; + QmlBindableValue *toBinding; ActionEvent *event; - bool actionDone; + + void deleteFromBinding(); }; class ActionEvent diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 7fcbcd7..b4ec476 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -52,23 +52,21 @@ class SimpleAction { public: enum State { StartState, EndState }; - SimpleAction(const Action &a, State state = StartState) : bv(0) + SimpleAction(const Action &a, State state = StartState) { property = a.property; if (state == StartState) { value = a.fromValue; - binding = a.fromBinding; + binding = property.binding(); } else { value = a.toValue; binding = a.toBinding; } - bv = a.bv; } QmlMetaProperty property; QVariant value; - QString binding; - QmlBindableValue *bv; + QmlBindableValue *binding; }; class QmlStatePrivate : public QObjectPrivate diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 02b54f8..b7398a3 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -417,14 +417,8 @@ QmlSetProperty::ActionList QmlSetProperty::actions() a.property = prop; a.fromValue = cur; a.toValue = d->value; - if (!d->binding.isEmpty()) { - QmlBindableValue *bv = prop.binding(); - if (bv) { - a.fromBinding = bv->expression(); - a.bv = bv; - } - } - a.toBinding = d->binding; + if (!d->binding.isEmpty()) + a.toBinding = new QmlBindableValue(d->binding, object(), qmlContext(this)); return ActionList() << a; } diff --git a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml index 61cedc2..9cb2509 100644 --- a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml @@ -13,15 +13,13 @@ Rect { states: [ State { name: "hello" - SetProperty { + SetProperties { target: MyRect - property: "x" - binding: 100 + x: 100 } - SetProperty { + SetProperties { target: MyMouseRegion - property: "onClicked" - value: "Page.currentState = ''" + onClicked: "Page.currentState = ''" } } ] diff --git a/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml b/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml index d351b8c..cb631d4 100644 --- a/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml +++ b/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml @@ -5,18 +5,16 @@ Rect { states: [ State { name: "first" - SetProperty { + SetProperties { target: mainrect - property: "color" - value: "red" + color: "red" } }, State { name: "second" - SetProperty { + SetProperties { target: mainrect - property: "color" - value: "blue" + color: "blue" } } ] diff --git a/tests/auto/declarative/visual/easing/easing.qml b/tests/auto/declarative/visual/easing/easing.qml index 4a0ed14..14622c9 100644 --- a/tests/auto/declarative/visual/easing/easing.qml +++ b/tests/auto/declarative/visual/easing/easing.qml @@ -148,19 +148,17 @@ Rect { State { name: "from" when: !mouse.pressed - SetProperty { + SetProperties { target: text - property: "x" - value: 0 + x: 0 } }, State { name: "to" when: mouse.pressed - SetProperty { + SetProperties { target: text - property: "x" - value: item.width-100 + x: item.width-100 } } ] -- cgit v0.12 From 16a8e075e09323b3e77f8faa58bfc9e9a3bf310f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Jun 2009 11:23:22 +1000 Subject: Move some non-essential classes to extra. --- src/declarative/extra/extra.pri | 17 +- src/declarative/extra/qbindablemap.cpp | 182 ++++++++++++ src/declarative/extra/qbindablemap.h | 87 ++++++ src/declarative/extra/qfxanimatedimageitem.cpp | 212 ++++++++++++++ src/declarative/extra/qfxanimatedimageitem.h | 100 +++++++ src/declarative/extra/qfxanimatedimageitem_p.h | 77 +++++ src/declarative/extra/qfxblendedimage.cpp | 308 ++++++++++++++++++++ src/declarative/extra/qfxblendedimage.h | 110 +++++++ src/declarative/extra/qfxflowview.cpp | 381 +++++++++++++++++++++++++ src/declarative/extra/qfxflowview.h | 106 +++++++ src/declarative/extra/qmlbehaviour.cpp | 259 +++++++++++++++++ src/declarative/extra/qmlbehaviour.h | 95 ++++++ src/declarative/extra/qmldatetimeformatter.cpp | 368 ++++++++++++++++++++++++ src/declarative/extra/qmldatetimeformatter.h | 115 ++++++++ src/declarative/fx/fx.pri | 6 - src/declarative/fx/qfxanimatedimageitem.cpp | 212 -------------- src/declarative/fx/qfxanimatedimageitem.h | 100 ------- src/declarative/fx/qfxanimatedimageitem_p.h | 77 ----- src/declarative/fx/qfxblendedimage.cpp | 308 -------------------- src/declarative/fx/qfxblendedimage.h | 110 ------- src/declarative/fx/qfxflowview.cpp | 381 ------------------------- src/declarative/fx/qfxflowview.h | 106 ------- src/declarative/util/qbindablemap.cpp | 182 ------------ src/declarative/util/qbindablemap.h | 87 ------ src/declarative/util/qmlbehaviour.cpp | 259 ----------------- src/declarative/util/qmlbehaviour.h | 95 ------ src/declarative/util/qmldatetimeformatter.cpp | 368 ------------------------ src/declarative/util/qmldatetimeformatter.h | 115 -------- src/declarative/util/util.pri | 6 - 29 files changed, 2415 insertions(+), 2414 deletions(-) create mode 100644 src/declarative/extra/qbindablemap.cpp create mode 100644 src/declarative/extra/qbindablemap.h create mode 100644 src/declarative/extra/qfxanimatedimageitem.cpp create mode 100644 src/declarative/extra/qfxanimatedimageitem.h create mode 100644 src/declarative/extra/qfxanimatedimageitem_p.h create mode 100644 src/declarative/extra/qfxblendedimage.cpp create mode 100644 src/declarative/extra/qfxblendedimage.h create mode 100644 src/declarative/extra/qfxflowview.cpp create mode 100644 src/declarative/extra/qfxflowview.h create mode 100644 src/declarative/extra/qmlbehaviour.cpp create mode 100644 src/declarative/extra/qmlbehaviour.h create mode 100644 src/declarative/extra/qmldatetimeformatter.cpp create mode 100644 src/declarative/extra/qmldatetimeformatter.h delete mode 100644 src/declarative/fx/qfxanimatedimageitem.cpp delete mode 100644 src/declarative/fx/qfxanimatedimageitem.h delete mode 100644 src/declarative/fx/qfxanimatedimageitem_p.h delete mode 100644 src/declarative/fx/qfxblendedimage.cpp delete mode 100644 src/declarative/fx/qfxblendedimage.h delete mode 100644 src/declarative/fx/qfxflowview.cpp delete mode 100644 src/declarative/fx/qfxflowview.h delete mode 100644 src/declarative/util/qbindablemap.cpp delete mode 100644 src/declarative/util/qbindablemap.h delete mode 100644 src/declarative/util/qmlbehaviour.cpp delete mode 100644 src/declarative/util/qmlbehaviour.h delete mode 100644 src/declarative/util/qmldatetimeformatter.cpp delete mode 100644 src/declarative/util/qmldatetimeformatter.h diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index 2590fbc..a0bbdf4 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -1,14 +1,27 @@ SOURCES += \ extra/qnumberformat.cpp \ extra/qmlnumberformatter.cpp \ + extra/qmldatetimeformatter.cpp \ extra/qfxintegermodel.cpp \ - extra/qmltimer.cpp + extra/qmltimer.cpp \ + extra/qfxanimatedimageitem.cpp \ + extra/qfxblendedimage.cpp \ + extra/qfxflowview.cpp \ + extra/qmlbehaviour.cpp \ + extra/qbindablemap.cpp HEADERS += \ extra/qnumberformat.h \ extra/qmlnumberformatter.h \ + extra/qmldatetimeformatter.h \ extra/qfxintegermodel.h \ - extra/qmltimer.h + extra/qmltimer.h \ + extra/qfxanimatedimageitem.h \ + extra/qfxanimatedimageitem_p.h \ + extra/qfxblendedimage.h \ + extra/qfxflowview.h \ + extra/qmlbehaviour.h \ + extra/qbindablemap.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns diff --git a/src/declarative/extra/qbindablemap.cpp b/src/declarative/extra/qbindablemap.cpp new file mode 100644 index 0000000..c8c8ced --- /dev/null +++ b/src/declarative/extra/qbindablemap.cpp @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbindablemap.h" +#include +#include + +QT_BEGIN_NAMESPACE + +//QBindableMapMetaObject lets us listen for changes coming from QML +//so we can emit the changed signal. +class QBindableMapMetaObject : public QmlOpenMetaObject +{ +public: + QBindableMapMetaObject(QBindableMap *obj) : QmlOpenMetaObject(obj) + { + map = obj; + } + +protected: + virtual void propertyWrite(int index) + { + map->emitChanged(QLatin1String(name(index))); + } + +private: + QBindableMap *map; +}; + +/*! + \class QBindableMap + \brief The QBindableMap class allows you to set key-value pairs that can be used in bindings. + + QBindableMap provides a convenient way to expose domain data to the UI layer. + The following example shows how you might declare data in C++ and then + access it in QML. + + Setup in C++: + \code + //create our data + QBindableMap ownerData; + ownerData.setValue("name", QVariant(QString("John Smith"))); + ownerData.setValue("phone", QVariant(QString("555-5555"))); + + //expose it to the UI layer + QmlContext *ctxt = view->bindContext(); + ctxt->setProperty("owner", &data); + \endcode + + Then, in QML: + \code + Text { text: owner.name } + Text { text: owner.phone } + \endcode + + The binding is dynamic - whenever a key's value is updated, anything bound to that + key will be updated as well. + + To detect value changes made in the UI layer you can connect to the changed() signal. + However, note that changed() is \b NOT emitted when changes are made by calling setValue() + or clearValue() - it is only emitted when a value is updated from QML. +*/ + +// is there a more efficient way to store/return keys? +// (or should we just provide an iterator or something else instead?) +// can we provide a way to clear keys? +// do we want to make any claims regarding key ordering? +// should we have signals for insertion and and deletion -- becoming more model like +// should we emit change for our own changes as well? +// Bug or Feature?: values can be created in QML (owner.somethingElse = "Hello") will create somethingElse property. (need to verify if this is actually the case) +// Bug or Feature?: all values are read-write (there are no read-only values) + +/*! + Constructs a bindable map with parent object \a parent. +*/ +QBindableMap::QBindableMap(QObject *parent) +: QObject(parent) +{ + m_mo = new QBindableMapMetaObject(this); +} + +/*! + Destroys the bindable map. +*/ +QBindableMap::~QBindableMap() +{ +} + +/*! + Clears the value (if any) associated with \a key. +*/ +void QBindableMap::clearValue(const QString &key) +{ + //m_keys.remove(); //### + m_mo->setValue(key.toLatin1(), QVariant()); + //emit changed(key); +} + +/*! + Returns the value associated with \a key. + + If no value has been set for this key (or if the value has been cleared), + an invalid QVariant is returned. +*/ +QVariant QBindableMap::value(const QString &key) const +{ + return m_mo->value(key.toLatin1()); +} + +/*! + Sets the value associated with \a key to \a value. + + If the key doesn't exist, it is automatically created. +*/ +void QBindableMap::setValue(const QString &key, QVariant value) +{ + if (!m_keys.contains(key)) + m_keys.append(key); + m_mo->setValue(key.toLatin1(), value); + //emit changed(key); +} + +/*! + Returns the list of keys. + + Keys that have been cleared will still appear in this list, even though their + associated values are invalid QVariants. +*/ +QStringList QBindableMap::keys() const +{ + return m_keys; +} + +/*! + \fn void QBindableMap::changed(const QString &key) + This signal is emitted whenever one of the values in the map is changed. \a key + is the key corresponding to the value that was changed. + */ + +void QBindableMap::emitChanged(const QString &key) +{ + emit changed(key); +} +QT_END_NAMESPACE diff --git a/src/declarative/extra/qbindablemap.h b/src/declarative/extra/qbindablemap.h new file mode 100644 index 0000000..c76928d --- /dev/null +++ b/src/declarative/extra/qbindablemap.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBINDABLEMAP_H +#define QBINDABLEMAP_H + +#include +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QBindableMapMetaObject; +class Q_DECLARATIVE_EXPORT QBindableMap : public QObject +{ + Q_OBJECT +public: + QBindableMap(QObject *parent = 0); + virtual ~QBindableMap(); + + QVariant value(const QString &key) const; + void setValue(const QString &key, QVariant value); + void clearValue(const QString &key); + + Q_INVOKABLE QStringList keys() const; + +Q_SIGNALS: + void changed(const QString &key); + +private: + Q_DISABLE_COPY(QBindableMap) + void emitChanged(const QString &key); + QBindableMapMetaObject *m_mo; + QStringList m_keys; + friend class QBindableMapMetaObject; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER +#endif diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp new file mode 100644 index 0000000..d22959a --- /dev/null +++ b/src/declarative/extra/qfxanimatedimageitem.cpp @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "qfxanimatedimageitem.h" +#include "qfxanimatedimageitem_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QFxAnimatedImageItem + \internal +*/ + +/*! + \qmlclass AnimatedImage + \inherits Image + + This item provides for playing animations stored as images containing a series of frames, + such as GIF files. The full list of supported formats can be determined with + QMovie::supportedFormats(). + + \table + \row + \o \image animatedimageitem.gif + \o + \qml +Item { + width: anim.width; height: anim.height+8 + AnimatedImage { id: anim; source: "pics/games-anim.gif" } + Rect { color: "red"; width: 4; height: 8; y: anim.height + x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1) + } +} + \endqml + \endtable +*/ +QML_DEFINE_TYPE(QFxAnimatedImageItem, AnimatedImage) + +QFxAnimatedImageItem::QFxAnimatedImageItem(QFxItem *parent) + : QFxImage(*(new QFxAnimatedImageItemPrivate), parent) +{ +} + +QFxAnimatedImageItem::QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent) + : QFxImage(dd, parent) +{ +} + +QFxAnimatedImageItem::~QFxAnimatedImageItem() +{ + Q_D(QFxAnimatedImageItem); + delete d->_movie; +} + +/*! + \qmlproperty bool AnimatedImage::playing + This property holds whether the animated image is playing or not + + Defaults to true, so as to start playing immediately. +*/ +bool QFxAnimatedImageItem::isPlaying() const +{ + Q_D(const QFxAnimatedImageItem); + if (!d->_movie) + return false; + return d->_movie->state()==QMovie::Running; +} + +void QFxAnimatedImageItem::setPlaying(bool play) +{ + Q_D(QFxAnimatedImageItem); + if (!d->_movie) + return; + if (play) + d->_movie->start(); + else + d->_movie->stop(); +} + +/*! + \qmlproperty int AnimatedImage::currentFrame + \qmlproperty int AnimatedImage::frameCount + + currentFrame is the frame that is currently visible. Watching when this changes can + allow other things to animate at the same time as the image. frameCount is the number + of frames in the animation. For some animation formats, frameCount is unknown and set to zero. +*/ +int QFxAnimatedImageItem::currentFrame() const +{ + Q_D(const QFxAnimatedImageItem); + if (!d->_movie) + return -1; + return d->_movie->currentFrameNumber(); +} + +void QFxAnimatedImageItem::setCurrentFrame(int frame) +{ + Q_D(QFxAnimatedImageItem); + if (!d->_movie) + return; + d->_movie->jumpToFrame(frame); +} + +int QFxAnimatedImageItem::frameCount() const +{ + Q_D(const QFxAnimatedImageItem); + if (!d->_movie) + return 0; + return d->_movie->frameCount(); +} + +void QFxAnimatedImageItem::setSource(const QUrl &url) +{ + Q_D(QFxAnimatedImageItem); + if (url == d->url) + return; + + delete d->_movie; + d->_movie = 0; + + if (d->reply) { + d->reply->deleteLater(); + d->reply = 0; + } + + d->url = url; + + if (url.isEmpty()) { + delete d->_movie; + d->status = Idle; + } else { + d->status = Loading; + QNetworkRequest req(d->url); + req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req); + QObject::connect(d->reply, SIGNAL(finished()), + this, SLOT(movieRequestFinished())); + } + + emit statusChanged(d->status); +} + +void QFxAnimatedImageItem::movieRequestFinished() +{ + Q_D(QFxAnimatedImageItem); + d->_movie = new QMovie(d->reply); + if (!d->_movie->isValid()){ + qWarning() << "Error Reading File " << d->url; + delete d->_movie; + d->_movie = 0; + return; + } + connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), + this, SIGNAL(playingChanged())); + connect(d->_movie, SIGNAL(frameChanged(int)), + this, SLOT(movieUpdate())); + d->_movie->setCacheMode(QMovie::CacheAll); + d->_movie->start(); + setPixmap(d->_movie->currentPixmap()); +} + +void QFxAnimatedImageItem::movieUpdate() +{ + Q_D(QFxAnimatedImageItem); + setPixmap(d->_movie->currentPixmap()); + emit frameChanged(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h new file mode 100644 index 0000000..5d115d7 --- /dev/null +++ b/src/declarative/extra/qfxanimatedimageitem.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXANIMATEDIMAGEITEM_H +#define QFXANIMATEDIMAGEITEM_H + +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QMovie; +class QFxAnimatedImageItemPrivate; + +class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage +{ + Q_OBJECT + + Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) + Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) + Q_PROPERTY(int frameCount READ frameCount) +public: + QFxAnimatedImageItem(QFxItem *parent=0); + ~QFxAnimatedImageItem(); + + bool isPlaying() const; + void setPlaying(bool play); + + int currentFrame() const; + void setCurrentFrame(int frame); + + int frameCount() const; + + // Extends QFxImage's src property*/ + virtual void setSource(const QUrl&); + +Q_SIGNALS: + void playingChanged(); + void frameChanged(); + +private Q_SLOTS: + void movieUpdate(); + void movieRequestFinished(); + +protected: + QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent); + +private: + Q_DISABLE_COPY(QFxAnimatedImageItem) + Q_DECLARE_PRIVATE(QFxAnimatedImageItem) +}; + +QML_DECLARE_TYPE(QFxAnimatedImageItem) + + +QT_END_NAMESPACE + +QT_END_HEADER +#endif diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h new file mode 100644 index 0000000..e7d8fb8 --- /dev/null +++ b/src/declarative/extra/qfxanimatedimageitem_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXANIMATEDIMAGE_P_H +#define QFXANIMATEDIMAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QMovie; + +class QFxAnimatedImageItemPrivate : public QFxImagePrivate +{ + Q_DECLARE_PUBLIC(QFxAnimatedImageItem) + +public: + QFxAnimatedImageItemPrivate() + : _movie(0) + { + } + + QMovie *_movie; +}; + +QT_END_NAMESPACE + +#endif // QFXANIMATEDIMAGE_P_H diff --git a/src/declarative/extra/qfxblendedimage.cpp b/src/declarative/extra/qfxblendedimage.cpp new file mode 100644 index 0000000..0c93fef --- /dev/null +++ b/src/declarative/extra/qfxblendedimage.cpp @@ -0,0 +1,308 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfxblendedimage.h" +#include + +#if defined(QFX_RENDER_OPENGL2) +#include +#endif + +QT_BEGIN_NAMESPACE + +/*! + \qmlclass BlendedImage + \brief The BlendedImage elements blends two different images depending on a blend ratio. + + This element can be used to simulate blur on slow devices by setting secondaryUrl with + a pre-rendered blurred version of primaryUrl. + + Note that this class will only work under OpenGL. On the software canvas it will display + only the primary image unless the blend is > 0.75, in which case it will display only the + secondary image. +*/ + +/*! + \internal + \class QFxBlendedImage + \brief The QFxBlendedImage blends two different images depending on a blend ratio. + + This class can be used to simulate blur on slow devices by setting secondaryUrl with + a pre-rendered blurred version of primaryUrl. + + Note that this class will only work under OpenGL. On the software canvas it will display + only the primary image unless the blend is > 0.75, in which case it will display only the + secondary image. +*/ +QFxBlendedImage::QFxBlendedImage(QFxItem *parent) +: QFxItem(parent), _blend(0), _smooth(false), dirty(false) +{ +#if defined(QFX_RENDER_OPENGL2) + setOptions(HasContents); +#endif +} + +/*! + Cancels any pending image loads and destroys the image. +*/ +QFxBlendedImage::~QFxBlendedImage() +{ + if (!primUrl.isEmpty()) + QFxPixmap::cancelGet(primUrl,this); + if (!secUrl.isEmpty()) + QFxPixmap::cancelGet(secUrl,this); +} + +/*! + \qmlproperty string BlendedImage::primaryUrl + The URL of the first image to be displayed in this item. +*/ +QUrl QFxBlendedImage::primaryUrl() const +{ + return primUrl; +} + +void QFxBlendedImage::primaryLoaded() +{ + primPix = QFxPixmap(primUrl); + dirty = true; + update(); +} + +void QFxBlendedImage::setPrimaryUrl(const QUrl &url) +{ + if (primUrl == url) + return; + if (!primUrl.isEmpty()) + QFxPixmap::cancelGet(primUrl,this); + Q_ASSERT(!url.isRelative()); + primUrl = url; + if (!primUrl.isEmpty()) + QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded())); +} + +/*! + \qmlproperty string BlendedImage::secondaryUrl + The URL of the second image to be displayed in this item. +*/ +QUrl QFxBlendedImage::secondaryUrl() const +{ + return secUrl; +} + +void QFxBlendedImage::secondaryLoaded() +{ + secPix = QFxPixmap(secUrl); + dirty = true; + update(); +} + +void QFxBlendedImage::setSecondaryUrl(const QUrl &url) +{ + if (secUrl == url) + return; + if (!secUrl.isEmpty()) + QFxPixmap::cancelGet(secUrl,this); + Q_ASSERT(!url.isRelative()); + secUrl = url; + if (!secUrl.isEmpty()) + QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded())); +} + +/*! + \qmlproperty real BlendedImage::blend + The ratio used to blend the two images. + + If blend has a value of 0, only the first image will be displayed. + If blend has a value of 1, only the second image will be displayed. +*/ +qreal QFxBlendedImage::blend() const +{ + return _blend; +} + +void QFxBlendedImage::setBlend(qreal b) +{ + _blend = b; + update(); +} + +/*! + \qmlproperty bool BlendedImage::smooth + + Set this property if you want the image to be smoothly filtered when scaled or + transformed. Smooth filtering gives better visual quality, but is slower. If + the BlendedImage is displayed at its natural size, this property has no visual or + performance effect. + + \note Generally scaling artifacts are only visible if the image is stationary on + the screen. A common pattern when animating an image is to disable smooth + filtering at the beginning of the animation and reenable it at the conclusion. + */ +bool QFxBlendedImage::smoothTransform() const +{ + return _smooth; +} + +void QFxBlendedImage::setSmoothTransform(bool s) +{ + if (_smooth == s) + return; + _smooth = s; + update(); +} + +#if defined(QFX_RENDER_QPAINTER) + +void QFxBlendedImage::paintContents(QPainter &p) +{ + if (primUrl.isEmpty() && secUrl.isEmpty()) + return; + + if (_smooth) { + p.save(); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth); + } + + if (_blend < 0.75) + p.drawPixmap(0, 0, primPix); + else + p.drawPixmap(0, 0, secPix); + + if (_smooth) { + p.restore(); + } +} + +#elif defined(QFX_RENDER_OPENGL2) + +void QFxBlendedImage::paintGLContents(GLPainter &p) +{ + static DualTextureBlendShader *shader = 0; + if (!shader) + shader = new DualTextureBlendShader(); + + if (dirty) { + prim.clear(); + sec.clear(); + prim.setImage(primPix.toImage()); + sec.setImage(secPix.toImage()); + + dirty = false; + } + + if (prim.isNull() || sec.isNull()) { + + return; + } + + GLfloat vertices[8]; + GLfloat texVertices[8]; + + float widthV = width(); + float heightV = height(); + if (!widthV) + widthV = qMax(primPix.width(), secPix.width()); + if (!heightV) + heightV = qMax(primPix.height(), secPix.height()); + + vertices[0] = 0; vertices[1] = heightV; + vertices[2] = widthV; vertices[3] = heightV; + vertices[4] = 0; vertices[5] = 0; + vertices[6] = widthV; vertices[7] = 0; + + texVertices[0] = 0; texVertices[1] = 0; + texVertices[2] = 1; texVertices[3] = 0; + texVertices[4] = 0; texVertices[5] = 1; + texVertices[6] = 1; texVertices[7] = 1; + + if (_blend == 0 || _blend == 1) { + QGLShaderProgram *tshader = p.useTextureShader(); + + GLTexture *tex = 0; + + if (_blend == 0) + tex = &prim; + else + tex = &sec; + + tshader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); + tshader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); + + glBindTexture(GL_TEXTURE_2D, tex->texture()); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + tshader->disableAttributeArray(SingleTextureShader::Vertices); + tshader->disableAttributeArray(SingleTextureShader::TextureCoords); + } else { + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, prim.texture()); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, sec.texture()); + + shader->enable(); + shader->setOpacity(1); + qreal b = _blend; + if (b > 1) b = 1; + else if (b < 0) b = 0; + shader->setBlend(b); + shader->setTransform(p.activeTransform); + + shader->setAttributeArray(DualTextureBlendShader::Vertices, vertices, 2); + shader->setAttributeArray(DualTextureBlendShader::TextureCoords, texVertices, 2); + shader->setAttributeArray(DualTextureBlendShader::BlendTextureCoords, texVertices, 2); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + shader->disableAttributeArray(DualTextureBlendShader::Vertices); + shader->disableAttributeArray(DualTextureBlendShader::TextureCoords); + shader->disableAttributeArray(DualTextureBlendShader::BlendTextureCoords); + + glBindTexture(GL_TEXTURE_2D, 0); + glActiveTexture(GL_TEXTURE0); + } +} +#endif + +QML_DEFINE_TYPE(QFxBlendedImage,BlendedImage) + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxblendedimage.h b/src/declarative/extra/qfxblendedimage.h new file mode 100644 index 0000000..248cc9d --- /dev/null +++ b/src/declarative/extra/qfxblendedimage.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXBLENDEDIMAGE_H +#define QFXBLENDEDIMAGE_H + +#include +#if defined(QFX_RENDER_OPENGL2) +#include +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem +{ + Q_OBJECT + + Q_PROPERTY(QUrl primaryUrl READ primaryUrl WRITE setPrimaryUrl) + Q_PROPERTY(QUrl secondaryUrl READ secondaryUrl WRITE setSecondaryUrl) + Q_PROPERTY(qreal blend READ blend WRITE setBlend) + Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) +public: + QFxBlendedImage(QFxItem *parent=0); + ~QFxBlendedImage(); + + QUrl primaryUrl() const; + void setPrimaryUrl(const QUrl &); + + QUrl secondaryUrl() const; + void setSecondaryUrl(const QUrl &); + + qreal blend() const; + void setBlend(qreal); + + bool smoothTransform() const; + void setSmoothTransform(bool); + +#if defined(QFX_RENDER_QPAINTER) + void paintContents(QPainter &painter); +#elif defined(QFX_RENDER_OPENGL2) + void paintGLContents(GLPainter &); +#endif + +private Q_SLOTS: + void primaryLoaded(); + void secondaryLoaded(); + +private: + QUrl primUrl; + QUrl secUrl; + + qreal _blend; + bool _smooth; + bool dirty; +#if defined(QFX_RENDER_OPENGL2) + GLTexture prim; + GLTexture sec; +#endif + QPixmap primPix; + QPixmap secPix; +}; +QML_DECLARE_TYPE(QFxBlendedImage) + + +QT_END_NAMESPACE + +QT_END_HEADER +#endif // QFXBLENDEDIMAGE_H diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp new file mode 100644 index 0000000..77cd6df --- /dev/null +++ b/src/declarative/extra/qfxflowview.cpp @@ -0,0 +1,381 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfxvisualitemmodel.h" +#include "qfxflowview.h" + +QT_BEGIN_NAMESPACE + +class QFxFlowViewAttached : public QObject +{ +Q_OBJECT +Q_PROPERTY(int row READ row NOTIFY posChanged); +Q_PROPERTY(int column READ column NOTIFY posChanged); +public: + QFxFlowViewAttached(QObject *parent); + + int row() const; + int column() const; + +signals: + void posChanged(); + +private: + friend class QFxFlowView; + int m_row; + int m_column; +}; + + +QFxFlowView::QFxFlowView() +: m_columns(0), m_model(0), m_vertical(false), m_dragItem(0), m_dragIdx(-1) +{ + setAcceptedMouseButtons(Qt::LeftButton); + setOptions(MouseEvents); +} + +QFxVisualItemModel *QFxFlowView::model() const +{ + return m_model; +} + +void QFxFlowView::setModel(QFxVisualItemModel *m) +{ + m_model = m; + refresh(); +} + +int QFxFlowView::columns() const +{ + return m_columns; +} + +void QFxFlowView::setColumns(int c) +{ + m_columns = c; + refresh(); +} + +bool QFxFlowView::vertical() const +{ + return m_vertical; +} + +void QFxFlowView::setVertical(bool v) +{ + m_vertical = v; +} + +class QFxFlowViewValue : public QmlTimeLineValue +{ +public: + enum Property { xProperty, yProperty }; + + QFxFlowViewValue(QFxItem *item, Property p) + : m_item(item), m_property(p) {} + + qreal value() const { + return (m_property == xProperty)?m_item->x():m_item->y(); + } + void setValue(qreal v) { + if (m_property == xProperty) m_item->setX(v); + else m_item->setY(v); + } +private: + QFxItem *m_item; + Property m_property; +}; + +void QFxFlowView::refresh() +{ + if (m_model && m_columns >= 1) { + for (int ii = 0; ii < m_model->count(); ++ii) { + if (QFxItem *item = m_model->item(ii)) { + item->setParent(this); + item->setZ(0); + m_items << item; + } + } + + reflow(); + } +} + +void QFxFlowView::reflow(bool animate) +{ + qreal y = 0; + qreal maxY = 0; + qreal x = 0; + int row = 0; + int column = -1; + if (animate) + clearTimeLine(); + + for (int ii = 0; ii < m_items.count(); ++ii) { + if (0 == (ii % m_columns)) { + y += maxY; + maxY = 0; + x = 0; + row = 0; + column++; + } + + QFxItem *item = m_items.at(ii); + QFxFlowViewAttached *att = + (QFxFlowViewAttached *)qmlAttachedPropertiesObject(item); + att->m_row = row; + att->m_column = column; + emit att->posChanged(); + + + if (animate) { + if (vertical()) + moveItem(item, QPointF(y, x)); + else + moveItem(item, QPointF(x, y)); + } else { + if (vertical()) { + item->setX(y); + item->setY(x); + } else { + item->setX(x); + item->setY(y); + } + } + if (vertical()) { + x += item->height(); + maxY = qMax(maxY, item->width()); + } else { + x += item->width(); + maxY = qMax(maxY, item->height()); + } + ++row; + } +} + +void QFxFlowView::reflowDrag(const QPointF &dp) +{ + qreal y = 0; + qreal maxY = 0; + qreal x = 0; + + int flowedItems = 0; + + clearTimeLine(); + + QList items; + + bool dragUsed = false; + bool dragSeen = false; + for (int ii = 0; ii < m_items.count(); ++ii) { + if (0 == (ii % m_columns)) { + y += maxY; + maxY = 0; + x = 0; + } + + QFxItem *item = m_items.at(ii); + if (item == m_dragItem) + dragSeen = true; + if (item == m_dragItem && dragUsed) + continue; + QRectF r; + if (vertical()) + r = QRectF(y, x, item->width(), item->height()); + else + r = QRectF(x, y, item->width(), item->height()); + if (r.contains(dp)) { + dragUsed = true; + if (dragSeen) + m_dragIdx = items.count() + 1; + else + m_dragIdx = items.count(); + + items.append(m_dragItem); + if (m_dragItem != item) { + if (dragSeen) + items.insert(items.count() - 1, item); + else + items.append(item); + } + } else { + if (m_dragItem != item) + items.append(item); + } + + if (vertical()) { + x += item->height(); + maxY = qMax(maxY, item->width()); + } else { + x += item->width(); + maxY = qMax(maxY, item->height()); + } + } + + y = 0; + maxY = 0; + x = 0; + clearTimeLine(); + for (int ii = 0; ii < items.count(); ++ii) { + if (0 == (ii % m_columns)) { + y += maxY; + maxY = 0; + x = 0; + } + + QFxItem *item = items.at(ii); + if (item != m_dragItem) { + if (vertical()) + moveItem(item, QPointF(y, x)); + else + moveItem(item, QPointF(x, y)); + } + if (vertical()) { + x += item->height(); + maxY = qMax(maxY, item->width()); + } else { + x += item->width(); + maxY = qMax(maxY, item->height()); + } + } + +} + +void QFxFlowView::moveItem(QFxItem *item, const QPointF &p) +{ + QFxFlowViewValue *xv = new QFxFlowViewValue(item, QFxFlowViewValue::xProperty); + QFxFlowViewValue *yv = new QFxFlowViewValue(item, QFxFlowViewValue::yProperty); + m_values << xv << yv; + m_timeline.move(*xv, p.x(), 100); + m_timeline.move(*yv, p.y(), 100); +} + +#include + +void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + for (int ii = 0; ii < m_items.count(); ++ii) { + QFxItem *item = m_items.at(ii); + QRectF r = rectForItem(ii); + + if (r.contains(event->pos())) { + m_dragItem = item; + m_dragItem->setZ(1); + m_dragOffset = r.topLeft() - event->pos(); + event->accept(); + return; + } + } + event->ignore(); +} + +QRectF QFxFlowView::rectForItem(int idx) const +{ + QFxItem *item = m_items.at(idx); + QRectF r(item->x(), item->y(), item->width(), item->height()); + return r; +} + +void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (m_dragItem) { + m_dragItem->setZ(0); + + clearTimeLine(); + + if (m_dragIdx != -1) { + m_items.removeAll(m_dragItem); + m_items.insert(m_dragIdx, m_dragItem); + } + + reflow(true); + m_dragItem = 0; + m_dragIdx = -1; + } +} + +QFxFlowViewAttached::QFxFlowViewAttached(QObject *parent) +: QObject(parent), m_row(0), m_column(0) +{ +} + +int QFxFlowViewAttached::row() const +{ + return m_row; +} + +int QFxFlowViewAttached::column() const +{ + return m_column; +} + +QFxFlowViewAttached *QFxFlowView::qmlAttachedProperties(QObject *obj) +{ + return new QFxFlowViewAttached(obj); +} + +void QFxFlowView::clearTimeLine() +{ + m_timeline.clear(); + qDeleteAll(m_values); + m_values.clear(); +} + +void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (m_dragItem) { + QPointF p = event->pos() + m_dragOffset; + m_dragItem->setX(p.x()); + m_dragItem->setY(p.y()); + + for (int ii = 0; ii < m_items.count(); ++ii) { + if (m_items.at(ii) != m_dragItem && rectForItem(ii).contains(event->pos())) { + reflowDrag(event->pos()); + } + } + } +} + +QML_DEFINE_TYPE(QFxFlowView,FlowView); + +#include "qfxflowview.moc" + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h new file mode 100644 index 0000000..0e7c2d3 --- /dev/null +++ b/src/declarative/extra/qfxflowview.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXFLOWVIEW_H +#define QFXFLOWVIEW_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QFxVisualItemModel; +class QFxFlowViewValue; +class QFxFlowViewAttached; +class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem +{ + Q_OBJECT + Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel) + Q_PROPERTY(int column READ columns WRITE setColumns); + Q_PROPERTY(bool vertical READ vertical WRITE setVertical); + +public: + QFxFlowView(); + + QFxVisualItemModel *model() const; + void setModel(QFxVisualItemModel *); + + int columns() const; + void setColumns(int); + + bool vertical() const; + void setVertical(bool); + + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + + static QFxFlowViewAttached *qmlAttachedProperties(QObject *); + +private: + QRectF rectForItem(int idx) const; + void refresh(); + void reflow(bool animate = false); + void reflowDrag(const QPointF &); + void clearTimeLine(); + int m_columns; + QFxVisualItemModel *m_model; + QList m_items; + bool m_vertical; + void moveItem(QFxItem *item, const QPointF &); + + QPointF m_dragOffset; + QFxItem *m_dragItem; + + QmlTimeLine m_timeline; + QList m_values; + int m_dragIdx; +}; +QML_DECLARE_TYPE(QFxFlowView); + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFXFLOWVIEW_H diff --git a/src/declarative/extra/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp new file mode 100644 index 0000000..4beca5e --- /dev/null +++ b/src/declarative/extra/qmlbehaviour.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmlanimation.h" +#include "qmltransition.h" +#include "qmlbehaviour.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QML_DEFINE_TYPE(QmlBehaviour,Behavior) + +class QmlBehaviourData : public QObject +{ +Q_OBJECT +public: + QmlBehaviourData(QObject *parent) + : QObject(parent) {} + + Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged); + Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged); + QVariant endValue() const { return e; } + QVariant startValue() const { return s; } + + QVariant e; + QVariant s; + +Q_SIGNALS: + void valuesChanged(); + +private: + friend class QmlBehaviour; +}; + +class QmlBehaviourPrivate : public QObjectPrivate +{ +public: + QmlBehaviourPrivate() + : context(0), valueData(0), operations(this) {} + QmlMetaProperty property; + QVariant currentValue; + + QVariant fromValue; + QVariant toValue; + QmlContext *context; + QmlBehaviourData *valueData; + class AnimationList : public QmlConcreteList + { + public: + AnimationList(QmlBehaviourPrivate *parent) : _parent(parent) {} + virtual void append(QmlAbstractAnimation *a) + { + QmlConcreteList::append(a); + _parent->group->addAnimation(a->qtAnimation()); + if (_parent->property.isValid()) { + a->setTarget(_parent->property); + } + } + virtual void clear() { QmlConcreteList::clear(); } //### + private: + QmlBehaviourPrivate *_parent; + }; + AnimationList operations; + QParallelAnimationGroup *group; +}; + +/*! + \qmlclass Behavior QmlBehaviour + \brief The Behavior element allows you to specify a default animation for a property change. + + In example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: + \code + Rect { + width: 20; height: 20 + color: "#00ff00" + y: 200 //initial value + y: Behavior { + NumberAnimation { + easing: "easeOutBounce(amplitude:100)" + duration: 200 + } + } + } + \endcode +*/ + +QmlBehaviour::QmlBehaviour(QObject *parent) +: QmlPropertyValueSource(*(new QmlBehaviourPrivate), parent) +{ + Q_D(QmlBehaviour); + d->valueData = new QmlBehaviourData(this); + d->group = new QParallelAnimationGroup(this); +} + +/*! + \qmlproperty QVariant Behavior::fromValue + This property holds a selector specifying a starting value for the behavior + + If you only want the behavior to apply when the change starts at a + specific value you can specify fromValue. This selector is used in conjunction + with the toValue selector. +*/ + +QVariant QmlBehaviour::fromValue() const +{ + Q_D(const QmlBehaviour); + return d->fromValue; +} + +void QmlBehaviour::setFromValue(const QVariant &v) +{ + Q_D(QmlBehaviour); + d->fromValue = v; +} + +/*! + \qmlproperty QVariant Behavior::toValue + This property holds a selector specifying a ending value for the behavior + + If you only want the behavior to apply when the change ends at a + specific value you can specify toValue. This selector is used in conjunction + with the fromValue selector. +*/ + +QVariant QmlBehaviour::toValue() const +{ + Q_D(const QmlBehaviour); + return d->toValue; +} + +void QmlBehaviour::setToValue(const QVariant &v) +{ + Q_D(QmlBehaviour); + d->toValue = v; +} + +QmlList* QmlBehaviour::operations() +{ + Q_D(QmlBehaviour); + return &d->operations; +} + +QmlBehaviour::~QmlBehaviour() +{ + //### do we need any other cleanup here? +} + +bool QmlBehaviour::_ignore = false; +void QmlBehaviour::propertyValueChanged() +{ + Q_D(QmlBehaviour); + if (_ignore) + return; + + QVariant newValue = d->property.read(); + + if ((!fromValue().isValid() || fromValue() == d->currentValue) && + (!toValue().isValid() || toValue() == newValue)) { + + //### does this clean up everything needed? + d->group->stop(); + + d->valueData->e = newValue; + d->valueData->s = d->currentValue; + emit d->valueData->valuesChanged(); + + QmlStateOperation::ActionList actions; + Action action; + action.property = d->property; + action.fromValue = d->currentValue; + action.toValue = newValue; + actions << action; + + _ignore = true; + d->property.write(d->currentValue); + + QList after; + for (int ii = 0; ii < d->operations.count(); ++ii) { + d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward); + } + d->group->start(); + if (!after.contains(d->property)) + d->property.write(newValue); + _ignore = false; + } + + d->currentValue = newValue; +} + +void QmlBehaviour::setTarget(const QmlMetaProperty &property) +{ + Q_D(QmlBehaviour); + d->property = property; + d->currentValue = property.read(); + d->property.connectNotifier(this, SLOT(propertyValueChanged())); + for (int ii = 0; ii < d->operations.count(); ++ii) { + d->operations.at(ii)->setTarget(property); + } +} + +void QmlBehaviour::classBegin() +{ + Q_D(QmlBehaviour); + if (!d->context) { + d->context = new QmlContext(qmlContext(this), this); + d->context->addDefaultObject(d->valueData); + } + d->context->activate(); +} + +void QmlBehaviour::classComplete() +{ + Q_D(QmlBehaviour); + d->context->deactivate(); +} + +#include "qmlbehaviour.moc" + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlbehaviour.h b/src/declarative/extra/qmlbehaviour.h new file mode 100644 index 0000000..7cc83b2 --- /dev/null +++ b/src/declarative/extra/qmlbehaviour.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLBEHAVIOUR_H +#define QMLBEHAVIOUR_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QmlAbstractAnimation; +class QmlBehaviourPrivate; +class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource, + public QmlParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlBehaviour) + Q_INTERFACES(QmlParserStatus) + + Q_PROPERTY(QVariant from READ fromValue WRITE setFromValue) + Q_PROPERTY(QVariant to READ toValue WRITE setToValue) + Q_CLASSINFO("DefaultProperty", "operations") + Q_PROPERTY(QmlList* operations READ operations) + +public: + QmlBehaviour(QObject *parent=0); + ~QmlBehaviour(); + + QVariant fromValue() const; + void setFromValue(const QVariant &); + QVariant toValue() const; + void setToValue(const QVariant &); + virtual void setTarget(const QmlMetaProperty &); + + QmlList* operations(); + + static bool _ignore; + +protected: + virtual void classBegin(); + virtual void classComplete(); + +private Q_SLOTS: + void propertyValueChanged(); +}; +QML_DECLARE_TYPE(QmlBehaviour) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLBEHAVIOUR_H diff --git a/src/declarative/extra/qmldatetimeformatter.cpp b/src/declarative/extra/qmldatetimeformatter.cpp new file mode 100644 index 0000000..ad0e473 --- /dev/null +++ b/src/declarative/extra/qmldatetimeformatter.cpp @@ -0,0 +1,368 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmldatetimeformatter.h" +#include "private/qobject_p.h" +#include + +QT_BEGIN_NAMESPACE +//TODO: may need optimisation as the QDateTime member may not be needed? +// be able to set a locale? + +class QmlDateTimeFormatterPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlDateTimeFormatter) +public: + QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), classComplete(true) {} + + void updateText(); + + QDateTime dateTime; + QDate date; + QTime time; + QLocale locale; + QString dateTimeText; + QString dateText; + QString timeText; + QString dateTimeFormat; //set for convienience? + QString dateFormat; + QString timeFormat; + bool longStyle; + bool classComplete; +}; + +/*! + \qmlclass DateTimeFormatter QmlDateTimeFormatter + \brief The DateTimeFormatter allows you to control the format of a date string. + + \code + DateTimeFormatter { id: Formatter; date: System.date } + Text { text: Formatter.dateText } + \endcode + + By default, the text properties (dateText, timeText, and dateTimeText) will return the + date and time using the current system locale's format. +*/ + +/*! + \internal + \class QmlDateTimeFormatter + \ingroup group_utility + \brief The QmlDateTimeFormatter class allows you to format a date string. +*/ + +QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent) +: QObject(*(new QmlDateTimeFormatterPrivate), parent) +{ +} + +QmlDateTimeFormatter::~QmlDateTimeFormatter() +{ +} + +/*! + \qmlproperty string DateTimeFormatter::dateText + \qmlproperty string DateTimeFormatter::timeText + \qmlproperty string DateTimeFormatter::dateTimeText + + Formatted text representations of the \c date, \c time, + and \c {date and time}, respectively. + + If there is no explictly specified format the DateTimeFormatter + will use the system locale's default 'short' setting. + + \code + // specify source date (assuming today is February 19, 2009) + DateTimeFormatter { id: formatter; dateTime: Today.date } + + // display the full date and time + Text { text: formatter.dateText } + \endcode + + Would be equivalent to the following for a US English locale: + + \code + // display the date + Text { text: "2/19/09" } + \endcode +*/ +QString QmlDateTimeFormatter::dateTimeText() const +{ + Q_D(const QmlDateTimeFormatter); + return d->dateTimeText; +} + +QString QmlDateTimeFormatter::dateText() const +{ + Q_D(const QmlDateTimeFormatter); + return d->dateText; +} + +QString QmlDateTimeFormatter::timeText() const +{ + Q_D(const QmlDateTimeFormatter); + return d->timeText; +} + +/*! + \qmlproperty date DateTimeFormatter::date + \qmlproperty time DateTimeFormatter::time + \qmlproperty datetime DateTimeFormatter::dateTime + + The source date and time to be used by the formatter. + + \code + // setting the date and time + DateTimeFormatter { date: System.date; time: System.time } + \endcode + + For convienience it is possible to set the datetime property to set both the date and the time. + \code + // setting the datetime + DateTimeFormatter { dateTime: System.dateTime } + \endcode + + There can only be one instance of date and time per formatter; if date, time, and dateTime are all + set the actual date and time used is not guaranteed. + + \note If no date is set, dateTimeText will be just the date; + If no time is set, the dateTimeText will be just the time. + +*/ +QDate QmlDateTimeFormatter::date() const +{ + Q_D(const QmlDateTimeFormatter); + return d->date; +} + +QTime QmlDateTimeFormatter::time() const +{ + Q_D(const QmlDateTimeFormatter); + return d->time; +} + +QDateTime QmlDateTimeFormatter::dateTime() const +{ + Q_D(const QmlDateTimeFormatter); + return d->dateTime; +} + +/*! + \qmlproperty string DateTimeFormatter::dateFormat + \qmlproperty string DateTimeFormatter::timeFormat + \qmlproperty string DateTimeFormatter::dateTimeFormat + + Specifies a custom format which the DateTime Formatter can use. + + If there is no explictly specified format the DateTimeFormatter + will use the system locale's default 'short' setting. + + The text's format may be modified by setting: + \list + \i \c dateFormat + \i \c timeFormat + \i \c dateTimeFormat + \endlist + + If only the format for date is defined, the time and dateTime formats will be defined + as the system locale default and likewise for the others. + + Syntax for the format is based on the QDateTime::toString() formatting options. + + \code + // Format the date such that the dateText is: '1997-12-12' + DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" } + \endcode + + Assigning an empty string to a particular format will reset it. +*/ +QString QmlDateTimeFormatter::dateTimeFormat() const +{ + Q_D(const QmlDateTimeFormatter); + return d->dateTimeFormat; +} + +QString QmlDateTimeFormatter::dateFormat() const +{ + Q_D(const QmlDateTimeFormatter); + return d->dateFormat; +} + +QString QmlDateTimeFormatter::timeFormat() const +{ + Q_D(const QmlDateTimeFormatter); + return d->timeFormat; +} + +/*! + \qmlproperty bool DateTimeFormatter::longStyle + + This property causes the formatter to use the system locale's long format rather than short format + by default. + + This setting is off by default. +*/ +bool QmlDateTimeFormatter::longStyle() const +{ + Q_D(const QmlDateTimeFormatter); + return d->longStyle; +} + +void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime) +{ + Q_D(QmlDateTimeFormatter); + if (d->dateTime == dateTime) + return; + d->dateTime = dateTime; + d->date = d->dateTime.date(); + d->time = d->dateTime.time(); + d->updateText(); +} + +void QmlDateTimeFormatter::setTime(const QTime &time) +{ + Q_D(QmlDateTimeFormatter); + if (d->dateTime.time() == time) + return; + d->time = time; + d->dateTime.setTime(time); + d->updateText(); +} + +void QmlDateTimeFormatter::setDate(const QDate &date) +{ + Q_D(QmlDateTimeFormatter); + if (d->dateTime.date() == date) + return; + d->date = date; + bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time + d->dateTime.setDate(date); + if (clearTime) + d->dateTime.setTime(QTime()); + d->updateText(); +} + +//DateTime formatting may be a combination of date and time? +void QmlDateTimeFormatter::setDateTimeFormat(const QString &format) +{ + Q_D(QmlDateTimeFormatter); + //no format checking + d->dateTimeFormat = format; + d->updateText(); +} + +void QmlDateTimeFormatter::setDateFormat(const QString &format) +{ + Q_D(QmlDateTimeFormatter); + //no format checking + d->dateFormat = format; + d->updateText(); +} + +void QmlDateTimeFormatter::setTimeFormat(const QString &format) +{ + Q_D(QmlDateTimeFormatter); + //no format checking + d->timeFormat = format; + d->updateText(); +} + +void QmlDateTimeFormatter::setLongStyle(bool longStyle) +{ + Q_D(QmlDateTimeFormatter); + d->longStyle = longStyle; + d->updateText(); +} + +void QmlDateTimeFormatterPrivate::updateText() +{ + Q_Q(QmlDateTimeFormatter); + if (!classComplete) + return; + + QString str; + QString str1; + QString str2; + + Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate; + + if (dateFormat.isEmpty()) + str1 = date.toString(defaultFormat); + else + str1 = date.toString(dateFormat); + + if (timeFormat.isEmpty()) + str2 = time.toString(defaultFormat); + else + str2 = time.toString(timeFormat); + + if (dateTimeFormat.isEmpty()) + str = dateTime.toString(defaultFormat); + //else if (!formatTime.isEmpty() && !formatDate.isEmpty()) + // str = str1 + QLatin1Char(' ') + str2; + else + str = dateTime.toString(dateTimeFormat); + + if (dateTimeText == str && dateText == str1 && timeText == str2) + return; + + dateTimeText = str; + dateText = str1; + timeText = str2; + + emit q->textChanged(); +} + +void QmlDateTimeFormatter::classBegin() +{ + Q_D(QmlDateTimeFormatter); + d->classComplete = false; +} + +void QmlDateTimeFormatter::classComplete() +{ + Q_D(QmlDateTimeFormatter); + d->classComplete = true; + d->updateText(); +} + +QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter) +QT_END_NAMESPACE diff --git a/src/declarative/extra/qmldatetimeformatter.h b/src/declarative/extra/qmldatetimeformatter.h new file mode 100644 index 0000000..84b27e3 --- /dev/null +++ b/src/declarative/extra/qmldatetimeformatter.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLDATETIMEFORMATTER_H +#define QMLDATETIMEFORMATTER_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QmlDateTimeFormatterPrivate; +class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QmlParserStatus) + + Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged) + Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged) + Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged) + Q_PROPERTY(QDate date READ date WRITE setDate) + Q_PROPERTY(QTime time READ time WRITE setTime) + Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime) + Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat) + Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat) + Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) + Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle) +public: + QmlDateTimeFormatter(QObject *parent=0); + ~QmlDateTimeFormatter(); + + QString dateTimeText() const; + QString dateText() const; + QString timeText() const; + + QDate date() const; + void setDate(const QDate &); + + QTime time() const; + void setTime(const QTime &); + + QDateTime dateTime() const; + void setDateTime(const QDateTime &); + + QString dateTimeFormat() const; + void setDateTimeFormat(const QString &); + + QString dateFormat() const; + void setDateFormat(const QString &); + + QString timeFormat() const; + void setTimeFormat(const QString &); + + bool longStyle() const; + void setLongStyle(bool); + + virtual void classBegin(); + virtual void classComplete(); + +Q_SIGNALS: + void textChanged(); + +private: + Q_DISABLE_COPY(QmlDateTimeFormatter) + Q_DECLARE_PRIVATE(QmlDateTimeFormatter) +}; + +QML_DECLARE_TYPE(QmlDateTimeFormatter) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 1c819e7..69fada0 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -1,8 +1,6 @@ HEADERS += \ fx/qfxanchors.h \ fx/qfxanchors_p.h \ - fx/qfxanimatedimageitem.h \ - fx/qfxblendedimage.h \ fx/qfxblurfilter.h \ fx/qfxcomponentinstance.h \ fx/qfxcomponentinstance_p.h \ @@ -15,7 +13,6 @@ HEADERS += \ fx/qfxfocuspanel.h \ fx/qfxfocusrealm.h \ fx/qfxgridview.h \ - fx/qfxflowview.h \ fx/qfxhighlightfilter.h \ fx/qfximage.h \ fx/qfxpainteditem.h \ @@ -53,8 +50,6 @@ HEADERS += \ SOURCES += \ fx/qfxanchors.cpp \ - fx/qfxanimatedimageitem.cpp \ - fx/qfxblendedimage.cpp \ fx/qfxblurfilter.cpp \ fx/qfxcomponentinstance.cpp \ fx/qfxcontentwrapper.cpp \ @@ -64,7 +59,6 @@ SOURCES += \ fx/qfxfocuspanel.cpp \ fx/qfxfocusrealm.cpp \ fx/qfxgridview.cpp \ - fx/qfxflowview.cpp \ fx/qfxhighlightfilter.cpp \ fx/qfximage.cpp \ fx/qfxpainteditem.cpp \ diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp deleted file mode 100644 index d22959a..0000000 --- a/src/declarative/fx/qfxanimatedimageitem.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "qfxanimatedimageitem.h" -#include "qfxanimatedimageitem_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QFxAnimatedImageItem - \internal -*/ - -/*! - \qmlclass AnimatedImage - \inherits Image - - This item provides for playing animations stored as images containing a series of frames, - such as GIF files. The full list of supported formats can be determined with - QMovie::supportedFormats(). - - \table - \row - \o \image animatedimageitem.gif - \o - \qml -Item { - width: anim.width; height: anim.height+8 - AnimatedImage { id: anim; source: "pics/games-anim.gif" } - Rect { color: "red"; width: 4; height: 8; y: anim.height - x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1) - } -} - \endqml - \endtable -*/ -QML_DEFINE_TYPE(QFxAnimatedImageItem, AnimatedImage) - -QFxAnimatedImageItem::QFxAnimatedImageItem(QFxItem *parent) - : QFxImage(*(new QFxAnimatedImageItemPrivate), parent) -{ -} - -QFxAnimatedImageItem::QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent) - : QFxImage(dd, parent) -{ -} - -QFxAnimatedImageItem::~QFxAnimatedImageItem() -{ - Q_D(QFxAnimatedImageItem); - delete d->_movie; -} - -/*! - \qmlproperty bool AnimatedImage::playing - This property holds whether the animated image is playing or not - - Defaults to true, so as to start playing immediately. -*/ -bool QFxAnimatedImageItem::isPlaying() const -{ - Q_D(const QFxAnimatedImageItem); - if (!d->_movie) - return false; - return d->_movie->state()==QMovie::Running; -} - -void QFxAnimatedImageItem::setPlaying(bool play) -{ - Q_D(QFxAnimatedImageItem); - if (!d->_movie) - return; - if (play) - d->_movie->start(); - else - d->_movie->stop(); -} - -/*! - \qmlproperty int AnimatedImage::currentFrame - \qmlproperty int AnimatedImage::frameCount - - currentFrame is the frame that is currently visible. Watching when this changes can - allow other things to animate at the same time as the image. frameCount is the number - of frames in the animation. For some animation formats, frameCount is unknown and set to zero. -*/ -int QFxAnimatedImageItem::currentFrame() const -{ - Q_D(const QFxAnimatedImageItem); - if (!d->_movie) - return -1; - return d->_movie->currentFrameNumber(); -} - -void QFxAnimatedImageItem::setCurrentFrame(int frame) -{ - Q_D(QFxAnimatedImageItem); - if (!d->_movie) - return; - d->_movie->jumpToFrame(frame); -} - -int QFxAnimatedImageItem::frameCount() const -{ - Q_D(const QFxAnimatedImageItem); - if (!d->_movie) - return 0; - return d->_movie->frameCount(); -} - -void QFxAnimatedImageItem::setSource(const QUrl &url) -{ - Q_D(QFxAnimatedImageItem); - if (url == d->url) - return; - - delete d->_movie; - d->_movie = 0; - - if (d->reply) { - d->reply->deleteLater(); - d->reply = 0; - } - - d->url = url; - - if (url.isEmpty()) { - delete d->_movie; - d->status = Idle; - } else { - d->status = Loading; - QNetworkRequest req(d->url); - req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), - this, SLOT(movieRequestFinished())); - } - - emit statusChanged(d->status); -} - -void QFxAnimatedImageItem::movieRequestFinished() -{ - Q_D(QFxAnimatedImageItem); - d->_movie = new QMovie(d->reply); - if (!d->_movie->isValid()){ - qWarning() << "Error Reading File " << d->url; - delete d->_movie; - d->_movie = 0; - return; - } - connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SIGNAL(playingChanged())); - connect(d->_movie, SIGNAL(frameChanged(int)), - this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); - d->_movie->start(); - setPixmap(d->_movie->currentPixmap()); -} - -void QFxAnimatedImageItem::movieUpdate() -{ - Q_D(QFxAnimatedImageItem); - setPixmap(d->_movie->currentPixmap()); - emit frameChanged(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxanimatedimageitem.h b/src/declarative/fx/qfxanimatedimageitem.h deleted file mode 100644 index 5d115d7..0000000 --- a/src/declarative/fx/qfxanimatedimageitem.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXANIMATEDIMAGEITEM_H -#define QFXANIMATEDIMAGEITEM_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QMovie; -class QFxAnimatedImageItemPrivate; - -class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage -{ - Q_OBJECT - - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) - Q_PROPERTY(int frameCount READ frameCount) -public: - QFxAnimatedImageItem(QFxItem *parent=0); - ~QFxAnimatedImageItem(); - - bool isPlaying() const; - void setPlaying(bool play); - - int currentFrame() const; - void setCurrentFrame(int frame); - - int frameCount() const; - - // Extends QFxImage's src property*/ - virtual void setSource(const QUrl&); - -Q_SIGNALS: - void playingChanged(); - void frameChanged(); - -private Q_SLOTS: - void movieUpdate(); - void movieRequestFinished(); - -protected: - QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent); - -private: - Q_DISABLE_COPY(QFxAnimatedImageItem) - Q_DECLARE_PRIVATE(QFxAnimatedImageItem) -}; - -QML_DECLARE_TYPE(QFxAnimatedImageItem) - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif diff --git a/src/declarative/fx/qfxanimatedimageitem_p.h b/src/declarative/fx/qfxanimatedimageitem_p.h deleted file mode 100644 index cb5da63..0000000 --- a/src/declarative/fx/qfxanimatedimageitem_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXANIMATEDIMAGE_P_H -#define QFXANIMATEDIMAGE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qfximage_p.h" - -QT_BEGIN_NAMESPACE - -class QMovie; - -class QFxAnimatedImageItemPrivate : public QFxImagePrivate -{ - Q_DECLARE_PUBLIC(QFxAnimatedImageItem) - -public: - QFxAnimatedImageItemPrivate() - : _movie(0) - { - } - - QMovie *_movie; -}; - -QT_END_NAMESPACE - -#endif // QFXANIMATEDIMAGE_P_H diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp deleted file mode 100644 index 0c93fef..0000000 --- a/src/declarative/fx/qfxblendedimage.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxblendedimage.h" -#include - -#if defined(QFX_RENDER_OPENGL2) -#include -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass BlendedImage - \brief The BlendedImage elements blends two different images depending on a blend ratio. - - This element can be used to simulate blur on slow devices by setting secondaryUrl with - a pre-rendered blurred version of primaryUrl. - - Note that this class will only work under OpenGL. On the software canvas it will display - only the primary image unless the blend is > 0.75, in which case it will display only the - secondary image. -*/ - -/*! - \internal - \class QFxBlendedImage - \brief The QFxBlendedImage blends two different images depending on a blend ratio. - - This class can be used to simulate blur on slow devices by setting secondaryUrl with - a pre-rendered blurred version of primaryUrl. - - Note that this class will only work under OpenGL. On the software canvas it will display - only the primary image unless the blend is > 0.75, in which case it will display only the - secondary image. -*/ -QFxBlendedImage::QFxBlendedImage(QFxItem *parent) -: QFxItem(parent), _blend(0), _smooth(false), dirty(false) -{ -#if defined(QFX_RENDER_OPENGL2) - setOptions(HasContents); -#endif -} - -/*! - Cancels any pending image loads and destroys the image. -*/ -QFxBlendedImage::~QFxBlendedImage() -{ - if (!primUrl.isEmpty()) - QFxPixmap::cancelGet(primUrl,this); - if (!secUrl.isEmpty()) - QFxPixmap::cancelGet(secUrl,this); -} - -/*! - \qmlproperty string BlendedImage::primaryUrl - The URL of the first image to be displayed in this item. -*/ -QUrl QFxBlendedImage::primaryUrl() const -{ - return primUrl; -} - -void QFxBlendedImage::primaryLoaded() -{ - primPix = QFxPixmap(primUrl); - dirty = true; - update(); -} - -void QFxBlendedImage::setPrimaryUrl(const QUrl &url) -{ - if (primUrl == url) - return; - if (!primUrl.isEmpty()) - QFxPixmap::cancelGet(primUrl,this); - Q_ASSERT(!url.isRelative()); - primUrl = url; - if (!primUrl.isEmpty()) - QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded())); -} - -/*! - \qmlproperty string BlendedImage::secondaryUrl - The URL of the second image to be displayed in this item. -*/ -QUrl QFxBlendedImage::secondaryUrl() const -{ - return secUrl; -} - -void QFxBlendedImage::secondaryLoaded() -{ - secPix = QFxPixmap(secUrl); - dirty = true; - update(); -} - -void QFxBlendedImage::setSecondaryUrl(const QUrl &url) -{ - if (secUrl == url) - return; - if (!secUrl.isEmpty()) - QFxPixmap::cancelGet(secUrl,this); - Q_ASSERT(!url.isRelative()); - secUrl = url; - if (!secUrl.isEmpty()) - QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded())); -} - -/*! - \qmlproperty real BlendedImage::blend - The ratio used to blend the two images. - - If blend has a value of 0, only the first image will be displayed. - If blend has a value of 1, only the second image will be displayed. -*/ -qreal QFxBlendedImage::blend() const -{ - return _blend; -} - -void QFxBlendedImage::setBlend(qreal b) -{ - _blend = b; - update(); -} - -/*! - \qmlproperty bool BlendedImage::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the BlendedImage is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. - */ -bool QFxBlendedImage::smoothTransform() const -{ - return _smooth; -} - -void QFxBlendedImage::setSmoothTransform(bool s) -{ - if (_smooth == s) - return; - _smooth = s; - update(); -} - -#if defined(QFX_RENDER_QPAINTER) - -void QFxBlendedImage::paintContents(QPainter &p) -{ - if (primUrl.isEmpty() && secUrl.isEmpty()) - return; - - if (_smooth) { - p.save(); - p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth); - } - - if (_blend < 0.75) - p.drawPixmap(0, 0, primPix); - else - p.drawPixmap(0, 0, secPix); - - if (_smooth) { - p.restore(); - } -} - -#elif defined(QFX_RENDER_OPENGL2) - -void QFxBlendedImage::paintGLContents(GLPainter &p) -{ - static DualTextureBlendShader *shader = 0; - if (!shader) - shader = new DualTextureBlendShader(); - - if (dirty) { - prim.clear(); - sec.clear(); - prim.setImage(primPix.toImage()); - sec.setImage(secPix.toImage()); - - dirty = false; - } - - if (prim.isNull() || sec.isNull()) { - - return; - } - - GLfloat vertices[8]; - GLfloat texVertices[8]; - - float widthV = width(); - float heightV = height(); - if (!widthV) - widthV = qMax(primPix.width(), secPix.width()); - if (!heightV) - heightV = qMax(primPix.height(), secPix.height()); - - vertices[0] = 0; vertices[1] = heightV; - vertices[2] = widthV; vertices[3] = heightV; - vertices[4] = 0; vertices[5] = 0; - vertices[6] = widthV; vertices[7] = 0; - - texVertices[0] = 0; texVertices[1] = 0; - texVertices[2] = 1; texVertices[3] = 0; - texVertices[4] = 0; texVertices[5] = 1; - texVertices[6] = 1; texVertices[7] = 1; - - if (_blend == 0 || _blend == 1) { - QGLShaderProgram *tshader = p.useTextureShader(); - - GLTexture *tex = 0; - - if (_blend == 0) - tex = &prim; - else - tex = &sec; - - tshader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - tshader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - - glBindTexture(GL_TEXTURE_2D, tex->texture()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - tshader->disableAttributeArray(SingleTextureShader::Vertices); - tshader->disableAttributeArray(SingleTextureShader::TextureCoords); - } else { - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, prim.texture()); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, sec.texture()); - - shader->enable(); - shader->setOpacity(1); - qreal b = _blend; - if (b > 1) b = 1; - else if (b < 0) b = 0; - shader->setBlend(b); - shader->setTransform(p.activeTransform); - - shader->setAttributeArray(DualTextureBlendShader::Vertices, vertices, 2); - shader->setAttributeArray(DualTextureBlendShader::TextureCoords, texVertices, 2); - shader->setAttributeArray(DualTextureBlendShader::BlendTextureCoords, texVertices, 2); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - shader->disableAttributeArray(DualTextureBlendShader::Vertices); - shader->disableAttributeArray(DualTextureBlendShader::TextureCoords); - shader->disableAttributeArray(DualTextureBlendShader::BlendTextureCoords); - - glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE0); - } -} -#endif - -QML_DEFINE_TYPE(QFxBlendedImage,BlendedImage) - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h deleted file mode 100644 index 248cc9d..0000000 --- a/src/declarative/fx/qfxblendedimage.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXBLENDEDIMAGE_H -#define QFXBLENDEDIMAGE_H - -#include -#if defined(QFX_RENDER_OPENGL2) -#include -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem -{ - Q_OBJECT - - Q_PROPERTY(QUrl primaryUrl READ primaryUrl WRITE setPrimaryUrl) - Q_PROPERTY(QUrl secondaryUrl READ secondaryUrl WRITE setSecondaryUrl) - Q_PROPERTY(qreal blend READ blend WRITE setBlend) - Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) -public: - QFxBlendedImage(QFxItem *parent=0); - ~QFxBlendedImage(); - - QUrl primaryUrl() const; - void setPrimaryUrl(const QUrl &); - - QUrl secondaryUrl() const; - void setSecondaryUrl(const QUrl &); - - qreal blend() const; - void setBlend(qreal); - - bool smoothTransform() const; - void setSmoothTransform(bool); - -#if defined(QFX_RENDER_QPAINTER) - void paintContents(QPainter &painter); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif - -private Q_SLOTS: - void primaryLoaded(); - void secondaryLoaded(); - -private: - QUrl primUrl; - QUrl secUrl; - - qreal _blend; - bool _smooth; - bool dirty; -#if defined(QFX_RENDER_OPENGL2) - GLTexture prim; - GLTexture sec; -#endif - QPixmap primPix; - QPixmap secPix; -}; -QML_DECLARE_TYPE(QFxBlendedImage) - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif // QFXBLENDEDIMAGE_H diff --git a/src/declarative/fx/qfxflowview.cpp b/src/declarative/fx/qfxflowview.cpp deleted file mode 100644 index 77cd6df..0000000 --- a/src/declarative/fx/qfxflowview.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxvisualitemmodel.h" -#include "qfxflowview.h" - -QT_BEGIN_NAMESPACE - -class QFxFlowViewAttached : public QObject -{ -Q_OBJECT -Q_PROPERTY(int row READ row NOTIFY posChanged); -Q_PROPERTY(int column READ column NOTIFY posChanged); -public: - QFxFlowViewAttached(QObject *parent); - - int row() const; - int column() const; - -signals: - void posChanged(); - -private: - friend class QFxFlowView; - int m_row; - int m_column; -}; - - -QFxFlowView::QFxFlowView() -: m_columns(0), m_model(0), m_vertical(false), m_dragItem(0), m_dragIdx(-1) -{ - setAcceptedMouseButtons(Qt::LeftButton); - setOptions(MouseEvents); -} - -QFxVisualItemModel *QFxFlowView::model() const -{ - return m_model; -} - -void QFxFlowView::setModel(QFxVisualItemModel *m) -{ - m_model = m; - refresh(); -} - -int QFxFlowView::columns() const -{ - return m_columns; -} - -void QFxFlowView::setColumns(int c) -{ - m_columns = c; - refresh(); -} - -bool QFxFlowView::vertical() const -{ - return m_vertical; -} - -void QFxFlowView::setVertical(bool v) -{ - m_vertical = v; -} - -class QFxFlowViewValue : public QmlTimeLineValue -{ -public: - enum Property { xProperty, yProperty }; - - QFxFlowViewValue(QFxItem *item, Property p) - : m_item(item), m_property(p) {} - - qreal value() const { - return (m_property == xProperty)?m_item->x():m_item->y(); - } - void setValue(qreal v) { - if (m_property == xProperty) m_item->setX(v); - else m_item->setY(v); - } -private: - QFxItem *m_item; - Property m_property; -}; - -void QFxFlowView::refresh() -{ - if (m_model && m_columns >= 1) { - for (int ii = 0; ii < m_model->count(); ++ii) { - if (QFxItem *item = m_model->item(ii)) { - item->setParent(this); - item->setZ(0); - m_items << item; - } - } - - reflow(); - } -} - -void QFxFlowView::reflow(bool animate) -{ - qreal y = 0; - qreal maxY = 0; - qreal x = 0; - int row = 0; - int column = -1; - if (animate) - clearTimeLine(); - - for (int ii = 0; ii < m_items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - row = 0; - column++; - } - - QFxItem *item = m_items.at(ii); - QFxFlowViewAttached *att = - (QFxFlowViewAttached *)qmlAttachedPropertiesObject(item); - att->m_row = row; - att->m_column = column; - emit att->posChanged(); - - - if (animate) { - if (vertical()) - moveItem(item, QPointF(y, x)); - else - moveItem(item, QPointF(x, y)); - } else { - if (vertical()) { - item->setX(y); - item->setY(x); - } else { - item->setX(x); - item->setY(y); - } - } - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - ++row; - } -} - -void QFxFlowView::reflowDrag(const QPointF &dp) -{ - qreal y = 0; - qreal maxY = 0; - qreal x = 0; - - int flowedItems = 0; - - clearTimeLine(); - - QList items; - - bool dragUsed = false; - bool dragSeen = false; - for (int ii = 0; ii < m_items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - } - - QFxItem *item = m_items.at(ii); - if (item == m_dragItem) - dragSeen = true; - if (item == m_dragItem && dragUsed) - continue; - QRectF r; - if (vertical()) - r = QRectF(y, x, item->width(), item->height()); - else - r = QRectF(x, y, item->width(), item->height()); - if (r.contains(dp)) { - dragUsed = true; - if (dragSeen) - m_dragIdx = items.count() + 1; - else - m_dragIdx = items.count(); - - items.append(m_dragItem); - if (m_dragItem != item) { - if (dragSeen) - items.insert(items.count() - 1, item); - else - items.append(item); - } - } else { - if (m_dragItem != item) - items.append(item); - } - - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - } - - y = 0; - maxY = 0; - x = 0; - clearTimeLine(); - for (int ii = 0; ii < items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - } - - QFxItem *item = items.at(ii); - if (item != m_dragItem) { - if (vertical()) - moveItem(item, QPointF(y, x)); - else - moveItem(item, QPointF(x, y)); - } - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - } - -} - -void QFxFlowView::moveItem(QFxItem *item, const QPointF &p) -{ - QFxFlowViewValue *xv = new QFxFlowViewValue(item, QFxFlowViewValue::xProperty); - QFxFlowViewValue *yv = new QFxFlowViewValue(item, QFxFlowViewValue::yProperty); - m_values << xv << yv; - m_timeline.move(*xv, p.x(), 100); - m_timeline.move(*yv, p.y(), 100); -} - -#include - -void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - for (int ii = 0; ii < m_items.count(); ++ii) { - QFxItem *item = m_items.at(ii); - QRectF r = rectForItem(ii); - - if (r.contains(event->pos())) { - m_dragItem = item; - m_dragItem->setZ(1); - m_dragOffset = r.topLeft() - event->pos(); - event->accept(); - return; - } - } - event->ignore(); -} - -QRectF QFxFlowView::rectForItem(int idx) const -{ - QFxItem *item = m_items.at(idx); - QRectF r(item->x(), item->y(), item->width(), item->height()); - return r; -} - -void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_dragItem) { - m_dragItem->setZ(0); - - clearTimeLine(); - - if (m_dragIdx != -1) { - m_items.removeAll(m_dragItem); - m_items.insert(m_dragIdx, m_dragItem); - } - - reflow(true); - m_dragItem = 0; - m_dragIdx = -1; - } -} - -QFxFlowViewAttached::QFxFlowViewAttached(QObject *parent) -: QObject(parent), m_row(0), m_column(0) -{ -} - -int QFxFlowViewAttached::row() const -{ - return m_row; -} - -int QFxFlowViewAttached::column() const -{ - return m_column; -} - -QFxFlowViewAttached *QFxFlowView::qmlAttachedProperties(QObject *obj) -{ - return new QFxFlowViewAttached(obj); -} - -void QFxFlowView::clearTimeLine() -{ - m_timeline.clear(); - qDeleteAll(m_values); - m_values.clear(); -} - -void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_dragItem) { - QPointF p = event->pos() + m_dragOffset; - m_dragItem->setX(p.x()); - m_dragItem->setY(p.y()); - - for (int ii = 0; ii < m_items.count(); ++ii) { - if (m_items.at(ii) != m_dragItem && rectForItem(ii).contains(event->pos())) { - reflowDrag(event->pos()); - } - } - } -} - -QML_DEFINE_TYPE(QFxFlowView,FlowView); - -#include "qfxflowview.moc" - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxflowview.h b/src/declarative/fx/qfxflowview.h deleted file mode 100644 index 0e7c2d3..0000000 --- a/src/declarative/fx/qfxflowview.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXFLOWVIEW_H -#define QFXFLOWVIEW_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxVisualItemModel; -class QFxFlowViewValue; -class QFxFlowViewAttached; -class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem -{ - Q_OBJECT - Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel) - Q_PROPERTY(int column READ columns WRITE setColumns); - Q_PROPERTY(bool vertical READ vertical WRITE setVertical); - -public: - QFxFlowView(); - - QFxVisualItemModel *model() const; - void setModel(QFxVisualItemModel *); - - int columns() const; - void setColumns(int); - - bool vertical() const; - void setVertical(bool); - - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - - static QFxFlowViewAttached *qmlAttachedProperties(QObject *); - -private: - QRectF rectForItem(int idx) const; - void refresh(); - void reflow(bool animate = false); - void reflowDrag(const QPointF &); - void clearTimeLine(); - int m_columns; - QFxVisualItemModel *m_model; - QList m_items; - bool m_vertical; - void moveItem(QFxItem *item, const QPointF &); - - QPointF m_dragOffset; - QFxItem *m_dragItem; - - QmlTimeLine m_timeline; - QList m_values; - int m_dragIdx; -}; -QML_DECLARE_TYPE(QFxFlowView); - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QFXFLOWVIEW_H diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp deleted file mode 100644 index c8c8ced..0000000 --- a/src/declarative/util/qbindablemap.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbindablemap.h" -#include -#include - -QT_BEGIN_NAMESPACE - -//QBindableMapMetaObject lets us listen for changes coming from QML -//so we can emit the changed signal. -class QBindableMapMetaObject : public QmlOpenMetaObject -{ -public: - QBindableMapMetaObject(QBindableMap *obj) : QmlOpenMetaObject(obj) - { - map = obj; - } - -protected: - virtual void propertyWrite(int index) - { - map->emitChanged(QLatin1String(name(index))); - } - -private: - QBindableMap *map; -}; - -/*! - \class QBindableMap - \brief The QBindableMap class allows you to set key-value pairs that can be used in bindings. - - QBindableMap provides a convenient way to expose domain data to the UI layer. - The following example shows how you might declare data in C++ and then - access it in QML. - - Setup in C++: - \code - //create our data - QBindableMap ownerData; - ownerData.setValue("name", QVariant(QString("John Smith"))); - ownerData.setValue("phone", QVariant(QString("555-5555"))); - - //expose it to the UI layer - QmlContext *ctxt = view->bindContext(); - ctxt->setProperty("owner", &data); - \endcode - - Then, in QML: - \code - Text { text: owner.name } - Text { text: owner.phone } - \endcode - - The binding is dynamic - whenever a key's value is updated, anything bound to that - key will be updated as well. - - To detect value changes made in the UI layer you can connect to the changed() signal. - However, note that changed() is \b NOT emitted when changes are made by calling setValue() - or clearValue() - it is only emitted when a value is updated from QML. -*/ - -// is there a more efficient way to store/return keys? -// (or should we just provide an iterator or something else instead?) -// can we provide a way to clear keys? -// do we want to make any claims regarding key ordering? -// should we have signals for insertion and and deletion -- becoming more model like -// should we emit change for our own changes as well? -// Bug or Feature?: values can be created in QML (owner.somethingElse = "Hello") will create somethingElse property. (need to verify if this is actually the case) -// Bug or Feature?: all values are read-write (there are no read-only values) - -/*! - Constructs a bindable map with parent object \a parent. -*/ -QBindableMap::QBindableMap(QObject *parent) -: QObject(parent) -{ - m_mo = new QBindableMapMetaObject(this); -} - -/*! - Destroys the bindable map. -*/ -QBindableMap::~QBindableMap() -{ -} - -/*! - Clears the value (if any) associated with \a key. -*/ -void QBindableMap::clearValue(const QString &key) -{ - //m_keys.remove(); //### - m_mo->setValue(key.toLatin1(), QVariant()); - //emit changed(key); -} - -/*! - Returns the value associated with \a key. - - If no value has been set for this key (or if the value has been cleared), - an invalid QVariant is returned. -*/ -QVariant QBindableMap::value(const QString &key) const -{ - return m_mo->value(key.toLatin1()); -} - -/*! - Sets the value associated with \a key to \a value. - - If the key doesn't exist, it is automatically created. -*/ -void QBindableMap::setValue(const QString &key, QVariant value) -{ - if (!m_keys.contains(key)) - m_keys.append(key); - m_mo->setValue(key.toLatin1(), value); - //emit changed(key); -} - -/*! - Returns the list of keys. - - Keys that have been cleared will still appear in this list, even though their - associated values are invalid QVariants. -*/ -QStringList QBindableMap::keys() const -{ - return m_keys; -} - -/*! - \fn void QBindableMap::changed(const QString &key) - This signal is emitted whenever one of the values in the map is changed. \a key - is the key corresponding to the value that was changed. - */ - -void QBindableMap::emitChanged(const QString &key) -{ - emit changed(key); -} -QT_END_NAMESPACE diff --git a/src/declarative/util/qbindablemap.h b/src/declarative/util/qbindablemap.h deleted file mode 100644 index c76928d..0000000 --- a/src/declarative/util/qbindablemap.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBINDABLEMAP_H -#define QBINDABLEMAP_H - -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QBindableMapMetaObject; -class Q_DECLARATIVE_EXPORT QBindableMap : public QObject -{ - Q_OBJECT -public: - QBindableMap(QObject *parent = 0); - virtual ~QBindableMap(); - - QVariant value(const QString &key) const; - void setValue(const QString &key, QVariant value); - void clearValue(const QString &key); - - Q_INVOKABLE QStringList keys() const; - -Q_SIGNALS: - void changed(const QString &key); - -private: - Q_DISABLE_COPY(QBindableMap) - void emitChanged(const QString &key); - QBindableMapMetaObject *m_mo; - QStringList m_keys; - friend class QBindableMapMetaObject; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp deleted file mode 100644 index 4beca5e..0000000 --- a/src/declarative/util/qmlbehaviour.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmlanimation.h" -#include "qmltransition.h" -#include "qmlbehaviour.h" -#include -#include - -QT_BEGIN_NAMESPACE - -QML_DEFINE_TYPE(QmlBehaviour,Behavior) - -class QmlBehaviourData : public QObject -{ -Q_OBJECT -public: - QmlBehaviourData(QObject *parent) - : QObject(parent) {} - - Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged); - Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged); - QVariant endValue() const { return e; } - QVariant startValue() const { return s; } - - QVariant e; - QVariant s; - -Q_SIGNALS: - void valuesChanged(); - -private: - friend class QmlBehaviour; -}; - -class QmlBehaviourPrivate : public QObjectPrivate -{ -public: - QmlBehaviourPrivate() - : context(0), valueData(0), operations(this) {} - QmlMetaProperty property; - QVariant currentValue; - - QVariant fromValue; - QVariant toValue; - QmlContext *context; - QmlBehaviourData *valueData; - class AnimationList : public QmlConcreteList - { - public: - AnimationList(QmlBehaviourPrivate *parent) : _parent(parent) {} - virtual void append(QmlAbstractAnimation *a) - { - QmlConcreteList::append(a); - _parent->group->addAnimation(a->qtAnimation()); - if (_parent->property.isValid()) { - a->setTarget(_parent->property); - } - } - virtual void clear() { QmlConcreteList::clear(); } //### - private: - QmlBehaviourPrivate *_parent; - }; - AnimationList operations; - QParallelAnimationGroup *group; -}; - -/*! - \qmlclass Behavior QmlBehaviour - \brief The Behavior element allows you to specify a default animation for a property change. - - In example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: - \code - Rect { - width: 20; height: 20 - color: "#00ff00" - y: 200 //initial value - y: Behavior { - NumberAnimation { - easing: "easeOutBounce(amplitude:100)" - duration: 200 - } - } - } - \endcode -*/ - -QmlBehaviour::QmlBehaviour(QObject *parent) -: QmlPropertyValueSource(*(new QmlBehaviourPrivate), parent) -{ - Q_D(QmlBehaviour); - d->valueData = new QmlBehaviourData(this); - d->group = new QParallelAnimationGroup(this); -} - -/*! - \qmlproperty QVariant Behavior::fromValue - This property holds a selector specifying a starting value for the behavior - - If you only want the behavior to apply when the change starts at a - specific value you can specify fromValue. This selector is used in conjunction - with the toValue selector. -*/ - -QVariant QmlBehaviour::fromValue() const -{ - Q_D(const QmlBehaviour); - return d->fromValue; -} - -void QmlBehaviour::setFromValue(const QVariant &v) -{ - Q_D(QmlBehaviour); - d->fromValue = v; -} - -/*! - \qmlproperty QVariant Behavior::toValue - This property holds a selector specifying a ending value for the behavior - - If you only want the behavior to apply when the change ends at a - specific value you can specify toValue. This selector is used in conjunction - with the fromValue selector. -*/ - -QVariant QmlBehaviour::toValue() const -{ - Q_D(const QmlBehaviour); - return d->toValue; -} - -void QmlBehaviour::setToValue(const QVariant &v) -{ - Q_D(QmlBehaviour); - d->toValue = v; -} - -QmlList* QmlBehaviour::operations() -{ - Q_D(QmlBehaviour); - return &d->operations; -} - -QmlBehaviour::~QmlBehaviour() -{ - //### do we need any other cleanup here? -} - -bool QmlBehaviour::_ignore = false; -void QmlBehaviour::propertyValueChanged() -{ - Q_D(QmlBehaviour); - if (_ignore) - return; - - QVariant newValue = d->property.read(); - - if ((!fromValue().isValid() || fromValue() == d->currentValue) && - (!toValue().isValid() || toValue() == newValue)) { - - //### does this clean up everything needed? - d->group->stop(); - - d->valueData->e = newValue; - d->valueData->s = d->currentValue; - emit d->valueData->valuesChanged(); - - QmlStateOperation::ActionList actions; - Action action; - action.property = d->property; - action.fromValue = d->currentValue; - action.toValue = newValue; - actions << action; - - _ignore = true; - d->property.write(d->currentValue); - - QList after; - for (int ii = 0; ii < d->operations.count(); ++ii) { - d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward); - } - d->group->start(); - if (!after.contains(d->property)) - d->property.write(newValue); - _ignore = false; - } - - d->currentValue = newValue; -} - -void QmlBehaviour::setTarget(const QmlMetaProperty &property) -{ - Q_D(QmlBehaviour); - d->property = property; - d->currentValue = property.read(); - d->property.connectNotifier(this, SLOT(propertyValueChanged())); - for (int ii = 0; ii < d->operations.count(); ++ii) { - d->operations.at(ii)->setTarget(property); - } -} - -void QmlBehaviour::classBegin() -{ - Q_D(QmlBehaviour); - if (!d->context) { - d->context = new QmlContext(qmlContext(this), this); - d->context->addDefaultObject(d->valueData); - } - d->context->activate(); -} - -void QmlBehaviour::classComplete() -{ - Q_D(QmlBehaviour); - d->context->deactivate(); -} - -#include "qmlbehaviour.moc" - -QT_END_NAMESPACE diff --git a/src/declarative/util/qmlbehaviour.h b/src/declarative/util/qmlbehaviour.h deleted file mode 100644 index 7cc83b2..0000000 --- a/src/declarative/util/qmlbehaviour.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLBEHAVIOUR_H -#define QMLBEHAVIOUR_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QmlAbstractAnimation; -class QmlBehaviourPrivate; -class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource, - public QmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlBehaviour) - Q_INTERFACES(QmlParserStatus) - - Q_PROPERTY(QVariant from READ fromValue WRITE setFromValue) - Q_PROPERTY(QVariant to READ toValue WRITE setToValue) - Q_CLASSINFO("DefaultProperty", "operations") - Q_PROPERTY(QmlList* operations READ operations) - -public: - QmlBehaviour(QObject *parent=0); - ~QmlBehaviour(); - - QVariant fromValue() const; - void setFromValue(const QVariant &); - QVariant toValue() const; - void setToValue(const QVariant &); - virtual void setTarget(const QmlMetaProperty &); - - QmlList* operations(); - - static bool _ignore; - -protected: - virtual void classBegin(); - virtual void classComplete(); - -private Q_SLOTS: - void propertyValueChanged(); -}; -QML_DECLARE_TYPE(QmlBehaviour) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLBEHAVIOUR_H diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp deleted file mode 100644 index ad0e473..0000000 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmldatetimeformatter.h" -#include "private/qobject_p.h" -#include - -QT_BEGIN_NAMESPACE -//TODO: may need optimisation as the QDateTime member may not be needed? -// be able to set a locale? - -class QmlDateTimeFormatterPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlDateTimeFormatter) -public: - QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), classComplete(true) {} - - void updateText(); - - QDateTime dateTime; - QDate date; - QTime time; - QLocale locale; - QString dateTimeText; - QString dateText; - QString timeText; - QString dateTimeFormat; //set for convienience? - QString dateFormat; - QString timeFormat; - bool longStyle; - bool classComplete; -}; - -/*! - \qmlclass DateTimeFormatter QmlDateTimeFormatter - \brief The DateTimeFormatter allows you to control the format of a date string. - - \code - DateTimeFormatter { id: Formatter; date: System.date } - Text { text: Formatter.dateText } - \endcode - - By default, the text properties (dateText, timeText, and dateTimeText) will return the - date and time using the current system locale's format. -*/ - -/*! - \internal - \class QmlDateTimeFormatter - \ingroup group_utility - \brief The QmlDateTimeFormatter class allows you to format a date string. -*/ - -QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent) -: QObject(*(new QmlDateTimeFormatterPrivate), parent) -{ -} - -QmlDateTimeFormatter::~QmlDateTimeFormatter() -{ -} - -/*! - \qmlproperty string DateTimeFormatter::dateText - \qmlproperty string DateTimeFormatter::timeText - \qmlproperty string DateTimeFormatter::dateTimeText - - Formatted text representations of the \c date, \c time, - and \c {date and time}, respectively. - - If there is no explictly specified format the DateTimeFormatter - will use the system locale's default 'short' setting. - - \code - // specify source date (assuming today is February 19, 2009) - DateTimeFormatter { id: formatter; dateTime: Today.date } - - // display the full date and time - Text { text: formatter.dateText } - \endcode - - Would be equivalent to the following for a US English locale: - - \code - // display the date - Text { text: "2/19/09" } - \endcode -*/ -QString QmlDateTimeFormatter::dateTimeText() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTimeText; -} - -QString QmlDateTimeFormatter::dateText() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateText; -} - -QString QmlDateTimeFormatter::timeText() const -{ - Q_D(const QmlDateTimeFormatter); - return d->timeText; -} - -/*! - \qmlproperty date DateTimeFormatter::date - \qmlproperty time DateTimeFormatter::time - \qmlproperty datetime DateTimeFormatter::dateTime - - The source date and time to be used by the formatter. - - \code - // setting the date and time - DateTimeFormatter { date: System.date; time: System.time } - \endcode - - For convienience it is possible to set the datetime property to set both the date and the time. - \code - // setting the datetime - DateTimeFormatter { dateTime: System.dateTime } - \endcode - - There can only be one instance of date and time per formatter; if date, time, and dateTime are all - set the actual date and time used is not guaranteed. - - \note If no date is set, dateTimeText will be just the date; - If no time is set, the dateTimeText will be just the time. - -*/ -QDate QmlDateTimeFormatter::date() const -{ - Q_D(const QmlDateTimeFormatter); - return d->date; -} - -QTime QmlDateTimeFormatter::time() const -{ - Q_D(const QmlDateTimeFormatter); - return d->time; -} - -QDateTime QmlDateTimeFormatter::dateTime() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTime; -} - -/*! - \qmlproperty string DateTimeFormatter::dateFormat - \qmlproperty string DateTimeFormatter::timeFormat - \qmlproperty string DateTimeFormatter::dateTimeFormat - - Specifies a custom format which the DateTime Formatter can use. - - If there is no explictly specified format the DateTimeFormatter - will use the system locale's default 'short' setting. - - The text's format may be modified by setting: - \list - \i \c dateFormat - \i \c timeFormat - \i \c dateTimeFormat - \endlist - - If only the format for date is defined, the time and dateTime formats will be defined - as the system locale default and likewise for the others. - - Syntax for the format is based on the QDateTime::toString() formatting options. - - \code - // Format the date such that the dateText is: '1997-12-12' - DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" } - \endcode - - Assigning an empty string to a particular format will reset it. -*/ -QString QmlDateTimeFormatter::dateTimeFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTimeFormat; -} - -QString QmlDateTimeFormatter::dateFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateFormat; -} - -QString QmlDateTimeFormatter::timeFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->timeFormat; -} - -/*! - \qmlproperty bool DateTimeFormatter::longStyle - - This property causes the formatter to use the system locale's long format rather than short format - by default. - - This setting is off by default. -*/ -bool QmlDateTimeFormatter::longStyle() const -{ - Q_D(const QmlDateTimeFormatter); - return d->longStyle; -} - -void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime == dateTime) - return; - d->dateTime = dateTime; - d->date = d->dateTime.date(); - d->time = d->dateTime.time(); - d->updateText(); -} - -void QmlDateTimeFormatter::setTime(const QTime &time) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime.time() == time) - return; - d->time = time; - d->dateTime.setTime(time); - d->updateText(); -} - -void QmlDateTimeFormatter::setDate(const QDate &date) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime.date() == date) - return; - d->date = date; - bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time - d->dateTime.setDate(date); - if (clearTime) - d->dateTime.setTime(QTime()); - d->updateText(); -} - -//DateTime formatting may be a combination of date and time? -void QmlDateTimeFormatter::setDateTimeFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->dateTimeFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setDateFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->dateFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setTimeFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->timeFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setLongStyle(bool longStyle) -{ - Q_D(QmlDateTimeFormatter); - d->longStyle = longStyle; - d->updateText(); -} - -void QmlDateTimeFormatterPrivate::updateText() -{ - Q_Q(QmlDateTimeFormatter); - if (!classComplete) - return; - - QString str; - QString str1; - QString str2; - - Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate; - - if (dateFormat.isEmpty()) - str1 = date.toString(defaultFormat); - else - str1 = date.toString(dateFormat); - - if (timeFormat.isEmpty()) - str2 = time.toString(defaultFormat); - else - str2 = time.toString(timeFormat); - - if (dateTimeFormat.isEmpty()) - str = dateTime.toString(defaultFormat); - //else if (!formatTime.isEmpty() && !formatDate.isEmpty()) - // str = str1 + QLatin1Char(' ') + str2; - else - str = dateTime.toString(dateTimeFormat); - - if (dateTimeText == str && dateText == str1 && timeText == str2) - return; - - dateTimeText = str; - dateText = str1; - timeText = str2; - - emit q->textChanged(); -} - -void QmlDateTimeFormatter::classBegin() -{ - Q_D(QmlDateTimeFormatter); - d->classComplete = false; -} - -void QmlDateTimeFormatter::classComplete() -{ - Q_D(QmlDateTimeFormatter); - d->classComplete = true; - d->updateText(); -} - -QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter) -QT_END_NAMESPACE diff --git a/src/declarative/util/qmldatetimeformatter.h b/src/declarative/util/qmldatetimeformatter.h deleted file mode 100644 index 84b27e3..0000000 --- a/src/declarative/util/qmldatetimeformatter.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLDATETIMEFORMATTER_H -#define QMLDATETIMEFORMATTER_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QmlDateTimeFormatterPrivate; -class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QmlParserStatus) - - Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged) - Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged) - Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged) - Q_PROPERTY(QDate date READ date WRITE setDate) - Q_PROPERTY(QTime time READ time WRITE setTime) - Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime) - Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat) - Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat) - Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) - Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle) -public: - QmlDateTimeFormatter(QObject *parent=0); - ~QmlDateTimeFormatter(); - - QString dateTimeText() const; - QString dateText() const; - QString timeText() const; - - QDate date() const; - void setDate(const QDate &); - - QTime time() const; - void setTime(const QTime &); - - QDateTime dateTime() const; - void setDateTime(const QDateTime &); - - QString dateTimeFormat() const; - void setDateTimeFormat(const QString &); - - QString dateFormat() const; - void setDateFormat(const QString &); - - QString timeFormat() const; - void setTimeFormat(const QString &); - - bool longStyle() const; - void setLongStyle(bool); - - virtual void classBegin(); - virtual void classComplete(); - -Q_SIGNALS: - void textChanged(); - -private: - Q_DISABLE_COPY(QmlDateTimeFormatter) - Q_DECLARE_PRIVATE(QmlDateTimeFormatter) -}; - -QML_DECLARE_TYPE(QmlDateTimeFormatter) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 030a44e..f35812c 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -6,7 +6,6 @@ SOURCES += \ util/qmlpackage.cpp \ util/qmlscript.cpp \ util/qmlanimation.cpp \ - util/qmlbehaviour.cpp \ util/qmlfont.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ @@ -14,8 +13,6 @@ SOURCES += \ util/qmlsetproperties.cpp \ util/qmlstategroup.cpp \ util/qmltransition.cpp \ - util/qbindablemap.cpp \ - util/qmldatetimeformatter.cpp \ util/qmllistmodel.cpp\ util/qmllistaccessor.cpp \ util/qmlopenmetaobject.cpp \ @@ -31,7 +28,6 @@ HEADERS += \ util/qmlscript.h \ util/qmlanimation.h \ util/qmlanimation_p.h \ - util/qmlbehaviour.h \ util/qmlfont.h \ util/qmlfollow.h \ util/qmlstate.h\ @@ -40,8 +36,6 @@ HEADERS += \ util/qmlstate_p.h\ util/qmlstategroup.h \ util/qmltransition.h \ - util/qbindablemap.h \ - util/qmldatetimeformatter.h \ util/qmllistmodel.h\ util/qmllistaccessor.h \ util/qmlopenmetaobject.h \ -- cgit v0.12 From 271c4ea851b71ddc346ab5b7d251c61e5e44c424 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Jun 2009 12:58:09 +1000 Subject: Cut down on the number of false positives for anchoring looping. The looping detection is not very reliable, but this makes it at least somewhat more so. --- src/declarative/fx/qfxanchors.cpp | 12 ++++++------ src/declarative/fx/qfxanchors_p.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index feac96e..84ccadf 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -402,8 +402,8 @@ void QFxAnchorsPrivate::updateVerticalAnchors() if (fill || centeredIn || !isItemComplete()) return; - if (!updatingVerticalAnchor) { - updatingVerticalAnchor = true; + if (updatingVerticalAnchor < 2) { + ++updatingVerticalAnchor; if (usedAnchors & QFxAnchors::HasTopAnchor) { //Handle stretching bool invalid = true; @@ -455,7 +455,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors() setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset()); } } - updatingVerticalAnchor = false; + --updatingVerticalAnchor; } else { // ### Make this certain :) qmlInfo(item) << "Possible anchor loop detected on vertical anchor."; @@ -467,8 +467,8 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() if (fill || centeredIn || !isItemComplete()) return; - if (!updatingHorizontalAnchor) { - updatingHorizontalAnchor = true; + if (updatingHorizontalAnchor < 2) { + ++updatingHorizontalAnchor; if (usedAnchors & QFxAnchors::HasLeftAnchor) { //Handle stretching @@ -514,7 +514,7 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() } } - updatingHorizontalAnchor = false; + --updatingHorizontalAnchor; } else { // ### Make this certain :) qmlInfo(item) << "Possible anchor loop detected on horizontal anchor."; diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 32d8b75..9ff6869 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -63,8 +63,8 @@ class QFxAnchorsPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QFxAnchors) public: QFxAnchorsPrivate() - : updatingMe(false), updatingHorizontalAnchor(false), - updatingVerticalAnchor(false), item(0), usedAnchors(0), fill(0), + : updatingMe(false), updatingHorizontalAnchor(0), + updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0), centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0) { @@ -80,9 +80,9 @@ public: void remDepend(QFxItem *); bool isItemComplete() const; - bool updatingMe:1; - bool updatingHorizontalAnchor:1; - bool updatingVerticalAnchor:1; + bool updatingMe; + int updatingHorizontalAnchor; + int updatingVerticalAnchor; void setItemHeight(qreal); void setItemWidth(qreal); -- cgit v0.12 From 3d725363a43d408e1f57292fc54ab2925529fa6e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Jun 2009 14:40:34 +1000 Subject: Cleanup, fixes, and basic docs for XmlListModel. --- demos/declarative/flickr/flickr.qml | 22 ++--- demos/declarative/flickr/flickr2.qml | 22 ++--- doc/src/declarative/elements.qdoc | 2 +- examples/declarative/flowview/flickr.qml | 22 ++--- examples/declarative/xmldata/daringfireball.qml | 8 +- examples/declarative/xmldata/yahoonews.qml | 8 +- src/declarative/extra/qmlxmllistmodel.cpp | 115 ++++++++++++++++++++++-- src/declarative/extra/qmlxmllistmodel.h | 15 +++- 8 files changed, 162 insertions(+), 52 deletions(-) diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 3ce442e..edf1095 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -10,19 +10,19 @@ Item { id: FeedModel property string tags : TagsEdit.text source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" - query: "doc($src)/rss/channel/item" + query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - Role { name: "title"; query: "title/string()" } - Role { name: "imagePath"; query: "media:thumbnail/@url/string()" } - Role { name: "url"; query: "media:content/@url/string()" } - Role { name: "description"; query: "description/string()" } - Role { name: "tags"; query: "media:category/string()" } - Role { name: "photoWidth"; query: "media:content/@width/string()" } - Role { name: "photoHeight"; query: "media:content/@height/string()" } - Role { name: "photoType"; query: "media:content/@type/string()" } - Role { name: "photoAuthor"; query: "author/string()" } - Role { name: "photoDate"; query: "pubDate/string()" } + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } }, Component { diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 947bf9e..d6d5c95 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -12,19 +12,19 @@ Item { id: FeedModel property string tags : TagsEdit.text source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" - query: "doc($src)/rss/channel/item" + query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - Role { name: "title"; query: "title/string()" } - Role { name: "imagePath"; query: "media:thumbnail/@url/string()" } - Role { name: "url"; query: "media:content/@url/string()" } - Role { name: "description"; query: "description/string()" } - Role { name: "tags"; query: "media:category/string()" } - Role { name: "photoWidth"; query: "media:content/@width/string()" } - Role { name: "photoHeight"; query: "media:content/@height/string()" } - Role { name: "photoType"; query: "media:content/@type/string()" } - Role { name: "photoAuthor"; query: "author/string()" } - Role { name: "photoDate"; query: "pubDate/string()" } + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } } delegate: Package { diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 9edb087..63566f6 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -42,7 +42,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \list \o \l Bind \o \l ListModel -\o \l XmlListModel +\o \l XmlListModel and XmlRole \o \l SqlQuery, \l SqlConnection, and \l SqlBind \o \l DateTimeFormatter \o \l NumberFormatter diff --git a/examples/declarative/flowview/flickr.qml b/examples/declarative/flowview/flickr.qml index fa8233b..2742839 100644 --- a/examples/declarative/flowview/flickr.qml +++ b/examples/declarative/flowview/flickr.qml @@ -8,19 +8,19 @@ Rect { XmlListModel { id: FeedModel source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" - query: "doc($src)/rss/channel/item" + query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - Role { name: "title"; query: "title/string()" } - Role { name: "imagePath"; query: "media:thumbnail/@url/string()" } - Role { name: "url"; query: "media:content/@url/string()" } - Role { name: "description"; query: "description/string()" } - Role { name: "tags"; query: "media:category/string()" } - Role { name: "photoWidth"; query: "media:content/@width/string()" } - Role { name: "photoHeight"; query: "media:content/@height/string()" } - Role { name: "photoType"; query: "media:content/@type/string()" } - Role { name: "photoAuthor"; query: "author/string()" } - Role { name: "photoDate"; query: "pubDate/string()" } + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } } ListView { diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index b14dfbf..6f3461e 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -6,17 +6,17 @@ Rect { XmlListModel { id: feedModel source: "http://daringfireball.net/index.xml" - query: "doc($src)/feed/entry" + query: "/feed/entry" namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - Role { + XmlRole { name: "title" query: "title/string()" } - Role { + XmlRole { name: "tagline" query: "author/name/string()" } - Role { + XmlRole { name: "content" query: "content/string()" } diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index d20da99..9d0c956 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -9,16 +9,16 @@ Rect { XmlListModel { id: feedModel source: "http://rss.news.yahoo.com/rss/oceania" - query: "doc($src)/rss/channel/item" - Role { + query: "/rss/channel/item" + XmlRole { name: "title" query: "title/string()" } - Role { + XmlRole { name: "link" query: "link/string()" } - Role { + XmlRole { name: "description" query: "description/string()" } diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 51905fa..082c9c2 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(XmlListModelRole, Role) +QML_DEFINE_TYPE(XmlListModelRole, XmlRole) QML_DEFINE_TYPE(QmlXmlListModel, XmlListModel) @@ -105,7 +105,7 @@ public: m_modelData.clear(); m_size = 0; m_data = data; - m_query = query; + m_query = QLatin1String("doc($src)") + query; m_namespaces = namespaces; m_roleObjects = roleObjects; if (!isRunning()) { @@ -224,6 +224,13 @@ void QmlXmlQuery::doSubQueryJob() //### we might be able to condense even further (query for everything in one go) for (int i = 0; i < m_roleObjects->size(); ++i) { XmlListModelRole *role = m_roleObjects->at(i); + if (!role->isValid()) { + QList resultList; + for (int j = 0; j < m_size; ++j) + resultList << QVariant(); + m_modelData << resultList; + continue; + } subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")")); QXmlResultItems output3; subquery.evaluateTo(&output3); @@ -233,6 +240,9 @@ void QmlXmlQuery::doSubQueryJob() resultList << item.toAtomicValue(); //### we used to trim strings item = output3.next(); } + //### should warn here if things have gone wrong. + while (resultList.count() < m_size) + resultList << QVariant(); m_modelData << resultList; b.seek(0); } @@ -308,6 +318,38 @@ void QmlXmlRoleList::append(XmlListModelRole *role) { model->roleNames << role->name(); ++model->highestRole; } + +/*! + \qmlclass XmlRole + \brief The XmlRole element allows you to specify a role for an XmlListModel. +*/ + +/*! + \qmlproperty string XmlRole::name + The name for the role. This name is used to access the model data for this role from Qml. + + \qml + XmlRole { name: "title"; query: "title/string()" } + + ... + + Component { + id: Delegate + Text { text: title } + } + \endqml +*/ + +/*! + \qmlproperty string XmlRole::query + The relative XPath query for this role. The query should not start with a '/' (i.e. it must be + relative). + + \qml + XmlRole { name: "title"; query: "title/string()" } + \endqml +*/ + //XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well // (and the model should emit the appropriate signals) void QmlXmlRoleList::clear() @@ -316,12 +358,15 @@ void QmlXmlRoleList::clear() model->roleNames.clear(); QmlConcreteList::clear(); } + void QmlXmlRoleList::removeAt(int i) { model->roles.removeAt(i); model->roleNames.removeAt(i); QmlConcreteList::removeAt(i); } + +//### we should enforce unique role names void QmlXmlRoleList::insert(int i, XmlListModelRole *role) { QmlConcreteList::insert(i, role); @@ -332,7 +377,7 @@ void QmlXmlRoleList::insert(int i, XmlListModelRole *role) /*! \qmlclass XmlListModel - \brief The XmlListModel class allows you to specify a model using XQuery. + \brief The XmlListModel element allows you to specify a model using XPath expressions. XmlListModel allows you to construct a model from XML data that can then be used as a data source for the view classes (ListView, PathView, GridView) and any other classes that interact with model @@ -343,13 +388,14 @@ void QmlXmlRoleList::insert(int i, XmlListModelRole *role) XmlListModel { id: FeedModel source: "http://rss.news.yahoo.com/rss/oceania" - query: "doc($src)/rss/channel/item" - Role { name: "title"; query: "title/string()" } - Role { name: "link"; query: "link/string()" } - Role { name: "description"; query: "description/string()" } + query: "/rss/channel/item" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } } \endqml - \note The model is currently static, so the above is really just a snapshot of an RSS feed. + \note The model is currently static, so the above is really just a snapshot of an RSS feed. To force a + reload of the entire model, you can call the reload function. */ QmlXmlListModel::QmlXmlListModel(QObject *parent) @@ -364,6 +410,11 @@ QmlXmlListModel::~QmlXmlListModel() { } +/*! + \qmlproperty list QmlListModel::roles + + The roles to make available for this model. +*/ QmlList *QmlXmlListModel::roleObjects() { Q_D(QmlXmlListModel); @@ -403,6 +454,10 @@ QString QmlXmlListModel::toString(int role) const return d->roleNames.at(index); } +/*! + \qmlproperty url XmlListModel::source + The location of the XML data source. +*/ QUrl QmlXmlListModel::source() const { Q_D(const QmlXmlListModel); @@ -418,6 +473,11 @@ void QmlXmlListModel::setSource(const QUrl &src) } } +/*! + \qmlproperty url XmlListModel::query + An absolute XPath query representing the base query for the model items. The query should start with + a '/' or '//'. +*/ QString QmlXmlListModel::query() const { Q_D(const QmlXmlListModel); @@ -427,12 +487,21 @@ QString QmlXmlListModel::query() const void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); + if (!query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << "An XmlListModel query must start with '/' or \"//\""; + return; + } + if (d->query != query) { d->query = query; reload(); } } +/*! + \qmlproperty string XmlListModel::namespaceDeclarations + A set of declarations for the namespaces used in the query. +*/ QString QmlXmlListModel::namespaceDeclarations() const { Q_D(const QmlXmlListModel); @@ -447,12 +516,34 @@ void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations) reload(); } } + +/*! + \qmlproperty enum XmlListModel::status + + This property holds the status of data source loading. It can be one of: + \list + \o Idle - no data source has been set, or the data source has been loaded + \o Loading - the data source is currently being loaded + \o Error - an error occurred while loading the data source + \endlist + + \sa progress + +*/ QmlXmlListModel::Status QmlXmlListModel::status() const { Q_D(const QmlXmlListModel); return d->status; } +/*! + \qmlproperty real XmlListModel::progress + + This property holds the progress of data source loading, from 0.0 (nothing loaded) + to 1.0 (finished). + + \sa status +*/ qreal QmlXmlListModel::progress() const { Q_D(const QmlXmlListModel); @@ -466,6 +557,12 @@ void QmlXmlListModel::classComplete() reload(); } +/*! + \qmlmethod XmlListModel::reload() + + Reloads the model. All the existing model data will be removed, and the model + will be rebuilt from scratch. +*/ void QmlXmlListModel::reload() { Q_D(QmlXmlListModel); @@ -484,7 +581,7 @@ void QmlXmlListModel::reload() emit itemsRemoved(0, count); if (d->src.isEmpty()) { - qWarning() << "Can't load empty src string"; + qmlInfo(this) << "Can't load empty src string"; return; } diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index c6aae4a..0d41456 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -66,7 +67,18 @@ public: void setName(const QString &name) { m_name = name; } QString query() const { return m_query; } - void setQuery(const QString &query) { m_query = query; } + void setQuery(const QString &query) + { + if (query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << "An XmlRole query must not start with '/'"; + return; + } + m_query = query; + } + + bool isValid() { + return !m_name.isEmpty() && !m_query.isEmpty(); + } private: QString m_name; @@ -88,6 +100,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations) Q_PROPERTY(QmlList *roles READ roleObjects) Q_CLASSINFO("DefaultProperty", "roles") + public: QmlXmlListModel(QObject *parent = 0); ~QmlXmlListModel(); -- cgit v0.12 From 6856dd2850245414fb610e651391f5fe141605de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Jun 2009 15:34:21 +1000 Subject: Change border semantics for Rect. * Odd pen widths are drawn at a half pixel offset to keep things smooth. * A mitre join is used to make sure rects with thick borders don't look rounded. * A pen width of zero means no border. --- src/declarative/fx/qfxrect.cpp | 38 ++++++++++++++++++++++++++------------ src/declarative/fx/qfxrect.h | 2 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index fd8d9ca..0536f12 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -55,9 +55,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient) \brief The QFxPen class provides a pen used for drawing rect borders on a QFxView. By default, the pen is invalid and nothing is drawn. You must either set a color (then the default - width is 0) or a width (then the default color is black). + width is 1) or a width (then the default color is black). - A width of 0 indicates a cosmetic pen, a single-pixel line on the border of the item being painted. + A width of 1 indicates is a single-pixel line on the border of the item being painted. Example: \qml @@ -68,9 +68,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient) /*! \property QFxPen::width \brief the width of the pen. - A width of 0 is a single-pixel line on the border of the item being painted. + A width of 1 is a single-pixel line on the border of the item being painted. - If the width is less than 0 the pen is considered invalid and won't be used. + If the width is less than 1 the pen is considered invalid and won't be used. */ /*! @@ -103,18 +103,18 @@ void QFxPen::setColor(const QColor &c) \brief the width of the pen. \qml - // rect with green border using hexidecimal notation Rect { pen.width: 4 } \endqml - A width of 0 creates a thin line. For no line, use a negative width or a transparent color. + A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. - Odd pen widths generally lead to half-pixel painting. + To keep the border smooth (rather than blurry), odd pen widths cause the rect to be painted at + a half-pixel offset; */ void QFxPen::setWidth(int w) { _width = w; - _valid = (_width < 0) ? false : true; + _valid = (_width < 1) ? false : true; emit updated(); } @@ -505,7 +505,10 @@ void QFxRect::generateRoundedRect() p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRoundedRect((pw+1)/2, (pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2, d->radius, d->radius); + if (pw%2) + p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius); + else + p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius); } } @@ -520,12 +523,16 @@ void QFxRect::generateBorderedRect() p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); + pn.setJoinStyle(Qt::MiterJoin); p.setPen(pn); } else { p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2); + if (pw%2) + p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1))); + else + p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw)); } } #elif defined(QFX_RENDER_OPENGL) @@ -550,7 +557,10 @@ void QFxRect::generateRoundedRect() p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRoundedRect((pw+1)/2, (pw+1)/2, roundRect.width()-(pw+1)/2*2, roundRect.height()-(pw+1)/2*2, d->radius, d->radius); + if (pw%2) + p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, roundRect.width()-(pw+1), roundRect.height()-(pw+1)), d->radius, d->radius); + else + p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, roundRect.width()-pw, roundRect.height()-pw), d->radius, d->radius); d->rectTexture = cachedTexture(key, roundRect); } @@ -573,12 +583,16 @@ void QFxRect::generateBorderedRect() p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(pen()->color()), pen()->width()); + pn.setJoinStyle(Qt::MiterJoin); p.setPen(pn); } else { p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, borderedRect.width()-(pw+1)/2*2, borderedRect.height()-(pw+1)/2*2); + if (pw%2) + p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, borderedRect.width()-(pw+1), borderedRect.height()-(pw+1))); + else + p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, borderedRect.width()-pw, borderedRect.height()-pw)); d->rectTexture = cachedTexture(key, borderedRect); } } diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index c279a1c..df490b0 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject Q_PROPERTY(QColor color READ color WRITE setColor) public: QFxPen(QObject *parent=0) - : QObject(parent), _width(0), _color("#000000"), _valid(false) + : QObject(parent), _width(1), _color("#000000"), _valid(false) {} int width() const { return _width; } -- cgit v0.12 From 3c6648385e8637536292c1351ef0d52708bd07d2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 12:55:10 +1000 Subject: Support animating dot properties. Make sure we can handle things like PropertyAnimation { property: "anchors.leftMargin" } --- src/declarative/qml/qmlmetaproperty.cpp | 30 +++++++++++++++++++ src/declarative/qml/qmlmetaproperty.h | 1 + src/declarative/util/qmlanimation.cpp | 48 +++++++++++++++++++++++-------- src/declarative/util/qmlanimation_p.h | 2 ++ src/declarative/util/qmlsetproperties.cpp | 37 +++++++----------------- src/declarative/util/qmlstate.cpp | 4 ++- src/declarative/util/qmlstate.h | 3 ++ src/declarative/util/qmlstate_p.h | 4 +++ 8 files changed, 89 insertions(+), 40 deletions(-) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 30e818b..682b8ad 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -1035,4 +1035,34 @@ QMetaMethod QmlMetaProperty::method() const return d->signal; } +/*! + \internal + + Creates a QmlMetaProperty for the property \a name of \a obj. Unlike + the QmlMetaProperty(QObject*, QString) constructor, this static function + will correctly handle dot properties. +*/ +QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj, const QString &name) +{ + QStringList path = name.split('.'); + + QObject *object = obj; + + for (int jj = 0; jj < path.count() - 1; ++jj) { + const QString &pathName = path.at(jj); + QmlMetaProperty prop(object, pathName); + QObject *objVal = QmlMetaType::toQObject(prop.read()); + if (!objVal) + return QmlMetaProperty(); + object = objVal; + } + + const QString &propName = path.last(); + QmlMetaProperty prop(object, propName); + if (!prop.isValid()) + return QmlMetaProperty(); + else + return prop; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index ce2fbcf..6c28a86 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -127,6 +127,7 @@ public: QmlBindableValue *setBinding(QmlBindableValue *) const; static int findSignal(const QObject *, const char *); + static QmlMetaProperty createProperty(QObject *, const QString &); int coreIndex() const; private: diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4ee5545..da26bdd 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -45,6 +45,7 @@ #include "qfile.h" #include "qmlpropertyvaluesource.h" #include "qml.h" +#include "qmlinfo.h" #include "qmlanimation_p.h" #include "qmlbehaviour.h" #include @@ -225,6 +226,21 @@ void QmlAbstractAnimationPrivate::commence() } } +//### make static? +QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str) +{ + Q_Q(QmlAbstractAnimation); + QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); + if (!prop.isValid()) { + qmlInfo(q) << "Cannot animate non-existant property" << str; + return QmlMetaProperty(); + } else if (!prop.isWritable()) { + qmlInfo(q) << "Cannot animate read-only property" << str; + return QmlMetaProperty(); + } + return prop; +} + void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); @@ -434,7 +450,7 @@ void QmlAbstractAnimation::setTarget(QObject *o) d->target = o; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -463,7 +479,7 @@ void QmlAbstractAnimation::setProperty(const QString &n) d->propertyName = n; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -1031,10 +1047,14 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -1051,7 +1071,7 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); myAction.toValue = d->value; data->actions << myAction; } @@ -1841,10 +1861,14 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -1870,7 +1894,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); if (d->fromIsDefined) { d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index da5ed97..b801d01 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -193,6 +193,8 @@ public: QmlMetaProperty property; QmlAnimationGroup *group; + + QmlMetaProperty createProperty(QObject *obj, const QString &str); }; class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 240e37b..7ceed5e 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -282,39 +282,19 @@ void QmlSetProperties::setRestoreEntryValues(bool v) d->restore = v; } -QmlMetaProperty -QmlSetPropertiesPrivate::property(const QByteArray &property) +QmlMetaProperty +QmlSetPropertiesPrivate::property(const QByteArray &property) { Q_Q(QmlSetProperties); - QList path = property.split('.'); - - QObject *obj = this->object; - - for (int jj = 0; jj < path.count() - 1; ++jj) { - const QByteArray &pathName = path.at(jj); - QmlMetaProperty prop(obj, QLatin1String(pathName)); - QObject *objVal = QmlMetaType::toQObject(prop.read()); - if (!objVal) { - qmlInfo(q) << obj->metaObject()->className() - << "has no object property named" << pathName; - return QmlMetaProperty(); - } - obj = objVal; - } - - const QByteArray &name = path.last(); - QmlMetaProperty prop(obj, QLatin1String(name)); + QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromLatin1(property)); if (!prop.isValid()) { - qmlInfo(q) << obj->metaObject()->className() - << "has no property named" << name; + qmlInfo(q) << "Cannot assign to non-existant property" << property; return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << obj->metaObject()->className() - << name << "is not writable, and cannot be set."; + qmlInfo(q) << "Cannot assign to read-only property" << property; return QmlMetaProperty(); - } else { - return prop; } + return prop; } QmlSetProperties::ActionList QmlSetProperties::actions() @@ -336,6 +316,8 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.property = prop; a.fromValue = a.property.read(); a.toValue = d->properties.at(ii).second; + a.specifiedObject = d->object; + a.specifiedProperty = QString::fromLatin1(property); list << a; } @@ -351,6 +333,8 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); + a.specifiedObject = d->object; + a.specifiedProperty = QString::fromLatin1(property); if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->value(); @@ -361,7 +345,6 @@ QmlSetProperties::ActionList QmlSetProperties::actions() list << a; } - } return list; diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index fe215e7..8ac1b33 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() : restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0) +Action::Action() : restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } @@ -403,6 +403,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever a.fromValue = cur; a.toValue = d->revertList.at(ii).value; a.toBinding = d->revertList.at(ii).binding; + a.specifiedObject = d->revertList.at(ii).specifiedObject; //### + a.specifiedProperty = d->revertList.at(ii).specifiedProperty; applyList << a; // Store these special reverts in the reverting list d->reverting << d->revertList.at(ii).property; diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index e9a173c..b219b99 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -71,6 +71,9 @@ public: QmlBindableValue *toBinding; ActionEvent *event; + QObject *specifiedObject; + QString specifiedProperty; + void deleteFromBinding(); }; diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index b4ec476..2f6ff42 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -55,6 +55,8 @@ public: SimpleAction(const Action &a, State state = StartState) { property = a.property; + specifiedObject = a.specifiedObject; + specifiedProperty = a.specifiedProperty; if (state == StartState) { value = a.fromValue; binding = property.binding(); @@ -67,6 +69,8 @@ public: QmlMetaProperty property; QVariant value; QmlBindableValue *binding; + QObject *specifiedObject; + QString specifiedProperty; }; class QmlStatePrivate : public QObjectPrivate -- cgit v0.12 From 518cbf7d241cdbd2a4414df289f4bc91e7583edc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 13:13:55 +1000 Subject: Change geometry-related properties from int to qreal. Most related properties were already qreal. --- src/declarative/fx/qfxanchors.cpp | 25 +++++++------ src/declarative/fx/qfxanchors.h | 45 +++++++++++------------- src/declarative/fx/qfxanchors_p.h | 14 ++++---- src/declarative/fx/qfxitem.cpp | 74 ++++++++++++++++++++------------------- src/declarative/fx/qfxitem.h | 26 +++++++------- src/declarative/fx/qfxitem_p.h | 2 +- 6 files changed, 92 insertions(+), 94 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 84ccadf..9a5c516 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxAnchors,Anchors) //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? -//TODO: baseline support //TODO: support non-parent, non-sibling (need to find lowest common ancestor) //### const item? @@ -760,13 +759,13 @@ void QFxAnchors::resetHorizontalCenter() d->updateHorizontalAnchors(); } -int QFxAnchors::leftMargin() const +qreal QFxAnchors::leftMargin() const { Q_D(const QFxAnchors); return d->leftMargin; } -void QFxAnchors::setLeftMargin(int offset) +void QFxAnchors::setLeftMargin(qreal offset) { Q_D(QFxAnchors); if (d->leftMargin == offset) @@ -776,13 +775,13 @@ void QFxAnchors::setLeftMargin(int offset) emit leftMarginChanged(); } -int QFxAnchors::rightMargin() const +qreal QFxAnchors::rightMargin() const { Q_D(const QFxAnchors); return d->rightMargin; } -void QFxAnchors::setRightMargin(int offset) +void QFxAnchors::setRightMargin(qreal offset) { Q_D(QFxAnchors); if (d->rightMargin == offset) @@ -792,13 +791,13 @@ void QFxAnchors::setRightMargin(int offset) emit rightMarginChanged(); } -int QFxAnchors::horizontalCenterOffset() const +qreal QFxAnchors::horizontalCenterOffset() const { Q_D(const QFxAnchors); return d->hCenterOffset; } -void QFxAnchors::setHorizontalCenterOffset(int offset) +void QFxAnchors::setHorizontalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->hCenterOffset == offset) @@ -808,13 +807,13 @@ void QFxAnchors::setHorizontalCenterOffset(int offset) emit horizontalCenterOffsetChanged(); } -int QFxAnchors::topMargin() const +qreal QFxAnchors::topMargin() const { Q_D(const QFxAnchors); return d->topMargin; } -void QFxAnchors::setTopMargin(int offset) +void QFxAnchors::setTopMargin(qreal offset) { Q_D(QFxAnchors); if (d->topMargin == offset) @@ -824,13 +823,13 @@ void QFxAnchors::setTopMargin(int offset) emit topMarginChanged(); } -int QFxAnchors::bottomMargin() const +qreal QFxAnchors::bottomMargin() const { Q_D(const QFxAnchors); return d->bottomMargin; } -void QFxAnchors::setBottomMargin(int offset) +void QFxAnchors::setBottomMargin(qreal offset) { Q_D(QFxAnchors); if (d->bottomMargin == offset) @@ -840,13 +839,13 @@ void QFxAnchors::setBottomMargin(int offset) emit bottomMarginChanged(); } -int QFxAnchors::verticalCenterOffset() const +qreal QFxAnchors::verticalCenterOffset() const { Q_D(const QFxAnchors); return d->vCenterOffset; } -void QFxAnchors::setVerticalCenterOffset(int offset) +void QFxAnchors::setVerticalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->vCenterOffset == offset) diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 206a05c..94c22a6 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -46,15 +46,13 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxItem; -class QFxAnchorsPrivate; +class QFxItem; class QFxAnchorLine { public: @@ -93,12 +91,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom) Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) Q_PROPERTY(QFxAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline) - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) + Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) + Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) + Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) + Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) + Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) + Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) Q_PROPERTY(QFxItem *fill READ fill WRITE setFill) Q_PROPERTY(QFxItem *centeredIn READ centeredIn WRITE setCenteredIn) @@ -121,7 +119,7 @@ public: QFxAnchorLine left() const; void setLeft(const QFxAnchorLine &edge); - Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing + void resetLeft(); QFxAnchorLine right() const; void setRight(const QFxAnchorLine &edge); @@ -147,23 +145,23 @@ public: void setBaseline(const QFxAnchorLine &edge); void resetBaseline(); - int leftMargin() const; - void setLeftMargin(int); + qreal leftMargin() const; + void setLeftMargin(qreal); - int rightMargin() const; - void setRightMargin(int); + qreal rightMargin() const; + void setRightMargin(qreal); - int horizontalCenterOffset() const; - void setHorizontalCenterOffset(int); + qreal horizontalCenterOffset() const; + void setHorizontalCenterOffset(qreal); - int topMargin() const; - void setTopMargin(int); + qreal topMargin() const; + void setTopMargin(qreal); - int bottomMargin() const; - void setBottomMargin(int); + qreal bottomMargin() const; + void setBottomMargin(qreal); - int verticalCenterOffset() const; - void setVerticalCenterOffset(int); + qreal verticalCenterOffset() const; + void setVerticalCenterOffset(qreal); QFxItem *fill() const; void setFill(QFxItem *); @@ -188,11 +186,10 @@ private: Q_DISABLE_COPY(QFxAnchors) Q_DECLARE_PRIVATE(QFxAnchors) }; - QML_DECLARE_TYPE(QFxAnchors) - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 9ff6869..a7c904b 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -56,8 +56,8 @@ #include "qfxanchors.h" #include "private/qobject_p.h" - QT_BEGIN_NAMESPACE + class QFxAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxAnchors) @@ -119,12 +119,12 @@ public: QFxAnchorLine hCenter; QFxAnchorLine baseline; - int leftMargin; - int rightMargin; - int topMargin; - int bottomMargin; - int vCenterOffset; - int hCenterOffset; + qreal leftMargin; + qreal rightMargin; + qreal topMargin; + qreal bottomMargin; + qreal vCenterOffset; + qreal hCenterOffset; }; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 73786a8..3764e3d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -65,10 +65,10 @@ #include #include - QT_BEGIN_NAMESPACE -#ifndef INT_MAX -#define INT_MAX 2147483647 + +#ifndef FLT_MAX +#define FLT_MAX 1E+37 #endif QML_DEFINE_NOCREATE_TYPE(QFxContents) @@ -123,7 +123,7 @@ QML_DEFINE_NOCREATE_TYPE(QSimpleCanvasFilter) */ -QFxContents::QFxContents() : _height(0), _width(0) +QFxContents::QFxContents() : m_height(0), m_width(0) { } @@ -131,70 +131,71 @@ QFxContents::QFxContents() : _height(0), _width(0) \property QFxContents::height \brief The height of the contents. */ -int QFxContents::height() const +qreal QFxContents::height() const { - return _height; + return m_height; } /*! \property QFxContents::width \brief The width of the contents. */ -int QFxContents::width() const +qreal QFxContents::width() const { - return _width; + return m_width; } //TODO: optimization: only check sender(), if there is one void QFxContents::calcHeight() { - int oldheight = _height; + qreal oldheight = m_height; - int top = INT_MAX; - int bottom = 0; + qreal top = FLT_MAX; + qreal bottom = 0; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); - int y = int(child->y()); + qreal y = child->y(); if (y + child->height() > bottom) bottom = y + child->height(); if (y < top) top = y; } - _height = bottom - top; + m_height = qMax(bottom - top, qreal(0.0)); - if (_height != oldheight) + if (m_height != oldheight) emit heightChanged(); } //TODO: optimization: only check sender(), if there is one void QFxContents::calcWidth() { - int oldwidth = _width; + qreal oldwidth = m_width; + + qreal left = FLT_MAX; + qreal right = 0; - int left = INT_MAX; - int right = 0; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); - int x = int(child->x()); + qreal x = int(child->x()); if (x + child->width() > right) right = x + child->width(); if (x < left) left = x; } - _width = right - left; + m_width = qMax(right - left, qreal(0.0)); - if (_width != oldwidth) + if (m_width != oldwidth) emit widthChanged(); } void QFxContents::setItem(QFxItem *item) { - _item = item; + m_item = item; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); @@ -925,8 +926,8 @@ void QFxItem::qmlLoaded() /*! \qmlproperty real Item::x \qmlproperty real Item::y - \qmlproperty int Item::width - \qmlproperty int Item::height + \qmlproperty real Item::width + \qmlproperty real Item::height Defines the item's position and size relative to its parent. @@ -1346,13 +1347,14 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty AnchorLine Item::anchors.baseline \qmlproperty Item Item::anchors.fill - - \qmlproperty int Item::anchors.topMargin - \qmlproperty int Item::anchors.bottomMargin - \qmlproperty int Item::anchors.leftMargin - \qmlproperty int Item::anchors.rightMargin - \qmlproperty int Item::anchors.horizontalCenterOffset - \qmlproperty int Item::anchors.verticalCenterOffset + \qmlproperty Item Item::anchors.centeredIn + + \qmlproperty real Item::anchors.topMargin + \qmlproperty real Item::anchors.bottomMargin + \qmlproperty real Item::anchors.leftMargin + \qmlproperty real Item::anchors.rightMargin + \qmlproperty real Item::anchors.horizontalCenterOffset + \qmlproperty real Item::anchors.verticalCenterOffset Anchors provide a way to position an item by specifying its relationship with other items. @@ -1411,11 +1413,11 @@ QFxAnchorLine QFxItem::baseline() const For non-text items, a default baseline offset of 0 is used. */ -int QFxItem::baselineOffset() const +qreal QFxItem::baselineOffset() const { Q_D(const QFxItem); if (!d->_baselineOffset.isValid()) { - return 0; + return 0.0; } else return d->_baselineOffset; } @@ -1423,7 +1425,7 @@ int QFxItem::baselineOffset() const /*! \internal */ -void QFxItem::setBaselineOffset(int offset) +void QFxItem::setBaselineOffset(qreal offset) { Q_D(QFxItem); if (offset == d->_baselineOffset) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 3c872e1..f0f1177 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -53,7 +53,6 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -63,14 +62,14 @@ QT_MODULE(Declarative) class Q_DECLARATIVE_EXPORT QFxContents : public QObject { Q_OBJECT - Q_PROPERTY(int height READ height NOTIFY heightChanged) - Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(qreal height READ height NOTIFY heightChanged) + Q_PROPERTY(qreal width READ width NOTIFY widthChanged) public: QFxContents(); - int height() const; + qreal height() const; - int width() const; + qreal width() const; void setItem(QFxItem *item); @@ -83,9 +82,9 @@ Q_SIGNALS: void widthChanged(); private: - QFxItem *_item; - int _height; - int _width; + QFxItem *m_item; + qreal m_height; + qreal m_width; }; QML_DECLARE_TYPE(QFxContents) Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) @@ -116,11 +115,11 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged) Q_PROPERTY(qreal z READ z WRITE setZ) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(QFxAnchorLine left READ left) Q_PROPERTY(QFxAnchorLine right READ right) Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter) @@ -179,8 +178,8 @@ public: bool flipHorizontally() const; void setFlipHorizontally(bool); - int baselineOffset() const; - void setBaselineOffset(int); + qreal baselineOffset() const; + void setBaselineOffset(qreal); qreal rotation() const; void setRotation(qreal); @@ -274,4 +273,5 @@ QML_DECLARE_TYPE(QSimpleCanvasFilter) QT_END_NAMESPACE QT_END_HEADER + #endif // QFXITEM_H diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index b38d877..32e8aef 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -138,7 +138,7 @@ public: QList _qmlnewloading; QList _qmlnewcomp; - QmlNullableValue _baselineOffset; + QmlNullableValue _baselineOffset; float _rotation; bool _classComplete:1; -- cgit v0.12 From 1674eeb1b331f000a6dc651ec12b682ba5b7fd77 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 13:29:26 +1000 Subject: Rename notifiers: topChanged -> yChanged; leftChanged -> xChanged. --- examples/declarative/follow/pong.qml | 2 +- src/declarative/fx/qfxflickable.cpp | 4 ++-- src/declarative/fx/qfxgridview.cpp | 12 ++++++------ src/declarative/fx/qfxitem.cpp | 16 ++++++++-------- src/declarative/fx/qfxitem.h | 8 ++++---- src/declarative/fx/qfxlistview.cpp | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml index 93ee6a7..c101d8d 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/pong.qml @@ -26,7 +26,7 @@ Rect { y: Follow { source: Ball.targetY; velocity: 200 } // Detect the ball hitting the top or bottom of the view and bounce it - onTopChanged: { + onYChanged: { if (y <= 0) targetY = Page.height-20; else if (y >= Page.height-20) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index bc4a5fc..3580edb 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -112,8 +112,8 @@ void QFxFlickablePrivate::init() QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); q->setOptions(QSimpleCanvasItem::ChildMouseFilter | QSimpleCanvasItem::MouseEvents); - QObject::connect(_flick, SIGNAL(leftChanged()), q, SIGNAL(positionChanged())); - QObject::connect(_flick, SIGNAL(topChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&elasticY, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange())); diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index a6ffbb9..11b630a 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -368,8 +368,8 @@ void QFxGridViewPrivate::releaseItem(FxGridItem *item) if (!item) return; if (trackedItem == item) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (model->release(item->item) == 0) { @@ -548,15 +548,15 @@ void QFxGridViewPrivate::updateTrackedItem() item = highlight; if (trackedItem && item != trackedItem) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (!trackedItem && item) { trackedItem = item; - QObject::connect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::connect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); q->trackedPositionChanged(); } if (trackedItem) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 3764e3d..5ef6106 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -199,9 +199,9 @@ void QFxContents::setItem(QFxItem *item) for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(topChanged()), this, SLOT(calcHeight())); + connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); - connect(child, SIGNAL(leftChanged()), this, SLOT(calcWidth())); + connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); } calcHeight(); @@ -269,15 +269,15 @@ void QFxContents::setItem(QFxItem *item) */ /*! - \fn void QFxItem::leftChanged() + \fn void QFxItem::xChanged() - This signal is emitted when the left coordinate of the item changes. + This signal is emitted when the x coordinate of the item changes. */ /*! - \fn void QFxItem::topChanged() + \fn void QFxItem::yChanged() - This signal is emitted when the top coordinate of the item changes. + This signal is emitted when the y coordinate of the item changes. */ /*! @@ -1068,11 +1068,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry, } if (newGeometry.x() != oldGeometry.x()) - emit leftChanged(); + emit xChanged(); if (newGeometry.width() != oldGeometry.width()) emit widthChanged(); if (newGeometry.y() != oldGeometry.y()) - emit topChanged(); + emit yChanged(); if (newGeometry.height() != oldGeometry.height()) emit heightChanged(); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index f0f1177..d66d24b 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -112,8 +112,8 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ z WRITE setZ) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) @@ -212,10 +212,10 @@ public Q_SLOTS: void newChild(const QString &url); Q_SIGNALS: - void leftChanged(); + void xChanged(); + void yChanged(); void widthChanged(); void heightChanged(); - void topChanged(); void baselineOffsetChanged(); void stateChanged(const QString &); void focusChanged(); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index a8c0747..889cfdd 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -444,7 +444,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) else QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); if (trackedItem == item) { - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); @@ -588,7 +588,7 @@ void QFxListViewPrivate::updateTrackedItem() if (highlight) item = highlight; - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); if (trackedItem && item != trackedItem) { -- cgit v0.12 From a77153a64e8559b21a7e6ea53fe26eb2719ce9f5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 14:26:23 +1000 Subject: Cleanup Fix up license headers and private warnings, as well as other general cleanups. --- src/declarative/debugger/qmldebugclient.cpp | 4 +- src/declarative/debugger/qmldebugger.cpp | 3 ++ src/declarative/debugger/qmldebugger.h | 1 - src/declarative/debugger/qmldebuggerstatus.h | 1 - src/declarative/debugger/qmldebugserver.cpp | 4 +- src/declarative/debugger/qmlobjecttree.cpp | 3 ++ src/declarative/debugger/qmlobjecttree_p.h | 15 ++++++++ src/declarative/debugger/qmlpropertyview.cpp | 4 ++ src/declarative/debugger/qmlpropertyview_p.h | 11 ++++++ src/declarative/debugger/qmlwatches.cpp | 4 ++ src/declarative/debugger/qmlwatches_p.h | 11 ++++++ src/declarative/debugger/qpacketprotocol.cpp | 41 ++++++++++++++++++-- src/declarative/debugger/qpacketprotocol.h | 47 +++++++++++++++++++++-- src/declarative/fx/qfxevents_p.h | 11 ++++++ src/declarative/fx/qfxitem.cpp | 7 ++++ src/declarative/fx/qfxitem.h | 6 +-- src/declarative/qml/parser/qmljs.g | 2 +- src/declarative/qml/parser/qmljsast_p.h | 2 +- src/declarative/qml/parser/qmljsengine_p.cpp | 38 +++++++++++------- src/declarative/qml/parser/qmljsengine_p.h | 49 +++++++++++++++++------- src/declarative/qml/parser/qmljslexer.cpp | 2 +- src/declarative/qml/parser/qmljsmemorypool_p.h | 2 +- src/declarative/qml/parser/qmljsnodepool_p.h | 2 +- src/declarative/qml/parser/qmljsprettypretty.cpp | 2 +- src/declarative/qml/parser/qmljsprettypretty_p.h | 2 +- src/declarative/qml/qmlbasicscript.cpp | 34 +++++++++++++++- src/declarative/qml/qmlbasicscript_p.h | 47 +++++++++++++++++++++-- src/declarative/qml/qmlbindablevalue.h | 4 +- src/declarative/qml/qmlbindablevalue_p.h | 11 ++++++ src/declarative/qml/qmlboundsignal_p.h | 15 +++++++- src/declarative/qml/qmlclassfactory.cpp | 3 ++ src/declarative/qml/qmlclassfactory_p.h | 11 ++++++ src/declarative/qml/qmlcompiledcomponent_p.h | 15 +++++++- src/declarative/qml/qmlcompiler_p.h | 12 ++++++ src/declarative/qml/qmlcomponent.cpp | 2 + src/declarative/qml/qmlcomponent.h | 1 + src/declarative/qml/qmlcomponent_p.h | 15 +++++++- src/declarative/qml/qmlcompositetypemanager.cpp | 4 ++ src/declarative/qml/qmlcompositetypemanager_p.h | 11 ++++++ src/declarative/qml/qmlcontext.h | 1 - src/declarative/qml/qmlcontext_p.h | 13 +++++++ src/declarative/qml/qmlcustomparser_p.h | 11 ++++++ src/declarative/qml/qmlcustomparser_p_p.h | 11 ++++++ src/declarative/qml/qmldeclarativedata_p.h | 11 ++++++ src/declarative/qml/qmldom.cpp | 1 - src/declarative/qml/qmldom_p.h | 11 ++++++ src/declarative/qml/qmlengine_p.h | 14 ++++++- src/declarative/qml/qmlexpression.h | 1 - src/declarative/qml/qmlinstruction.cpp | 1 + src/declarative/qml/qmlinstruction_p.h | 17 ++++++-- src/declarative/qml/qmllist.h | 1 - src/declarative/qml/qmlmetaproperty.cpp | 1 - src/declarative/qml/qmlmetaproperty_p.h | 12 +++++- src/declarative/qml/qmlmetatype.cpp | 1 + src/declarative/qml/qmlparser_p.h | 11 ++++++ src/declarative/qml/qmlparserstatus.h | 1 - src/declarative/qml/qmlprivate.h | 6 +-- src/declarative/qml/qmlpropertyvaluesource.cpp | 2 +- src/declarative/qml/qmlpropertyvaluesource.h | 7 ++-- src/declarative/qml/qmlproxymetaobject.cpp | 2 +- src/declarative/qml/qmlproxymetaobject_p.h | 12 ++++++ src/declarative/qml/qmlrefcount.cpp | 4 ++ src/declarative/qml/qmlrefcount_p.h | 11 ++++++ src/declarative/qml/qmlscriptparser.cpp | 1 - src/declarative/qml/qmlscriptparser_p.h | 14 ++++++- src/declarative/qml/qmlstringconverters_p.h | 11 ++++++ src/declarative/qml/qmlvme_p.h | 13 +++++++ src/declarative/qml/qmlvmemetaobject.cpp | 2 +- src/declarative/qml/qmlvmemetaobject_p.h | 12 ++++++ src/declarative/qml/qpodvector_p.h | 12 ++++++ src/declarative/util/qfxglobal.h | 4 +- src/declarative/util/qfxperf.cpp | 3 +- src/declarative/util/qfxperf.h | 11 +++--- src/declarative/util/qfxview.cpp | 3 +- src/declarative/util/qmlanimation_p.h | 15 +++++++- src/declarative/util/qmlbind.cpp | 1 + src/declarative/util/qmlconnection.cpp | 2 +- src/declarative/util/qmlfollow.cpp | 2 +- src/declarative/util/qmlfont.cpp | 3 +- src/declarative/util/qmllistmodel.cpp | 1 + src/declarative/util/qmllistmodel.h | 1 - src/declarative/util/qmlnullablevalue_p.h | 16 +++++++- src/declarative/util/qmlopenmetaobject.cpp | 1 - src/declarative/util/qmlpackage.cpp | 3 +- src/declarative/util/qmlscript.h | 3 ++ src/declarative/util/qmlsetproperties.cpp | 2 +- src/declarative/util/qmlsetproperties.h | 1 - src/declarative/util/qmlstate_p.h | 11 ++++++ src/declarative/util/qmlstategroup.cpp | 2 +- src/declarative/util/qperformancelog.cpp | 3 ++ src/declarative/util/qperformancelog.h | 5 +++ src/declarative/widgets/graphicslayouts.h | 4 +- src/declarative/widgets/graphicswidgets.cpp | 4 +- 93 files changed, 677 insertions(+), 111 deletions(-) diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp index 3dacf01..e442333 100644 --- a/src/declarative/debugger/qmldebugclient.cpp +++ b/src/declarative/debugger/qmldebugclient.cpp @@ -185,6 +185,6 @@ void QmlDebugClientPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugclient.moc" - QT_END_NAMESPACE + +#include "qmldebugclient.moc" diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index 9ab3247..aad11de 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -62,6 +62,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlDebugger::QmlDebugger(QWidget *parent) : QWidget(parent), m_tree(0), m_warnings(0), m_watchTable(0), m_watches(0), m_properties(0), m_text(0), m_highlightedItem(0) @@ -353,3 +355,4 @@ void QmlDebugger::setDebugObject(QObject *obj) item->setExpanded(true); } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index 10b2f9a..03efeb6 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -101,4 +101,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLDEBUGGER_H - diff --git a/src/declarative/debugger/qmldebuggerstatus.h b/src/declarative/debugger/qmldebuggerstatus.h index 62336de..a8480f4 100644 --- a/src/declarative/debugger/qmldebuggerstatus.h +++ b/src/declarative/debugger/qmldebuggerstatus.h @@ -64,4 +64,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QLMDEBUGGERSTATUS_P_H - diff --git a/src/declarative/debugger/qmldebugserver.cpp b/src/declarative/debugger/qmldebugserver.cpp index 23e59e0..e055ad5 100644 --- a/src/declarative/debugger/qmldebugserver.cpp +++ b/src/declarative/debugger/qmldebugserver.cpp @@ -294,6 +294,6 @@ void QmlDebugServerPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugserver.moc" - QT_END_NAMESPACE + +#include "qmldebugserver.moc" diff --git a/src/declarative/debugger/qmlobjecttree.cpp b/src/declarative/debugger/qmlobjecttree.cpp index 27dc000..8a2358a 100644 --- a/src/declarative/debugger/qmlobjecttree.cpp +++ b/src/declarative/debugger/qmlobjecttree.cpp @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlObjectTree::QmlObjectTree(QWidget *parent) : QTreeWidget(parent) { @@ -73,3 +75,4 @@ void QmlObjectTree::mousePressEvent(QMouseEvent *me) } } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmlobjecttree_p.h b/src/declarative/debugger/qmlobjecttree_p.h index 4e6d484..54d6d8e 100644 --- a/src/declarative/debugger/qmlobjecttree_p.h +++ b/src/declarative/debugger/qmlobjecttree_p.h @@ -42,10 +42,23 @@ #ifndef QMLOBJECTTREE_P_H #define QMLOBJECTTREE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include +QT_BEGIN_NAMESPACE + class QmlBindableValue; class QmlDebuggerItem : public QTreeWidgetItem { @@ -82,5 +95,7 @@ protected: virtual void mousePressEvent(QMouseEvent *); }; +QT_END_NAMESPACE + #endif // QMLOBJECTTREE_P_H diff --git a/src/declarative/debugger/qmlpropertyview.cpp b/src/declarative/debugger/qmlpropertyview.cpp index abe1902..76a192d 100644 --- a/src/declarative/debugger/qmlpropertyview.cpp +++ b/src/declarative/debugger/qmlpropertyview.cpp @@ -47,6 +47,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlPropertyView::QmlPropertyView(QmlWatches *watches, QWidget *parent) : QWidget(parent), m_tree(0), m_watches(watches) { @@ -221,4 +223,6 @@ void QmlPropertyView::refresh() setObject(m_object); } +QT_END_NAMESPACE + #include "qmlpropertyview.moc" diff --git a/src/declarative/debugger/qmlpropertyview_p.h b/src/declarative/debugger/qmlpropertyview_p.h index 469a08d..4694482 100644 --- a/src/declarative/debugger/qmlpropertyview_p.h +++ b/src/declarative/debugger/qmlpropertyview_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROPERTYVIEW_P_H #define QMLPROPERTYVIEW_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/debugger/qmlwatches.cpp b/src/declarative/debugger/qmlwatches.cpp index bac4cbd..8fc9e89 100644 --- a/src/declarative/debugger/qmlwatches.cpp +++ b/src/declarative/debugger/qmlwatches.cpp @@ -46,6 +46,8 @@ #include #include +QT_BEGIN_NAMESPACE + QString QmlWatches::objectToString(QObject *obj) { if(!obj) @@ -301,4 +303,6 @@ QVariant QmlWatches::data(const QModelIndex &idx, int role) const } } +QT_END_NAMESPACE + #include "qmlwatches.moc" diff --git a/src/declarative/debugger/qmlwatches_p.h b/src/declarative/debugger/qmlwatches_p.h index 6c383a1..dfec979 100644 --- a/src/declarative/debugger/qmlwatches_p.h +++ b/src/declarative/debugger/qmlwatches_p.h @@ -42,6 +42,17 @@ #ifndef QMLWATCHES_P_H #define QMLWATCHES_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index 6911b89..7be23b7 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -1,16 +1,49 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qpacketprotocol.h" #include +QT_BEGIN_NAMESPACE + #define MAX_PACKET_SIZE 0x7FFFFFFF /*! @@ -458,5 +491,7 @@ QPacketAutoSend::~QPacketAutoSend() p->send(*this); } +QT_END_NAMESPACE + #include "qpacketprotocol.moc" diff --git a/src/declarative/debugger/qpacketprotocol.h b/src/declarative/debugger/qpacketprotocol.h index 6dd8bda..f3fb44b 100644 --- a/src/declarative/debugger/qpacketprotocol.h +++ b/src/declarative/debugger/qpacketprotocol.h @@ -1,10 +1,41 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -14,6 +45,12 @@ #include #include +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + class QIODevice; class QBuffer; class QPacket; @@ -78,4 +115,8 @@ private: QPacketProtocol * p; }; +QT_END_NAMESPACE + +QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h index 2eb29af..60494e6 100644 --- a/src/declarative/fx/qfxevents_p.h +++ b/src/declarative/fx/qfxevents_p.h @@ -42,6 +42,17 @@ #ifndef QFXEVENTS_P_H #define QFXEVENTS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 5ef6106..1c35290 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -128,6 +128,13 @@ QFxContents::QFxContents() : m_height(0), m_width(0) } /*! + \qmlproperty qreal Item::contents.width + \qmlproperty qreal Item::contents.height + + The contents properties allow an item access to the size of its + children. This property is useful if you have an item that needs to be + sized to fit its children. +/*! \property QFxContents::height \brief The height of the contents. */ diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index d66d24b..67a4553 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -116,10 +116,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ z WRITE setZ) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) - Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(QFxAnchorLine left READ left) Q_PROPERTY(QFxAnchorLine right READ right) Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter) @@ -127,6 +124,9 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(QFxAnchorLine bottom READ bottom) Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter) Q_PROPERTY(QFxAnchorLine baseline READ baseline) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) + Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) + Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index 907ca52..ed5f653 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -3,7 +3,7 @@ -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -- Contact: Qt Software Information (qt-info@nokia.com) -- --- This file is part of the QtScript module of the Qt Toolkit. +-- This file is part of the QtDeclarative module of the Qt Toolkit. -- -- $QT_BEGIN_LICENSE:LGPL$ -- No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h index 8dc32ed..1db037a 100644 --- a/src/declarative/qml/parser/qmljsast_p.h +++ b/src/declarative/qml/parser/qmljsast_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index 42885d8..02d9b9c 100644 --- a/src/declarative/qml/parser/qmljsengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** -**************************************************************************/ +****************************************************************************/ #include "qmljsengine_p.h" #include "qmljsnodepool_p.h" diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h index b9ff042..5aea983 100644 --- a/src/declarative/qml/parser/qmljsengine_p.h +++ b/src/declarative/qml/parser/qmljsengine_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,14 +20,39 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** -**************************************************************************/ +****************************************************************************/ #ifndef QMLJSENGINE_P_H #define QMLJSENGINE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index 843f6ae..e0de71a 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsmemorypool_p.h b/src/declarative/qml/parser/qmljsmemorypool_p.h index d7506be..6bd21f8 100644 --- a/src/declarative/qml/parser/qmljsmemorypool_p.h +++ b/src/declarative/qml/parser/qmljsmemorypool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsnodepool_p.h b/src/declarative/qml/parser/qmljsnodepool_p.h index 1a5b7f6..e2f0a3c 100644 --- a/src/declarative/qml/parser/qmljsnodepool_p.h +++ b/src/declarative/qml/parser/qmljsnodepool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsprettypretty.cpp b/src/declarative/qml/parser/qmljsprettypretty.cpp index 1045792..b6733e5 100644 --- a/src/declarative/qml/parser/qmljsprettypretty.cpp +++ b/src/declarative/qml/parser/qmljsprettypretty.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsprettypretty_p.h b/src/declarative/qml/parser/qmljsprettypretty_p.h index fe82ca2..3227e7d 100644 --- a/src/declarative/qml/parser/qmljsprettypretty_p.h +++ b/src/declarative/qml/parser/qmljsprettypretty_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index f02a176..80ca5a9 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -3,9 +3,39 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/declarative/qml/qmlbasicscript_p.h b/src/declarative/qml/qmlbasicscript_p.h index 43c0d36..c7ab280 100644 --- a/src/declarative/qml/qmlbasicscript_p.h +++ b/src/declarative/qml/qmlbasicscript_p.h @@ -3,15 +3,56 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMLBASICSCRIPT_P_H #define QMLBASICSCRIPT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -109,5 +150,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLBASICSCRIPT_P_H - - diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index 50bbf36..00da57e 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -48,12 +48,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlExpression; class QmlContext; class QmlBindableValuePrivate; @@ -90,8 +90,8 @@ private: }; QML_DECLARE_TYPE(QmlBindableValue) - QT_END_NAMESPACE QT_END_HEADER + #endif // QMLBINDABLEVALUE_H diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h index b55a314..a37b2c0 100644 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -42,6 +42,17 @@ #ifndef QMLBINDABLEVALUE_P_H #define QMLBINDABLEVALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlboundsignal_p.h b/src/declarative/qml/qmlboundsignal_p.h index 2c05770..39c0c46 100644 --- a/src/declarative/qml/qmlboundsignal_p.h +++ b/src/declarative/qml/qmlboundsignal_p.h @@ -42,10 +42,22 @@ #ifndef QMLBOUNDSIGNAL_P_H #define QMLBOUNDSIGNAL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include QT_BEGIN_NAMESPACE + class QmlBoundSignal : public QmlExpressionObject { Q_OBJECT @@ -98,7 +110,6 @@ private: QmlBoundSignalParameters *params; }; +QT_END_NAMESPACE #endif // QMLBOUNDSIGNAL_P_H - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory.cpp b/src/declarative/qml/qmlclassfactory.cpp index 7e5b929..ddfbd78 100644 --- a/src/declarative/qml/qmlclassfactory.cpp +++ b/src/declarative/qml/qmlclassfactory.cpp @@ -41,7 +41,10 @@ #include "qmlclassfactory_p.h" +QT_BEGIN_NAMESPACE + QmlClassFactory::~QmlClassFactory() { } +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory_p.h b/src/declarative/qml/qmlclassfactory_p.h index e3e71c9..cd80ffc 100644 --- a/src/declarative/qml/qmlclassfactory_p.h +++ b/src/declarative/qml/qmlclassfactory_p.h @@ -42,6 +42,17 @@ #ifndef QMLCLASSFACTORY_P_H #define QMLCLASSFACTORY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlcompiledcomponent_p.h index 2201423..0945892 100644 --- a/src/declarative/qml/qmlcompiledcomponent_p.h +++ b/src/declarative/qml/qmlcompiledcomponent_p.h @@ -42,13 +42,26 @@ #ifndef QMLCOMPILEDCOMPONENT_P_H #define QMLCOMPILEDCOMPONENT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include #include QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE + namespace QmlParser { class Property; class Object; @@ -72,8 +85,8 @@ private: friend class QmlDomDocument; }; - QT_END_NAMESPACE + QT_END_HEADER #endif // QMLCOMPILEDCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 2559b14..2c722b9 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPILER_P_H #define QMLCOMPILER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -215,4 +226,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLCOMPILER_P_H diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 3429813..1144639 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -58,6 +58,7 @@ #include "qmlscriptparser_p.h" QT_BEGIN_NAMESPACE + class QByteArray; int statusId = qRegisterMetaType("QmlComponent::Status"); @@ -564,4 +565,5 @@ void QmlComponent::completeCreate() d->completePending = false; } } + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index ae2f362..2e80b6b 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -54,6 +54,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlCompiledComponent; class QByteArray; class QmlComponentPrivate; diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 254d9ba..0be3dc6 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPONENT_P_H #define QMLCOMPONENT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -87,6 +98,6 @@ public: void clear(); }; -#endif // QMLCOMPONENT_P_H - QT_END_NAMESPACE + +#endif // QMLCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9950b48..ef77803 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -50,6 +50,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlCompositeTypeData::QmlCompositeTypeData() : status(Invalid), errorType(NoError), component(0), compiledComponent(0) { @@ -365,3 +367,5 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) doComplete(unit); } } + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 9312819..96e77d6 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPOSITETYPEMANAGER_P_H #define QMLCOMPOSITETYPEMANAGER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 935c7ca..ce5fe52 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -99,7 +99,6 @@ private: QmlContext(QmlEngine *); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 4d88fc2..569b320 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -42,6 +42,17 @@ #ifndef QMLCONTEXT_P_H #define QMLCONTEXT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -50,6 +61,7 @@ #include QT_BEGIN_NAMESPACE + class QmlContext; class QmlExpression; class QmlEngine; @@ -99,6 +111,7 @@ public: QmlSimpleDeclarativeData contextData; QObjectList contextObjects; }; + QT_END_NAMESPACE #endif // QMLCONTEXT_P_H diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 75da579..67f39d9 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_H #define QMLCUSTOMPARSER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h index 96e9b32..0011c3b 100644 --- a/src/declarative/qml/qmlcustomparser_p_p.h +++ b/src/declarative/qml/qmlcustomparser_p_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_P_H #define QMLCUSTOMPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include "qmlcustomparser_p.h" diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index 85a80fa..559f0ee 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -42,6 +42,17 @@ #ifndef QMLDECLARATIVEDATA_P_H #define QMLDECLARATIVEDATA_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 5271dc5..8497bea 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -1571,4 +1571,3 @@ void QmlDomComponent::setComponentRoot(const QmlDomObject &root) } QT_END_NAMESPACE - diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 441269c..a7c3cc7 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -42,6 +42,17 @@ #ifndef QMLDOM_P_H #define QMLDOM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_HEADER diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index a1028e6..93ae704 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -42,6 +42,17 @@ #ifndef QMLENGINE_P_H #define QMLENGINE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -61,6 +72,7 @@ #include QT_BEGIN_NAMESPACE + class QmlContext; class QmlEngine; class QmlContextPrivate; @@ -288,7 +300,7 @@ public: void addLog(const QmlExpressionLog &); QList *log; }; + QT_END_NAMESPACE #endif // QMLENGINE_P_H - diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index 15d026a..e8cac7a 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -109,7 +109,6 @@ Q_SIGNALS: void valueChanged(); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index a618fe7..1647a12 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -44,6 +44,7 @@ #include QT_BEGIN_NAMESPACE + void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) { QByteArray lineNumber = QByteArray::number(instr->line); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index e3b0dfe..f2f3ac2 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -42,10 +42,21 @@ #ifndef QMLINSTRUCTION_P_H #define QMLINSTRUCTION_P_H -#include +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include QT_BEGIN_NAMESPACE + class QmlCompiledComponent; class Q_DECLARATIVE_EXPORT QmlInstruction { @@ -283,6 +294,6 @@ public: void dump(QmlCompiledComponent *); }; -#endif // QMLINSTRUCTION_P_H - QT_END_NAMESPACE + +#endif // QMLINSTRUCTION_P_H diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h index cc13924..80c3138 100644 --- a/src/declarative/qml/qmllist.h +++ b/src/declarative/qml/qmllist.h @@ -119,7 +119,6 @@ class Qml_ProxyList_ ##ListName : public QmlList \ friend class Qml_ProxyList_ ##ListName ; \ Qml_ProxyList_##ListName ListName; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 682b8ad..218fdf8 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -50,7 +50,6 @@ #include #include - QT_BEGIN_NAMESPACE class QMetaPropertyEx : public QMetaProperty diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 738bfec..3bd9089 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -42,6 +42,17 @@ #ifndef QMLMETAPROPERTY_P_H #define QMLMETAPROPERTY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qmlmetaproperty.h" class QmlContext; @@ -79,4 +90,3 @@ public: }; #endif // QMLMETAPROPERTY_P_H - diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 8ce8571..f69e5e5 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -60,6 +60,7 @@ #include QT_BEGIN_NAMESPACE + #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT # define QT_NO_GEOM_VARIANT diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 78040da..ef038f9 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLPARSER_P_H #define QMLPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h index 7c2e141..4db6d8c 100644 --- a/src/declarative/qml/qmlparserstatus.h +++ b/src/declarative/qml/qmlparserstatus.h @@ -68,7 +68,6 @@ private: }; Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus") - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index ed1304a..3d5fa61 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -394,10 +394,8 @@ int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val, return 0; } - -#endif // QMLPRIVATE_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLPRIVATE_H diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 18092c8..c6ff596 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -42,8 +42,8 @@ #include "qmlpropertyvaluesource.h" #include "qml.h" - QT_BEGIN_NAMESPACE + /*! \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h index 9cef150..c142095 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.h +++ b/src/declarative/qml/qmlpropertyvaluesource.h @@ -46,12 +46,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QObjectPrivate; class QmlMetaProperty; class Q_DECLARATIVE_EXPORT QmlPropertyValueSource : public QObject @@ -71,9 +71,8 @@ private: }; QML_DECLARE_TYPE(QmlPropertyValueSource) -#endif // QMLPROPERTYVALUESOURCE_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLPROPERTYVALUESOURCE_H diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp index 06d8a50..5568bab 100644 --- a/src/declarative/qml/qmlproxymetaobject.cpp +++ b/src/declarative/qml/qmlproxymetaobject.cpp @@ -41,8 +41,8 @@ #include "qmlproxymetaobject_p.h" - QT_BEGIN_NAMESPACE + QmlProxyMetaObject::QmlProxyMetaObject(QObject *obj, QList *mList) : metaObjects(mList), proxies(0), parent(0), object(obj) { diff --git a/src/declarative/qml/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h index c0ce36e..736bd91 100644 --- a/src/declarative/qml/qmlproxymetaobject_p.h +++ b/src/declarative/qml/qmlproxymetaobject_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROXYMETAOBJECT_P_H #define QMLPROXYMETAOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -53,6 +64,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlProxyMetaObject : public QAbstractDynamicMetaObject { public: diff --git a/src/declarative/qml/qmlrefcount.cpp b/src/declarative/qml/qmlrefcount.cpp index 8f71f1b..6c409e1 100644 --- a/src/declarative/qml/qmlrefcount.cpp +++ b/src/declarative/qml/qmlrefcount.cpp @@ -41,6 +41,8 @@ #include "qmlrefcount_p.h" +QT_BEGIN_NAMESPACE + QmlRefCount::QmlRefCount() : refCount(1) { @@ -64,3 +66,5 @@ void QmlRefCount::release() delete this; } +QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlrefcount_p.h b/src/declarative/qml/qmlrefcount_p.h index 1355c86..a87d596 100644 --- a/src/declarative/qml/qmlrefcount_p.h +++ b/src/declarative/qml/qmlrefcount_p.h @@ -42,6 +42,17 @@ #ifndef QMLREFCOUNT_P_H #define QMLREFCOUNT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_HEADER diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index fb7492d..24e26de 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -886,5 +886,4 @@ void QmlScriptParser::addNamespacePath(const QString &path) _nameSpacePaths.insertMulti(QString(), path); } - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index b057e2b..15f165c 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -41,13 +41,24 @@ #ifndef QMLSCRIPTPARSER_P_H #define QMLSCRIPTPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include #include "qmlparser_p.h" - QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -107,6 +118,7 @@ public: }; QT_END_NAMESPACE + QT_END_HEADER #endif // QMLSCRIPTPARSER_P_H diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h index ed1f959..52426a7 100644 --- a/src/declarative/qml/qmlstringconverters_p.h +++ b/src/declarative/qml/qmlstringconverters_p.h @@ -42,6 +42,17 @@ #ifndef QMLSTRINGCONVERTERS_P_H #define QMLSTRINGCONVERTERS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include class QColor; class QPointF; diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index 149c82c..2da7bb4 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -42,11 +42,23 @@ #ifndef QMLVME_P_H #define QMLVME_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include QT_BEGIN_NAMESPACE + class QObject; class QmlInstruction; class QmlCompiledComponent; @@ -70,4 +82,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLVME_P_H diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 4b2c64c..3b784a4 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -48,8 +48,8 @@ #include #include - QT_BEGIN_NAMESPACE + QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj, const QMetaObject *other, QList *strData, diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h index 17140ef..7b6fd2d 100644 --- a/src/declarative/qml/qmlvmemetaobject_p.h +++ b/src/declarative/qml/qmlvmemetaobject_p.h @@ -42,6 +42,17 @@ #ifndef QMLVMEMETAOBJECT_P_H #define QMLVMEMETAOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -73,4 +84,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLVMEMETAOBJECT_P_H diff --git a/src/declarative/qml/qpodvector_p.h b/src/declarative/qml/qpodvector_p.h index 55c04e7..101c62d 100644 --- a/src/declarative/qml/qpodvector_p.h +++ b/src/declarative/qml/qpodvector_p.h @@ -42,6 +42,17 @@ #ifndef QPODVECTOR_P_H #define QPODVECTOR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE @@ -119,6 +130,7 @@ private: int m_capacity; T *m_data; }; + QT_END_NAMESPACE #endif diff --git a/src/declarative/util/qfxglobal.h b/src/declarative/util/qfxglobal.h index 6ba9409..6f2a9fb 100644 --- a/src/declarative/util/qfxglobal.h +++ b/src/declarative/util/qfxglobal.h @@ -45,12 +45,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + #if defined(QT_OPENGL_ES_1) #define QFX_CONFIGURATION_OPENGL1 #elif defined(QT_OPENGL_ES_2) @@ -117,8 +117,8 @@ inline void QFx_setParent_noEvent(QObject *object, QObject *parent) static_cast(object)->setParent_noEvent(parent); } - QT_END_NAMESPACE QT_END_HEADER + #endif // QFXGLOBAL_H diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index e4f0c53..9ac9e8d 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -41,8 +41,8 @@ #include "qfxperf.h" - QT_BEGIN_NAMESPACE + Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing") Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation") @@ -64,4 +64,5 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText") Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine") } + QT_END_NAMESPACE diff --git a/src/declarative/util/qfxperf.h b/src/declarative/util/qfxperf.h index 9fcf1d6..0bc0cc9 100644 --- a/src/declarative/util/qfxperf.h +++ b/src/declarative/util/qfxperf.h @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef _QFXPERF_H_ -#define _QFXPERF_H_ +#ifndef QFXPERF_H +#define QFXPERF_H #include "qperformancelog.h" - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(QmlParsing) @@ -73,9 +73,8 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(AddScript) } -#endif // _QFXPERF_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QFXPERF_H diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index d8d9ba1..0855224 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -62,8 +62,8 @@ #include #include - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(itemTreeDump, ITEMTREE_DUMP); DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER); @@ -561,4 +561,5 @@ void QFxView::dumpRoot() { root()->dump(); } + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index b801d01..051516d 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -42,6 +42,17 @@ #ifndef QMLANIMATION_P_H #define QMLANIMATION_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -336,6 +347,6 @@ public: static void convertVariant(QVariant &variant, QVariant::Type type); }; -#endif // QMLANIMATION_P_H - QT_END_NAMESPACE + +#endif // QMLANIMATION_P_H diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index b45d07d..bb342bc 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -52,6 +52,7 @@ #include "qmlbind.h" QT_BEGIN_NAMESPACE + class QmlBindPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 6c7b158..95f4573 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -46,8 +46,8 @@ #include #include - QT_BEGIN_NAMESPACE + class QmlConnectionPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index d3b3617..c6d806a 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -45,8 +45,8 @@ #include "qmlfollow.h" #include "private/qmlanimation_p.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlFollow,Follow) class QmlFollowPrivate : public QObjectPrivate diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp index c537a83..3075b82 100644 --- a/src/declarative/util/qmlfont.cpp +++ b/src/declarative/util/qmlfont.cpp @@ -43,8 +43,8 @@ #include "qfont.h" #include "qmlfont.h" - QT_BEGIN_NAMESPACE + class QmlFontPrivate : public QObjectPrivate { public: @@ -144,4 +144,5 @@ QFont QmlFont::font() const Q_D(const QmlFont); return d->font; } + QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index cc85661..1884e8b 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -567,4 +567,5 @@ ModelNode::~ModelNode() } QT_END_NAMESPACE + #include "qmllistmodel.moc" diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h index ddf1e13..56ed8fb 100644 --- a/src/declarative/util/qmllistmodel.h +++ b/src/declarative/util/qmllistmodel.h @@ -51,7 +51,6 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlnullablevalue_p.h b/src/declarative/util/qmlnullablevalue_p.h index f16ddd6..6455642 100644 --- a/src/declarative/util/qmlnullablevalue_p.h +++ b/src/declarative/util/qmlnullablevalue_p.h @@ -42,6 +42,19 @@ #ifndef QMLNULLABLEVALUE_P_H #define QMLNULLABLEVALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + template struct QmlNullableValue { @@ -63,5 +76,6 @@ struct QmlNullableValue T value; }; -#endif // QMLNULLABLEVALUE_P_H +QT_END_NAMESPACE +#endif // QMLNULLABLEVALUE_P_H diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp index d0dd817..7305362 100644 --- a/src/declarative/util/qmlopenmetaobject.cpp +++ b/src/declarative/util/qmlopenmetaobject.cpp @@ -43,7 +43,6 @@ #include "private/qmetaobjectbuilder_p.h" #include - QT_BEGIN_NAMESPACE class QmlOpenMetaObjectPrivate diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index e527c1f..eec769e 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -42,8 +42,8 @@ #include "private/qobject_p.h" #include "qmlpackage.h" - QT_BEGIN_NAMESPACE + class QmlPackagePrivate : public QObjectPrivate { public: @@ -150,4 +150,5 @@ QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o) QML_DEFINE_TYPE(QmlPackage, Package) QT_END_NAMESPACE + #include "qmlpackage.moc" diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h index 09ebc2c..5b62da5 100644 --- a/src/declarative/util/qmlscript.h +++ b/src/declarative/util/qmlscript.h @@ -47,6 +47,7 @@ #include QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -76,5 +77,7 @@ private Q_SLOTS: QML_DECLARE_TYPE(QmlScript) QT_END_NAMESPACE + QT_END_HEADER + #endif diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 7ceed5e..7a68ba2 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -49,8 +49,8 @@ #include #include - QT_BEGIN_NAMESPACE + /*! \qmlclass SetProperties QmlSetProperties \brief The SetProperties element describes new property values for a state. diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index fe98900..717d0ee 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -44,7 +44,6 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 2f6ff42..1b784f3 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -42,6 +42,17 @@ #ifndef QMLSTATE_P_H #define QMLSTATE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 57ccd37..2b1cf7d 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -45,8 +45,8 @@ #include "qmltransition.h" #include - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); QML_DEFINE_TYPE(QmlStateGroup,StateGroup) diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp index 8065f9d..932e4b3 100644 --- a/src/declarative/util/qperformancelog.cpp +++ b/src/declarative/util/qperformancelog.cpp @@ -43,6 +43,7 @@ #include #include +QT_BEGIN_NAMESPACE #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -175,3 +176,5 @@ void QPerformanceLog::clear() } #endif // Q_ENABLE_PERFORMANCE_LOG + +QT_END_NAMESPACE diff --git a/src/declarative/util/qperformancelog.h b/src/declarative/util/qperformancelog.h index 3203685..6655a8d 100644 --- a/src/declarative/util/qperformancelog.h +++ b/src/declarative/util/qperformancelog.h @@ -43,6 +43,9 @@ #define QPERFORMANCELOG_H #include + +QT_BEGIN_NAMESPACE + namespace QPerformanceLog { Q_DECLARATIVE_EXPORT void displayData(); @@ -133,4 +136,6 @@ namespace QPerformanceLog #endif // Q_ENABLE_PERFORMANCE_LOG +QT_END_NAMESPACE + #endif // QPERFORMANCELOG_H diff --git a/src/declarative/widgets/graphicslayouts.h b/src/declarative/widgets/graphicslayouts.h index 303f749..525a848 100644 --- a/src/declarative/widgets/graphicslayouts.h +++ b/src/declarative/widgets/graphicslayouts.h @@ -183,8 +183,8 @@ private: }; QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -#endif // GRAPHICSLAYOUTS_H - QT_END_NAMESPACE QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp index 86509f5..e7d01e3 100644 --- a/src/declarative/widgets/graphicswidgets.cpp +++ b/src/declarative/widgets/graphicswidgets.cpp @@ -168,6 +168,6 @@ QML_DEFINE_EXTENDED_TYPE(QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarat QML_DEFINE_INTERFACE(QGraphicsItem) -#include "graphicswidgets.moc" - QT_END_NAMESPACE + +#include "graphicswidgets.moc" -- cgit v0.12