summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-23 05:46:14 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-23 06:29:52 (GMT)
commiteefe993a4241b48f14991c44baa2c074b10bc194 (patch)
treea1a6ecdeb90c17707839c9c5e9cb8776ec4ff97f /src/declarative/util
parentf8eee22dcdd9b6b530c0e5c346e16552352ec03b (diff)
parente988763395625171bed001b5916d4da003d39aee (diff)
downloadQt-eefe993a4241b48f14991c44baa2c074b10bc194.zip
Qt-eefe993a4241b48f14991c44baa2c074b10bc194.tar.gz
Qt-eefe993a4241b48f14991c44baa2c074b10bc194.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qfxperf.cpp2
-rw-r--r--src/declarative/util/qfxperf_p_p.h2
-rw-r--r--src/declarative/util/qmlanimation.cpp975
-rw-r--r--src/declarative/util/qmlanimation_p.h62
-rw-r--r--src/declarative/util/qmlanimation_p_p.h88
-rw-r--r--src/declarative/util/qmlbehavior.cpp12
-rw-r--r--src/declarative/util/qmlbehavior_p.h2
-rw-r--r--src/declarative/util/qmlbind.cpp2
-rw-r--r--src/declarative/util/qmlbind_p.h2
-rw-r--r--src/declarative/util/qmlconnection.cpp8
-rw-r--r--src/declarative/util/qmlconnection_p.h2
-rw-r--r--src/declarative/util/qmldatetimeformatter.cpp2
-rw-r--r--src/declarative/util/qmldatetimeformatter_p.h2
-rw-r--r--src/declarative/util/qmleasefollow.cpp13
-rw-r--r--src/declarative/util/qmleasefollow_p.h2
-rw-r--r--src/declarative/util/qmlfontloader.cpp2
-rw-r--r--src/declarative/util/qmlfontloader_p.h2
-rw-r--r--src/declarative/util/qmllistaccessor.cpp131
-rw-r--r--src/declarative/util/qmllistaccessor_p.h9
-rw-r--r--src/declarative/util/qmllistmodel.cpp46
-rw-r--r--src/declarative/util/qmllistmodel_p.h2
-rw-r--r--src/declarative/util/qmlnullablevalue_p_p.h2
-rw-r--r--src/declarative/util/qmlnumberformatter.cpp2
-rw-r--r--src/declarative/util/qmlnumberformatter_p.h2
-rw-r--r--src/declarative/util/qmlopenmetaobject.cpp2
-rw-r--r--src/declarative/util/qmlopenmetaobject_p.h2
-rw-r--r--src/declarative/util/qmlpackage.cpp42
-rw-r--r--src/declarative/util/qmlpackage_p.h6
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp40
-rw-r--r--src/declarative/util/qmlpixmapcache_p.h2
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp8
-rw-r--r--src/declarative/util/qmlpropertychanges_p.h2
-rw-r--r--src/declarative/util/qmlpropertymap.cpp2
-rw-r--r--src/declarative/util/qmlpropertymap.h2
-rw-r--r--src/declarative/util/qmlspringfollow.cpp2
-rw-r--r--src/declarative/util/qmlspringfollow_p.h2
-rw-r--r--src/declarative/util/qmlstate.cpp22
-rw-r--r--src/declarative/util/qmlstate_p.h9
-rw-r--r--src/declarative/util/qmlstate_p_p.h35
-rw-r--r--src/declarative/util/qmlstategroup.cpp55
-rw-r--r--src/declarative/util/qmlstategroup_p.h10
-rw-r--r--src/declarative/util/qmlstateoperations.cpp12
-rw-r--r--src/declarative/util/qmlstateoperations_p.h2
-rw-r--r--src/declarative/util/qmlstyledtext.cpp2
-rw-r--r--src/declarative/util/qmlstyledtext_p.h2
-rw-r--r--src/declarative/util/qmlsystempalette.cpp2
-rw-r--r--src/declarative/util/qmlsystempalette_p.h2
-rw-r--r--src/declarative/util/qmltimeline.cpp49
-rw-r--r--src/declarative/util/qmltimeline_p_p.h53
-rw-r--r--src/declarative/util/qmltimer.cpp2
-rw-r--r--src/declarative/util/qmltimer_p.h2
-rw-r--r--src/declarative/util/qmltransition.cpp41
-rw-r--r--src/declarative/util/qmltransition_p.h6
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp2
-rw-r--r--src/declarative/util/qmltransitionmanager_p_p.h2
-rw-r--r--src/declarative/util/qmlview.cpp367
-rw-r--r--src/declarative/util/qmlview.h47
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp81
-rw-r--r--src/declarative/util/qmlxmllistmodel_p.h6
-rw-r--r--src/declarative/util/qnumberformat.cpp2
-rw-r--r--src/declarative/util/qnumberformat_p.h2
-rw-r--r--src/declarative/util/qperformancelog.cpp2
-rw-r--r--src/declarative/util/qperformancelog_p_p.h2
63 files changed, 1139 insertions, 1166 deletions
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
index f62f810..8f5617c 100644
--- a/src/declarative/util/qfxperf.cpp
+++ b/src/declarative/util/qfxperf.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qfxperf_p_p.h b/src/declarative/util/qfxperf_p_p.h
index e3f820c..106f761 100644
--- a/src/declarative/util/qfxperf_p_p.h
+++ b/src/declarative/util/qfxperf_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 4f68b6c..c044f97 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -77,7 +77,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
if (hasParams) {
QString easeName = curve.trimmed();
if (!easeName.endsWith(QLatin1Char(')'))) {
- qmlInfo(obj) << obj->tr("Unmatched parenthesis in easing function \"%1\"").arg(curve);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve);
return easingCurve;
}
@@ -86,7 +86,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
normalizedCurve = easeName.left(idx);
if (!normalizedCurve.startsWith(QLatin1String("ease"))) {
- qmlInfo(obj) << obj->tr("Easing function \"%1\" must start with \"ease\"").arg(curve);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve);
return easingCurve;
}
@@ -101,7 +101,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
int value = me.keyToValue(normalizedCurve.toUtf8().constData());
if (value < 0) {
- qmlInfo(obj) << obj->tr("Unknown easing curve \"%1\"").arg(curve);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve);
return easingCurve;
}
easingCurve.setType((QEasingCurve::Type)value);
@@ -111,7 +111,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
int sep = str.indexOf(QLatin1Char(':'));
if (sep == -1) {
- qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
continue;
}
@@ -120,7 +120,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk);
if (propName.isEmpty() || !isOk) {
- qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
continue;
}
@@ -131,7 +131,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
} else if (propName == QLatin1String("overshoot")) {
easingCurve.setOvershoot(propValue);
} else {
- qmlInfo(obj) << obj->tr("Unknown easing parameter \"%1\"").arg(propName);
+ qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName);
continue;
}
}
@@ -176,7 +176,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
The \c running property can be set to declaratively control whether or not
an animation is running. The following example will animate a rectangle
- whenever the \l MouseRegion is pressed.
+ whenever the \l MouseArea is pressed.
\code
Rectangle {
@@ -185,7 +185,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
running: myMouse.pressed
from: 0; to: 100
}
- MouseRegion { id: myMouse }
+ MouseArea { id: myMouse }
}
\endcode
@@ -210,11 +210,16 @@ bool QmlAbstractAnimation::isRunning() const
return d->running;
}
+//commence is called to start an animation when it is used as a
+//simple animation, and not as part of a transition
void QmlAbstractAnimationPrivate::commence()
{
Q_Q(QmlAbstractAnimation);
- q->prepare(userProperty.value);
+ QmlStateActions actions;
+ QmlMetaProperties properties;
+ q->transition(actions, properties, QmlAbstractAnimation::Forward);
+
q->qtAnimation()->start();
if (q->qtAnimation()->state() != QAbstractAnimation::Running) {
running = false;
@@ -226,7 +231,7 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const
{
QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj));
if (!prop.isValid()) {
- qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str);
+ qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
return QmlMetaProperty();
} else if (!prop.isWritable()) {
qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
@@ -238,14 +243,17 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const
void QmlAbstractAnimation::setRunning(bool r)
{
Q_D(QmlAbstractAnimation);
-
- if (r == false)
- d->avoidPropertyValueSourceStart = true;
+ if (!d->componentComplete) {
+ d->running = r;
+ if (r == false)
+ d->avoidPropertyValueSourceStart = true;
+ return;
+ }
if (d->running == r)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
return;
}
@@ -262,10 +270,7 @@ void QmlAbstractAnimation::setRunning(bool r)
this, SLOT(timelineComplete()));
d->connectedTimeLine = true;
}
- if (d->componentComplete)
- d->commence();
- else
- d->startOnCompletion = true;
+ d->commence();
emit started();
} else {
if (d->alwaysRunToEnd) {
@@ -304,7 +309,7 @@ void QmlAbstractAnimation::setPaused(bool p)
if (d->paused == p)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
return;
}
@@ -315,7 +320,7 @@ void QmlAbstractAnimation::setPaused(bool p)
else
qtAnimation()->resume();
- emit pausedChanged(d->running);
+ emit pausedChanged(d->paused);
}
void QmlAbstractAnimation::classBegin()
@@ -327,9 +332,11 @@ void QmlAbstractAnimation::classBegin()
void QmlAbstractAnimation::componentComplete()
{
Q_D(QmlAbstractAnimation);
- if (d->startOnCompletion)
- d->commence();
d->componentComplete = true;
+ if (d->running) {
+ d->running = false;
+ setRunning(true);
+ }
}
/*!
@@ -534,17 +541,32 @@ void QmlAbstractAnimation::complete()
void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p)
{
Q_D(QmlAbstractAnimation);
- if (d->userProperty.isNull)
- d->userProperty = p;
+ d->defaultProperty = p;
if (!d->avoidPropertyValueSourceStart)
setRunning(true);
}
-//prepare is called before an animation begins
-//(when an animation is used as a simple animation, and not as part of a transition)
-void QmlAbstractAnimation::prepare(QmlMetaProperty &)
+/*
+ we rely on setTarget only being called when used as a value source
+ so this function allows us to do the same thing as setTarget without
+ that assumption
+*/
+void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p)
+{
+ Q_D(QmlAbstractAnimation);
+ d->defaultProperty = p;
+}
+
+/*
+ don't allow start/stop/pause/resume to be manually invoked,
+ because something else (like a Behavior) already has control
+ over the animation.
+*/
+void QmlAbstractAnimation::setDisableUserControl()
{
+ Q_D(QmlAbstractAnimation);
+ d->disableUserControl = true;
}
void QmlAbstractAnimation::transition(QmlStateActions &actions,
@@ -685,7 +707,7 @@ void QmlColorAnimation::setFrom(const QColor &f)
}
/*!
- \qmlproperty color ColorAnimation::from
+ \qmlproperty color ColorAnimation::to
This property holds the ending color.
*/
QColor QmlColorAnimation::to() const
@@ -819,7 +841,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction)
Set \c thewebview.url to the value set for the destination state:
\code
- PropertyAction { matchTargets: thewebview; matchProperties: "url" }
+ PropertyAction { target: thewebview; property: "url" }
\endcode
The PropertyAction is immediate -
@@ -866,25 +888,10 @@ void QmlPropertyAction::setTarget(QObject *o)
Q_D(QmlPropertyAction);
if (d->target == o)
return;
-
d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAction::property
- This property holds an explicit property to animated.
-
- The exact effect of the \c property property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
-
QString QmlPropertyAction::property() const
{
Q_D(const QmlPropertyAction);
@@ -896,29 +903,24 @@ void QmlPropertyAction::setProperty(const QString &n)
Q_D(QmlPropertyAction);
if (d->propertyName == n)
return;
-
d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
/*!
- \qmlproperty string PropertyAction::matchProperties
- This property holds a comma-separated list of property names this action
- will match against. These names are used in conjunction with matchTargets
- to create a list of properties that the action will set, assuming those
- properties have changed.
+ \qmlproperty string PropertyAction::property
+ \qmlproperty string PropertyAction::properties
+ \qmlproperty Object PropertyAction::target
+ \qmlproperty list<Object> PropertyAction::targets
- This property is typically used for an action appearing as part of a Transition.
+ These properties are used as a set to determine which properties should be
+ affected by this action.
- By default, no property names will be matched.
+ The details of how these properties are interpreted in different situations
+ is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
+ documentation.
- \sa matchTargets PropertyAnimation::matchProperties
+ \sa exclude
*/
QString QmlPropertyAction::properties() const
{
@@ -935,18 +937,6 @@ void QmlPropertyAction::setProperties(const QString &p)
emit propertiesChanged(p);
}
-/*!
- \qmlproperty list<Object> PropertyAction::matchTargets
- This property holds a list of objects this action will match against.
- These objects are used in conjunction with matchProperties to create a list of properties
- that the action will set, assuming those properties have changed.
-
- This property is typically used for an action appearing as part of a Transition.
-
- By default, all changing targets will be matched.
-
- \sa exclude matchProperties PropertyAnimation::matchTargets
-*/
QmlListProperty<QObject> QmlPropertyAction::targets()
{
Q_D(QmlPropertyAction);
@@ -956,7 +946,7 @@ QmlListProperty<QObject> QmlPropertyAction::targets()
/*!
\qmlproperty list<Object> PropertyAction::exclude
This property holds the objects not to be affected by this animation.
- \sa matchTargets
+ \sa targets
*/
QmlListProperty<QObject> QmlPropertyAction::exclude()
{
@@ -984,29 +974,12 @@ void QmlPropertyAction::setValue(const QVariant &v)
}
}
-void QmlPropertyActionPrivate::doAction()
-{
- property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
-}
-
QAbstractAnimation *QmlPropertyAction::qtAnimation()
{
Q_D(QmlPropertyAction);
return d->spa;
}
-void QmlPropertyAction::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlPropertyAction);
-
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- d->spa->setAnimAction(&d->proxy, QAbstractAnimation::KeepWhenStopped);
-}
-
void QmlPropertyAction::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
@@ -1029,31 +1002,42 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
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 << d->propertyName;
- bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
- bool hasTarget = !d->propertyName.isEmpty() || d->target;
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
- if (hasSelectors && hasTarget) {
- qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
- return;
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
}
QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction;
bool hasExplicit = false;
- if (hasTarget && d->value.isValid()) {
- QmlAction myAction;
- myAction.property = d->createProperty(target(), d->propertyName, this);
- if (myAction.property.isValid()) {
- myAction.toValue = d->value;
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
+ //an explicit animation has been specified
+ if (d->value.isValid()) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QmlAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ myAction.toValue = d->value;
+ QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
}
}
}
@@ -1069,31 +1053,18 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
QString sPropertyName = action.specifiedProperty;
bool same = (obj == sObj);
- if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
(props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
QmlAction myAction = action;
if (d->value.isValid())
myAction.toValue = d->value;
+ QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
modified << action.property;
data->actions << myAction;
action.fromValue = myAction.toValue;
- } else if (d->userProperty.isValid() &&
- !hasSelectors && !hasTarget) {
- if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
- (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
- //### same as above. merge
- QmlAction myAction = action;
-
- if (d->value.isValid())
- myAction.toValue = d->value;
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
}
}
@@ -1161,24 +1132,7 @@ void QmlParentActionPrivate::init()
/*!
\qmlproperty Item ParentAction::target
- This property holds an explicit target item to reparent.
- */
-QmlGraphicsItem *QmlParentAction::object() const
-{
- Q_D(const QmlParentAction);
- return d->pcTarget;
-}
-
-void QmlParentAction::setObject(QmlGraphicsItem *target)
-{
- Q_D(QmlParentAction);
- d->pcTarget = target;
-}
-
-/*!
- \qmlproperty Item ParentAction::matchTarget
- This property holds the item this action will match against -- the item
- that the action will reparent, assuming its parent has changed.
+ This property holds a target item to reparent.
In the following example, \c myItem will be reparented by the ParentAction, while
\c myOtherItem will not.
@@ -1196,24 +1150,23 @@ void QmlParentAction::setObject(QmlGraphicsItem *target)
Transition {
SequentialAnimation {
PropertyAnimation { ... }
- ParentAction { matchTargets: myItem }
+ ParentAction { target: myItem }
PropertyAnimation { ... }
}
}
\endqml
- This property is typically used for an action appearing as part of a Transition.
*/
-QmlGraphicsItem *QmlParentAction::matchTarget() const
+QmlGraphicsItem *QmlParentAction::object() const
{
Q_D(const QmlParentAction);
return d->pcTarget;
}
-void QmlParentAction::setMatchTarget(QmlGraphicsItem *target)
+void QmlParentAction::setObject(QmlGraphicsItem *target)
{
Q_D(QmlParentAction);
- d->pcMatchTarget = target;
+ d->pcTarget = target;
}
/*!
@@ -1277,17 +1230,27 @@ void QmlParentAction::transition(QmlStateActions &actions,
QmlParentActionData *data = new QmlParentActionData;
- if (d->pcTarget && d->pcMatchTarget) {
- qmlInfo(this) << tr("matchTarget and target are mutually exclusive.");
- return;
+ //### need to correctly handle modified/done
+
+ bool hasExplicit = false;
+ if (d->pcTarget && d->pcParent) {
+ data->reverse = false;
+ QmlAction myAction;
+ QmlParentChange *pc = new QmlParentChange;
+ pc->setObject(d->pcTarget);
+ pc->setParent(d->pcParent);
+ myAction.event = pc;
+ data->pc = pc;
+ data->actions << myAction;
+ hasExplicit = true;
}
+ if (!hasExplicit)
for (int ii = 0; ii < actions.count(); ++ii) {
QmlAction &action = actions[ii];
if (action.event && action.event->typeName() == QLatin1String("ParentChange")
- && !d->pcTarget
- && (!d->pcMatchTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcMatchTarget)) {
+ && (!d->pcTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcTarget)) {
QmlAction myAction = action;
data->reverse = action.reverseEvent;
//### this logic differs from PropertyAnimation
@@ -1308,17 +1271,6 @@ void QmlParentAction::transition(QmlStateActions &actions,
}
}
- if (d->pcTarget && d->pcParent) {
- data->reverse = false;
- QmlAction myAction;
- QmlParentChange *pc = new QmlParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(d->pcParent);
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- }
-
if (data->actions.count()) {
d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
} else {
@@ -1336,7 +1288,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction)
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
- NumberAnimation { matchProperties: "x,y,scale"; duration: 200 }
+ NumberAnimation { properties: "x,y,scale"; duration: 200 }
\endcode
*/
@@ -1376,7 +1328,7 @@ void QmlNumberAnimation::setFrom(qreal f)
/*!
\qmlproperty real NumberAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
qreal QmlNumberAnimation::to() const
{
@@ -1434,7 +1386,7 @@ void QmlVector3dAnimation::setFrom(QVector3D f)
/*!
\qmlproperty real Vector3dAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
QVector3D QmlVector3dAnimation::to() const
{
@@ -1449,19 +1401,212 @@ void QmlVector3dAnimation::setTo(QVector3D t)
QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation)
+/*!
+ \qmlclass RotationAnimation QmlRotationAnimation
+ \inherits PropertyAnimation
+ \brief The RotationAnimation element allows you to animate rotations.
+
+ RotationAnimation is a specialized PropertyAnimation that gives control
+ over the direction of rotation.
+
+ The RotationAnimation in the following example ensures that we always take
+ the shortest rotation path when switching between our states.
+ \qml
+ states: {
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
+ State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
+ }
+ transition: Transition {
+ RotationAnimation { direction: RotationAnimation.Shortest }
+ }
+ \endqml
+
+ By default, when used in a transition RotationAnimation will rotate all
+ properties named "rotation" or "angle". You can override this by providing
+ your own properties via \c properties or \c property.
+*/
+
+/*!
+ \internal
+ \class QmlRotationAnimation
+*/
+
+QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 180.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff < 0.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 0.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QmlRotationAnimation::QmlRotationAnimation(QObject *parent)
+: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent)
+{
+ Q_D(QmlRotationAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ d->defaultProperties = QLatin1String("rotation,angle");
+}
+
+QmlRotationAnimation::~QmlRotationAnimation()
+{
+}
+
+/*!
+ \qmlproperty real RotationAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+qreal QmlRotationAnimation::from() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->from.toReal();
+}
+
+void QmlRotationAnimation::setFrom(qreal f)
+{
+ QmlPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real RotationAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+qreal QmlRotationAnimation::to() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->to.toReal();
+}
+
+void QmlRotationAnimation::setTo(qreal t)
+{
+ QmlPropertyAnimation::setTo(t);
+}
+
+/*!
+ \qmlproperty enum RotationAnimation::direction
+ The direction in which to rotate.
+ Possible values are Numerical, Clockwise, Counterclockwise,
+ or Shortest.
+
+ \list
+ \row
+ \o Numerical
+ \o Rotate by linearly interpolating between the two numbers.
+ A rotation from 10 to 350 will rotate 340 degrees clockwise.
+ \row
+ \o Clockwise
+ \o Rotate clockwise between the two values
+ \row
+ \o Counterclockwise
+ \o Rotate counterclockwise between the two values
+ \row
+ \o Shortest
+ \o Rotate in the direction that produces the shortest animation path.
+ A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
+ \list
+
+ The default direction is Shortest.
+*/
+QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->direction;
+}
+
+void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction)
+{
+ Q_D(QmlRotationAnimation);
+ if (d->direction == direction)
+ return;
+
+ d->direction = direction;
+ switch(d->direction) {
+ case Clockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
+ break;
+ case Counterclockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
+ break;
+ case Shortest:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ break;
+ default:
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ break;
+ }
+
+ emit directionChanged();
+}
+
+QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation)
+
QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent)
{
}
+void QmlAnimationGroupPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
+{
+ QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
+ if (q) {
+ q->d_func()->animations.append(a);
+ a->setGroup(q);
+ }
+}
+
+void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimation> *list)
+{
+ QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
+ if (q) {
+ for (int i = 0; i < q->d_func()->animations.count(); ++i)
+ q->d_func()->animations.at(i)->setGroup(0);
+ q->d_func()->animations.clear();
+ }
+}
+
QmlAnimationGroup::~QmlAnimationGroup()
{
}
-QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations()
+QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations()
{
Q_D(QmlAnimationGroup);
- return &d->animations;
+ QmlListProperty<QmlAbstractAnimation> list(this, d->animations);
+ list.append = &QmlAnimationGroupPrivate::append_animation;
+ list.clear = &QmlAnimationGroupPrivate::clear_animation;
+ return list;
}
/*!
@@ -1495,18 +1640,6 @@ QmlSequentialAnimation::~QmlSequentialAnimation()
{
}
-void QmlSequentialAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlAnimationGroup);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- for (int i = 0; i < d->animations.size(); ++i)
- d->animations.at(i)->prepare(d->property);
-}
-
QAbstractAnimation *QmlSequentialAnimation::qtAnimation()
{
Q_D(QmlAnimationGroup);
@@ -1526,13 +1659,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
from = d->animations.count() - 1;
}
- //needed for Behavior
- if (d->userProperty.isValid()) {
- for (int i = 0; i < d->animations.count(); ++i)
- d->animations.at(i)->setTarget(d->userProperty);
- }
-
+ bool valid = d->defaultProperty.isValid();
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
d->animations.at(ii)->transition(actions, modified, direction);
}
}
@@ -1574,18 +1704,6 @@ QmlParallelAnimation::~QmlParallelAnimation()
{
}
-void QmlParallelAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlAnimationGroup);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- for (int i = 0; i < d->animations.size(); ++i)
- d->animations.at(i)->prepare(d->property);
-}
-
QAbstractAnimation *QmlParallelAnimation::qtAnimation()
{
Q_D(QmlAnimationGroup);
@@ -1597,14 +1715,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
TransitionDirection direction)
{
Q_D(QmlAnimationGroup);
-
- //needed for Behavior
- if (d->userProperty.isValid()) {
- for (int i = 0; i < d->animations.count(); ++i)
- d->animations.at(i)->setTarget(d->userProperty);
- }
-
+ bool valid = d->defaultProperty.isValid();
for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
d->animations.at(ii)->transition(actions, modified, direction);
}
}
@@ -1668,12 +1782,56 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
\inherits Animation
\brief The PropertyAnimation element allows you to animate property changes.
- Animate theObject's size property over 200ms, from its current size to 20-by-20:
- \code
+ PropertyAnimation provides a way to animate changes to a property's value. It can
+ be used in many different situations:
+ \list
+ \o In a Transition
+
+ Animate any objects that have changed their x or y properties in the target state using
+ an InOutQuad easing curve:
+ \qml
+ Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } }
+ \endqml
+ \o In a Behavior
+
+ Animate all changes to a rectangle's x property.
+ \qml
+ Rectangle {
+ x: Behavior { PropertyAnimation {} }
+ }
+ \endqml
+ \o As a property value source
+
+ Repeatedly animate the rectangle's x property.
+ \qml
+ Rectangle {
+ x: SequentialAnimation {
+ repeat: true
+ PropertyAnimation { to: 50 }
+ PropertyAnimation { to: 0 }
+ }
+ }
+ \endqml
+ \o In a signal handler
+
+ Fade out \c theObject when clicked:
+ \qml
+ MouseArea {
+ anchors.fill: theObject
+ onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
+ }
+ \endqml
+ \o Standalone
+
+ Animate \c theObject's size property over 200ms, from its current size to 20-by-20:
+ \qml
PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 }
- \endcode
+ \endqml
+ \endlist
- For an introduction to animation in QML, see \l{QML Animation}.
+ Depending on how the animation is used, the set of properties normally used will be
+ different. For more information see the individual property documentation, as well
+ as the \l{QML Animation} introduction.
*/
QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
@@ -1683,6 +1841,13 @@ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
d->init();
}
+QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent)
+: QmlAbstractAnimation(dd, parent)
+{
+ Q_D(QmlPropertyAnimation);
+ d->init();
+}
+
QmlPropertyAnimation::~QmlPropertyAnimation()
{
}
@@ -1744,7 +1909,7 @@ void QmlPropertyAnimation::setFrom(const QVariant &f)
/*!
\qmlproperty real PropertyAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
QVariant QmlPropertyAnimation::to() const
{
@@ -1955,16 +2120,6 @@ void QmlPropertyAnimation::setEasing(const QString &e)
emit easingChanged(e);
}
-/*!
- \qmlproperty Object PropertyAnimation::target
- This property holds an explicit target object to animate.
-
- target is used in conjunction with property to determine
- what property should be animated.
-
- \sa property matchTargets
-*/
-
QObject *QmlPropertyAnimation::target() const
{
Q_D(const QmlPropertyAnimation);
@@ -1976,27 +2131,10 @@ void QmlPropertyAnimation::setTarget(QObject *o)
Q_D(QmlPropertyAnimation);
if (d->target == o)
return;
-
d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAnimation::property
- This property holds an explicit property name to animate.
-
- property is used in conjunction with target to determine
- what property should be animated.
-
- \sa target matchProperties
-*/
-
QString QmlPropertyAnimation::property() const
{
Q_D(const QmlPropertyAnimation);
@@ -2008,46 +2146,10 @@ void QmlPropertyAnimation::setProperty(const QString &n)
Q_D(QmlPropertyAnimation);
if (d->propertyName == n)
return;
-
d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAnimation::matchProperties
- This property holds a comma-separated list of property names this animation
- will match against. These names are used in conjunction with matchTargets
- to create a list of properties that the animation will animate, assuming those
- properties have changed.
-
- In the following example, the change in 'x' will be animated by the transition, while
- the change in 'y' will not.
- \qml
- State {
- PropertyChanges {
- target: myItem
- x: 15; y: 15
- }
- }
- Transition {
- PropertyAnimation {
- matchProperties: "x"
- }
- }
- \endqml
-
- This property is typically used for an animation appearing as part of a Transition.
-
- By default, no property names will be matched.
-
- \sa matchTargets PropertyAction::matchTargets
-*/
QString QmlPropertyAnimation::properties() const
{
Q_D(const QmlPropertyAnimation);
@@ -2065,37 +2167,86 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
}
/*!
- \qmlproperty list<Object> PropertyAnimation::matchTargets
- This property holds a list of objects this animation will match against.
- These objects are used in conjunction with matchProperties to create a list of properties
- that the animation will animate, assuming those properties have changed.
+ \qmlproperty string PropertyAnimation::property
+ \qmlproperty string PropertyAnimation::properties
+ \qmlproperty Object PropertyAnimation::target
+ \qmlproperty list<Object> PropertyAnimation::targets
- In the following example, the changes to \c myItem will be animated by the transition, while
- the changes to \c myOtherItem will not.
+ These properties are used as a set to determine which properties should be animated.
+ The singular and plural forms are functionally identical, e.g.
\qml
- State {
- PropertyChanges {
- target: myItem
- x: 15; y: 15
- }
- PropertyChanges {
- target: myOtherItem
- x: 30; y: 30
- }
- }
- Transition {
- PropertyAnimation {
- matchTargets: myItem
- matchProperties: "x,y"
- }
- }
+ NumberAnimation { target: theItem; property: "x"; to: 500 }
+ \endqml
+ has the same meaning as
+ \qml
+ NumberAnimation { targets: theItem; properties: "x"; to: 500 }
\endqml
+ The singular forms are slightly optimized, so if you do have only a single target/property
+ to animate you should try to use them.
- This property is typically used for an animation appearing as part of a Transition.
+ In many cases these properties do not need to be explicitly specified -- they can be
+ inferred from the animation framework.
+ \table 80%
+ \row
+ \o Value Source / Behavior
+ \o When an animation is used as a value source or in a Behavior, the default target and property
+ name to be animated can both be inferred.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
+ y: Behavior { NumberAnimation {} } //animate theRect's y property
+ }
+ \endqml
+ \row
+ \o Transition
+ \o When used in a transition, a property animation is assumed to match \e all targets
+ but \e no properties. In practice, that means you need to specify at least the properties
+ in order for the animation to do anything.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ Item { id: uselessItem }
+ states: State {
+ name: "state1"
+ PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
+ PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
+ }
+ transitions: Transition {
+ //animate both theRect's and uselessItem's x and y to their final values
+ NumberAnimation { properties: "x,y" }
+
+ //animate theRect's z to its final value
+ NumberAnimation { target: theRect; property: "z" }
+ }
+ }
+ \endqml
+ \row
+ \o Standalone
+ \o When an animation is used standalone, both the target and property need to be
+ explicitly specified.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ //need to explicitly specify target and property
+ NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: theAnim.start()
+ }
+ }
+ \endqml
+ \endtable
- By default, all changing targets will be matched.
-
- \sa exclude matchProperties
+ As seen in the above example, properties is specified as a comma-separated string of property names to animate.
+
+ \sa exclude
*/
QmlListProperty<QObject> QmlPropertyAnimation::targets()
{
@@ -2106,7 +2257,7 @@ QmlListProperty<QObject> QmlPropertyAnimation::targets()
/*!
\qmlproperty list<Object> PropertyAnimation::exclude
This property holds the items not to be affected by this animation.
- \sa matchTargets
+ \sa targets
*/
QmlListProperty<QObject> QmlPropertyAnimation::exclude()
{
@@ -2114,152 +2265,119 @@ QmlListProperty<QObject> QmlPropertyAnimation::exclude()
return QmlListProperty<QObject>(this, d->exclude);
}
-void QmlPropertyAnimationPrivate::valueChanged(qreal r)
-{
- if (!fromSourced) {
- if (!fromIsDefined) {
- from = property.read();
- convertVariant(from, interpolatorType ? interpolatorType : property.propertyType());
- //### check for invalid variant if using property type
- }
- fromSourced = true;
- }
-
- if (r == 1.) {
- property.write(to, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- } else {
- if (interpolator)
- property.write(interpolator(from.constData(), to.constData(), r), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
-}
-
QAbstractAnimation *QmlPropertyAnimation::qtAnimation()
{
Q_D(QmlPropertyAnimation);
return d->va;
}
-void QmlPropertyAnimation::prepare(QmlMetaProperty &p)
+struct PropertyUpdater : public QmlTimeLineValue
{
- Q_D(QmlPropertyAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- if (!d->rangeIsSet) {
- d->va->setStartValue(qreal(0));
- d->va->setEndValue(qreal(1));
- d->rangeIsSet = true;
- }
-
- int propType = d->property.propertyType();
- d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType);
- if (d->fromIsDefined)
- d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType);
-
- if (!d->interpolatorType) {
- //### check for invalid variants
- d->interpolator = QVariantAnimationPrivate::getInterpolator(propType);
+ QmlStateActions actions;
+ int interpolatorType; //for Number/ColorAnimation
+ int prevInterpolatorType; //for generic
+ QVariantAnimation::Interpolator interpolator;
+ bool reverse;
+ bool fromSourced;
+ bool fromDefined;
+ bool *wasDeleted;
+ PropertyUpdater() : wasDeleted(0) {}
+ ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
+ void setValue(qreal v)
+ {
+ bool deleted = false;
+ wasDeleted = &deleted;
+ if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
+ v = 1 - v;
+ QmlTimeLineValue::setValue(v);
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+
+ if (v == 1.)
+ action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
+ else {
+ if (!fromSourced && !fromDefined) {
+ action.fromValue = action.property.read();
+ if (interpolatorType)
+ QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
+ }
+ if (!interpolatorType) {
+ int propType = action.property.propertyType();
+ if (!prevInterpolatorType || prevInterpolatorType != propType) {
+ prevInterpolatorType = propType;
+ interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
+ }
+ }
+ if (interpolator)
+ action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
+ }
+ if (deleted)
+ return;
+ }
+ wasDeleted = 0;
+ fromSourced = true;
}
-
- d->fromSourced = false;
- d->value.QmlTimeLineValue::setValue(0.);
- d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
- d->va->setFromSourcedValue(&d->fromSourced);
-}
+};
void QmlPropertyAnimation::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
{
Q_D(QmlPropertyAnimation);
- Q_UNUSED(direction);
-
- struct PropertyUpdater : public QmlTimeLineValue
- {
- QmlStateActions actions;
- int interpolatorType; //for Number/ColorAnimation
- int prevInterpolatorType; //for generic
- QVariantAnimation::Interpolator interpolator;
- bool reverse;
- bool *wasDeleted;
- PropertyUpdater() : wasDeleted(0) {}
- ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
- void setValue(qreal v)
- {
- bool deleted = false;
- wasDeleted = &deleted;
- if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
- v = 1 - v;
- QmlTimeLineValue::setValue(v);
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- if (v == 1.)
- action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- else {
- if (action.fromValue.isNull()) {
- action.fromValue = action.property.read();
- if (interpolatorType)
- QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
- }
- if (!interpolatorType) {
- int propType = action.property.propertyType();
- if (!prevInterpolatorType || prevInterpolatorType != propType) {
- prevInterpolatorType = propType;
- interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
- }
- }
- if (interpolator)
- action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
- if (deleted)
- return;
- }
- wasDeleted = 0;
- }
- };
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 << d->propertyName;
- bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
- bool hasTarget = !d->propertyName.isEmpty() || d->target;
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
- if (hasSelectors && hasTarget) {
- qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
- return;
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
}
- bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+ if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
+ props << d->defaultProperties.split(QLatin1Char(','));
+ }
PropertyUpdater *data = new PropertyUpdater;
data->interpolatorType = d->interpolatorType;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = d->fromIsDefined;
bool hasExplicit = false;
//an explicit animation has been specified
- if (hasTarget && d->toIsDefined) {
- QmlAction myAction;
- myAction.property = d->createProperty(target(), d->propertyName, this);
- if (myAction.property.isValid()) {
- if (d->fromIsDefined) {
- d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.fromValue = d->from;
- }
- d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.toValue = d->to;
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
+ if (d->toIsDefined) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QmlAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ if (d->fromIsDefined) {
+ myAction.fromValue = d->from;
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ }
+ myAction.toValue = d->to;
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
}
}
}
@@ -2275,7 +2393,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
QString sPropertyName = action.specifiedProperty;
bool same = (obj == sObj);
- if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
(props.contains(propertyName) || (!same && props.contains(sPropertyName))
|| (useType && action.property.propertyType() == d->interpolatorType))) {
@@ -2295,29 +2413,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
data->actions << myAction;
action.fromValue = myAction.toValue;
- } else if (d->userProperty.isValid() &&
- !hasSelectors && !hasTarget) {
- if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
- (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
- //### same as above. merge
- QmlAction myAction = action;
-
- if (d->fromIsDefined)
- myAction.fromValue = d->from;
- else
- myAction.fromValue = QVariant();
- if (d->toIsDefined)
- myAction.toValue = d->to;
-
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
-
- modified << action.property;
-
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
+ }
}
if (data->actions.count()) {
@@ -2327,6 +2423,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
d->rangeIsSet = true;
}
d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
+ d->va->setFromSourcedValue(&data->fromSourced);
} else {
delete data;
}
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index a566074..623ad8d 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -94,7 +94,8 @@ public:
QmlAnimationGroup *group() const;
void setGroup(QmlAnimationGroup *);
- virtual void setTarget(const QmlMetaProperty &);
+ void setDefaultTarget(const QmlMetaProperty &);
+ void setDisableUserControl();
void classBegin();
void componentComplete();
@@ -123,11 +124,13 @@ public:
virtual void transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction);
- virtual void prepare(QmlMetaProperty &);
virtual QAbstractAnimation *qtAnimation() = 0;
private Q_SLOTS:
void timelineComplete();
+
+private:
+ virtual void setTarget(const QmlMetaProperty &);
};
class QmlPauseAnimationPrivate;
@@ -186,8 +189,8 @@ class QmlPropertyAction : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QmlListProperty<QObject> matchTargets READ targets)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
@@ -220,7 +223,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
class QmlGraphicsItem;
@@ -231,8 +233,7 @@ class QmlParentAction : public QmlAbstractAnimation
Q_DECLARE_PRIVATE(QmlParentAction)
Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject)
- Q_PROPERTY(QmlGraphicsItem *matchTarget READ matchTarget WRITE setMatchTarget)
- Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent)
+ Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent
public:
QmlParentAction(QObject *parent=0);
@@ -241,9 +242,6 @@ public:
QmlGraphicsItem *object() const;
void setObject(QmlGraphicsItem *);
- QmlGraphicsItem *matchTarget() const;
- void setMatchTarget(QmlGraphicsItem *);
-
QmlGraphicsItem *parent() const;
void setParent(QmlGraphicsItem *);
@@ -266,8 +264,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QmlListProperty<QObject> matchTargets READ targets)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
public:
@@ -299,11 +297,11 @@ public:
QmlListProperty<QObject> exclude();
protected:
+ QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent);
virtual void transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
Q_SIGNALS:
void durationChanged(int);
@@ -370,6 +368,35 @@ public:
void setTo(QVector3D);
};
+class QmlRotationAnimationPrivate;
+class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlRotationAnimation)
+ Q_ENUMS(RotationDirection)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+
+public:
+ QmlRotationAnimation(QObject *parent=0);
+ virtual ~QmlRotationAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+
+ enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
+ RotationDirection direction() const;
+ void setDirection(RotationDirection direction);
+
+Q_SIGNALS:
+ void directionChanged();
+};
+
class QmlAnimationGroupPrivate;
class QmlAnimationGroup : public QmlAbstractAnimation
{
@@ -377,13 +404,13 @@ class QmlAnimationGroup : public QmlAbstractAnimation
Q_DECLARE_PRIVATE(QmlAnimationGroup)
Q_CLASSINFO("DefaultProperty", "animations")
- Q_PROPERTY(QmlList<QmlAbstractAnimation *> *animations READ animations)
+ Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
public:
QmlAnimationGroup(QObject *parent);
virtual ~QmlAnimationGroup();
- QmlList<QmlAbstractAnimation *>* animations();
+ QmlListProperty<QmlAbstractAnimation> animations();
friend class QmlAbstractAnimation;
};
@@ -401,7 +428,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
class QmlParallelAnimation : public QmlAnimationGroup
@@ -418,7 +444,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
QT_END_NAMESPACE
@@ -434,6 +459,7 @@ QML_DECLARE_TYPE(QmlNumberAnimation)
QML_DECLARE_TYPE(QmlSequentialAnimation)
QML_DECLARE_TYPE(QmlParallelAnimation)
QML_DECLARE_TYPE(QmlVector3dAnimation)
+QML_DECLARE_TYPE(QmlRotationAnimation)
QT_END_HEADER
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index d680194..056ce82 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -108,6 +108,8 @@ public:
{
if (state() == Running)
stop();
+ if (policy == DeleteWhenStopped)
+ delete animAction;
animAction = action;
policy = p;
}
@@ -126,12 +128,12 @@ protected:
animAction = 0;
}
}
- } else if (newState == Stopped && policy == DeleteWhenStopped) {
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
if (!running) {
delete animAction;
animAction = 0;
}
- }
+ }*/
}
private:
@@ -151,6 +153,8 @@ public:
{
if (state() == Running)
stop();
+ if (policy == DeleteWhenStopped)
+ delete animValue;
animValue = value;
policy = p;
}
@@ -165,16 +169,17 @@ protected:
animValue->setValue(value.toReal());
}
virtual void updateState(State newState, State oldState)
- {
+ {
QVariantAnimation::updateState(newState, oldState);
if (newState == Running) {
//check for new from every loop
if (fromSourced)
*fromSourced = false;
- } else if (newState == Stopped && policy == DeleteWhenStopped) {
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
delete animValue;
animValue = 0;
- }
+ }*/ //### we get a stop each loop if we are in a group
+ //### top-level animation is the only reliable one for this
}
private:
@@ -204,24 +209,22 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate
public:
QmlAbstractAnimationPrivate()
: running(false), paused(false), alwaysRunToEnd(false), repeat(false),
- connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
- avoidPropertyValueSourceStart(false), group(0) {}
+ connectedTimeLine(false), componentComplete(true),
+ avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
bool running:1;
bool paused:1;
bool alwaysRunToEnd:1;
bool repeat:1;
bool connectedTimeLine:1;
-
bool componentComplete:1;
- bool startOnCompletion:1;
bool avoidPropertyValueSourceStart:1;
+ bool disableUserControl:1;
void commence();
- QmlNullableValue<QmlMetaProperty> userProperty;
+ QmlMetaProperty defaultProperty;
- QmlMetaProperty property;
QmlAnimationGroup *group;
static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
@@ -265,7 +268,7 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAction)
public:
QmlPropertyActionPrivate()
- : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {}
+ : QmlAbstractAnimationPrivate(), target(0), spa(0) {}
void init();
@@ -277,10 +280,6 @@ public:
QmlNullableValue<QVariant> value;
- void doAction();
-
- QAnimationActionProxy<QmlPropertyActionPrivate,
- &QmlPropertyActionPrivate::doAction> proxy;
QActionAnimation *spa;
};
@@ -289,12 +288,11 @@ class QmlParentActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlParentAction)
public:
QmlParentActionPrivate()
- : QmlAbstractAnimationPrivate(), pcTarget(0), pcMatchTarget(0), pcParent(0) {}
+ : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {}
void init();
QmlGraphicsItem *pcTarget;
- QmlGraphicsItem *pcMatchTarget;
QmlGraphicsItem *pcParent;
void doAction();
@@ -306,37 +304,13 @@ class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlAnimationGroup)
public:
QmlAnimationGroupPrivate()
- : QmlAbstractAnimationPrivate(), animations(this), ag(0) {}
+ : QmlAbstractAnimationPrivate(), ag(0) {}
- struct AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
- {
- AnimationList(QmlAnimationGroupPrivate *p)
- : anim(p) {}
- virtual void append(QmlAbstractAnimation *a) {
- QmlConcreteList<QmlAbstractAnimation *>::append(a);
- a->setGroup(anim->q_func());
- }
- virtual void clear()
- {
- for (int i = 0; i < count(); ++i)
- at(i)->setGroup(0);
- QmlConcreteList<QmlAbstractAnimation *>::clear();
- }
- virtual void removeAt(int i)
- {
- at(i)->setGroup(0);
- QmlConcreteList<QmlAbstractAnimation *>::removeAt(i);
- }
- virtual void insert(int i, QmlAbstractAnimation *a)
- {
- QmlConcreteList<QmlAbstractAnimation *>::insert(i, a);
- a->setGroup(anim->q_func());
- }
-
- QmlAnimationGroupPrivate *anim;
- };
-
- AnimationList animations;
+ static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *role);
+ static void clear_animation(QmlListProperty<QmlAbstractAnimation> *list);
+ static void removeAt_animation(QmlListProperty<QmlAbstractAnimation> *list, int i);
+ static void insert_animation(QmlListProperty<QmlAbstractAnimation> *list, int i, QmlAbstractAnimation *role);
+ QList<QmlAbstractAnimation *> animations;
QAnimationGroup *ag;
};
@@ -346,8 +320,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
public:
QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
- value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
+ rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {}
void init();
@@ -361,6 +334,7 @@ public:
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;
+ QString defaultProperties;
bool fromSourced;
bool fromIsDefined:1;
@@ -371,14 +345,20 @@ public:
QVariantAnimation::Interpolator interpolator;
QmlTimeLineValueAnimator *va;
- virtual void valueChanged(qreal);
-
- QmlTimeLineValueProxy<QmlPropertyAnimationPrivate> value;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
static void convertVariant(QVariant &variant, int type);
};
+class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QmlRotationAnimation)
+public:
+ QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {}
+
+ QmlRotationAnimation::RotationDirection direction;
+};
+
QT_END_NAMESPACE
#endif // QMLANIMATION_P_H
diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp
index b9c77f5..d65d8cd 100644
--- a/src/declarative/util/qmlbehavior.cpp
+++ b/src/declarative/util/qmlbehavior.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -119,13 +119,15 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation)
{
Q_D(QmlBehavior);
if (d->animation) {
- qmlInfo(this) << tr("Can't change the animation assigned to a Behavior.");
+ qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
return;
}
d->animation = animation;
- if (d->animation)
- d->animation->setTarget(d->property);
+ if (d->animation) {
+ d->animation->setDefaultTarget(d->property);
+ d->animation->setDisableUserControl();
+ }
}
/*!
@@ -183,7 +185,7 @@ void QmlBehavior::setTarget(const QmlMetaProperty &property)
d->property = property;
d->currentValue = property.read();
if (d->animation)
- d->animation->setTarget(property);
+ d->animation->setDefaultTarget(property);
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlbehavior_p.h b/src/declarative/util/qmlbehavior_p.h
index da3b40f..ee9e862 100644
--- a/src/declarative/util/qmlbehavior_p.h
+++ b/src/declarative/util/qmlbehavior_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp
index c68cef2..fc1562b 100644
--- a/src/declarative/util/qmlbind.cpp
+++ b/src/declarative/util/qmlbind.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlbind_p.h b/src/declarative/util/qmlbind_p.h
index 4d7cd1f..6fdd2dc 100644
--- a/src/declarative/util/qmlbind_p.h
+++ b/src/declarative/util/qmlbind_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index 800fd6b..3d04aaf 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -72,7 +72,7 @@ public:
"on<Signal>" handler that reacts when a signal is received, like this:
\qml
- MouseRegion {
+ MouseArea {
onClicked: { foo(x+123,y+456) }
}
\endqml
@@ -94,7 +94,7 @@ public:
like this:
\qml
- MouseRegion {
+ MouseArea {
Connection {
signal: "clicked(x,y)"
script: { foo(x+123,y+456) }
@@ -106,7 +106,7 @@ public:
the sender of the signal, and the script is the default attribute:
\qml
- MouseRegion {
+ MouseArea {
id: mr
}
...
diff --git a/src/declarative/util/qmlconnection_p.h b/src/declarative/util/qmlconnection_p.h
index 52bc247..2106cb0 100644
--- a/src/declarative/util/qmlconnection_p.h
+++ b/src/declarative/util/qmlconnection_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp
index 9d216cf..c44ca5e 100644
--- a/src/declarative/util/qmldatetimeformatter.cpp
+++ b/src/declarative/util/qmldatetimeformatter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmldatetimeformatter_p.h b/src/declarative/util/qmldatetimeformatter_p.h
index c90ee8c..2cd80b9 100644
--- a/src/declarative/util/qmldatetimeformatter_p.h
+++ b/src/declarative/util/qmldatetimeformatter_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
index e3153b1..deb474a 100644
--- a/src/declarative/util/qmleasefollow.cpp
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -300,6 +300,13 @@ Rectangle {
}
\endcode
+ The default velocity of EaseFollow is 200 units/second. Note that if the range of the
+ value being animated is small, then the velocity will need to be adjusted
+ appropriately. For example, the opacity of an item ranges from 0 - 1.0.
+ To enable a smooth animation in this range the velocity will need to be
+ set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
+ of 0.5 will take 2000 ms to complete.
+
\sa SpringFollow
*/
@@ -415,7 +422,7 @@ void QmlEaseFollow::setSourceValue(qreal s)
This property holds the animation duration used when tracking the source.
- Setting this to -1 disables the duration value.
+ Setting this to -1 (the default) disables the duration value.
*/
qreal QmlEaseFollow::duration() const
{
@@ -449,6 +456,8 @@ qreal QmlEaseFollow::velocity() const
This property holds the average velocity allowed when tracking the source.
+ The default velocity of EaseFollow is 200 units/second.
+
Setting this to -1 disables the velocity value.
*/
void QmlEaseFollow::setVelocity(qreal v)
diff --git a/src/declarative/util/qmleasefollow_p.h b/src/declarative/util/qmleasefollow_p.h
index ef095a3..dddf54f 100644
--- a/src/declarative/util/qmleasefollow_p.h
+++ b/src/declarative/util/qmleasefollow_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qmlfontloader.cpp
index b56043b..4599b99 100644
--- a/src/declarative/util/qmlfontloader.cpp
+++ b/src/declarative/util/qmlfontloader.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlfontloader_p.h b/src/declarative/util/qmlfontloader_p.h
index aac8a71..3d27452 100644
--- a/src/declarative/util/qmlfontloader_p.h
+++ b/src/declarative/util/qmlfontloader_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp
index 2e37d49..abdb626 100644
--- a/src/declarative/util/qmllistaccessor.cpp
+++ b/src/declarative/util/qmllistaccessor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -84,10 +84,7 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine)
QObject *data = enginePrivate?enginePrivate->toQObject(v):QmlMetaType::toQObject(v);
d = QVariant::fromValue(data);
m_type = Instance;
- } else if ((!enginePrivate && QmlMetaType::isQmlList(d.userType())) ||
- (enginePrivate && enginePrivate->isQmlList(d.userType()))) {
- m_type = QmlList;
- } else if (QmlMetaType::isList(d.userType())) {
+ } else if (d.userType() == qMetaTypeId<QmlListReference>()) {
m_type = ListProperty;
} else {
m_type = Instance;
@@ -101,17 +98,8 @@ int QmlListAccessor::count() const
return qvariant_cast<QStringList>(d).count();
case VariantList:
return qvariant_cast<QVariantList>(d).count();
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- return li->count();
- }
case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->count) return li->count(li);
- else return 0;
- }
+ return ((QmlListReference *)d.constData())->count();
case Instance:
return 1;
case Integer:
@@ -130,19 +118,8 @@ QVariant QmlListAccessor::at(int idx) const
return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
case VariantList:
return qvariant_cast<QVariantList>(d).at(idx);
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- void *ptr[1];
- li->at(idx, ptr);
- return QVariant::fromValue((QObject*)ptr[0]);
- }
case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->at) return QVariant::fromValue((QObject *)li->at(li, idx));
- else return QVariant();
- }
+ return QVariant::fromValue(((QmlListReference *)d.constData())->at(idx));
case Instance:
return d;
case Integer:
@@ -153,106 +130,6 @@ QVariant QmlListAccessor::at(int idx) const
}
}
-bool QmlListAccessor::append(const QVariant &value)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->append(const_cast<void *>(value.constData())); //XXX Typesafety
- return true;
- }
- case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->append) li->append(li, *(void **)value.constData()); // XXX Typesafety
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::insert(int index, const QVariant &value)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->insert(index, const_cast<void *>(value.constData())); //XXX Typesafety
- return true;
- }
- case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->insert) li->insert(li, index, *(void **)value.constData()); // XXX Typesafety
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::removeAt(int index)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->removeAt(index);
- return true;
- }
- case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->removeAt) li->removeAt(li, index);
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::clear()
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->clear();
- return true;
- }
- case ListProperty:
- {
- QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
- if (li->clear) li->clear(li);
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
bool QmlListAccessor::isValid() const
{
return m_type != Invalid;
diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h
index 6866150..611eebb 100644
--- a/src/declarative/util/qmllistaccessor_p.h
+++ b/src/declarative/util/qmllistaccessor_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -65,12 +65,7 @@ public:
int count() const;
QVariant at(int) const;
- bool append(const QVariant &);
- bool insert(int, const QVariant &);
- bool removeAt(int);
- bool clear();
-
- enum Type { Invalid, StringList, VariantList, QmlList, ListProperty, Instance, Integer };
+ enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
Type type() const { return m_type; }
private:
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 61fc50d..8fda3ae 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -188,7 +188,7 @@ static void dump(ModelNode *node, int ind);
Text { text: '$'+cost; anchors.right: parent.right }
// Double the price when clicked.
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: fruitModel.set(index, "cost", cost*2)
}
@@ -806,7 +806,23 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
qvariant_cast<QmlParser::Variant>(value);
int ref = data.count();
- QByteArray d = variant.asScript().toUtf8();
+
+ QByteArray d;
+ d += char(variant.type()); // type tag
+ if (variant.isString()) {
+ d += variant.asString().toUtf8();
+ } else if (variant.isNumber()) {
+ d += QByteArray::number(variant.asNumber(),'g',20);
+ } else if (variant.isBoolean()) {
+ d += char(variant.asBoolean());
+ } else if (variant.isScript()) {
+ if (definesEmptyList(variant.asScript())) {
+ d[0] = 0; // QmlParser::Variant::Invalid - marks empty list
+ } else {
+ error(prop, QmlListModel::tr("ListElement: cannot use script for property value"));
+ return false;
+ }
+ }
d.append('\0');
data.append(d);
@@ -814,7 +830,6 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
li.type = ListInstruction::Value;
li.dataIdx = ref;
instr << li;
-
}
}
@@ -892,15 +907,22 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d)
case ListInstruction::Value:
{
ModelNode *n = nodes.top();
- QString s = QString::fromUtf8(QByteArray(data + instr.dataIdx));
-
- bool isEmptyList = false;
- if (!n->isArray)
- isEmptyList = definesEmptyList(s);
- if (isEmptyList)
+ switch (QmlParser::Variant::Type(data[instr.dataIdx])) {
+ case QmlParser::Variant::Invalid:
n->isArray = true;
- else
- n->values.append(s);
+ break;
+ case QmlParser::Variant::Boolean:
+ n->values.append(bool(data[1 + instr.dataIdx]));
+ break;
+ case QmlParser::Variant::Number:
+ n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
+ break;
+ case QmlParser::Variant::String:
+ n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
+ break;
+ default:
+ Q_ASSERT("Format error in ListInstruction");
+ }
processingSet = false;
}
diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h
index e18d3fd..4cf6746 100644
--- a/src/declarative/util/qmllistmodel_p.h
+++ b/src/declarative/util/qmllistmodel_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlnullablevalue_p_p.h b/src/declarative/util/qmlnullablevalue_p_p.h
index 151a3d4..c426258 100644
--- a/src/declarative/util/qmlnullablevalue_p_p.h
+++ b/src/declarative/util/qmlnullablevalue_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp
index 073dc68..f78abdf 100644
--- a/src/declarative/util/qmlnumberformatter.cpp
+++ b/src/declarative/util/qmlnumberformatter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlnumberformatter_p.h b/src/declarative/util/qmlnumberformatter_p.h
index 71fceb2..d08885b 100644
--- a/src/declarative/util/qmlnumberformatter_p.h
+++ b/src/declarative/util/qmlnumberformatter_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp
index 1be81de..0847c47 100644
--- a/src/declarative/util/qmlopenmetaobject.cpp
+++ b/src/declarative/util/qmlopenmetaobject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlopenmetaobject_p.h b/src/declarative/util/qmlopenmetaobject_p.h
index c6da71a..3f9450d 100644
--- a/src/declarative/util/qmlopenmetaobject_p.h
+++ b/src/declarative/util/qmlopenmetaobject_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp
index 3214dc8..82f776f 100644
--- a/src/declarative/util/qmlpackage.cpp
+++ b/src/declarative/util/qmlpackage.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -51,28 +51,33 @@ class QmlPackagePrivate : public QObjectPrivate
public:
QmlPackagePrivate() {}
- class DataList;
struct DataGuard : public QmlGuard<QObject>
{
- DataGuard(QObject *obj, DataList *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- DataList *list;
+ DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
+ QList<DataGuard> *list;
void objectDestroyed(QObject *) {
// we assume priv will always be destroyed after objectDestroyed calls
list->removeOne(*this);
}
};
- class DataList : public QList<DataGuard>, public QmlList<QObject*>
- {
- public:
- virtual void append(QObject* v) { QList<DataGuard>::append(DataGuard(v, this)); }
- virtual void insert(int i, QObject* v) { QList<DataGuard>::insert(i, DataGuard(v, this)); }
- virtual void clear() { QList<DataGuard>::clear(); }
- virtual QObject* at(int i) const { return QList<DataGuard>::at(i); }
- virtual void removeAt(int i) { QList<DataGuard>::removeAt(i); }
- virtual int count() const { return QList<DataGuard>::count(); }
- };
- DataList dataList;
+ QList<DataGuard> dataList;
+ static void data_append(QmlListProperty<QObject> *prop, QObject *o) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->append(DataGuard(o, list));
+ }
+ static void data_clear(QmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->clear();
+ }
+ static QObject *data_at(QmlListProperty<QObject> *prop, int index) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->at(index);
+ }
+ static int data_count(QmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->count();
+ }
};
class QmlPackageAttached : public QObject
@@ -128,10 +133,13 @@ QmlPackage::~QmlPackage()
}
}
-QmlList<QObject *> *QmlPackage::data()
+QmlListProperty<QObject> QmlPackage::data()
{
Q_D(QmlPackage);
- return &d->dataList;
+ return QmlListProperty<QObject>(this, &d->dataList, QmlPackagePrivate::data_append,
+ QmlPackagePrivate::data_count,
+ QmlPackagePrivate::data_at,
+ QmlPackagePrivate::data_clear);
}
bool QmlPackage::hasPart(const QString &name)
diff --git a/src/declarative/util/qmlpackage_p.h b/src/declarative/util/qmlpackage_p.h
index ff42aad..29b6bbe 100644
--- a/src/declarative/util/qmlpackage_p.h
+++ b/src/declarative/util/qmlpackage_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,13 +64,13 @@ class QmlPackage : public QObject
Q_DECLARE_PRIVATE(QmlPackage)
Q_CLASSINFO("DefaultProperty", "data")
- Q_PROPERTY(QmlList<QObject *> *data READ data SCRIPTABLE false)
+ Q_PROPERTY(QmlListProperty<QObject> data READ data SCRIPTABLE false)
public:
QmlPackage(QObject *parent=0);
virtual ~QmlPackage();
- QmlList<QObject *> *data();
+ QmlListProperty<QObject> data();
QObject *part(const QString & = QString());
bool hasPart(const QString &);
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index 4e581bd..2459651 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -179,11 +179,19 @@ bool QmlImageRequestHandler::event(QEvent *event)
if (reader->cancelled.count()) {
for (int i = 0; i < reader->cancelled.count(); ++i) {
QmlPixmapReply *job = reader->cancelled.at(i);
+ // cancel any jobs already started
QNetworkReply *reply = replies.key(job, 0);
if (reply && reply->isRunning()) {
replies.remove(reply);
reply->close();
- job->release(true);
+ }
+ // remove from pending job list
+ for (int j = 0; j < reader->jobs.count(); ++j) {
+ if (reader->jobs.at(j) == job) {
+ reader->jobs.removeAt(j);
+ job->release(true);
+ break;
+ }
}
}
reader->cancelled.clear();
@@ -195,8 +203,6 @@ bool QmlImageRequestHandler::event(QEvent *event)
}
QmlPixmapReply *runningJob = reader->jobs.takeLast();
- runningJob->addRef();
- runningJob->setLoading();
QUrl url = runningJob->url();
reader->mutex.unlock();
@@ -267,12 +273,12 @@ QmlImageReader::QmlImageReader(QmlEngine *eng)
QmlImageReader::~QmlImageReader()
{
- quit();
- wait();
readerMutex.lock();
readers.remove(engine);
readerMutex.unlock();
- delete handler;
+
+ quit();
+ wait();
}
QmlImageReader *QmlImageReader::instance(QmlEngine *engine)
@@ -292,6 +298,8 @@ QmlPixmapReply *QmlImageReader::getImage(const QUrl &url)
{
mutex.lock();
QmlPixmapReply *reply = new QmlPixmapReply(this, url);
+ reply->addRef();
+ reply->setLoading();
jobs.append(reply);
if (jobs.count() == 1 && handler)
QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
@@ -303,21 +311,10 @@ void QmlImageReader::cancel(QmlPixmapReply *reply)
{
mutex.lock();
if (reply->isLoading()) {
- // Already requested. Add to cancel list to be cancelled in reader thread.
+ // Add to cancel list to be cancelled in reader thread.
cancelled.append(reply);
if (cancelled.count() == 1 && handler)
QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
- } else {
- // Not yet processed - just remove from waiting list
- QList<QmlPixmapReply*>::iterator it = jobs.begin();
- while (it != jobs.end()) {
- QmlPixmapReply *job = *it;
- if (job == reply) {
- jobs.erase(it);
- break;
- }
- ++it;
- }
}
mutex.unlock();
}
@@ -335,6 +332,9 @@ void QmlImageReader::run()
handler = new QmlImageRequestHandler(this, engine);
exec();
+
+ delete handler;
+ handler = 0;
}
//===========================================================================
@@ -479,8 +479,6 @@ bool QmlPixmapReply::release(bool defer)
--d->refCount;
if (d->refCount == 0) {
qmlActivePixmapReplies()->remove(d->url);
- if (d->status == Loading && !d->loading)
- d->reader->cancel(this);
if (defer)
deleteLater();
else
diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h
index 462faf6..86908cc 100644
--- a/src/declarative/util/qmlpixmapcache_p.h
+++ b/src/declarative/util/qmlpixmapcache_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp
index 68fc5cc..068cb4d 100644
--- a/src/declarative/util/qmlpropertychanges.cpp
+++ b/src/declarative/util/qmlpropertychanges.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
}
}
- MouseRegion { anchors.fill: parent; onClicked: myText.state = 'myState' }
+ MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
}
\endqml
@@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE
\qml
PropertyChanges {
- target: myMouseRegion
+ target: myMouseArea
onClicked: doSomethingDifferent()
}
\endqml
@@ -357,7 +357,7 @@ QmlPropertyChangesPrivate::property(const QByteArray &property)
Q_Q(QmlPropertyChanges);
QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property));
if (!prop.isValid()) {
- qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(property));
+ qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property));
return QmlMetaProperty();
} else if (!(prop.type() & QmlMetaProperty::SignalProperty) && !prop.isWritable()) {
qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property));
diff --git a/src/declarative/util/qmlpropertychanges_p.h b/src/declarative/util/qmlpropertychanges_p.h
index 461730d..19dcf9d 100644
--- a/src/declarative/util/qmlpropertychanges_p.h
+++ b/src/declarative/util/qmlpropertychanges_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlpropertymap.cpp b/src/declarative/util/qmlpropertymap.cpp
index 226f82e..ccbec6f 100644
--- a/src/declarative/util/qmlpropertymap.cpp
+++ b/src/declarative/util/qmlpropertymap.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlpropertymap.h b/src/declarative/util/qmlpropertymap.h
index bb397fe..a56ed0f 100644
--- a/src/declarative/util/qmlpropertymap.h
+++ b/src/declarative/util/qmlpropertymap.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp
index 764d7f9..6d4ecf2 100644
--- a/src/declarative/util/qmlspringfollow.cpp
+++ b/src/declarative/util/qmlspringfollow.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlspringfollow_p.h b/src/declarative/util/qmlspringfollow_p.h
index 7731b9e..4a0ed1c 100644
--- a/src/declarative/util/qmlspringfollow_p.h
+++ b/src/declarative/util/qmlspringfollow_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index cae8054..4462b1f 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -242,16 +242,30 @@ void QmlState::setExtends(const QString &extends)
extends another state, then the changes are applied against the state being
extended.
*/
-QmlList<QmlStateOperation *> *QmlState::changes()
+QmlListProperty<QmlStateOperation> QmlState::changes()
{
Q_D(QmlState);
- return &d->operations;
+ return QmlListProperty<QmlStateOperation>(this, &d->operations, QmlStatePrivate::operations_append,
+ QmlStatePrivate::operations_count, QmlStatePrivate::operations_at,
+ QmlStatePrivate::operations_clear);
+}
+
+int QmlState::operationCount() const
+{
+ Q_D(const QmlState);
+ return d->operations.count();
+}
+
+QmlStateOperation *QmlState::operationAt(int index) const
+{
+ Q_D(const QmlState);
+ return d->operations.at(index);
}
QmlState &QmlState::operator<<(QmlStateOperation *op)
{
Q_D(QmlState);
- d->operations.append(op);
+ d->operations.append(QmlStatePrivate::OperationGuard(op, &d->operations));
return *this;
}
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
index 5862c02..2c92387 100644
--- a/src/declarative/util/qmlstate_p.h
+++ b/src/declarative/util/qmlstate_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -131,7 +131,7 @@ class Q_DECLARATIVE_EXPORT QmlState : public QObject
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QmlBinding *when READ when WRITE setWhen)
Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QmlList<QmlStateOperation *>* changes READ changes)
+ Q_PROPERTY(QmlListProperty<QmlStateOperation> changes READ changes)
Q_CLASSINFO("DefaultProperty", "changes")
Q_CLASSINFO("DeferredPropertyNames", "changes")
@@ -151,7 +151,10 @@ public:
QString extends() const;
void setExtends(const QString &);
- QmlList<QmlStateOperation *> *changes();
+ QmlListProperty<QmlStateOperation> changes();
+ int operationCount() const;
+ QmlStateOperation *operationAt(int) const;
+
QmlState &operator<<(QmlStateOperation *);
void apply(QmlStateGroup *, QmlTransition *, QmlState *revert);
diff --git a/src/declarative/util/qmlstate_p_p.h b/src/declarative/util/qmlstate_p_p.h
index 235fe62..d138e4e 100644
--- a/src/declarative/util/qmlstate_p_p.h
+++ b/src/declarative/util/qmlstate_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -107,28 +107,33 @@ public:
QString name;
QmlBinding *when;
- class OperationList;
struct OperationGuard : public QmlGuard<QmlStateOperation>
{
- OperationGuard(QObject *obj, OperationList *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- OperationList *list;
+ OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
+ QList<OperationGuard> *list;
void objectDestroyed(QmlStateOperation *) {
// we assume priv will always be destroyed after objectDestroyed calls
list->removeOne(*this);
}
};
+ QList<OperationGuard> operations;
- class OperationList : public QList<OperationGuard>, public QmlList<QmlStateOperation*>
- {
- public:
- virtual void append(QmlStateOperation* v) { QList<OperationGuard>::append(OperationGuard(v, this)); }
- virtual void insert(int i, QmlStateOperation* v) { QList<OperationGuard>::insert(i, OperationGuard(v, this)); }
- virtual void clear() { QList<OperationGuard>::clear(); }
- virtual QmlStateOperation* at(int i) const { return QList<OperationGuard>::at(i); }
- virtual void removeAt(int i) { QList<OperationGuard>::removeAt(i); }
- virtual int count() const { return QList<OperationGuard>::count(); }
- };
- OperationList operations;
+ static void operations_append(QmlListProperty<QmlStateOperation> *prop, QmlStateOperation *op) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->append(OperationGuard(op, list));
+ }
+ static void operations_clear(QmlListProperty<QmlStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->clear();
+ }
+ static int operations_count(QmlListProperty<QmlStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->count();
+ }
+ static QmlStateOperation *operations_at(QmlListProperty<QmlStateOperation> *prop, int index) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->at(index);
+ }
QmlTransitionManager transitionManager;
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index aad19d9..4ad77c8 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,26 +60,19 @@ class QmlStateGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlStateGroup)
public:
QmlStateGroupPrivate(QmlStateGroup *p)
- : nullState(0), states(p), componentComplete(true),
+ : nullState(0), componentComplete(true),
ignoreTrans(false), applyingState(false) {}
QString currentState;
QmlState *nullState;
- struct StateList : public QmlConcreteList<QmlState *>
- {
- StateList(QmlStateGroup *g)
- :group(g) {}
- void append(QmlState *s) {
- QmlConcreteList<QmlState *>::append(s);
- if (s) s->setStateGroup(group);
- }
- private:
- QmlStateGroup *group;
- };
- StateList states;
+ static void append_state(QmlListProperty<QmlState> *list, QmlState *state);
+ static int count_state(QmlListProperty<QmlState> *list);
+ static QmlState *at_state(QmlListProperty<QmlState> *list, int index);
+
+ QList<QmlState *> states;
+ QList<QmlTransition *> transitions;
- QmlConcreteList<QmlTransition *> transitions;
bool componentComplete;
bool ignoreTrans;
bool applyingState;
@@ -151,10 +144,34 @@ QList<QmlState *> QmlStateGroup::states() const
\sa {qmlstate}{States}
*/
-QmlList<QmlState *>* QmlStateGroup::statesProperty()
+QmlListProperty<QmlState> QmlStateGroup::statesProperty()
{
Q_D(QmlStateGroup);
- return &(d->states);
+ return QmlListProperty<QmlState>(this, &d->states, &QmlStateGroupPrivate::append_state,
+ &QmlStateGroupPrivate::count_state,
+ &QmlStateGroupPrivate::at_state);
+}
+
+void QmlStateGroupPrivate::append_state(QmlListProperty<QmlState> *list, QmlState *state)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ if (state) {
+ _this->d_func()->states.append(state);
+ state->setStateGroup(_this);
+ }
+
+}
+
+int QmlStateGroupPrivate::count_state(QmlListProperty<QmlState> *list)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ return _this->d_func()->states.count();
+}
+
+QmlState *QmlStateGroupPrivate::at_state(QmlListProperty<QmlState> *list, int index)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ return _this->d_func()->states.at(index);
}
/*!
@@ -173,10 +190,10 @@ QmlList<QmlState *>* QmlStateGroup::statesProperty()
\sa {state-transitions}{Transitions}
*/
-QmlList<QmlTransition *>* QmlStateGroup::transitionsProperty()
+QmlListProperty<QmlTransition> QmlStateGroup::transitionsProperty()
{
Q_D(QmlStateGroup);
- return &(d->transitions);
+ return QmlListProperty<QmlTransition>(this, d->transitions);
}
/*!
diff --git a/src/declarative/util/qmlstategroup_p.h b/src/declarative/util/qmlstategroup_p.h
index 112c9eb..d39ca03 100644
--- a/src/declarative/util/qmlstategroup_p.h
+++ b/src/declarative/util/qmlstategroup_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -58,8 +58,8 @@ class Q_DECLARATIVE_EXPORT QmlStateGroup : public QObject, public QmlParserStatu
Q_DECLARE_PRIVATE(QmlStateGroup)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QmlList<QmlState *>* states READ statesProperty DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitionsProperty DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlState> states READ statesProperty DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitionsProperty DESIGNABLE false)
public:
QmlStateGroup(QObject * = 0);
@@ -68,10 +68,10 @@ public:
QString state() const;
void setState(const QString &);
- QmlList<QmlState *>* statesProperty();
+ QmlListProperty<QmlState> statesProperty();
QList<QmlState *> states() const;
- QmlList<QmlTransition *>* transitionsProperty();
+ QmlListProperty<QmlTransition> transitionsProperty();
QmlState *findState(const QString &name) const;
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index 35c8f7d..bd1f5f0 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -82,7 +82,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics
bool ok;
const QTransform &transform = target->itemTransform(targetParent, &ok);
if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(q) << QObject::tr("Unable to preserve appearance under complex transform");
+ qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under complex transform");
ok = false;
}
@@ -92,21 +92,21 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics
if (transform.m11() == transform.m22())
scale = transform.m11();
else {
- qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale");
+ qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
} else if (ok && transform.type() == QTransform::TxRotate) {
if (transform.m11() == transform.m22())
scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
else {
- qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale");
+ qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
if (scale != 0)
rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
else {
- qmlInfo(q) << QObject::tr("Unable to preserve appearance under scale of 0");
+ qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under scale of 0");
ok = false;
}
}
@@ -403,7 +403,7 @@ QString QmlStateChangeScript::typeName() const
so you can animate them as you would normally changes to these properties:
\qml
//animate our anchor changes
- NumberAnimation { matchTargets: content; matchProperties: "x,y,width,height" }
+ NumberAnimation { targets: content; properties: "x,y,width,height" }
\endqml
For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
diff --git a/src/declarative/util/qmlstateoperations_p.h b/src/declarative/util/qmlstateoperations_p.h
index 1a9f76f..dc1974b 100644
--- a/src/declarative/util/qmlstateoperations_p.h
+++ b/src/declarative/util/qmlstateoperations_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp
index 63f341e..1f31214 100644
--- a/src/declarative/util/qmlstyledtext.cpp
+++ b/src/declarative/util/qmlstyledtext.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h
index 502a4b5..4698279 100644
--- a/src/declarative/util/qmlstyledtext_p.h
+++ b/src/declarative/util/qmlstyledtext_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp
index 39d8f3e..cc4fb3e 100644
--- a/src/declarative/util/qmlsystempalette.cpp
+++ b/src/declarative/util/qmlsystempalette.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlsystempalette_p.h b/src/declarative/util/qmlsystempalette_p.h
index 7c39d4a..e25bf7f 100644
--- a/src/declarative/util/qmlsystempalette_p.h
+++ b/src/declarative/util/qmlsystempalette_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp
index 130e02d..5c5df40 100644
--- a/src/declarative/util/qmltimeline.cpp
+++ b/src/declarative/util/qmltimeline.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE
struct Update {
Update(QmlTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
- Update(const QmlTimeLineEvent &_e)
+ Update(const QmlTimeLineCallback &_e)
: g(0), v(0), e(_e) {}
QmlTimeLineValue *g;
qreal v;
- QmlTimeLineEvent e;
+ QmlTimeLineCallback e;
};
struct QmlTimeLinePrivate
@@ -79,7 +79,7 @@ struct QmlTimeLinePrivate
};
Op() {}
Op(Type t, int l, qreal v, qreal v2, int o,
- const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
+ const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
Op(const Op &o)
@@ -98,7 +98,7 @@ struct QmlTimeLinePrivate
qreal value2;
int order;
- QmlTimeLineEvent event;
+ QmlTimeLineCallback event;
QEasingCurve easing;
};
struct TimeLine
@@ -244,7 +244,7 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
}
case Op::Execute:
- op.event.execute();
+ op.event.d0(op.event.d1);
*changed = false;
return -1;
}
@@ -364,10 +364,10 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
/*!
Execute the \a event.
*/
-void QmlTimeLine::execute(const QmlTimeLineEvent &event)
+void QmlTimeLine::callback(const QmlTimeLineCallback &callback)
{
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
- d->add(*event.eventObject(), op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
+ d->add(*callback.callbackObject(), op);
}
/*!
@@ -466,7 +466,7 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int t
void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -488,7 +488,7 @@ void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time
void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -805,10 +805,11 @@ int QmlTimeLinePrivate::advance(int t)
updateQueue = &updates;
for (int ii = 0; ii < updates.count(); ++ii) {
const Update &v = updates.at(ii).second;
- if (v.g)
+ if (v.g) {
v.g->setValue(v.v);
- else
- v.e.execute();
+ } else {
+ v.e.d0(v.e.d1);
+ }
}
updateQueue = 0;
} while(t);
@@ -854,7 +855,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v)
if (d->updateQueue) {
for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
if (d->updateQueue->at(ii).second.g == v ||
- d->updateQueue->at(ii).second.e.eventObject() == v) {
+ d->updateQueue->at(ii).second.e.callbackObject() == v) {
d->updateQueue->removeAt(ii);
--ii;
}
@@ -910,17 +911,22 @@ QmlTimeLineObject::~QmlTimeLineObject()
}
}
-QmlTimeLineEvent::QmlTimeLineEvent()
+QmlTimeLineCallback::QmlTimeLineCallback()
: d0(0), d1(0), d2(0)
{
}
-QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
+QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d)
+: d0(f), d1(d), d2(b)
+{
+}
+
+QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o)
: d0(o.d0), d1(o.d1), d2(o.d2)
{
}
-QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
+QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o)
{
d0 = o.d0;
d1 = o.d1;
@@ -928,12 +934,7 @@ QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
return *this;
}
-void QmlTimeLineEvent::execute() const
-{
- d0(d1);
-}
-
-QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
+QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const
{
return d2;
}
diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h
index 09d46ba..076355d 100644
--- a/src/declarative/util/qmltimeline_p_p.h
+++ b/src/declarative/util/qmltimeline_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE
class QEasingCurve;
class QmlTimeLineValue;
-class QmlTimeLineEvent;
+class QmlTimeLineCallback;
struct QmlTimeLinePrivate;
class QmlTimeLineObject;
-class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
+class QmlTimeLine : public QAbstractAnimation
{
Q_OBJECT
public:
@@ -75,7 +75,7 @@ public:
void setSyncMode(SyncMode);
void pause(QmlTimeLineObject &, int);
- void execute(const QmlTimeLineEvent &);
+ void callback(const QmlTimeLineCallback &);
void set(QmlTimeLineValue &, qreal);
int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
@@ -117,7 +117,7 @@ private:
QmlTimeLinePrivate *d;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineObject
+class QmlTimeLineObject
{
public:
QmlTimeLineObject();
@@ -129,7 +129,7 @@ protected:
QmlTimeLine *_t;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
+class QmlTimeLineValue : public QmlTimeLineObject
{
public:
QmlTimeLineValue(qreal v = 0.) : _v(v) {}
@@ -147,44 +147,21 @@ private:
qreal _v;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
+class QmlTimeLineCallback
{
public:
- QmlTimeLineEvent();
- QmlTimeLineEvent(const QmlTimeLineEvent &o);
+ typedef void (*Callback)(void *);
- template<class T, void (T::*method)()>
- QmlTimeLineEvent(QmlTimeLineObject *b, T *c)
- {
- d0 = &callFunc<T, method>;
- d1 = (void *)c;
- d2 = b;
- }
-
- template<class T, void (T::*method)()>
- static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
- {
- QmlTimeLineEvent rv;
- rv.d0 = &callFunc<T, method>;
- rv.d1 = (void *)c;
- rv.d2 = b;
- return rv;
- }
+ QmlTimeLineCallback();
+ QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0);
+ QmlTimeLineCallback(const QmlTimeLineCallback &o);
- QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
- void execute() const;
- QmlTimeLineObject *eventObject() const;
+ QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o);
+ QmlTimeLineObject *callbackObject() const;
private:
- typedef void (*CallFunc)(void *c);
-
- template <class T, void (T::*method)()>
- static void callFunc(void *c)
- {
- T *cls = (T *)c;
- (cls->*method)();
- }
- CallFunc d0;
+ friend class QmlTimeLinePrivate;
+ Callback d0;
void *d1;
QmlTimeLineObject *d2;
};
diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp
index 046dfe9..d3a1a7c 100644
--- a/src/declarative/util/qmltimer.cpp
+++ b/src/declarative/util/qmltimer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmltimer_p.h b/src/declarative/util/qmltimer_p.h
index fcd6c84..d1c5ee5 100644
--- a/src/declarative/util/qmltimer_p.h
+++ b/src/declarative/util/qmltimer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index 215fc91..e90fc20 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -82,10 +82,11 @@ class QmlTransitionPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlTransition)
public:
- QmlTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*"))
- , reversed(false), reversible(false), endState(0)
+ QmlTransitionPrivate()
+ : fromState(QLatin1String("*")), toState(QLatin1String("*")),
+ reversed(false), reversible(false), endState(0)
{
- animations.parent = this;
+ group.trans = this;
}
QString fromState;
@@ -95,32 +96,20 @@ public:
ParallelAnimationWrapper group;
QmlTransitionManager *endState;
- void init()
- {
- group.trans = this;
- }
-
void complete()
{
endState->complete();
}
-
- class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
- {
- public:
- AnimationList() : parent(0) {}
- virtual void append(QmlAbstractAnimation *a);
- virtual void clear() { QmlConcreteList<QmlAbstractAnimation *>::clear(); } //###
-
- QmlTransitionPrivate *parent;
- };
- AnimationList animations;
+ static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a);
+ QList<QmlAbstractAnimation *> animations;
};
-void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
+void QmlTransitionPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
{
- QmlConcreteList<QmlAbstractAnimation *>::append(a);
- parent->group.addAnimation(a->qtAnimation());
+ QmlTransition *q = static_cast<QmlTransition *>(list->object);
+ q->d_func()->animations.append(a);
+ q->d_func()->group.addAnimation(a->qtAnimation());
+ a->setDisableUserControl();
}
void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
@@ -139,8 +128,6 @@ QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition)
QmlTransition::QmlTransition(QObject *parent)
: QObject(*(new QmlTransitionPrivate), parent)
{
- Q_D(QmlTransition);
- d->init();
}
QmlTransition::~QmlTransition()
@@ -250,10 +237,10 @@ void QmlTransition::setToState(const QString &t)
and assign that to animations the animations property.
\default
*/
-QmlList<QmlAbstractAnimation *>* QmlTransition::animations()
+QmlListProperty<QmlAbstractAnimation> QmlTransition::animations()
{
Q_D(QmlTransition);
- return &d->animations;
+ return QmlListProperty<QmlAbstractAnimation>(this, &d->animations, QmlTransitionPrivate::append_animation);
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qmltransition_p.h
index c1a6f66..ea02a33 100644
--- a/src/declarative/util/qmltransition_p.h
+++ b/src/declarative/util/qmltransition_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -65,7 +65,7 @@ class Q_DECLARATIVE_EXPORT QmlTransition : public QObject
Q_PROPERTY(QString from READ fromState WRITE setFromState)
Q_PROPERTY(QString to READ toState WRITE setToState)
Q_PROPERTY(bool reversible READ reversible WRITE setReversible)
- Q_PROPERTY(QmlList<QmlAbstractAnimation *>* animations READ animations)
+ Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
@@ -82,7 +82,7 @@ public:
bool reversible() const;
void setReversible(bool);
- QmlList<QmlAbstractAnimation *>* animations();
+ QmlListProperty<QmlAbstractAnimation> animations();
void prepare(QmlStateOperation::ActionList &actions,
QList<QmlMetaProperty> &after,
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
index a3a16ca..f2a4d64 100644
--- a/src/declarative/util/qmltransitionmanager.cpp
+++ b/src/declarative/util/qmltransitionmanager.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmltransitionmanager_p_p.h b/src/declarative/util/qmltransitionmanager_p_p.h
index cb4111c..19ee706 100644
--- a/src/declarative/util/qmltransitionmanager_p_p.h
+++ b/src/declarative/util/qmltransitionmanager_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 690924f..400ae52 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,6 +64,7 @@
#include <qboxlayout.h>
#include <qbasictimer.h>
#include <QtCore/qabstractanimation.h>
+#include <private/qgraphicsview_p.h>
QT_BEGIN_NAMESPACE
@@ -128,21 +129,22 @@ void FrameBreakAnimation::updateCurrentTime(int msecs)
class QmlViewPrivate
{
public:
- QmlViewPrivate(QmlView *w)
- : q(w), root(0), component(0), resizable(false) {}
+ QmlViewPrivate(QmlView *view)
+ : q(view), root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {}
QmlView *q;
- QmlGraphicsItem *root;
+
+ QGuard<QGraphicsObject> root;
+ QGuard<QmlGraphicsItem> qmlRoot;
QUrl source;
- QString qml;
QmlEngine engine;
QmlComponent *component;
QBasicTimer resizetimer;
- QSize initialSize;
- bool resizable;
+ mutable QSize initialSize;
+ QmlView::ResizeMode resizeMode;
QTime frameTimer;
void init();
@@ -154,9 +156,30 @@ public:
\class QmlView
\brief The QmlView class provides a widget for displaying a Qt Declarative user interface.
- QmlView currently provides a minimal interface for displaying QML
+ Any QGraphicsObject or QmlGraphicsItem
+ created via QML can be placed on a standard QGraphicsScene and viewed with a standard
+ QGraphicsView.
+
+ QmlView is a QGraphicsView subclass provided as a convenience for displaying QML
files, and connecting between QML and C++ Qt objects.
+ QmlView performs the following functions:
+
+ \list
+ \o Manages QmlComponent loading and object creation.
+ \o Initializes QGraphicsView for optimal performance with QML:
+ \list
+ \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
+ \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
+ \endlist
+ \o Initializes QGraphicsView for QML key handling:
+ \list
+ \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsScene::setStickyFocus(true);
+ \endlist
+ \endlist
+
Typical usage:
\code
...
@@ -164,7 +187,7 @@ public:
vbox->addWidget(view);
QUrl url(fileName);
- view->setUrl(url);
+ view->setSource(url);
...
view->execute();
...
@@ -172,7 +195,17 @@ public:
\endcode
To receive errors related to loading and executing QML with QmlView,
- you can connect to the errors() signal.
+ you can connect to the statusChanged() signal and monitor for QmlView::Error.
+ The errors are available via QmlView::errors().
+*/
+
+
+/*! \fn void QmlView::sceneResized(QSize size)
+ This signal is emitted when the view is resized to \a size.
+*/
+
+/*! \fn void QmlView::statusChanged(QmlView::Status status)
+ This signal is emitted when the component's current \l{QmlView::Status} {status} changes.
*/
/*!
@@ -212,56 +245,37 @@ void QmlViewPrivate::init()
}
/*!
- The destructor clears the view's \l {QmlGraphicsItem} {items} and
+ The destructor clears the view's \l {QGraphicsObject} {items} and
deletes the internal representation.
-
- \sa clearItems()
*/
QmlView::~QmlView()
{
- clearItems();
- delete d; d = 0;
+ delete d->root;
}
/*!
- Sets the source to the \a url. The QML string is set to
- empty.
+ Sets the source to the \a url.
+
+ Call \l execute() to load the QML and instantiate the component.
+
+ \sa execute()
*/
-void QmlView::setUrl(const QUrl& url)
+void QmlView::setSource(const QUrl& url)
{
d->source = url;
- d->qml = QString();
}
/*!
Returns the source URL, if set.
- \sa setUrl()
+ \sa setSource()
*/
-QUrl QmlView::url() const
+QUrl QmlView::source() const
{
return d->source;
}
/*!
- Sets the source to the URL from the \a filename, and sets
- the QML string to \a qml.
- */
-void QmlView::setQml(const QString &qml, const QString &filename)
-{
- d->source = QUrl::fromLocalFile(filename);
- d->qml = qml;
-}
-
-/*!
- Returns the QML string.
- */
-QString QmlView::qml() const
-{
- return d->qml;
-}
-
-/*!
Returns a pointer to the QmlEngine used for instantiating
QML Components.
*/
@@ -283,17 +297,15 @@ QmlContext* QmlView::rootContext()
}
/*!
- Displays the Qt Declarative user interface.
+ Loads and instantiates the QML component set by the \l setSource() method.
+
+ \sa setSource()
*/
void QmlView::execute()
{
- if (d->qml.isEmpty()) {
- d->component = new QmlComponent(&d->engine, d->source, this);
- } else {
- d->component = new QmlComponent(&d->engine, this);
- d->component->setData(d->qml.toUtf8(), d->source);
- }
- connect (&d->engine, SIGNAL (quit ()), this, SIGNAL (quit ()));
+ delete d->root;
+ delete d->component;
+ d->component = new QmlComponent(&d->engine, d->source, this);
if (!d->component->isLoading()) {
continueExecute();
@@ -302,26 +314,95 @@ void QmlView::execute()
}
}
+/*!
+ \enum QmlView::Status
+
+ Specifies the loading status of the QmlView.
+
+ \value Null This QmlView has no source set.
+ \value Ready This QmlView has loaded and created the QML component.
+ \value Loading This QmlView is loading network data.
+ \value Error An error has occured. Calling errorDescription() to retrieve a description.
+*/
+
+/*!
+ \property QmlView::status
+ The component's current \l{QmlView::Status} {status}.
+*/
+
+QmlView::Status QmlView::status() const
+{
+ if (!d->component)
+ return QmlView::Null;
+
+ return QmlView::Status(d->component->status());
+}
+
+/*!
+ Return the list of errors that occured during the last compile or create
+ operation. An empty list is returned if isError() is not set.
+*/
+QList<QmlError> QmlView::errors() const
+{
+ if (d->component)
+ return d->component->errors();
+ return QList<QmlError>();
+}
+
+
+/*!
+ \property QmlView::resizeMode
+ \brief whether the view should resize the canvas contents
+
+ If this property is set to SizeViewToRootObject (the default), the view
+ resizes with the root item in the QML.
+
+ If this property is set to SizeRootObjectToView, the view will
+ automatically resize the root item.
+
+ Regardless of this property, the sizeHint of the view
+ is the initial size of the root item. Note though that
+ since QML may load dynamically, that size may change.
+
+ \sa initialSize()
+*/
+
+void QmlView::setResizeMode(ResizeMode mode)
+{
+ if (d->resizeMode == mode)
+ return;
+
+ d->resizeMode = mode;
+ if (d->qmlRoot) {
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ } else {
+ d->qmlRoot->setWidth(d->initialSize.width());
+ d->qmlRoot->setHeight(d->initialSize.height());
+ }
+ }
+}
+
+QmlView::ResizeMode QmlView::resizeMode() const
+{
+ return d->resizeMode;
+}
/*!
\internal
*/
void QmlView::continueExecute()
{
- disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- if (!d->component) {
- qWarning() << "Error in loading" << d->source;
- return;
- }
+ disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- if(d->component->isError()) {
+ if (d->component->isError()) {
QList<QmlError> errorList = d->component->errors();
foreach (const QmlError &error, errorList) {
qWarning() << error;
}
- emit errors(errorList);
-
+ emit statusChanged(status());
return;
}
@@ -332,8 +413,7 @@ void QmlView::continueExecute()
foreach (const QmlError &error, errorList) {
qWarning() << error;
}
- emit errors(errorList);
-
+ emit statusChanged(status());
return;
}
@@ -345,24 +425,27 @@ void QmlView::continueExecute()
QPerformanceLog::displayData();
QPerformanceLog::clear();
d->root = item;
+ d->qmlRoot = item;
connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
- if (d->initialSize.height() <= 0 && d->root->width() > 0)
- d->initialSize.setWidth(d->root->width());
- if (d->initialSize.height() <= 0 && d->root->height() > 0)
- d->initialSize.setHeight(d->root->height());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
+ d->initialSize.setWidth(d->qmlRoot->width());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
+ d->initialSize.setHeight(d->qmlRoot->height());
resize(d->initialSize);
- if (d->resizable) {
- d->root->setWidth(width());
- d->root->setHeight(height());
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
} else {
- QSize sz(d->root->width(),d->root->height());
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
emit sceneResized(sz);
resize(sz);
}
updateGeometry();
- emit initialSize(d->initialSize);
+ } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
+ d->scene.addItem(item);
+ qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject";
} else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
window()->setAttribute(Qt::WA_NoSystemBackground, false);
@@ -377,23 +460,11 @@ void QmlView::continueExecute()
}
layout()->addWidget(wid);
emit sceneResized(wid->size());
- emit initialSize(wid->size());
}
}
+ emit statusChanged(status());
}
-/*! \fn void QmlView::sceneResized(QSize size)
- This signal is emitted when the view is resized to \a size.
- */
-
-/*! \fn void QmlView::initialSize(QSize size)
- This signal is emitted when the initial \a size of the root item is known.
- */
-
-/*! \fn void QmlView::errors(const QList<QmlError> &errors)
- This signal is emitted when the qml loaded contains \a errors.
- */
-
/*!
\internal
*/
@@ -404,14 +475,15 @@ void QmlView::sizeChanged()
}
/*!
+ \internal
If the \l {QTimerEvent} {timer event} \a e is this
view's resize timer, sceneResized() is emitted.
*/
void QmlView::timerEvent(QTimerEvent* e)
{
if (!e || e->timerId() == d->resizetimer.timerId()) {
- if (d->root) {
- QSize sz(d->root->width(),d->root->height());
+ if (d->qmlRoot) {
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
emit sceneResized(sz);
//if (!d->resizable)
//resize(sz);
@@ -421,147 +493,44 @@ void QmlView::timerEvent(QTimerEvent* e)
}
}
-// modelled on QScrollArea::widgetResizable
-/*!
- \property QmlView::contentResizable
- \brief whether the view should resize the canvas contents
-
- If this property is set to false (the default), the view
- resizes with the root item in the QML.
-
- If this property is set to true, the view will
- automatically resize the root item.
-
- Regardless of this property, the sizeHint of the view
- is the initial size of the root item. Note though that
- since QML may load dynamically, that size may change.
-
- \sa initialSize()
-*/
-
-void QmlView::setContentResizable(bool on)
-{
- if (d->resizable != on) {
- d->resizable = on;
- if (d->root) {
- if (on) {
- d->root->setWidth(width());
- d->root->setHeight(height());
- } else {
- d->root->setWidth(d->initialSize.width());
- d->root->setHeight(d->initialSize.height());
- }
- }
- }
-}
-
-bool QmlView::contentResizable() const
-{
- return d->resizable;
-}
-
-
/*!
+ \internal
The size hint is the size of the root item.
*/
QSize QmlView::sizeHint() const
{
- if (d->root) {
+ if (d->qmlRoot) {
if (d->initialSize.width() <= 0)
- d->initialSize.setWidth(d->root->width());
+ d->initialSize.setWidth(d->qmlRoot->width());
if (d->initialSize.height() <= 0)
- d->initialSize.setHeight(d->root->height());
+ d->initialSize.setHeight(d->qmlRoot->height());
}
return d->initialSize;
}
/*!
- Creates a \l{QmlComponent} {component} from the \a qml
- string, and returns it as an \l {QmlGraphicsItem} {item}. If the
- \a parent item is provided, it becomes the new item's
- parent. \a parent should be in this view's item hierarchy.
+ Returns the view's root \l {QGraphicsObject} {item}.
*/
-QmlGraphicsItem* QmlView::addItem(const QString &qml, QmlGraphicsItem* parent)
-{
- if (!d->root)
- return 0;
-
- QmlComponent component(&d->engine);
- component.setData(qml.toUtf8(), QUrl());
- if(d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit errors(errorList);
-
- return 0;
- }
-
- QObject *obj = component.create();
- if(d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit errors(errorList);
-
- return 0;
- }
-
- if (obj){
- QmlGraphicsItem *item = static_cast<QmlGraphicsItem *>(obj);
- if (!parent)
- parent = d->root;
-
- item->setParentItem(parent);
- return item;
- }
- return 0;
-}
-
-/*!
- Deletes the view's \l {QmlGraphicsItem} {items} and clears the \l {QmlEngine}
- {QML engine's} Component cache.
- */
-void QmlView::reset()
-{
- clearItems();
- d->engine.clearComponentCache();
- d->initialSize = QSize();
-}
-
-/*!
- Deletes the view's \l {QmlGraphicsItem} {items}.
- */
-void QmlView::clearItems()
-{
- if (!d->root)
- return;
- delete d->root;
- d->root = 0;
-}
-
-/*!
- Returns the view's root \l {QmlGraphicsItem} {item}.
- */
-QmlGraphicsItem *QmlView::root() const
+QGraphicsObject *QmlView::rootObject() const
{
return d->root;
}
/*!
+ \internal
This function handles the \l {QResizeEvent} {resize event}
\a e.
*/
void QmlView::resizeEvent(QResizeEvent *e)
{
- if (d->resizable && d->root) {
- d->root->setWidth(width());
- d->root->setHeight(height());
+ if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
}
- if (d->root) {
- setSceneRect(QRectF(0, 0, d->root->width(), d->root->height()));
+ if (d->qmlRoot) {
+ setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height()));
+ } else if (d->root) {
+ setSceneRect(d->root->boundingRect());
} else {
setSceneRect(rect());
}
@@ -569,7 +538,7 @@ void QmlView::resizeEvent(QResizeEvent *e)
}
/*!
- \reimp
+ \internal
*/
void QmlView::paintEvent(QPaintEvent *event)
{
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
index f4f58fd..1d6ef1c 100644
--- a/src/declarative/util/qmlview.h
+++ b/src/declarative/util/qmlview.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFXVIEW_H
-#define QFXVIEW_H
+#ifndef QMLVIEW_H
+#define QMLVIEW_H
#include <QtCore/qdatetime.h>
#include <QtGui/qgraphicssceneevent.h>
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlGraphicsItem;
+class QGraphicsObject;
class QmlEngine;
class QmlContext;
class QmlError;
@@ -62,35 +62,36 @@ class QmlViewPrivate;
class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView
{
Q_OBJECT
- Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
public:
explicit QmlView(QWidget *parent = 0);
-
virtual ~QmlView();
- void setUrl(const QUrl&);
- QUrl url() const;
- void setQml(const QString &qml, const QString &filename=QString());
- QString qml() const;
+ QUrl source() const;
+ void setSource(const QUrl&);
+
QmlEngine* engine();
QmlContext* rootContext();
- virtual void execute();
- virtual void reset();
+ void execute();
+
+ QGraphicsObject *rootObject() const;
+
+ enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode);
- virtual QmlGraphicsItem* addItem(const QString &qml, QmlGraphicsItem* parent=0);
- virtual void clearItems();
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
- virtual QmlGraphicsItem *root() const;
+ QList<QmlError> errors() const;
- void setContentResizable(bool);
- bool contentResizable() const;
QSize sizeHint() const;
Q_SIGNALS:
- void initialSize(QSize size);
- void sceneResized(QSize size);
- void errors(const QList<QmlError> &error);
- void quit ();
+ void sceneResized(QSize size); // ???
+ void statusChanged(QmlView::Status);
private Q_SLOTS:
void continueExecute();
@@ -101,8 +102,6 @@ protected:
virtual void paintEvent(QPaintEvent *event);
void timerEvent(QTimerEvent*);
-private:
- friend class QmlViewPrivate;
QmlViewPrivate *d;
};
@@ -110,4 +109,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QFXVIEW_H
+#endif // QMLVIEW_H
diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp
index 5de4d6f..7e66576 100644
--- a/src/declarative/util/qmlxmllistmodel.cpp
+++ b/src/declarative/util/qmlxmllistmodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -148,19 +148,6 @@ QML_DECLARE_TYPE(QmlXmlListModelRole)
QT_BEGIN_NAMESPACE
-class QmlXmlListModelPrivate;
-struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
-{
- QmlXmlRoleList(QmlXmlListModelPrivate *p)
- : model(p) {}
- virtual void append(QmlXmlListModelRole *role);
- virtual void clear();
- virtual void removeAt(int i);
- virtual void insert(int i, QmlXmlListModelRole *role);
-
- QmlXmlListModelPrivate *model;
-};
-
class QmlXmlQuery : public QThread
{
Q_OBJECT
@@ -182,7 +169,7 @@ public:
m_abort = true;
}
- int doQuery(QString query, QString namespaces, QByteArray data, QmlXmlRoleList *roleObjects) {
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QmlXmlListModelRole *> *roleObjects) {
QMutexLocker locker(&m_mutex);
m_size = 0;
m_data = data;
@@ -257,7 +244,7 @@ private:
QString m_prefix;
int m_size;
int m_queryId;
- const QmlXmlRoleList *m_roleObjects;
+ const QList<QmlXmlListModelRole *> *m_roleObjects;
QList<QList<QVariant> > m_modelData;
QStringList m_keysValues;
QList<QmlXmlListRange> m_insertedItemRanges;
@@ -441,7 +428,7 @@ public:
QmlXmlListModelPrivate()
: isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
, reply(0), status(QmlXmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects(this) {}
+ , queryId(-1), roleObjects() {}
bool isComponentComplete;
QUrl src;
@@ -457,42 +444,39 @@ public:
qreal progress;
QmlXmlQuery qmlXmlQuery;
int queryId;
- QmlXmlRoleList roleObjects;
+ QList<QmlXmlListModelRole *> roleObjects;
+ static void append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role);
+ static void clear_role(QmlListProperty<QmlXmlListModelRole> *list);
+ static void removeAt_role(QmlListProperty<QmlXmlListModelRole> *list, int i);
+ static void insert_role(QmlListProperty<QmlXmlListModelRole> *list, int i, QmlXmlListModelRole *role);
QList<QList<QVariant> > data;
};
-void QmlXmlRoleList::append(QmlXmlListModelRole *role)
+void QmlXmlListModelPrivate::append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role)
{
- insert(size(), role);
+ QmlXmlListModel *_this = qobject_cast<QmlXmlListModel *>(list->object);
+ if (_this) {
+ int i = _this->d_func()->roleObjects.count();
+ _this->d_func()->roleObjects.append(role);
+ if (_this->d_func()->roleNames.contains(role->name())) {
+ qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
+ return;
+ }
+ _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
+ _this->d_func()->roleNames.insert(i, role->name());
+ ++_this->d_func()->highestRole;
+ }
}
-//### clear, removeAt, and insert need to invalidate any cached data (in data table) as well
+//### clear needs to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
-void QmlXmlRoleList::clear()
+void QmlXmlListModelPrivate::clear_role(QmlListProperty<QmlXmlListModelRole> *list)
{
- model->roles.clear();
- model->roleNames.clear();
- QmlConcreteList<QmlXmlListModelRole *>::clear();
-}
-
-void QmlXmlRoleList::removeAt(int i)
-{
- model->roles.removeAt(i);
- model->roleNames.removeAt(i);
- QmlConcreteList<QmlXmlListModelRole *>::removeAt(i);
-}
-
-void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role)
-{
- QmlConcreteList<QmlXmlListModelRole *>::insert(i, role);
- if (model->roleNames.contains(role->name())) {
- qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
- return;
- }
- model->roles.insert(i, model->highestRole);
- model->roleNames.insert(i, role->name());
- ++model->highestRole;
+ QmlXmlListModel *_this = static_cast<QmlXmlListModel *>(list->object);
+ _this->d_func()->roles.clear();
+ _this->d_func()->roleNames.clear();
+ _this->d_func()->roleObjects.clear();
}
/*!
@@ -555,10 +539,13 @@ QmlXmlListModel::~QmlXmlListModel()
The roles to make available for this model.
*/
-QmlList<QmlXmlListModelRole *> *QmlXmlListModel::roleObjects()
+QmlListProperty<QmlXmlListModelRole> QmlXmlListModel::roleObjects()
{
Q_D(QmlXmlListModel);
- return &d->roleObjects;
+ QmlListProperty<QmlXmlListModelRole> list(this, d->roleObjects);
+ list.append = &QmlXmlListModelPrivate::append_role;
+ list.clear = &QmlXmlListModelPrivate::clear_role;
+ return list;
}
QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) const
@@ -662,7 +649,7 @@ void QmlXmlListModel::setQuery(const QString &query)
{
Q_D(QmlXmlListModel);
if (!query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << tr("An XmlListModel query must start with '/' or \"//\"");
+ qmlInfo(this) << QCoreApplication::translate("QmlXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
return;
}
diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qmlxmllistmodel_p.h
index e4b8cab..a6627e2 100644
--- a/src/declarative/util/qmlxmllistmodel_p.h
+++ b/src/declarative/util/qmlxmllistmodel_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString xml READ xml WRITE setXml)
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
- Q_PROPERTY(QmlList<QmlXmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(QmlListProperty<QmlXmlListModelRole> roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -84,7 +84,7 @@ public:
virtual QList<int> roles() const;
virtual QString toString(int role) const;
- QmlList<QmlXmlListModelRole *> *roleObjects();
+ QmlListProperty<QmlXmlListModelRole> roleObjects();
QUrl source() const;
void setSource(const QUrl&);
diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp
index fd44db1..42c12fe 100644
--- a/src/declarative/util/qnumberformat.cpp
+++ b/src/declarative/util/qnumberformat.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qnumberformat_p.h b/src/declarative/util/qnumberformat_p.h
index c73ef8a..902dcde 100644
--- a/src/declarative/util/qnumberformat_p.h
+++ b/src/declarative/util/qnumberformat_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp
index 2f91dfb..83cc919 100644
--- a/src/declarative/util/qperformancelog.cpp
+++ b/src/declarative/util/qperformancelog.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qperformancelog_p_p.h b/src/declarative/util/qperformancelog_p_p.h
index e7a3b5e..a212f28 100644
--- a/src/declarative/util/qperformancelog_p_p.h
+++ b/src/declarative/util/qperformancelog_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**