diff options
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativeanimation.cpp (renamed from src/declarative/util/qmlanimation.cpp) | 918 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation_p.h (renamed from src/declarative/util/qmlanimation_p.h) | 257 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation_p_p.h (renamed from src/declarative/util/qmlanimation_p_p.h) | 131 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebehavior.cpp (renamed from src/declarative/util/qmlbehavior.cpp) | 69 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebehavior_p.h (renamed from src/declarative/util/qmlbehavior_p.h) | 38 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebind.cpp (renamed from src/declarative/util/qmlbind.cpp) | 73 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebind_p.h (renamed from src/declarative/util/qmlbind_p.h) | 20 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeconnection.cpp (renamed from src/declarative/util/qmlconnection.cpp) | 75 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeconnection_p.h (renamed from src/declarative/util/qmlconnection_p.h) | 32 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativedatetimeformatter.cpp (renamed from src/declarative/util/qmldatetimeformatter.cpp) | 102 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativedatetimeformatter_p.h (renamed from src/declarative/util/qmldatetimeformatter_p.h) | 22 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeeasefollow.cpp (renamed from src/declarative/util/qmleasefollow.cpp) | 98 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeeasefollow_p.h (renamed from src/declarative/util/qmleasefollow_p.h) | 30 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativefontloader.cpp (renamed from src/declarative/util/qmlfontloader.cpp) | 61 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativefontloader_p.h (renamed from src/declarative/util/qmlfontloader_p.h) | 21 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistaccessor.cpp (renamed from src/declarative/util/qmllistaccessor.cpp) | 34 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistaccessor_p.h (renamed from src/declarative/util/qmllistaccessor_p.h) | 16 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp (renamed from src/declarative/util/qmllistmodel.cpp) | 155 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel_p.h (renamed from src/declarative/util/qmllistmodel_p.h) | 50 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativenullablevalue_p_p.h (renamed from src/declarative/util/qmlnullablevalue_p_p.h) | 18 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativenumberformatter.cpp (renamed from src/declarative/util/qmlnumberformatter.cpp) | 52 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativenumberformatter_p.h (renamed from src/declarative/util/qmlnumberformatter_p.h) | 22 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeopenmetaobject.cpp (renamed from src/declarative/util/qmlopenmetaobject.cpp) | 94 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeopenmetaobject_p.h (renamed from src/declarative/util/qmlopenmetaobject_p.h) | 40 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepackage.cpp (renamed from src/declarative/util/qmlpackage.cpp) | 113 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepackage_p.h (renamed from src/declarative/util/qmlpackage_p.h) | 46 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache.cpp (renamed from src/declarative/util/qmlpixmapcache.cpp) | 311 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache_p.h (renamed from src/declarative/util/qmlpixmapcache_p.h) | 34 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertychanges.cpp (renamed from src/declarative/util/qmlpropertychanges.cpp) | 221 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertychanges_p.h (renamed from src/declarative/util/qmlpropertychanges_p.h) | 31 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertymap.cpp (renamed from src/declarative/util/qmlpropertymap.cpp) | 88 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertymap.h (renamed from src/declarative/util/qmlpropertymap.h) | 16 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativespringfollow.cpp (renamed from src/declarative/util/qmlspringfollow.cpp) | 114 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativespringfollow_p.h (renamed from src/declarative/util/qmlspringfollow_p.h) | 28 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate.cpp (renamed from src/declarative/util/qmlstate.cpp) | 198 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate_p.h (renamed from src/declarative/util/qmlstate_p.h) | 90 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate_p_p.h (renamed from src/declarative/util/qmlstate_p_p.h) | 59 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestategroup.cpp (renamed from src/declarative/util/qmlstategroup.cpp) | 130 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestategroup_p.h (renamed from src/declarative/util/qmlstategroup_p.h) | 38 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations.cpp (renamed from src/declarative/util/qmlstateoperations.cpp) | 470 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations_p.h | 184 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestyledtext.cpp (renamed from src/declarative/util/qmlstyledtext.cpp) | 70 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestyledtext_p.h (renamed from src/declarative/util/qmlstyledtext_p.h) | 15 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativesystempalette.cpp (renamed from src/declarative/util/qmlsystempalette.cpp) | 90 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativesystempalette_p.h (renamed from src/declarative/util/qmlsystempalette_p.h) | 26 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetimeline.cpp (renamed from src/declarative/util/qmltimeline.cpp) | 230 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetimeline_p_p.h (renamed from src/declarative/util/qmltimeline_p_p.h) | 104 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetimer.cpp (renamed from src/declarative/util/qmltimer.cpp) | 80 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetimer_p.h (renamed from src/declarative/util/qmltimer_p.h) | 18 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetransition.cpp (renamed from src/declarative/util/qmltransition.cpp) | 98 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetransition_p.h (renamed from src/declarative/util/qmltransition_p.h) | 36 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetransitionmanager.cpp (renamed from src/declarative/util/qmltransitionmanager.cpp) | 83 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativetransitionmanager_p_p.h (renamed from src/declarative/util/qmltransitionmanager_p_p.h) | 30 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeutilmodule.cpp | 120 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeutilmodule_p.h | 63 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeview.cpp (renamed from src/declarative/util/qmlview.cpp) | 310 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeview.h (renamed from src/declarative/util/qmlview.h) | 36 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel.cpp (renamed from src/declarative/util/qmlxmllistmodel.cpp) | 376 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel_p.h (renamed from src/declarative/util/qmlxmllistmodel_p.h) | 74 | ||||
-rw-r--r-- | src/declarative/util/qfxperf.cpp | 22 | ||||
-rw-r--r-- | src/declarative/util/qfxperf_p_p.h | 8 | ||||
-rw-r--r-- | src/declarative/util/qmlstateoperations_p.h | 184 | ||||
-rw-r--r-- | src/declarative/util/qnumberformat.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qnumberformat_p.h | 2 | ||||
-rw-r--r-- | src/declarative/util/util.pri | 116 |
65 files changed, 3567 insertions, 3226 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1be95df..264b88c 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -39,18 +39,20 @@ ** ****************************************************************************/ -#include "qmlanimation_p.h" -#include "qmlanimation_p_p.h" +#include "qdeclarativeanimation_p.h" +#include "qdeclarativeanimation_p_p.h" -#include "qmlbehavior_p.h" -#include "qmlstateoperations_p.h" +#include "qdeclarativebehavior_p.h" +#include "qdeclarativestateoperations_p.h" -#include <qmlpropertyvaluesource.h> -#include <qml.h> -#include <qmlinfo.h> -#include <qmlexpression.h> -#include <qmlstringconverters_p.h> -#include <qmlglobal_p.h> +#include <qdeclarativepropertyvaluesource.h> +#include <qdeclarative.h> +#include <qdeclarativeinfo.h> +#include <qdeclarativeexpression.h> +#include <qdeclarativestringconverters_p.h> +#include <qdeclarativeglobal_p.h> +#include <qdeclarativemetatype_p.h> +#include <qdeclarativeproperty_p.h> #include <qvariant.h> #include <qcolor.h> @@ -66,83 +68,8 @@ QT_BEGIN_NAMESPACE -static QEasingCurve stringToCurve(const QString &curve, QObject *obj) -{ - QEasingCurve easingCurve; - - QString normalizedCurve = curve; - bool hasParams = curve.contains(QLatin1Char('(')); - QStringList props; - - if (hasParams) { - QString easeName = curve.trimmed(); - if (!easeName.endsWith(QLatin1Char(')'))) { - qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); - return easingCurve; - } - - int idx = easeName.indexOf(QLatin1Char('(')); - QString prop_str = - easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); - normalizedCurve = easeName.left(idx); - if (!normalizedCurve.startsWith(QLatin1String("ease"))) { - qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve); - return easingCurve; - } - - props = prop_str.split(QLatin1Char(',')); - } - - if (normalizedCurve.startsWith(QLatin1String("ease"))) - normalizedCurve = normalizedCurve.mid(4); - - static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); - static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); - - int value = me.keyToValue(normalizedCurve.toUtf8().constData()); - if (value < 0) { - qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve); - return easingCurve; - } - easingCurve.setType((QEasingCurve::Type)value); - - if (hasParams) { - foreach(const QString &str, props) { - int sep = str.indexOf(QLatin1Char(':')); - - if (sep == -1) { - qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); - continue; - } - - QString propName = str.left(sep).trimmed(); - bool isOk; - qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk); - - if (propName.isEmpty() || !isOk) { - qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); - continue; - } - - if (propName == QLatin1String("amplitude")) { - easingCurve.setAmplitude(propValue); - } else if (propName == QLatin1String("period")) { - easingCurve.setPeriod(propValue); - } else if (propName == QLatin1String("overshoot")) { - easingCurve.setOvershoot(propValue); - } else { - qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName); - continue; - } - } - } - return easingCurve; -} - -QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation) - /*! - \qmlclass Animation QmlAbstractAnimation + \qmlclass Animation QDeclarativeAbstractAnimation \since 4.7 \brief The Animation element is the base of all QML animations. @@ -153,20 +80,20 @@ QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation) */ /*! - \class QmlAbstractAnimation + \class QDeclarativeAbstractAnimation \internal */ -QmlAbstractAnimation::QmlAbstractAnimation(QObject *parent) -: QObject(*(new QmlAbstractAnimationPrivate), parent) +QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QObject *parent) +: QObject(*(new QDeclarativeAbstractAnimationPrivate), parent) { } -QmlAbstractAnimation::~QmlAbstractAnimation() +QDeclarativeAbstractAnimation::~QDeclarativeAbstractAnimation() { } -QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObject *parent) +QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent) : QObject(dd, parent) { } @@ -205,21 +132,21 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj By default, animations are not running. Though, when the animations are assigned to properties, as property value sources, they are set to running by default. */ -bool QmlAbstractAnimation::isRunning() const +bool QDeclarativeAbstractAnimation::isRunning() const { - Q_D(const QmlAbstractAnimation); + Q_D(const QDeclarativeAbstractAnimation); 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() +void QDeclarativeAbstractAnimationPrivate::commence() { - Q_Q(QmlAbstractAnimation); + Q_Q(QDeclarativeAbstractAnimation); - QmlStateActions actions; - QmlMetaProperties properties; - q->transition(actions, properties, QmlAbstractAnimation::Forward); + QDeclarativeStateActions actions; + QDeclarativeProperties properties; + q->transition(actions, properties, QDeclarativeAbstractAnimation::Forward); q->qtAnimation()->start(); if (q->qtAnimation()->state() != QAbstractAnimation::Running) { @@ -228,22 +155,22 @@ void QmlAbstractAnimationPrivate::commence() } } -QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) +QDeclarativeProperty QDeclarativeAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) { - QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj)); + QDeclarativeProperty prop(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { - qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); - return QmlMetaProperty(); + qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); + return QDeclarativeProperty(); } else if (!prop.isWritable()) { - qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); - return QmlMetaProperty(); + qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); + return QDeclarativeProperty(); } return prop; } -void QmlAbstractAnimation::setRunning(bool r) +void QDeclarativeAbstractAnimation::setRunning(bool r) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); if (!d->componentComplete) { d->running = r; if (r == false) @@ -255,7 +182,7 @@ void QmlAbstractAnimation::setRunning(bool r) return; if (d->group || d->disableUserControl) { - qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + qWarning("QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); return; } @@ -298,20 +225,20 @@ void QmlAbstractAnimation::setRunning(bool r) By default, animations are not paused. */ -bool QmlAbstractAnimation::isPaused() const +bool QDeclarativeAbstractAnimation::isPaused() const { - Q_D(const QmlAbstractAnimation); + Q_D(const QDeclarativeAbstractAnimation); return d->paused; } -void QmlAbstractAnimation::setPaused(bool p) +void QDeclarativeAbstractAnimation::setPaused(bool p) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); if (d->paused == p) return; if (d->group || d->disableUserControl) { - qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); + qWarning("QDeclarativeAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); return; } @@ -324,15 +251,15 @@ void QmlAbstractAnimation::setPaused(bool p) emit pausedChanged(d->paused); } -void QmlAbstractAnimation::classBegin() +void QDeclarativeAbstractAnimation::classBegin() { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); d->componentComplete = false; } -void QmlAbstractAnimation::componentComplete() +void QDeclarativeAbstractAnimation::componentComplete() { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); d->componentComplete = true; if (d->running) { d->running = false; @@ -354,15 +281,15 @@ void QmlAbstractAnimation::componentComplete() By default, the alwaysRunToEnd property is not set. */ -bool QmlAbstractAnimation::alwaysRunToEnd() const +bool QDeclarativeAbstractAnimation::alwaysRunToEnd() const { - Q_D(const QmlAbstractAnimation); + Q_D(const QDeclarativeAbstractAnimation); return d->alwaysRunToEnd; } -void QmlAbstractAnimation::setAlwaysRunToEnd(bool f) +void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); if (d->alwaysRunToEnd == f) return; @@ -386,15 +313,15 @@ void QmlAbstractAnimation::setAlwaysRunToEnd(bool f) } \endcode */ -bool QmlAbstractAnimation::repeat() const +bool QDeclarativeAbstractAnimation::repeat() const { - Q_D(const QmlAbstractAnimation); + Q_D(const QDeclarativeAbstractAnimation); return d->repeat; } -void QmlAbstractAnimation::setRepeat(bool r) +void QDeclarativeAbstractAnimation::setRepeat(bool r) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); if (r == d->repeat) return; @@ -404,34 +331,34 @@ void QmlAbstractAnimation::setRepeat(bool r) emit repeatChanged(r); } -int QmlAbstractAnimation::currentTime() +int QDeclarativeAbstractAnimation::currentTime() { return qtAnimation()->currentLoopTime(); } -void QmlAbstractAnimation::setCurrentTime(int time) +void QDeclarativeAbstractAnimation::setCurrentTime(int time) { qtAnimation()->setCurrentTime(time); } -QmlAnimationGroup *QmlAbstractAnimation::group() const +QDeclarativeAnimationGroup *QDeclarativeAbstractAnimation::group() const { - Q_D(const QmlAbstractAnimation); + Q_D(const QDeclarativeAbstractAnimation); return d->group; } -void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g) +void QDeclarativeAbstractAnimation::setGroup(QDeclarativeAnimationGroup *g) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); if (d->group == g) return; if (d->group) - static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this); + static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this); d->group = g; - if (d->group && !static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this)) - static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.append(this); + if (d->group && !static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this)) + static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.append(this); if (d->group) ((QAnimationGroup*)d->group->qtAnimation())->addAnimation(qtAnimation()); @@ -447,7 +374,7 @@ void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g) If the animation is already running, calling this method has no effect. The \c running property will be true following a call to \c start(). */ -void QmlAbstractAnimation::start() +void QDeclarativeAbstractAnimation::start() { setRunning(true); } @@ -459,7 +386,7 @@ void QmlAbstractAnimation::start() If the animation is already paused, calling this method has no effect. The \c paused property will be true following a call to \c pause(). */ -void QmlAbstractAnimation::pause() +void QDeclarativeAbstractAnimation::pause() { setPaused(true); } @@ -471,7 +398,7 @@ void QmlAbstractAnimation::pause() If the animation is not paused, calling this method has no effect. The \c paused property will be false following a call to \c resume(). */ -void QmlAbstractAnimation::resume() +void QDeclarativeAbstractAnimation::resume() { setPaused(false); } @@ -496,7 +423,7 @@ void QmlAbstractAnimation::resume() continue running until it completes and then stop. The \c running property will still become false immediately. */ -void QmlAbstractAnimation::stop() +void QDeclarativeAbstractAnimation::stop() { setRunning(false); } @@ -508,7 +435,7 @@ void QmlAbstractAnimation::stop() This is a convenience method, and is equivalent to calling \c stop() and then \c start(). */ -void QmlAbstractAnimation::restart() +void QDeclarativeAbstractAnimation::restart() { stop(); start(); @@ -532,16 +459,16 @@ void QmlAbstractAnimation::restart() a value of 50, while calling \c complete() will set the \c x property to 100, exactly as though the animation had played the whole way through. */ -void QmlAbstractAnimation::complete() +void QDeclarativeAbstractAnimation::complete() { if (isRunning()) { qtAnimation()->setCurrentTime(qtAnimation()->duration()); } } -void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) +void QDeclarativeAbstractAnimation::setTarget(const QDeclarativeProperty &p) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); d->defaultProperty = p; if (!d->avoidPropertyValueSourceStart) @@ -553,9 +480,9 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) so this function allows us to do the same thing as setTarget without that assumption */ -void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) +void QDeclarativeAbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p) { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); d->defaultProperty = p; } @@ -564,14 +491,14 @@ void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) because something else (like a Behavior) already has control over the animation. */ -void QmlAbstractAnimation::setDisableUserControl() +void QDeclarativeAbstractAnimation::setDisableUserControl() { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); d->disableUserControl = true; } -void QmlAbstractAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativeAbstractAnimation::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { Q_UNUSED(actions); @@ -579,9 +506,9 @@ void QmlAbstractAnimation::transition(QmlStateActions &actions, Q_UNUSED(direction); } -void QmlAbstractAnimation::timelineComplete() +void QDeclarativeAbstractAnimation::timelineComplete() { - Q_D(QmlAbstractAnimation); + Q_D(QDeclarativeAbstractAnimation); setRunning(false); if (d->alwaysRunToEnd && d->repeat) { qtAnimation()->setLoopCount(-1); @@ -589,7 +516,7 @@ void QmlAbstractAnimation::timelineComplete() } /*! - \qmlclass PauseAnimation QmlPauseAnimation + \qmlclass PauseAnimation QDeclarativePauseAnimation \since 4.7 \inherits Animation \brief The PauseAnimation element provides a pause for an animation. @@ -608,26 +535,26 @@ void QmlAbstractAnimation::timelineComplete() */ /*! \internal - \class QmlPauseAnimation + \class QDeclarativePauseAnimation */ -QML_DEFINE_TYPE(Qt,4,6,PauseAnimation,QmlPauseAnimation) -QmlPauseAnimation::QmlPauseAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlPauseAnimationPrivate), parent) + +QDeclarativePauseAnimation::QDeclarativePauseAnimation(QObject *parent) +: QDeclarativeAbstractAnimation(*(new QDeclarativePauseAnimationPrivate), parent) { - Q_D(QmlPauseAnimation); + Q_D(QDeclarativePauseAnimation); d->init(); } -QmlPauseAnimation::~QmlPauseAnimation() +QDeclarativePauseAnimation::~QDeclarativePauseAnimation() { } -void QmlPauseAnimationPrivate::init() +void QDeclarativePauseAnimationPrivate::init() { - Q_Q(QmlPauseAnimation); + Q_Q(QDeclarativePauseAnimation); pa = new QPauseAnimation; - QmlGraphics_setParent_noEvent(pa, q); + QDeclarativeGraphics_setParent_noEvent(pa, q); } /*! @@ -636,34 +563,34 @@ void QmlPauseAnimationPrivate::init() The default value is 250. */ -int QmlPauseAnimation::duration() const +int QDeclarativePauseAnimation::duration() const { - Q_D(const QmlPauseAnimation); + Q_D(const QDeclarativePauseAnimation); return d->pa->duration(); } -void QmlPauseAnimation::setDuration(int duration) +void QDeclarativePauseAnimation::setDuration(int duration) { if (duration < 0) { qmlInfo(this) << tr("Cannot set a duration of < 0"); return; } - Q_D(QmlPauseAnimation); + Q_D(QDeclarativePauseAnimation); if (d->pa->duration() == duration) return; d->pa->setDuration(duration); emit durationChanged(duration); } -QAbstractAnimation *QmlPauseAnimation::qtAnimation() +QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation() { - Q_D(QmlPauseAnimation); + Q_D(QDeclarativePauseAnimation); return d->pa; } /*! - \qmlclass ColorAnimation QmlColorAnimation + \qmlclass ColorAnimation QDeclarativeColorAnimation \since 4.7 \inherits PropertyAnimation \brief The ColorAnimation element allows you to animate color changes. @@ -678,19 +605,19 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() */ /*! \internal - \class QmlColorAnimation + \class QDeclarativeColorAnimation */ -QmlColorAnimation::QmlColorAnimation(QObject *parent) -: QmlPropertyAnimation(parent) +QDeclarativeColorAnimation::QDeclarativeColorAnimation(QObject *parent) +: QDeclarativePropertyAnimation(parent) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); d->interpolatorType = QMetaType::QColor; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); d->defaultToInterpolatorType = true; } -QmlColorAnimation::~QmlColorAnimation() +QDeclarativeColorAnimation::~QDeclarativeColorAnimation() { } @@ -698,36 +625,36 @@ QmlColorAnimation::~QmlColorAnimation() \qmlproperty color ColorAnimation::from This property holds the starting color. */ -QColor QmlColorAnimation::from() const +QColor QDeclarativeColorAnimation::from() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->from.value<QColor>(); } -void QmlColorAnimation::setFrom(const QColor &f) +void QDeclarativeColorAnimation::setFrom(const QColor &f) { - QmlPropertyAnimation::setFrom(f); + QDeclarativePropertyAnimation::setFrom(f); } /*! \qmlproperty color ColorAnimation::to This property holds the ending color. */ -QColor QmlColorAnimation::to() const +QColor QDeclarativeColorAnimation::to() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->to.value<QColor>(); } -void QmlColorAnimation::setTo(const QColor &t) +void QDeclarativeColorAnimation::setTo(const QColor &t) { - QmlPropertyAnimation::setTo(t); + QDeclarativePropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation) + /*! - \qmlclass ScriptAction QmlScriptAction + \qmlclass ScriptAction QDeclarativeScriptAction \since 4.7 \inherits Animation \brief The ScriptAction element allows scripts to be run during an animation. @@ -735,39 +662,39 @@ QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation) */ /*! \internal - \class QmlScriptAction + \class QDeclarativeScriptAction */ -QmlScriptAction::QmlScriptAction(QObject *parent) - :QmlAbstractAnimation(*(new QmlScriptActionPrivate), parent) +QDeclarativeScriptAction::QDeclarativeScriptAction(QObject *parent) + :QDeclarativeAbstractAnimation(*(new QDeclarativeScriptActionPrivate), parent) { - Q_D(QmlScriptAction); + Q_D(QDeclarativeScriptAction); d->init(); } -QmlScriptAction::~QmlScriptAction() +QDeclarativeScriptAction::~QDeclarativeScriptAction() { } -void QmlScriptActionPrivate::init() +void QDeclarativeScriptActionPrivate::init() { - Q_Q(QmlScriptAction); + Q_Q(QDeclarativeScriptAction); rsa = new QActionAnimation(&proxy); - QmlGraphics_setParent_noEvent(rsa, q); + QDeclarativeGraphics_setParent_noEvent(rsa, q); } /*! \qmlproperty script ScriptAction::script This property holds the script to run. */ -QmlScriptString QmlScriptAction::script() const +QDeclarativeScriptString QDeclarativeScriptAction::script() const { - Q_D(const QmlScriptAction); + Q_D(const QDeclarativeScriptAction); return d->script; } -void QmlScriptAction::setScript(const QmlScriptString &script) +void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script) { - Q_D(QmlScriptAction); + Q_D(QDeclarativeScriptAction); d->script = script; } @@ -778,46 +705,45 @@ void QmlScriptAction::setScript(const QmlScriptString &script) This property is only valid when ScriptAction is used as part of a transition. If both script and stateChangeScriptName are set, stateChangeScriptName will be used. */ -QString QmlScriptAction::stateChangeScriptName() const +QString QDeclarativeScriptAction::stateChangeScriptName() const { - Q_D(const QmlScriptAction); + Q_D(const QDeclarativeScriptAction); return d->name; } -void QmlScriptAction::setStateChangeScriptName(const QString &name) +void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name) { - Q_D(QmlScriptAction); + Q_D(QDeclarativeScriptAction); d->name = name; } -void QmlScriptActionPrivate::execute() +void QDeclarativeScriptActionPrivate::execute() { - QmlScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; + QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; const QString &str = scriptStr.script(); if (!str.isEmpty()) { - QmlExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); - expr.setTrackChange(false); + QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); expr.value(); } } -void QmlScriptAction::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativeScriptAction::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlScriptAction); + Q_D(QDeclarativeScriptAction); Q_UNUSED(modified); Q_UNUSED(direction); d->hasRunScriptScript = false; for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; if (action.event && action.event->typeName() == QLatin1String("StateChangeScript") - && static_cast<QmlStateChangeScript*>(action.event)->name() == d->name) { + && static_cast<QDeclarativeStateChangeScript*>(action.event)->name() == d->name) { //### how should we handle reverse direction? - d->runScriptScript = static_cast<QmlStateChangeScript*>(action.event)->script(); + d->runScriptScript = static_cast<QDeclarativeStateChangeScript*>(action.event)->script(); d->hasRunScriptScript = true; action.actionDone = true; break; //assumes names are unique @@ -825,16 +751,16 @@ void QmlScriptAction::transition(QmlStateActions &actions, } } -QAbstractAnimation *QmlScriptAction::qtAnimation() +QAbstractAnimation *QDeclarativeScriptAction::qtAnimation() { - Q_D(QmlScriptAction); + Q_D(QDeclarativeScriptAction); return d->rsa; } -QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) + /*! - \qmlclass PropertyAction QmlPropertyAction + \qmlclass PropertyAction QDeclarativePropertyAction \since 4.7 \inherits Animation \brief The PropertyAction element allows immediate property changes during animation. @@ -854,24 +780,24 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) */ /*! \internal - \class QmlPropertyAction + \class QDeclarativePropertyAction */ -QmlPropertyAction::QmlPropertyAction(QObject *parent) -: QmlAbstractAnimation(*(new QmlPropertyActionPrivate), parent) +QDeclarativePropertyAction::QDeclarativePropertyAction(QObject *parent) +: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyActionPrivate), parent) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); d->init(); } -QmlPropertyAction::~QmlPropertyAction() +QDeclarativePropertyAction::~QDeclarativePropertyAction() { } -void QmlPropertyActionPrivate::init() +void QDeclarativePropertyActionPrivate::init() { - Q_Q(QmlPropertyAction); + Q_Q(QDeclarativePropertyAction); spa = new QActionAnimation; - QmlGraphics_setParent_noEvent(spa, q); + QDeclarativeGraphics_setParent_noEvent(spa, q); } /*! @@ -882,30 +808,30 @@ void QmlPropertyActionPrivate::init() is being used. Refer to the \l animation documentation for details. */ -QObject *QmlPropertyAction::target() const +QObject *QDeclarativePropertyAction::target() const { - Q_D(const QmlPropertyAction); + Q_D(const QDeclarativePropertyAction); return d->target; } -void QmlPropertyAction::setTarget(QObject *o) +void QDeclarativePropertyAction::setTarget(QObject *o) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); if (d->target == o) return; d->target = o; emit targetChanged(d->target, d->propertyName); } -QString QmlPropertyAction::property() const +QString QDeclarativePropertyAction::property() const { - Q_D(const QmlPropertyAction); + Q_D(const QDeclarativePropertyAction); return d->propertyName; } -void QmlPropertyAction::setProperty(const QString &n) +void QDeclarativePropertyAction::setProperty(const QString &n) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); if (d->propertyName == n) return; d->propertyName = n; @@ -927,25 +853,25 @@ void QmlPropertyAction::setProperty(const QString &n) \sa exclude */ -QString QmlPropertyAction::properties() const +QString QDeclarativePropertyAction::properties() const { - Q_D(const QmlPropertyAction); + Q_D(const QDeclarativePropertyAction); return d->properties; } -void QmlPropertyAction::setProperties(const QString &p) +void QDeclarativePropertyAction::setProperties(const QString &p) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); if (d->properties == p) return; d->properties = p; emit propertiesChanged(p); } -QmlListProperty<QObject> QmlPropertyAction::targets() +QDeclarativeListProperty<QObject> QDeclarativePropertyAction::targets() { - Q_D(QmlPropertyAction); - return QmlListProperty<QObject>(this, d->targets); + Q_D(QDeclarativePropertyAction); + return QDeclarativeListProperty<QObject>(this, d->targets); } /*! @@ -953,10 +879,10 @@ QmlListProperty<QObject> QmlPropertyAction::targets() This property holds the objects not to be affected by this animation. \sa targets */ -QmlListProperty<QObject> QmlPropertyAction::exclude() +QDeclarativeListProperty<QObject> QDeclarativePropertyAction::exclude() { - Q_D(QmlPropertyAction); - return QmlListProperty<QObject>(this, d->exclude); + Q_D(QDeclarativePropertyAction); + return QDeclarativeListProperty<QObject>(this, d->exclude); } /*! @@ -964,42 +890,42 @@ QmlListProperty<QObject> QmlPropertyAction::exclude() This property holds the value to be set on the property. If not set, then the value defined for the end state of the transition. */ -QVariant QmlPropertyAction::value() const +QVariant QDeclarativePropertyAction::value() const { - Q_D(const QmlPropertyAction); + Q_D(const QDeclarativePropertyAction); return d->value; } -void QmlPropertyAction::setValue(const QVariant &v) +void QDeclarativePropertyAction::setValue(const QVariant &v) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); if (d->value.isNull || d->value != v) { d->value = v; emit valueChanged(v); } } -QAbstractAnimation *QmlPropertyAction::qtAnimation() +QAbstractAnimation *QDeclarativePropertyAction::qtAnimation() { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); return d->spa; } -void QmlPropertyAction::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlPropertyAction); + Q_D(QDeclarativePropertyAction); Q_UNUSED(direction); - struct QmlSetPropertyAnimationAction : public QAbstractAnimationAction + struct QDeclarativeSetPropertyAnimationAction : public QAbstractAnimationAction { - QmlStateActions actions; + QDeclarativeStateActions actions; virtual void doAction() { for (int ii = 0; ii < actions.count(); ++ii) { - const QmlAction &action = actions.at(ii); - action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + const QDeclarativeAction &action = actions.at(ii); + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } } }; @@ -1021,22 +947,22 @@ void QmlPropertyAction::transition(QmlStateActions &actions, targets << d->defaultProperty.object(); } - QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction; + QDeclarativeSetPropertyAnimationAction *data = new QDeclarativeSetPropertyAnimationAction; bool hasExplicit = false; //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; + QDeclarativeAction 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()); + QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); data->actions << myAction; hasExplicit = true; for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; if (action.property.object() == myAction.property.object() && myAction.property.name() == action.property.name()) { modified << action.property; @@ -1050,7 +976,7 @@ void QmlPropertyAction::transition(QmlStateActions &actions, if (!hasExplicit) for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; QObject *obj = action.property.object(); QString propertyName = action.property.name(); @@ -1061,11 +987,11 @@ void QmlPropertyAction::transition(QmlStateActions &actions, 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; + QDeclarativeAction myAction = action; if (d->value.isValid()) myAction.toValue = d->value; - QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); + QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); modified << action.property; data->actions << myAction; @@ -1080,10 +1006,10 @@ void QmlPropertyAction::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction) + /*! - \qmlclass ParentAction QmlParentAction + \qmlclass ParentAction QDeclarativeParentAction \since 4.7 \inherits Animation \brief The ParentAction element allows parent changes during animation. @@ -1117,22 +1043,22 @@ QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction) The ParentAction is immediate - it is not animated in any way. */ -QmlParentAction::QmlParentAction(QObject *parent) -: QmlAbstractAnimation(*(new QmlParentActionPrivate), parent) +QDeclarativeParentAction::QDeclarativeParentAction(QObject *parent) +: QDeclarativeAbstractAnimation(*(new QDeclarativeParentActionPrivate), parent) { - Q_D(QmlParentAction); + Q_D(QDeclarativeParentAction); d->init(); } -QmlParentAction::~QmlParentAction() +QDeclarativeParentAction::~QDeclarativeParentAction() { } -void QmlParentActionPrivate::init() +void QDeclarativeParentActionPrivate::init() { - Q_Q(QmlParentAction); + Q_Q(QDeclarativeParentAction); cpa = new QActionAnimation; - QmlGraphics_setParent_noEvent(cpa, q); + QDeclarativeGraphics_setParent_noEvent(cpa, q); } /*! @@ -1163,15 +1089,15 @@ void QmlParentActionPrivate::init() \endqml */ -QmlGraphicsItem *QmlParentAction::object() const +QDeclarativeItem *QDeclarativeParentAction::object() const { - Q_D(const QmlParentAction); + Q_D(const QDeclarativeParentAction); return d->pcTarget; } -void QmlParentAction::setObject(QmlGraphicsItem *target) +void QDeclarativeParentAction::setObject(QDeclarativeItem *target) { - Q_D(QmlParentAction); + Q_D(QDeclarativeParentAction); d->pcTarget = target; } @@ -1180,52 +1106,52 @@ void QmlParentAction::setObject(QmlGraphicsItem *target) The item to reparent to (i.e. the new parent). */ -QmlGraphicsItem *QmlParentAction::parent() const +QDeclarativeItem *QDeclarativeParentAction::parent() const { - Q_D(const QmlParentAction); + Q_D(const QDeclarativeParentAction); return d->pcParent; } -void QmlParentAction::setParent(QmlGraphicsItem *parent) +void QDeclarativeParentAction::setParent(QDeclarativeItem *parent) { - Q_D(QmlParentAction); + Q_D(QDeclarativeParentAction); d->pcParent = parent; } -void QmlParentActionPrivate::doAction() +void QDeclarativeParentActionPrivate::doAction() { - QmlParentChange pc; + QDeclarativeParentChange pc; pc.setObject(pcTarget); pc.setParent(pcParent); pc.execute(); } -QAbstractAnimation *QmlParentAction::qtAnimation() +QAbstractAnimation *QDeclarativeParentAction::qtAnimation() { - Q_D(QmlParentAction); + Q_D(QDeclarativeParentAction); return d->cpa; } -void QmlParentAction::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativeParentAction::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlParentAction); + Q_D(QDeclarativeParentAction); Q_UNUSED(modified); Q_UNUSED(direction); - struct QmlParentActionData : public QAbstractAnimationAction + struct QDeclarativeParentActionData : public QAbstractAnimationAction { - QmlParentActionData(): pc(0) {} - ~QmlParentActionData() { delete pc; } + QDeclarativeParentActionData(): pc(0) {} + ~QDeclarativeParentActionData() { delete pc; } - QmlStateActions actions; + QDeclarativeStateActions actions; bool reverse; - QmlParentChange *pc; + QDeclarativeParentChange *pc; virtual void doAction() { for (int ii = 0; ii < actions.count(); ++ii) { - const QmlAction &action = actions.at(ii); + const QDeclarativeAction &action = actions.at(ii); if (reverse) action.event->reverse(); else @@ -1234,15 +1160,15 @@ void QmlParentAction::transition(QmlStateActions &actions, } }; - QmlParentActionData *data = new QmlParentActionData; + QDeclarativeParentActionData *data = new QDeclarativeParentActionData; //### need to correctly handle modified/done bool hasExplicit = false; if (d->pcTarget && d->pcParent) { data->reverse = false; - QmlAction myAction; - QmlParentChange *pc = new QmlParentChange; + QDeclarativeAction myAction; + QDeclarativeParentChange *pc = new QDeclarativeParentChange; pc->setObject(d->pcTarget); pc->setParent(d->pcParent); myAction.event = pc; @@ -1253,19 +1179,19 @@ void QmlParentAction::transition(QmlStateActions &actions, if (!hasExplicit) for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; if (action.event && action.event->typeName() == QLatin1String("ParentChange") - && (!d->pcTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcTarget)) { - QmlAction myAction = action; + && (!d->pcTarget || static_cast<QDeclarativeParentChange*>(action.event)->object() == d->pcTarget)) { + QDeclarativeAction myAction = action; data->reverse = action.reverseEvent; //### this logic differs from PropertyAnimation // (probably a result of modified vs. done) if (d->pcParent) { //### should we disallow this case? - QmlParentChange *pc = new QmlParentChange; + QDeclarativeParentChange *pc = new QDeclarativeParentChange; pc->setObject(d->pcTarget); - pc->setParent(static_cast<QmlParentChange*>(action.event)->parent()); + pc->setParent(static_cast<QDeclarativeParentChange*>(action.event)->parent()); myAction.event = pc; data->pc = pc; data->actions << myAction; @@ -1284,10 +1210,10 @@ void QmlParentAction::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) + /*! - \qmlclass NumberAnimation QmlNumberAnimation + \qmlclass NumberAnimation QDeclarativeNumberAnimation \since 4.7 \inherits PropertyAnimation \brief The NumberAnimation element allows you to animate changes in properties of type qreal. @@ -1301,18 +1227,18 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) /*! \internal - \class QmlNumberAnimation + \class QDeclarativeNumberAnimation */ -QmlNumberAnimation::QmlNumberAnimation(QObject *parent) -: QmlPropertyAnimation(parent) +QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QObject *parent) +: QDeclarativePropertyAnimation(parent) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); d->interpolatorType = QMetaType::QReal; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } -QmlNumberAnimation::~QmlNumberAnimation() +QDeclarativeNumberAnimation::~QDeclarativeNumberAnimation() { } @@ -1321,15 +1247,15 @@ QmlNumberAnimation::~QmlNumberAnimation() This property holds the starting value. If not set, then the value defined in the start state of the transition. */ -qreal QmlNumberAnimation::from() const +qreal QDeclarativeNumberAnimation::from() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->from.toReal(); } -void QmlNumberAnimation::setFrom(qreal f) +void QDeclarativeNumberAnimation::setFrom(qreal f) { - QmlPropertyAnimation::setFrom(f); + QDeclarativePropertyAnimation::setFrom(f); } /*! @@ -1337,21 +1263,21 @@ void QmlNumberAnimation::setFrom(qreal f) This property holds the ending value. If not set, then the value defined in the end state of the transition or Behavior. */ -qreal QmlNumberAnimation::to() const +qreal QDeclarativeNumberAnimation::to() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->to.toReal(); } -void QmlNumberAnimation::setTo(qreal t) +void QDeclarativeNumberAnimation::setTo(qreal t) { - QmlPropertyAnimation::setTo(t); + QDeclarativePropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation) + /*! - \qmlclass Vector3dAnimation QmlVector3dAnimation + \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation \since 4.7 \inherits PropertyAnimation \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d. @@ -1359,19 +1285,19 @@ QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation) /*! \internal - \class QmlVector3dAnimation + \class QDeclarativeVector3dAnimation */ -QmlVector3dAnimation::QmlVector3dAnimation(QObject *parent) -: QmlPropertyAnimation(parent) +QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent) +: QDeclarativePropertyAnimation(parent) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); d->interpolatorType = QMetaType::QVector3D; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); d->defaultToInterpolatorType = true; } -QmlVector3dAnimation::~QmlVector3dAnimation() +QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation() { } @@ -1380,15 +1306,15 @@ QmlVector3dAnimation::~QmlVector3dAnimation() This property holds the starting value. If not set, then the value defined in the start state of the transition. */ -QVector3D QmlVector3dAnimation::from() const +QVector3D QDeclarativeVector3dAnimation::from() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->from.value<QVector3D>(); } -void QmlVector3dAnimation::setFrom(QVector3D f) +void QDeclarativeVector3dAnimation::setFrom(QVector3D f) { - QmlPropertyAnimation::setFrom(f); + QDeclarativePropertyAnimation::setFrom(f); } /*! @@ -1396,21 +1322,21 @@ void QmlVector3dAnimation::setFrom(QVector3D f) This property holds the ending value. If not set, then the value defined in the end state of the transition or Behavior. */ -QVector3D QmlVector3dAnimation::to() const +QVector3D QDeclarativeVector3dAnimation::to() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->to.value<QVector3D>(); } -void QmlVector3dAnimation::setTo(QVector3D t) +void QDeclarativeVector3dAnimation::setTo(QVector3D t) { - QmlPropertyAnimation::setTo(t); + QDeclarativePropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) + /*! - \qmlclass RotationAnimation QmlRotationAnimation + \qmlclass RotationAnimation QDeclarativeRotationAnimation \inherits PropertyAnimation \brief The RotationAnimation element allows you to animate rotations. @@ -1437,7 +1363,7 @@ QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) /*! \internal - \class QmlRotationAnimation + \class QDeclarativeRotationAnimation */ QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) @@ -1477,16 +1403,16 @@ QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progre return QVariant(f + (newt - f) * progress); } -QmlRotationAnimation::QmlRotationAnimation(QObject *parent) -: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent) +QDeclarativeRotationAnimation::QDeclarativeRotationAnimation(QObject *parent) +: QDeclarativePropertyAnimation(*(new QDeclarativeRotationAnimationPrivate), parent) { - Q_D(QmlRotationAnimation); + Q_D(QDeclarativeRotationAnimation); d->interpolatorType = QMetaType::QReal; d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation); d->defaultProperties = QLatin1String("rotation,angle"); } -QmlRotationAnimation::~QmlRotationAnimation() +QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation() { } @@ -1495,15 +1421,15 @@ QmlRotationAnimation::~QmlRotationAnimation() This property holds the starting value. If not set, then the value defined in the start state of the transition. */ -qreal QmlRotationAnimation::from() const +qreal QDeclarativeRotationAnimation::from() const { - Q_D(const QmlRotationAnimation); + Q_D(const QDeclarativeRotationAnimation); return d->from.toReal(); } -void QmlRotationAnimation::setFrom(qreal f) +void QDeclarativeRotationAnimation::setFrom(qreal f) { - QmlPropertyAnimation::setFrom(f); + QDeclarativePropertyAnimation::setFrom(f); } /*! @@ -1511,15 +1437,15 @@ void QmlRotationAnimation::setFrom(qreal f) 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 +qreal QDeclarativeRotationAnimation::to() const { - Q_D(const QmlRotationAnimation); + Q_D(const QDeclarativeRotationAnimation); return d->to.toReal(); } -void QmlRotationAnimation::setTo(qreal t) +void QDeclarativeRotationAnimation::setTo(qreal t) { - QmlPropertyAnimation::setTo(t); + QDeclarativePropertyAnimation::setTo(t); } /*! @@ -1547,15 +1473,15 @@ void QmlRotationAnimation::setTo(qreal t) The default direction is Shortest. */ -QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const +QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const { - Q_D(const QmlRotationAnimation); + Q_D(const QDeclarativeRotationAnimation); return d->direction; } -void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction) +void QDeclarativeRotationAnimation::setDirection(QDeclarativeRotationAnimation::RotationDirection direction) { - Q_D(QmlRotationAnimation); + Q_D(QDeclarativeRotationAnimation); if (d->direction == direction) return; @@ -1578,25 +1504,25 @@ void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection emit directionChanged(); } -QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation) -QmlAnimationGroup::QmlAnimationGroup(QObject *parent) -: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) + +QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QObject *parent) +: QDeclarativeAbstractAnimation(*(new QDeclarativeAnimationGroupPrivate), parent) { } -void QmlAnimationGroupPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a) +void QDeclarativeAnimationGroupPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a) { - QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object); + QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object); if (q) { q->d_func()->animations.append(a); a->setGroup(q); } } -void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimation> *list) +void QDeclarativeAnimationGroupPrivate::clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list) { - QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object); + QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object); if (q) { for (int i = 0; i < q->d_func()->animations.count(); ++i) q->d_func()->animations.at(i)->setGroup(0); @@ -1604,21 +1530,21 @@ void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimat } } -QmlAnimationGroup::~QmlAnimationGroup() +QDeclarativeAnimationGroup::~QDeclarativeAnimationGroup() { } -QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations() +QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGroup::animations() { - Q_D(QmlAnimationGroup); - QmlListProperty<QmlAbstractAnimation> list(this, d->animations); - list.append = &QmlAnimationGroupPrivate::append_animation; - list.clear = &QmlAnimationGroupPrivate::clear_animation; + Q_D(QDeclarativeAnimationGroup); + QDeclarativeListProperty<QDeclarativeAbstractAnimation> list(this, d->animations); + list.append = &QDeclarativeAnimationGroupPrivate::append_animation; + list.clear = &QDeclarativeAnimationGroupPrivate::clear_animation; return list; } /*! - \qmlclass SequentialAnimation QmlSequentialAnimation + \qmlclass SequentialAnimation QDeclarativeSequentialAnimation \since 4.7 \inherits Animation \brief The SequentialAnimation element allows you to run animations sequentially. @@ -1638,28 +1564,28 @@ QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations() \sa ParallelAnimation */ -QmlSequentialAnimation::QmlSequentialAnimation(QObject *parent) : - QmlAnimationGroup(parent) +QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) : + QDeclarativeAnimationGroup(parent) { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); d->ag = new QSequentialAnimationGroup(this); } -QmlSequentialAnimation::~QmlSequentialAnimation() +QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation() { } -QAbstractAnimation *QmlSequentialAnimation::qtAnimation() +QAbstractAnimation *QDeclarativeSequentialAnimation::qtAnimation() { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); return d->ag; } -void QmlSequentialAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); int inc = 1; int from = 0; @@ -1676,10 +1602,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation) + /*! - \qmlclass ParallelAnimation QmlParallelAnimation + \qmlclass ParallelAnimation QDeclarativeParallelAnimation \since 4.7 \inherits Animation \brief The ParallelAnimation element allows you to run animations in parallel. @@ -1700,31 +1626,31 @@ QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation) */ /*! \internal - \class QmlParallelAnimation + \class QDeclarativeParallelAnimation */ -QmlParallelAnimation::QmlParallelAnimation(QObject *parent) : - QmlAnimationGroup(parent) +QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) : + QDeclarativeAnimationGroup(parent) { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); d->ag = new QParallelAnimationGroup(this); } -QmlParallelAnimation::~QmlParallelAnimation() +QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation() { } -QAbstractAnimation *QmlParallelAnimation::qtAnimation() +QAbstractAnimation *QDeclarativeParallelAnimation::qtAnimation() { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); return d->ag; } -void QmlParallelAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativeParallelAnimation::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlAnimationGroup); + Q_D(QDeclarativeAnimationGroup); bool valid = d->defaultProperty.isValid(); for (int ii = 0; ii < d->animations.count(); ++ii) { if (valid) @@ -1733,10 +1659,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,ParallelAnimation,QmlParallelAnimation) + //convert a variant from string type to another animatable type -void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) +void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { if (variant.userType() != QVariant::String) { variant.convert((QVariant::Type)type); @@ -1745,40 +1671,40 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) switch (type) { case QVariant::Rect: { - variant.setValue(QmlStringConverters::rectFFromString(variant.toString()).toRect()); + variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect()); break; } case QVariant::RectF: { - variant.setValue(QmlStringConverters::rectFFromString(variant.toString())); + variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString())); break; } case QVariant::Point: { - variant.setValue(QmlStringConverters::pointFFromString(variant.toString()).toPoint()); + variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint()); break; } case QVariant::PointF: { - variant.setValue(QmlStringConverters::pointFFromString(variant.toString())); + variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString())); break; } case QVariant::Size: { - variant.setValue(QmlStringConverters::sizeFFromString(variant.toString()).toSize()); + variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize()); break; } case QVariant::SizeF: { - variant.setValue(QmlStringConverters::sizeFFromString(variant.toString())); + variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString())); break; } case QVariant::Color: { - variant.setValue(QmlStringConverters::colorFromString(variant.toString())); + variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString())); break; } case QVariant::Vector3D: { - variant.setValue(QmlStringConverters::vector3DFromString(variant.toString())); + variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString())); break; } default: if ((uint)type >= QVariant::UserType) { - QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(type); + QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); if (converter) variant = converter(variant.toString()); } else @@ -1788,7 +1714,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) } /*! - \qmlclass PropertyAnimation QmlPropertyAnimation + \qmlclass PropertyAnimation QDeclarativePropertyAnimation \since 4.7 \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. @@ -1845,29 +1771,29 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) as the \l{QML Animation} introduction. */ -QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlPropertyAnimationPrivate), parent) +QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QObject *parent) +: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyAnimationPrivate), parent) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); d->init(); } -QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent) -: QmlAbstractAnimation(dd, parent) +QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent) +: QDeclarativeAbstractAnimation(dd, parent) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); d->init(); } -QmlPropertyAnimation::~QmlPropertyAnimation() +QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation() { } -void QmlPropertyAnimationPrivate::init() +void QDeclarativePropertyAnimationPrivate::init() { - Q_Q(QmlPropertyAnimation); - va = new QmlTimeLineValueAnimator; - QmlGraphics_setParent_noEvent(va, q); + Q_Q(QDeclarativePropertyAnimation); + va = new QDeclarativeTimeLineValueAnimator; + QDeclarativeGraphics_setParent_noEvent(va, q); } /*! @@ -1876,20 +1802,20 @@ void QmlPropertyAnimationPrivate::init() The default value is 250. */ -int QmlPropertyAnimation::duration() const +int QDeclarativePropertyAnimation::duration() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->va->duration(); } -void QmlPropertyAnimation::setDuration(int duration) +void QDeclarativePropertyAnimation::setDuration(int duration) { if (duration < 0) { qmlInfo(this) << tr("Cannot set a duration of < 0"); return; } - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->va->duration() == duration) return; d->va->setDuration(duration); @@ -1901,15 +1827,15 @@ void QmlPropertyAnimation::setDuration(int duration) This property holds the starting value. If not set, then the value defined in the start state of the transition. */ -QVariant QmlPropertyAnimation::from() const +QVariant QDeclarativePropertyAnimation::from() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->from; } -void QmlPropertyAnimation::setFrom(const QVariant &f) +void QDeclarativePropertyAnimation::setFrom(const QVariant &f) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->fromIsDefined && f == d->from) return; d->from = f; @@ -1922,15 +1848,15 @@ void QmlPropertyAnimation::setFrom(const QVariant &f) This property holds the ending value. If not set, then the value defined in the end state of the transition or Behavior. */ -QVariant QmlPropertyAnimation::to() const +QVariant QDeclarativePropertyAnimation::to() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->to; } -void QmlPropertyAnimation::setTo(const QVariant &t) +void QDeclarativePropertyAnimation::setTo(const QVariant &t) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->toIsDefined && t == d->to) return; d->to = t; @@ -1939,237 +1865,237 @@ void QmlPropertyAnimation::setTo(const QVariant &t) } /*! - \qmlproperty string PropertyAnimation::easing + \qmlproperty QEasingCurve PropertyAnimation::easing \brief the easing curve used for the transition. Available values are: \table \row - \o \c easeLinear + \o \c Linear \o Easing curve for a linear (t) function: velocity is constant. \o \inlineimage qeasingcurve-linear.png \row - \o \c easeInQuad + \o \c InQuad \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquad.png \row - \o \c easeOutQuad + \o \c OutQuad \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity. \o \inlineimage qeasingcurve-outquad.png \row - \o \c easeInOutQuad + \o \c InOutQuad \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquad.png \row - \o \c easeOutInQuad + \o \c OutInQuad \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquad.png \row - \o \c easeInCubic + \o \c InCubic \o Easing curve for a cubic (t^3) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-incubic.png \row - \o \c easeOutCubic + \o \c OutCubic \o Easing curve for a cubic (t^3) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outcubic.png \row - \o \c easeInOutCubic + \o \c InOutCubic \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutcubic.png \row - \o \c easeOutInCubic + \o \c OutInCubic \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outincubic.png \row - \o \c easeInQuart + \o \c InQuart \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquart.png \row - \o \c easeOutQuart + \o \c OutQuart \o Easing curve for a cubic (t^4) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquart.png \row - \o \c easeInOutQuart + \o \c InOutQuart \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquart.png \row - \o \c easeOutInQuart + \o \c OutInQuart \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquart.png \row - \o \c easeInQuint + \o \c InQuint \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inquint.png \row - \o \c easeOutQuint + \o \c OutQuint \o Easing curve for a cubic (t^5) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquint.png \row - \o \c easeInOutQuint + \o \c InOutQuint \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquint.png \row - \o \c easeOutInQuint + \o \c OutInQuint \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquint.png \row - \o \c easeInSine + \o \c InSine \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-insine.png \row - \o \c easeOutSine + \o \c OutSine \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outsine.png \row - \o \c easeInOutSine + \o \c InOutSine \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutsine.png \row - \o \c easeOutInSine + \o \c OutInSine \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinsine.png \row - \o \c easeInExpo + \o \c InExpo \o Easing curve for an exponential (2^t) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inexpo.png \row - \o \c easeOutExpo + \o \c OutExpo \o Easing curve for an exponential (2^t) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outexpo.png \row - \o \c easeInOutExpo + \o \c InOutExpo \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutexpo.png \row - \o \c easeOutInExpo + \o \c OutInExpo \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinexpo.png \row - \o \c easeInCirc + \o \c InCirc \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-incirc.png \row - \o \c easeOutCirc + \o \c OutCirc \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outcirc.png \row - \o \c easeInOutCirc + \o \c InOutCirc \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutcirc.png \row - \o \c easeOutInCirc + \o \c OutInCirc \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outincirc.png \row - \o \c easeInElastic + \o \c InElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity. \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \o \inlineimage qeasingcurve-inelastic.png \row - \o \c easeOutElastic + \o \c OutElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity. \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. \o \inlineimage qeasingcurve-outelastic.png \row - \o \c easeInOutElastic + \o \c InOutElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutelastic.png \row - \o \c easeOutInElastic + \o \c OutInElastic \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinelastic.png \row - \o \c easeInBack + \o \c InBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. \o \inlineimage qeasingcurve-inback.png \row - \o \c easeOutBack + \o \c OutBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity. \o \inlineimage qeasingcurve-outback.png \row - \o \c easeInOutBack + \o \c InOutBack \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutback.png \row - \o \c easeOutInBack + \o \c OutInBack \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinback.png \row - \o \c easeInBounce + \o \c InBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity. \o \inlineimage qeasingcurve-inbounce.png \row - \o \c easeOutBounce + \o \c OutBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outbounce.png \row - \o \c easeInOutBounce + \o \c InOutBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutbounce.png \row - \o \c easeOutInBounce + \o \c OutInBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinbounce.png \endtable */ -QString QmlPropertyAnimation::easing() const +QEasingCurve QDeclarativePropertyAnimation::easing() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->easing; } -void QmlPropertyAnimation::setEasing(const QString &e) +void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->easing == e) return; d->easing = e; - d->va->setEasingCurve(stringToCurve(d->easing, this)); + d->va->setEasingCurve(d->easing); emit easingChanged(e); } -QObject *QmlPropertyAnimation::target() const +QObject *QDeclarativePropertyAnimation::target() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->target; } -void QmlPropertyAnimation::setTarget(QObject *o) +void QDeclarativePropertyAnimation::setTarget(QObject *o) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->target == o) return; d->target = o; emit targetChanged(d->target, d->propertyName); } -QString QmlPropertyAnimation::property() const +QString QDeclarativePropertyAnimation::property() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->propertyName; } -void QmlPropertyAnimation::setProperty(const QString &n) +void QDeclarativePropertyAnimation::setProperty(const QString &n) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->propertyName == n) return; d->propertyName = n; emit targetChanged(d->target, d->propertyName); } -QString QmlPropertyAnimation::properties() const +QString QDeclarativePropertyAnimation::properties() const { - Q_D(const QmlPropertyAnimation); + Q_D(const QDeclarativePropertyAnimation); return d->properties; } -void QmlPropertyAnimation::setProperties(const QString &prop) +void QDeclarativePropertyAnimation::setProperties(const QString &prop) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); if (d->properties == prop) return; @@ -2259,10 +2185,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop) \sa exclude */ -QmlListProperty<QObject> QmlPropertyAnimation::targets() +QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::targets() { - Q_D(QmlPropertyAnimation); - return QmlListProperty<QObject>(this, d->targets); + Q_D(QDeclarativePropertyAnimation); + return QDeclarativeListProperty<QObject>(this, d->targets); } /*! @@ -2270,21 +2196,21 @@ QmlListProperty<QObject> QmlPropertyAnimation::targets() This property holds the items not to be affected by this animation. \sa targets */ -QmlListProperty<QObject> QmlPropertyAnimation::exclude() +QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::exclude() { - Q_D(QmlPropertyAnimation); - return QmlListProperty<QObject>(this, d->exclude); + Q_D(QDeclarativePropertyAnimation); + return QDeclarativeListProperty<QObject>(this, d->exclude); } -QAbstractAnimation *QmlPropertyAnimation::qtAnimation() +QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation() { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); return d->va; } -struct PropertyUpdater : public QmlTimeLineValue +struct PropertyUpdater : public QDeclarativeTimeLineValue { - QmlStateActions actions; + QDeclarativeStateActions actions; int interpolatorType; //for Number/ColorAnimation int prevInterpolatorType; //for generic QVariantAnimation::Interpolator interpolator; @@ -2300,17 +2226,17 @@ struct PropertyUpdater : public QmlTimeLineValue wasDeleted = &deleted; if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 v = 1 - v; - QmlTimeLineValue::setValue(v); + QDeclarativeTimeLineValue::setValue(v); for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; if (v == 1.) - action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); else { if (!fromSourced && !fromDefined) { action.fromValue = action.property.read(); if (interpolatorType) - QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); } if (!interpolatorType) { int propType = action.property.propertyType(); @@ -2320,7 +2246,7 @@ struct PropertyUpdater : public QmlTimeLineValue } } if (interpolator) - action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } if (deleted) return; @@ -2330,11 +2256,11 @@ struct PropertyUpdater : public QmlTimeLineValue } }; -void QmlPropertyAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, +void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction) { - Q_D(QmlPropertyAnimation); + Q_D(QDeclarativePropertyAnimation); QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) @@ -2370,7 +2296,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, if (d->toIsDefined) { for (int i = 0; i < props.count(); ++i) { for (int j = 0; j < targets.count(); ++j) { - QmlAction myAction; + QDeclarativeAction myAction; myAction.property = d->createProperty(targets.at(j), props.at(i), this); if (myAction.property.isValid()) { if (d->fromIsDefined) { @@ -2382,7 +2308,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, data->actions << myAction; hasExplicit = true; for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; if (action.property.object() == myAction.property.object() && myAction.property.name() == action.property.name()) { modified << action.property; @@ -2396,7 +2322,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, if (!hasExplicit) for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; + QDeclarativeAction &action = actions[ii]; QObject *obj = action.property.object(); QString propertyName = action.property.name(); @@ -2408,7 +2334,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)) || (useType && action.property.propertyType() == d->interpolatorType))) { - QmlAction myAction = action; + QDeclarativeAction myAction = action; if (d->fromIsDefined) myAction.fromValue = d->from; @@ -2440,6 +2366,6 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,PropertyAnimation,QmlPropertyAnimation) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 623ad8d..53afbb5 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -39,18 +39,19 @@ ** ****************************************************************************/ -#ifndef QMLANIMATION_H -#define QMLANIMATION_H +#ifndef QDECLARATIVEANIMATION_H +#define QDECLARATIVEANIMATION_H -#include "qmltransition_p.h" -#include "qmlstate_p.h" +#include "qdeclarativetransition_p.h" +#include "qdeclarativestate_p.h" #include <QtGui/qvector3d.h> -#include <qmlpropertyvaluesource.h> -#include <qml.h> -#include <qmlscriptstring.h> +#include <qdeclarativepropertyvaluesource.h> +#include <qdeclarative.h> +#include <qdeclarativescriptstring.h> #include <QtCore/qvariant.h> +#include <QtCore/qeasingcurve.h> #include <QtCore/QAbstractAnimation> #include <QtGui/qcolor.h> @@ -60,15 +61,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlAbstractAnimationPrivate; -class QmlAnimationGroup; -class Q_AUTOTEST_EXPORT QmlAbstractAnimation : public QObject, public QmlPropertyValueSource, public QmlParserStatus +class QDeclarativeAbstractAnimationPrivate; +class QDeclarativeAnimationGroup; +class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus { Q_OBJECT - Q_DECLARE_PRIVATE(QmlAbstractAnimation) + Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation) - Q_INTERFACES(QmlParserStatus) - Q_INTERFACES(QmlPropertyValueSource) + Q_INTERFACES(QDeclarativeParserStatus) + Q_INTERFACES(QDeclarativePropertyValueSource) Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged()) @@ -76,8 +77,8 @@ class Q_AUTOTEST_EXPORT QmlAbstractAnimation : public QObject, public QmlPropert Q_CLASSINFO("DefaultMethod", "start()") public: - QmlAbstractAnimation(QObject *parent=0); - virtual ~QmlAbstractAnimation(); + QDeclarativeAbstractAnimation(QObject *parent=0); + virtual ~QDeclarativeAbstractAnimation(); bool isRunning() const; void setRunning(bool); @@ -91,10 +92,10 @@ public: int currentTime(); void setCurrentTime(int); - QmlAnimationGroup *group() const; - void setGroup(QmlAnimationGroup *); + QDeclarativeAnimationGroup *group() const; + void setGroup(QDeclarativeAnimationGroup *); - void setDefaultTarget(const QmlMetaProperty &); + void setDefaultTarget(const QDeclarativeProperty &); void setDisableUserControl(); void classBegin(); @@ -117,12 +118,12 @@ public Q_SLOTS: void complete(); protected: - QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObject *parent); + QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent); public: enum TransitionDirection { Forward, Backward }; - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation() = 0; @@ -130,20 +131,20 @@ private Q_SLOTS: void timelineComplete(); private: - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QDeclarativeProperty &); }; -class QmlPauseAnimationPrivate; -class Q_AUTOTEST_EXPORT QmlPauseAnimation : public QmlAbstractAnimation +class QDeclarativePauseAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarativePauseAnimation : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPauseAnimation) + Q_DECLARE_PRIVATE(QDeclarativePauseAnimation) Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) public: - QmlPauseAnimation(QObject *parent=0); - virtual ~QmlPauseAnimation(); + QDeclarativePauseAnimation(QObject *parent=0); + virtual ~QDeclarativePauseAnimation(); int duration() const; void setDuration(int); @@ -155,48 +156,48 @@ protected: virtual QAbstractAnimation *qtAnimation(); }; -class QmlScriptActionPrivate; -class QmlScriptAction : public QmlAbstractAnimation +class QDeclarativeScriptActionPrivate; +class QDeclarativeScriptAction : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlScriptAction) + Q_DECLARE_PRIVATE(QDeclarativeScriptAction) - Q_PROPERTY(QmlScriptString script READ script WRITE setScript) + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) Q_PROPERTY(QString stateChangeScriptName READ stateChangeScriptName WRITE setStateChangeScriptName) public: - QmlScriptAction(QObject *parent=0); - virtual ~QmlScriptAction(); + QDeclarativeScriptAction(QObject *parent=0); + virtual ~QDeclarativeScriptAction(); - QmlScriptString script() const; - void setScript(const QmlScriptString &); + QDeclarativeScriptString script() const; + void setScript(const QDeclarativeScriptString &); QString stateChangeScriptName() const; void setStateChangeScriptName(const QString &); protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); }; -class QmlPropertyActionPrivate; -class QmlPropertyAction : public QmlAbstractAnimation +class QDeclarativePropertyActionPrivate; +class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyAction) + Q_DECLARE_PRIVATE(QDeclarativePropertyAction) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) 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(QDeclarativeListProperty<QObject> targets READ targets) + Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) public: - QmlPropertyAction(QObject *parent=0); - virtual ~QmlPropertyAction(); + QDeclarativePropertyAction(QObject *parent=0); + virtual ~QDeclarativePropertyAction(); QObject *target() const; void setTarget(QObject *); @@ -207,8 +208,8 @@ public: QString properties() const; void setProperties(const QString &); - QmlListProperty<QObject> targets(); - QmlListProperty<QObject> exclude(); + QDeclarativeListProperty<QObject> targets(); + QDeclarativeListProperty<QObject> exclude(); QVariant value() const; void setValue(const QVariant &); @@ -219,58 +220,58 @@ Q_SIGNALS: void targetChanged(QObject *, const QString &); protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); }; -class QmlGraphicsItem; -class QmlParentActionPrivate; -class QmlParentAction : public QmlAbstractAnimation +class QDeclarativeItem; +class QDeclarativeParentActionPrivate; +class QDeclarativeParentAction : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlParentAction) + Q_DECLARE_PRIVATE(QDeclarativeParentAction) - Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject) - Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) //### newParent public: - QmlParentAction(QObject *parent=0); - virtual ~QmlParentAction(); + QDeclarativeParentAction(QObject *parent=0); + virtual ~QDeclarativeParentAction(); - QmlGraphicsItem *object() const; - void setObject(QmlGraphicsItem *); + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); - QmlGraphicsItem *parent() const; - void setParent(QmlGraphicsItem *); + QDeclarativeItem *parent() const; + void setParent(QDeclarativeItem *); protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); }; -class QmlPropertyAnimationPrivate; -class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation +class QDeclarativePropertyAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyAnimation) + Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation) Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) + Q_PROPERTY(QEasingCurve 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 properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QmlListProperty<QObject> targets READ targets) - Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude) + Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets) + Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude) public: - QmlPropertyAnimation(QObject *parent=0); - virtual ~QmlPropertyAnimation(); + QDeclarativePropertyAnimation(QObject *parent=0); + virtual ~QDeclarativePropertyAnimation(); int duration() const; void setDuration(int); @@ -281,8 +282,8 @@ public: QVariant to() const; void setTo(const QVariant &); - QString easing() const; - void setEasing(const QString &); + QEasingCurve easing() const; + void setEasing(const QEasingCurve &); QObject *target() const; void setTarget(QObject *); @@ -293,13 +294,13 @@ public: QString properties() const; void setProperties(const QString &); - QmlListProperty<QObject> targets(); - QmlListProperty<QObject> exclude(); + QDeclarativeListProperty<QObject> targets(); + QDeclarativeListProperty<QObject> exclude(); protected: - QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent); - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent); + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); @@ -307,21 +308,21 @@ Q_SIGNALS: void durationChanged(int); void fromChanged(QVariant); void toChanged(QVariant); - void easingChanged(const QString &); + void easingChanged(const QEasingCurve &); void propertiesChanged(const QString &); void targetChanged(QObject *, const QString &); }; -class Q_AUTOTEST_EXPORT QmlColorAnimation : public QmlPropertyAnimation +class Q_AUTOTEST_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyAnimation) + Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation) Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) public: - QmlColorAnimation(QObject *parent=0); - virtual ~QmlColorAnimation(); + QDeclarativeColorAnimation(QObject *parent=0); + virtual ~QDeclarativeColorAnimation(); QColor from() const; void setFrom(const QColor &); @@ -330,17 +331,17 @@ public: void setTo(const QColor &); }; -class Q_AUTOTEST_EXPORT QmlNumberAnimation : public QmlPropertyAnimation +class Q_AUTOTEST_EXPORT QDeclarativeNumberAnimation : public QDeclarativePropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyAnimation) + Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation) Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) public: - QmlNumberAnimation(QObject *parent=0); - virtual ~QmlNumberAnimation(); + QDeclarativeNumberAnimation(QObject *parent=0); + virtual ~QDeclarativeNumberAnimation(); qreal from() const; void setFrom(qreal); @@ -349,17 +350,17 @@ public: void setTo(qreal); }; -class Q_AUTOTEST_EXPORT QmlVector3dAnimation : public QmlPropertyAnimation +class Q_AUTOTEST_EXPORT QDeclarativeVector3dAnimation : public QDeclarativePropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyAnimation) + Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation) Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged) public: - QmlVector3dAnimation(QObject *parent=0); - virtual ~QmlVector3dAnimation(); + QDeclarativeVector3dAnimation(QObject *parent=0); + virtual ~QDeclarativeVector3dAnimation(); QVector3D from() const; void setFrom(QVector3D); @@ -368,11 +369,11 @@ public: void setTo(QVector3D); }; -class QmlRotationAnimationPrivate; -class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation +class QDeclarativeRotationAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarativeRotationAnimation : public QDeclarativePropertyAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlRotationAnimation) + Q_DECLARE_PRIVATE(QDeclarativeRotationAnimation) Q_ENUMS(RotationDirection) Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) @@ -380,8 +381,8 @@ class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) public: - QmlRotationAnimation(QObject *parent=0); - virtual ~QmlRotationAnimation(); + QDeclarativeRotationAnimation(QObject *parent=0); + virtual ~QDeclarativeRotationAnimation(); qreal from() const; void setFrom(qreal); @@ -397,70 +398,70 @@ Q_SIGNALS: void directionChanged(); }; -class QmlAnimationGroupPrivate; -class QmlAnimationGroup : public QmlAbstractAnimation +class QDeclarativeAnimationGroupPrivate; +class QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlAnimationGroup) + Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup) Q_CLASSINFO("DefaultProperty", "animations") - Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations) public: - QmlAnimationGroup(QObject *parent); - virtual ~QmlAnimationGroup(); + QDeclarativeAnimationGroup(QObject *parent); + virtual ~QDeclarativeAnimationGroup(); - QmlListProperty<QmlAbstractAnimation> animations(); - friend class QmlAbstractAnimation; + QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations(); + friend class QDeclarativeAbstractAnimation; }; -class QmlSequentialAnimation : public QmlAnimationGroup +class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup { Q_OBJECT - Q_DECLARE_PRIVATE(QmlAnimationGroup) + Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup) public: - QmlSequentialAnimation(QObject *parent=0); - virtual ~QmlSequentialAnimation(); + QDeclarativeSequentialAnimation(QObject *parent=0); + virtual ~QDeclarativeSequentialAnimation(); protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); }; -class QmlParallelAnimation : public QmlAnimationGroup +class QDeclarativeParallelAnimation : public QDeclarativeAnimationGroup { Q_OBJECT - Q_DECLARE_PRIVATE(QmlAnimationGroup) + Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup) public: - QmlParallelAnimation(QObject *parent=0); - virtual ~QmlParallelAnimation(); + QDeclarativeParallelAnimation(QObject *parent=0); + virtual ~QDeclarativeParallelAnimation(); protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, + virtual void transition(QDeclarativeStateActions &actions, + QDeclarativeProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlAbstractAnimation) -QML_DECLARE_TYPE(QmlPauseAnimation) -QML_DECLARE_TYPE(QmlScriptAction) -QML_DECLARE_TYPE(QmlPropertyAction) -QML_DECLARE_TYPE(QmlParentAction) -QML_DECLARE_TYPE(QmlPropertyAnimation) -QML_DECLARE_TYPE(QmlColorAnimation) -QML_DECLARE_TYPE(QmlNumberAnimation) -QML_DECLARE_TYPE(QmlSequentialAnimation) -QML_DECLARE_TYPE(QmlParallelAnimation) -QML_DECLARE_TYPE(QmlVector3dAnimation) -QML_DECLARE_TYPE(QmlRotationAnimation) +QML_DECLARE_TYPE(QDeclarativeAbstractAnimation) +QML_DECLARE_TYPE(QDeclarativePauseAnimation) +QML_DECLARE_TYPE(QDeclarativeScriptAction) +QML_DECLARE_TYPE(QDeclarativePropertyAction) +QML_DECLARE_TYPE(QDeclarativeParentAction) +QML_DECLARE_TYPE(QDeclarativePropertyAnimation) +QML_DECLARE_TYPE(QDeclarativeColorAnimation) +QML_DECLARE_TYPE(QDeclarativeNumberAnimation) +QML_DECLARE_TYPE(QDeclarativeSequentialAnimation) +QML_DECLARE_TYPE(QDeclarativeParallelAnimation) +QML_DECLARE_TYPE(QDeclarativeVector3dAnimation) +QML_DECLARE_TYPE(QDeclarativeRotationAnimation) QT_END_HEADER -#endif // QMLANIMATION_H +#endif // QDECLARATIVEANIMATION_H diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index 056ce82..fc4e6e6 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLANIMATION_P_H -#define QMLANIMATION_P_H +#ifndef QDECLARATIVEANIMATION_P_H +#define QDECLARATIVEANIMATION_P_H // // W A R N I N G @@ -53,13 +53,13 @@ // We mean it. // -#include "qmlanimation_p.h" +#include "qdeclarativeanimation_p.h" -#include "qmlnullablevalue_p_p.h" -#include "qmltimeline_p_p.h" +#include "qdeclarativenullablevalue_p_p.h" +#include "qdeclarativetimeline_p_p.h" -#include <qml.h> -#include <qmlcontext.h> +#include <qdeclarative.h> +#include <qdeclarativecontext.h> #include <QtCore/QPauseAnimation> #include <QtCore/QVariantAnimation> @@ -82,7 +82,7 @@ public: //templated animation action //allows us to specify an action that calls a function of a class. -//(so that class doesn't have to inherit QmlAbstractAnimationAction) +//(so that class doesn't have to inherit QDeclarativeAbstractAnimationAction) template<class T, void (T::*method)()> class QAnimationActionProxy : public QAbstractAnimationAction { @@ -142,14 +142,14 @@ private: bool running; }; -//animates QmlTimeLineValue (assumes start and end values will be reals or compatible) -class QmlTimeLineValueAnimator : public QVariantAnimation +//animates QDeclarativeTimeLineValue (assumes start and end values will be reals or compatible) +class QDeclarativeTimeLineValueAnimator : public QVariantAnimation { Q_OBJECT public: - QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} - ~QmlTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } - void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p) + QDeclarativeTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} + ~QDeclarativeTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } + void setAnimValue(QDeclarativeTimeLineValue *value, DeletionPolicy p) { if (state() == Running) stop(); @@ -165,6 +165,9 @@ public: protected: virtual void updateCurrentValue(const QVariant &value) { + if (state() == QAbstractAnimation::Stopped) + return; + if (animValue) animValue->setValue(value.toReal()); } @@ -183,7 +186,7 @@ protected: } private: - QmlTimeLineValue *animValue; + QDeclarativeTimeLineValue *animValue; bool *fromSourced; DeletionPolicy policy; }; @@ -203,11 +206,11 @@ private: T *m_p; }; -class QmlAbstractAnimationPrivate : public QObjectPrivate +class QDeclarativeAbstractAnimationPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlAbstractAnimation) + Q_DECLARE_PUBLIC(QDeclarativeAbstractAnimation) public: - QmlAbstractAnimationPrivate() + QDeclarativeAbstractAnimationPrivate() : running(false), paused(false), alwaysRunToEnd(false), repeat(false), connectedTimeLine(false), componentComplete(true), avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {} @@ -223,52 +226,52 @@ public: void commence(); - QmlMetaProperty defaultProperty; + QDeclarativeProperty defaultProperty; - QmlAnimationGroup *group; + QDeclarativeAnimationGroup *group; - static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); + static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); }; -class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate +class QDeclarativePauseAnimationPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlPauseAnimation) + Q_DECLARE_PUBLIC(QDeclarativePauseAnimation) public: - QmlPauseAnimationPrivate() - : QmlAbstractAnimationPrivate(), pa(0) {} + QDeclarativePauseAnimationPrivate() + : QDeclarativeAbstractAnimationPrivate(), pa(0) {} void init(); QPauseAnimation *pa; }; -class QmlScriptActionPrivate : public QmlAbstractAnimationPrivate +class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlScriptAction) + Q_DECLARE_PUBLIC(QDeclarativeScriptAction) public: - QmlScriptActionPrivate() - : QmlAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {} + QDeclarativeScriptActionPrivate() + : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {} void init(); - QmlScriptString script; + QDeclarativeScriptString script; QString name; - QmlScriptString runScriptScript; + QDeclarativeScriptString runScriptScript; bool hasRunScriptScript; void execute(); - QAnimationActionProxy<QmlScriptActionPrivate, - &QmlScriptActionPrivate::execute> proxy; + QAnimationActionProxy<QDeclarativeScriptActionPrivate, + &QDeclarativeScriptActionPrivate::execute> proxy; QActionAnimation *rsa; }; -class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate +class QDeclarativePropertyActionPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlPropertyAction) + Q_DECLARE_PUBLIC(QDeclarativePropertyAction) public: - QmlPropertyActionPrivate() - : QmlAbstractAnimationPrivate(), target(0), spa(0) {} + QDeclarativePropertyActionPrivate() + : QDeclarativeAbstractAnimationPrivate(), target(0), spa(0) {} void init(); @@ -278,48 +281,48 @@ public: QList<QObject *> targets; QList<QObject *> exclude; - QmlNullableValue<QVariant> value; + QDeclarativeNullableValue<QVariant> value; QActionAnimation *spa; }; -class QmlParentActionPrivate : public QmlAbstractAnimationPrivate +class QDeclarativeParentActionPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlParentAction) + Q_DECLARE_PUBLIC(QDeclarativeParentAction) public: - QmlParentActionPrivate() - : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {} + QDeclarativeParentActionPrivate() + : QDeclarativeAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {} void init(); - QmlGraphicsItem *pcTarget; - QmlGraphicsItem *pcParent; + QDeclarativeItem *pcTarget; + QDeclarativeItem *pcParent; void doAction(); QActionAnimation *cpa; }; -class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate +class QDeclarativeAnimationGroupPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlAnimationGroup) + Q_DECLARE_PUBLIC(QDeclarativeAnimationGroup) public: - QmlAnimationGroupPrivate() - : QmlAbstractAnimationPrivate(), ag(0) {} - - 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; + QDeclarativeAnimationGroupPrivate() + : QDeclarativeAbstractAnimationPrivate(), ag(0) {} + + static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *role); + static void clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list); + static void removeAt_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int i); + static void insert_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int i, QDeclarativeAbstractAnimation *role); + QList<QDeclarativeAbstractAnimation *> animations; QAnimationGroup *ag; }; -class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate +class QDeclarativePropertyAnimationPrivate : public QDeclarativeAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlPropertyAnimation) + Q_DECLARE_PUBLIC(QDeclarativePropertyAnimation) public: - QmlPropertyAnimationPrivate() - : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), + QDeclarativePropertyAnimationPrivate() + : QDeclarativeAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {} void init(); @@ -327,7 +330,7 @@ public: QVariant from; QVariant to; - QString easing; + QEasingCurve easing; QObject *target; QString propertyName; @@ -344,21 +347,21 @@ public: int interpolatorType; QVariantAnimation::Interpolator interpolator; - QmlTimeLineValueAnimator *va; + QDeclarativeTimeLineValueAnimator *va; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, int type); }; -class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate +class QDeclarativeRotationAnimationPrivate : public QDeclarativePropertyAnimationPrivate { - Q_DECLARE_PUBLIC(QmlRotationAnimation) + Q_DECLARE_PUBLIC(QDeclarativeRotationAnimation) public: - QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {} + QDeclarativeRotationAnimationPrivate() : direction(QDeclarativeRotationAnimation::Shortest) {} - QmlRotationAnimation::RotationDirection direction; + QDeclarativeRotationAnimation::RotationDirection direction; }; QT_END_NAMESPACE -#endif // QMLANIMATION_P_H +#endif // QDECLARATIVEANIMATION_P_H diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index d65d8cd..e0189dc 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -39,13 +39,14 @@ ** ****************************************************************************/ -#include "qmlbehavior_p.h" +#include "qdeclarativebehavior_p.h" -#include "qmlanimation_p.h" -#include "qmltransition_p.h" +#include "qdeclarativeanimation_p.h" +#include "qdeclarativetransition_p.h" -#include <qmlcontext.h> -#include <qmlinfo.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeinfo.h> +#include <qdeclarativeproperty_p.h> #include <QtCore/qparallelanimationgroup.h> @@ -53,25 +54,25 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Behavior,QmlBehavior) -class QmlBehaviorPrivate : public QObjectPrivate + +class QDeclarativeBehaviorPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlBehavior) + Q_DECLARE_PUBLIC(QDeclarativeBehavior) public: - QmlBehaviorPrivate() : animation(0), enabled(true) {} + QDeclarativeBehaviorPrivate() : animation(0), enabled(true) {} - QmlMetaProperty property; + QDeclarativeProperty property; QVariant currentValue; - QmlAbstractAnimation *animation; + QDeclarativeAbstractAnimation *animation; bool enabled; }; /*! - \qmlclass Behavior QmlBehavior + \qmlclass Behavior QDeclarativeBehavior \brief The Behavior element allows you to specify a default animation for a property change. - Behaviors provide one way to specify \l{qmlanimation.html}{animations} in QML. + Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML. In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: \code @@ -93,12 +94,12 @@ public: */ -QmlBehavior::QmlBehavior(QObject *parent) - : QObject(*(new QmlBehaviorPrivate), parent) +QDeclarativeBehavior::QDeclarativeBehavior(QObject *parent) + : QObject(*(new QDeclarativeBehaviorPrivate), parent) { } -QmlBehavior::~QmlBehavior() +QDeclarativeBehavior::~QDeclarativeBehavior() { } @@ -109,15 +110,15 @@ QmlBehavior::~QmlBehavior() The animation to use when the behavior is triggered. */ -QmlAbstractAnimation *QmlBehavior::animation() +QDeclarativeAbstractAnimation *QDeclarativeBehavior::animation() { - Q_D(QmlBehavior); + Q_D(QDeclarativeBehavior); return d->animation; } -void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) +void QDeclarativeBehavior::setAnimation(QDeclarativeAbstractAnimation *animation) { - Q_D(QmlBehavior); + Q_D(QDeclarativeBehavior); if (d->animation) { qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior."); return; @@ -137,26 +138,26 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) By default a Behavior is enabled. */ -bool QmlBehavior::enabled() const +bool QDeclarativeBehavior::enabled() const { - Q_D(const QmlBehavior); + Q_D(const QDeclarativeBehavior); return d->enabled; } -void QmlBehavior::setEnabled(bool enabled) +void QDeclarativeBehavior::setEnabled(bool enabled) { - Q_D(QmlBehavior); + Q_D(QDeclarativeBehavior); if (d->enabled == enabled) return; d->enabled = enabled; emit enabledChanged(); } -void QmlBehavior::write(const QVariant &value) +void QDeclarativeBehavior::write(const QVariant &value) { - Q_D(QmlBehavior); + Q_D(QDeclarativeBehavior); if (!d->animation || !d->enabled) { - d->property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); return; } @@ -164,24 +165,24 @@ void QmlBehavior::write(const QVariant &value) d->animation->qtAnimation()->stop(); - QmlStateOperation::ActionList actions; - QmlAction action; + QDeclarativeStateOperation::ActionList actions; + QDeclarativeAction action; action.property = d->property; action.fromValue = d->currentValue; action.toValue = value; actions << action; - QList<QmlMetaProperty> after; + QList<QDeclarativeProperty> after; if (d->animation) - d->animation->transition(actions, after, QmlAbstractAnimation::Forward); + d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward); d->animation->qtAnimation()->start(); if (!after.contains(d->property)) - d->property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } -void QmlBehavior::setTarget(const QmlMetaProperty &property) +void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property) { - Q_D(QmlBehavior); + Q_D(QDeclarativeBehavior); d->property = property; d->currentValue = property.read(); if (d->animation) diff --git a/src/declarative/util/qmlbehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h index ee9e862..a633b55 100644 --- a/src/declarative/util/qmlbehavior_p.h +++ b/src/declarative/util/qdeclarativebehavior_p.h @@ -39,14 +39,14 @@ ** ****************************************************************************/ -#ifndef QMLBEHAVIOR_H -#define QMLBEHAVIOR_H +#ifndef QDECLARATIVEBEHAVIOR_H +#define QDECLARATIVEBEHAVIOR_H -#include "qmlstate_p.h" +#include "qdeclarativestate_p.h" -#include <qmlpropertyvaluesource.h> -#include <qmlpropertyvalueinterceptor.h> -#include <qml.h> +#include <qdeclarativepropertyvaluesource.h> +#include <qdeclarativepropertyvalueinterceptor.h> +#include <qdeclarative.h> QT_BEGIN_HEADER @@ -54,27 +54,27 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlAbstractAnimation; -class QmlBehaviorPrivate; -class Q_DECLARATIVE_EXPORT QmlBehavior : public QObject, public QmlPropertyValueInterceptor +class QDeclarativeAbstractAnimation; +class QDeclarativeBehaviorPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeBehavior : public QObject, public QDeclarativePropertyValueInterceptor { Q_OBJECT - Q_DECLARE_PRIVATE(QmlBehavior) + Q_DECLARE_PRIVATE(QDeclarativeBehavior) - Q_INTERFACES(QmlPropertyValueInterceptor) + Q_INTERFACES(QDeclarativePropertyValueInterceptor) Q_CLASSINFO("DefaultProperty", "animation") - Q_PROPERTY(QmlAbstractAnimation *animation READ animation WRITE setAnimation) + Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: - QmlBehavior(QObject *parent=0); - ~QmlBehavior(); + QDeclarativeBehavior(QObject *parent=0); + ~QDeclarativeBehavior(); - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QDeclarativeProperty &); virtual void write(const QVariant &value); - QmlAbstractAnimation *animation(); - void setAnimation(QmlAbstractAnimation *); + QDeclarativeAbstractAnimation *animation(); + void setAnimation(QDeclarativeAbstractAnimation *); bool enabled() const; void setEnabled(bool enabled); @@ -85,8 +85,8 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlBehavior) +QML_DECLARE_TYPE(QDeclarativeBehavior) QT_END_HEADER -#endif // QMLBEHAVIOR_H +#endif // QDECLARATIVEBEHAVIOR_H diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qdeclarativebind.cpp index 6743edd..e95a03e 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qdeclarativebind.cpp @@ -39,12 +39,13 @@ ** ****************************************************************************/ -#include "qmlbind_p.h" +#include "qdeclarativebind_p.h" -#include "qmlnullablevalue_p_p.h" +#include "qdeclarativenullablevalue_p_p.h" -#include <qmlengine.h> -#include <qmlcontext.h> +#include <qdeclarativeengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeproperty.h> #include <QtCore/qfile.h> #include <QtCore/qdebug.h> @@ -56,21 +57,21 @@ QT_BEGIN_NAMESPACE -class QmlBindPrivate : public QObjectPrivate +class QDeclarativeBindPrivate : public QObjectPrivate { public: - QmlBindPrivate() : when(true), componentComplete(false), obj(0) {} + QDeclarativeBindPrivate() : when(true), componentComplete(false), obj(0) {} bool when : 1; bool componentComplete : 1; QObject *obj; QString prop; - QmlNullableValue<QVariant> value; + QDeclarativeNullableValue<QVariant> value; }; -QML_DEFINE_TYPE(Qt,4,6,Binding,QmlBind) + /*! - \qmlclass Binding QmlBind + \qmlclass Binding QDeclarativeBind \since 4.7 \brief The Binding element allows arbitrary property bindings to be created. @@ -94,34 +95,34 @@ QML_DEFINE_TYPE(Qt,4,6,Binding,QmlBind) */ /*! \internal - \class QmlBind + \class QDeclarativeBind \ingroup group_utility - \brief The QmlBind class allows arbitrary property bindings to be created. + \brief The QDeclarativeBind class allows arbitrary property bindings to be created. Simple bindings are usually earier to do in-place rather than creating a - QmlBind item. For that reason, QmlBind is usually used to transfer property information + QDeclarativeBind item. For that reason, QDeclarativeBind is usually used to transfer property information from Qml to C++. \sa cppqml */ -QmlBind::QmlBind(QObject *parent) - : QObject(*(new QmlBindPrivate), parent) +QDeclarativeBind::QDeclarativeBind(QObject *parent) + : QObject(*(new QDeclarativeBindPrivate), parent) { } -QmlBind::~QmlBind() +QDeclarativeBind::~QDeclarativeBind() { } -bool QmlBind::when() const +bool QDeclarativeBind::when() const { - Q_D(const QmlBind); + Q_D(const QDeclarativeBind); return d->when; } -void QmlBind::setWhen(bool v) +void QDeclarativeBind::setWhen(bool v) { - Q_D(QmlBind); + Q_D(QDeclarativeBind); d->when = v; eval(); } @@ -131,15 +132,15 @@ void QmlBind::setWhen(bool v) The object to be updated. */ -QObject *QmlBind::object() +QObject *QDeclarativeBind::object() { - Q_D(const QmlBind); + Q_D(const QDeclarativeBind); return d->obj; } -void QmlBind::setObject(QObject *obj) +void QDeclarativeBind::setObject(QObject *obj) { - Q_D(QmlBind); + Q_D(QDeclarativeBind); d->obj = obj; eval(); } @@ -149,15 +150,15 @@ void QmlBind::setObject(QObject *obj) The property to be updated. */ -QString QmlBind::property() const +QString QDeclarativeBind::property() const { - Q_D(const QmlBind); + Q_D(const QDeclarativeBind); return d->prop; } -void QmlBind::setProperty(const QString &p) +void QDeclarativeBind::setProperty(const QString &p) { - Q_D(QmlBind); + Q_D(QDeclarativeBind); d->prop = p; eval(); } @@ -168,34 +169,34 @@ void QmlBind::setProperty(const QString &p) The value to be set on the target object and property. This can be a constant (which isn't very useful), or a bound expression. */ -QVariant QmlBind::value() const +QVariant QDeclarativeBind::value() const { - Q_D(const QmlBind); + Q_D(const QDeclarativeBind); return d->value.value; } -void QmlBind::setValue(const QVariant &v) +void QDeclarativeBind::setValue(const QVariant &v) { - Q_D(QmlBind); + Q_D(QDeclarativeBind); d->value.value = v; d->value.isNull = false; eval(); } -void QmlBind::componentComplete() +void QDeclarativeBind::componentComplete() { - Q_D(QmlBind); + Q_D(QDeclarativeBind); d->componentComplete = true; eval(); } -void QmlBind::eval() +void QDeclarativeBind::eval() { - Q_D(QmlBind); + Q_D(QDeclarativeBind); if (!d->obj || d->value.isNull || !d->when || !d->componentComplete) return; - QmlMetaProperty prop(d->obj, d->prop); + QDeclarativeProperty prop(d->obj, d->prop); prop.write(d->value.value); } diff --git a/src/declarative/util/qmlbind_p.h b/src/declarative/util/qdeclarativebind_p.h index 6fdd2dc..f756e80 100644 --- a/src/declarative/util/qmlbind_p.h +++ b/src/declarative/util/qdeclarativebind_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLBIND_H -#define QMLBIND_H +#ifndef QDECLARATIVEBIND_H +#define QDECLARATIVEBIND_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qobject.h> @@ -52,20 +52,20 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlBindPrivate; -class Q_DECLARATIVE_EXPORT QmlBind : public QObject, public QmlParserStatus +class QDeclarativeBindPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeBind : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_DECLARE_PRIVATE(QmlBind) - Q_INTERFACES(QmlParserStatus) + Q_DECLARE_PRIVATE(QDeclarativeBind) + Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(QString property READ property WRITE setProperty) Q_PROPERTY(QVariant value READ value WRITE setValue) Q_PROPERTY(bool when READ when WRITE setWhen) public: - QmlBind(QObject *parent=0); - ~QmlBind(); + QDeclarativeBind(QObject *parent=0); + ~QDeclarativeBind(); bool when() const; void setWhen(bool); @@ -88,7 +88,7 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlBind) +QML_DECLARE_TYPE(QDeclarativeBind) QT_END_HEADER diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qdeclarativeconnection.cpp index 204377c..e9ae74b 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qdeclarativeconnection.cpp @@ -39,33 +39,34 @@ ** ****************************************************************************/ -#include "qmlconnection_p.h" +#include "qdeclarativeconnection_p.h" -#include <qmlexpression.h> -#include <qmlboundsignal_p.h> -#include <qmlcontext.h> +#include <qdeclarativeexpression.h> +#include <qdeclarativeboundsignal_p.h> +#include <qdeclarativecontext.h> #include <QtCore/qdebug.h> +#include <QtCore/qstringlist.h> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE -class QmlConnectionPrivate : public QObjectPrivate +class QDeclarativeConnectionPrivate : public QObjectPrivate { public: - QmlConnectionPrivate() : boundsignal(0), signalSender(0), scriptset(false), componentcomplete(false) {} + QDeclarativeConnectionPrivate() : boundsignal(0), signalSender(0), scriptset(false), componentcomplete(false) {} - QmlBoundSignal *boundsignal; + QDeclarativeBoundSignal *boundsignal; QObject *signalSender; - QmlScriptString script; + QDeclarativeScriptString script; bool scriptset; QString signal; bool componentcomplete; }; /*! - \qmlclass Connection QmlConnection + \qmlclass Connection QDeclarativeConnection \since 4.7 \brief A Connection object describes generalized connections to signals. @@ -104,7 +105,7 @@ public: \endqml More generally, the Connection object can be a child of some other object than - the sender of the signal, and the script is the default attribute: + the sender of the signal: \qml MouseArea { @@ -121,18 +122,18 @@ public: /*! \internal - \class QmlConnection - \brief The QmlConnection class describes generalized connections to signals. + \class QDeclarativeConnection + \brief The QDeclarativeConnection class describes generalized connections to signals. */ -QmlConnection::QmlConnection(QObject *parent) : - QObject(*(new QmlConnectionPrivate), parent) +QDeclarativeConnection::QDeclarativeConnection(QObject *parent) : + QObject(*(new QDeclarativeConnectionPrivate), parent) { } -QmlConnection::~QmlConnection() +QDeclarativeConnection::~QDeclarativeConnection() { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); delete d->boundsignal; } @@ -142,15 +143,15 @@ QmlConnection::~QmlConnection() By default, the sender is assumed to be the parent of the Connection. */ -QObject *QmlConnection::signalSender() const +QObject *QDeclarativeConnection::signalSender() const { - Q_D(const QmlConnection); + Q_D(const QDeclarativeConnection); return d->signalSender ? d->signalSender : parent(); } -void QmlConnection::setSignalSender(QObject *obj) +void QDeclarativeConnection::setSignalSender(QObject *obj) { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); if (d->signalSender == obj) return; disconnectIfValid(); @@ -158,9 +159,9 @@ void QmlConnection::setSignalSender(QObject *obj) connectIfValid(); } -void QmlConnection::connectIfValid() +void QDeclarativeConnection::connectIfValid() { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); if (!d->componentcomplete) return; // boundsignal must not exist @@ -197,13 +198,13 @@ void QmlConnection::connectIfValid() return; } - d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script.script(), sender, mo->method(sigIdx), this); + d->boundsignal = new QDeclarativeBoundSignal(qmlContext(this), d->script.script(), sender, mo->method(sigIdx), this); } } -void QmlConnection::disconnectIfValid() +void QDeclarativeConnection::disconnectIfValid() { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); if (!d->componentcomplete) return; if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) { @@ -214,9 +215,9 @@ void QmlConnection::disconnectIfValid() } } -void QmlConnection::componentComplete() +void QDeclarativeConnection::componentComplete() { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); d->componentcomplete=true; connectIfValid(); } @@ -225,18 +226,16 @@ void QmlConnection::componentComplete() /*! \qmlproperty script Connection::script This property holds the JavaScript executed whenever the signal is sent. - - This is the default attribute of Connection. */ -QmlScriptString QmlConnection::script() const +QDeclarativeScriptString QDeclarativeConnection::script() const { - Q_D(const QmlConnection); + Q_D(const QDeclarativeConnection); return d->script; } -void QmlConnection::setScript(const QmlScriptString& script) +void QDeclarativeConnection::setScript(const QDeclarativeScriptString& script) { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); if ((d->signalSender || parent()) && !d->signal.isEmpty()) { if (!d->scriptset) { // mustn't exist - create @@ -267,15 +266,15 @@ Connection { } \endqml */ -QString QmlConnection::signal() const +QString QDeclarativeConnection::signal() const { - Q_D(const QmlConnection); + Q_D(const QDeclarativeConnection); return d->signal; } -void QmlConnection::setSignal(const QString& sig) +void QDeclarativeConnection::setSignal(const QString& sig) { - Q_D(QmlConnection); + Q_D(QDeclarativeConnection); if (d->signal == sig) return; disconnectIfValid(); @@ -283,6 +282,6 @@ void QmlConnection::setSignal(const QString& sig) connectIfValid(); } -QML_DEFINE_TYPE(Qt,4,6,Connection,QmlConnection) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlconnection_p.h b/src/declarative/util/qdeclarativeconnection_p.h index 2106cb0..ae2efe9 100644 --- a/src/declarative/util/qmlconnection_p.h +++ b/src/declarative/util/qdeclarativeconnection_p.h @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLCONNECTION_H -#define QMLCONNECTION_H +#ifndef QDECLARATIVECONNECTION_H +#define QDECLARATIVECONNECTION_H -#include <qml.h> -#include <qmlscriptstring.h> +#include <qdeclarative.h> +#include <qdeclarativescriptstring.h> #include <QtCore/qobject.h> #include <QtCore/qstring.h> @@ -54,27 +54,27 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlBoundSignal; -class QmlContext; -class QmlConnectionPrivate; -class Q_DECLARATIVE_EXPORT QmlConnection : public QObject, public QmlParserStatus +class QDeclarativeBoundSignal; +class QDeclarativeContext; +class QDeclarativeConnectionPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeConnection : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_DECLARE_PRIVATE(QmlConnection) + Q_DECLARE_PRIVATE(QDeclarativeConnection) - Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QObject *sender READ signalSender WRITE setSignalSender) - Q_PROPERTY(QmlScriptString script READ script WRITE setScript) + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) Q_PROPERTY(QString signal READ signal WRITE setSignal) public: - QmlConnection(QObject *parent=0); - ~QmlConnection(); + QDeclarativeConnection(QObject *parent=0); + ~QDeclarativeConnection(); QObject *signalSender() const; void setSignalSender(QObject *); - QmlScriptString script() const; - void setScript(const QmlScriptString&); + QDeclarativeScriptString script() const; + void setScript(const QDeclarativeScriptString&); QString signal() const; void setSignal(const QString&); @@ -86,7 +86,7 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlConnection) +QML_DECLARE_TYPE(QDeclarativeConnection) QT_END_HEADER diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qdeclarativedatetimeformatter.cpp index 4b8fb00..4087091 100644 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ b/src/declarative/util/qdeclarativedatetimeformatter.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmldatetimeformatter_p.h" +#include "qdeclarativedatetimeformatter_p.h" #include <QtCore/qlocale.h> @@ -50,11 +50,11 @@ QT_BEGIN_NAMESPACE //TODO: may need optimisation as the QDateTime member may not be needed? // be able to set a locale? -class QmlDateTimeFormatterPrivate : public QObjectPrivate +class QDeclarativeDateTimeFormatterPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlDateTimeFormatter) + Q_DECLARE_PUBLIC(QDeclarativeDateTimeFormatter) public: - QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {} + QDeclarativeDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {} void updateText(); @@ -73,7 +73,7 @@ public: }; /*! - \qmlclass DateTimeFormatter QmlDateTimeFormatter + \qmlclass DateTimeFormatter QDeclarativeDateTimeFormatter \since 4.7 \brief The DateTimeFormatter allows you to control the format of a date string. @@ -88,17 +88,17 @@ public: /*! \internal - \class QmlDateTimeFormatter + \class QDeclarativeDateTimeFormatter \ingroup group_utility - \brief The QmlDateTimeFormatter class allows you to format a date string. + \brief The QDeclarativeDateTimeFormatter class allows you to format a date string. */ -QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent) -: QObject(*(new QmlDateTimeFormatterPrivate), parent) +QDeclarativeDateTimeFormatter::QDeclarativeDateTimeFormatter(QObject *parent) +: QObject(*(new QDeclarativeDateTimeFormatterPrivate), parent) { } -QmlDateTimeFormatter::~QmlDateTimeFormatter() +QDeclarativeDateTimeFormatter::~QDeclarativeDateTimeFormatter() { } @@ -128,21 +128,21 @@ QmlDateTimeFormatter::~QmlDateTimeFormatter() Text { text: "2/19/09" } \endcode */ -QString QmlDateTimeFormatter::dateTimeText() const +QString QDeclarativeDateTimeFormatter::dateTimeText() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->dateTimeText; } -QString QmlDateTimeFormatter::dateText() const +QString QDeclarativeDateTimeFormatter::dateText() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->dateText; } -QString QmlDateTimeFormatter::timeText() const +QString QDeclarativeDateTimeFormatter::timeText() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->timeText; } @@ -171,21 +171,21 @@ QString QmlDateTimeFormatter::timeText() const If no time is set, the dateTimeText will be just the time. */ -QDate QmlDateTimeFormatter::date() const +QDate QDeclarativeDateTimeFormatter::date() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->date; } -QTime QmlDateTimeFormatter::time() const +QTime QDeclarativeDateTimeFormatter::time() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->time; } -QDateTime QmlDateTimeFormatter::dateTime() const +QDateTime QDeclarativeDateTimeFormatter::dateTime() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->dateTime; } @@ -218,21 +218,21 @@ QDateTime QmlDateTimeFormatter::dateTime() const Assigning an empty string to a particular format will reset it. */ -QString QmlDateTimeFormatter::dateTimeFormat() const +QString QDeclarativeDateTimeFormatter::dateTimeFormat() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->dateTimeFormat; } -QString QmlDateTimeFormatter::dateFormat() const +QString QDeclarativeDateTimeFormatter::dateFormat() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->dateFormat; } -QString QmlDateTimeFormatter::timeFormat() const +QString QDeclarativeDateTimeFormatter::timeFormat() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->timeFormat; } @@ -244,15 +244,15 @@ QString QmlDateTimeFormatter::timeFormat() const This setting is off by default. */ -bool QmlDateTimeFormatter::longStyle() const +bool QDeclarativeDateTimeFormatter::longStyle() const { - Q_D(const QmlDateTimeFormatter); + Q_D(const QDeclarativeDateTimeFormatter); return d->longStyle; } -void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime) +void QDeclarativeDateTimeFormatter::setDateTime(const QDateTime &dateTime) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); if (d->dateTime == dateTime) return; d->dateTime = dateTime; @@ -261,9 +261,9 @@ void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime) d->updateText(); } -void QmlDateTimeFormatter::setTime(const QTime &time) +void QDeclarativeDateTimeFormatter::setTime(const QTime &time) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); if (d->dateTime.time() == time) return; d->time = time; @@ -271,9 +271,9 @@ void QmlDateTimeFormatter::setTime(const QTime &time) d->updateText(); } -void QmlDateTimeFormatter::setDate(const QDate &date) +void QDeclarativeDateTimeFormatter::setDate(const QDate &date) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); if (d->dateTime.date() == date) return; d->date = date; @@ -285,40 +285,40 @@ void QmlDateTimeFormatter::setDate(const QDate &date) } //DateTime formatting may be a combination of date and time? -void QmlDateTimeFormatter::setDateTimeFormat(const QString &format) +void QDeclarativeDateTimeFormatter::setDateTimeFormat(const QString &format) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); //no format checking d->dateTimeFormat = format; d->updateText(); } -void QmlDateTimeFormatter::setDateFormat(const QString &format) +void QDeclarativeDateTimeFormatter::setDateFormat(const QString &format) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); //no format checking d->dateFormat = format; d->updateText(); } -void QmlDateTimeFormatter::setTimeFormat(const QString &format) +void QDeclarativeDateTimeFormatter::setTimeFormat(const QString &format) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); //no format checking d->timeFormat = format; d->updateText(); } -void QmlDateTimeFormatter::setLongStyle(bool longStyle) +void QDeclarativeDateTimeFormatter::setLongStyle(bool longStyle) { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); d->longStyle = longStyle; d->updateText(); } -void QmlDateTimeFormatterPrivate::updateText() +void QDeclarativeDateTimeFormatterPrivate::updateText() { - Q_Q(QmlDateTimeFormatter); + Q_Q(QDeclarativeDateTimeFormatter); if (!componentComplete) return; @@ -355,19 +355,19 @@ void QmlDateTimeFormatterPrivate::updateText() emit q->textChanged(); } -void QmlDateTimeFormatter::classBegin() +void QDeclarativeDateTimeFormatter::classBegin() { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); d->componentComplete = false; } -void QmlDateTimeFormatter::componentComplete() +void QDeclarativeDateTimeFormatter::componentComplete() { - Q_D(QmlDateTimeFormatter); + Q_D(QDeclarativeDateTimeFormatter); d->componentComplete = true; d->updateText(); } -QML_DEFINE_TYPE(Qt,4,6,DateTimeFormatter,QmlDateTimeFormatter) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmldatetimeformatter_p.h b/src/declarative/util/qdeclarativedatetimeformatter_p.h index 2cd80b9..da900be 100644 --- a/src/declarative/util/qmldatetimeformatter_p.h +++ b/src/declarative/util/qdeclarativedatetimeformatter_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLDATETIMEFORMATTER_H -#define QMLDATETIMEFORMATTER_H +#ifndef QDECLARATIVEDATETIMEFORMATTER_H +#define QDECLARATIVEDATETIMEFORMATTER_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qdatetime.h> @@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlDateTimeFormatterPrivate; -class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus +class QDeclarativeDateTimeFormatterPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeDateTimeFormatter : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged) Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged) @@ -69,8 +69,8 @@ class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlPars Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle) public: - QmlDateTimeFormatter(QObject *parent=0); - ~QmlDateTimeFormatter(); + QDeclarativeDateTimeFormatter(QObject *parent=0); + ~QDeclarativeDateTimeFormatter(); QString dateTimeText() const; QString dateText() const; @@ -104,13 +104,13 @@ Q_SIGNALS: void textChanged(); private: - Q_DISABLE_COPY(QmlDateTimeFormatter) - Q_DECLARE_PRIVATE(QmlDateTimeFormatter) + Q_DISABLE_COPY(QDeclarativeDateTimeFormatter) + Q_DECLARE_PRIVATE(QDeclarativeDateTimeFormatter) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlDateTimeFormatter) +QML_DECLARE_TYPE(QDeclarativeDateTimeFormatter) QT_END_HEADER diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp index deb474a..232dc90 100644 --- a/src/declarative/util/qmleasefollow.cpp +++ b/src/declarative/util/qdeclarativeeasefollow.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#include "qmleasefollow_p.h" +#include "qdeclarativeeasefollow_p.h" -#include "qmlanimation_p_p.h" +#include "qdeclarativeanimation_p_p.h" -#include <qmlmetaproperty.h> +#include <qdeclarativeproperty.h> #include <QtCore/qdebug.h> @@ -51,15 +51,15 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,EaseFollow,QmlEaseFollow); -class QmlEaseFollowPrivate : public QObjectPrivate + +class QDeclarativeEaseFollowPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlEaseFollow) + Q_DECLARE_PUBLIC(QDeclarativeEaseFollow) public: - QmlEaseFollowPrivate() + QDeclarativeEaseFollowPrivate() : source(0), velocity(200), duration(-1), maximumEasingTime(-1), - reversingMode(QmlEaseFollow::Eased), initialVelocity(0), + reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0), initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0), lastTick(0), clock(this) {} @@ -68,7 +68,7 @@ public: qreal velocity; qreal duration; qreal maximumEasingTime; - QmlEaseFollow::ReversingMode reversingMode; + QDeclarativeEaseFollow::ReversingMode reversingMode; qreal initialVelocity; qreal initialValue; @@ -77,14 +77,14 @@ public: qreal trackVelocity; - QmlMetaProperty target; + QDeclarativeProperty target; int clockOffset; int lastTick; void tick(int); void clockStart(); void clockStop(); - QTickAnimationProxy<QmlEaseFollowPrivate, &QmlEaseFollowPrivate::tick> clock; + QTickAnimationProxy<QDeclarativeEaseFollowPrivate, &QDeclarativeEaseFollowPrivate::tick> clock; void restart(); @@ -101,7 +101,7 @@ public: bool recalc(); }; -bool QmlEaseFollowPrivate::recalc() +bool QDeclarativeEaseFollowPrivate::recalc() { qreal s = source - initialValue; vi = initialVelocity; @@ -179,7 +179,7 @@ bool QmlEaseFollowPrivate::recalc() return true; } -void QmlEaseFollowPrivate::clockStart() +void QDeclarativeEaseFollowPrivate::clockStart() { if (clock.state() == QAbstractAnimation::Running) { clockOffset = lastTick; @@ -191,14 +191,14 @@ void QmlEaseFollowPrivate::clockStart() } } -void QmlEaseFollowPrivate::clockStop() +void QDeclarativeEaseFollowPrivate::clockStop() { clockOffset = 0; lastTick = 0; clock.stop(); } -void QmlEaseFollowPrivate::tick(int t) +void QDeclarativeEaseFollowPrivate::tick(int t) { lastTick = t; t -= clockOffset; @@ -250,7 +250,7 @@ void QmlEaseFollowPrivate::tick(int t) } /*! - \qmlclass EaseFollow QmlEaseFollow + \qmlclass EaseFollow QDeclarativeEaseFollow \brief The EaseFollow element allows a property to smoothly track a value. The EaseFollow smoothly animates a property's value to a set target value @@ -310,12 +310,12 @@ Rectangle { \sa SpringFollow */ -QmlEaseFollow::QmlEaseFollow(QObject *parent) -: QObject(*(new QmlEaseFollowPrivate), parent) +QDeclarativeEaseFollow::QDeclarativeEaseFollow(QObject *parent) +: QObject(*(new QDeclarativeEaseFollowPrivate), parent) { } -QmlEaseFollow::~QmlEaseFollow() +QDeclarativeEaseFollow::~QDeclarativeEaseFollow() { } @@ -325,9 +325,9 @@ QmlEaseFollow::~QmlEaseFollow() Bind to a property in order to track its changes. */ -qreal QmlEaseFollow::sourceValue() const +qreal QDeclarativeEaseFollow::sourceValue() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->source; } @@ -342,15 +342,15 @@ qreal QmlEaseFollow::sourceValue() const begining with a velocity of 0. If the reversing mode is \c Sync, the property is immediately set to the target value. */ -QmlEaseFollow::ReversingMode QmlEaseFollow::reversingMode() const +QDeclarativeEaseFollow::ReversingMode QDeclarativeEaseFollow::reversingMode() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->reversingMode; } -void QmlEaseFollow::setReversingMode(ReversingMode m) +void QDeclarativeEaseFollow::setReversingMode(ReversingMode m) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); if (d->reversingMode == m) return; @@ -358,7 +358,7 @@ void QmlEaseFollow::setReversingMode(ReversingMode m) emit reversingModeChanged(); } -void QmlEaseFollowPrivate::restart() +void QDeclarativeEaseFollowPrivate::restart() { if (!enabled || velocity == 0) { clockStop(); @@ -378,12 +378,12 @@ void QmlEaseFollowPrivate::restart() if (hasReversed) { switch (reversingMode) { default: - case QmlEaseFollow::Eased: + case QDeclarativeEaseFollow::Eased: break; - case QmlEaseFollow::Sync: + case QDeclarativeEaseFollow::Sync: target.write(source); return; - case QmlEaseFollow::Immediate: + case QDeclarativeEaseFollow::Immediate: initialVelocity = 0; clockStop(); break; @@ -403,9 +403,9 @@ void QmlEaseFollowPrivate::restart() clockStart(); } -void QmlEaseFollow::setSourceValue(qreal s) +void QDeclarativeEaseFollow::setSourceValue(qreal s) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); if (d->clock.state() == QAbstractAnimation::Running && d->source == s) return; @@ -424,15 +424,15 @@ void QmlEaseFollow::setSourceValue(qreal s) Setting this to -1 (the default) disables the duration value. */ -qreal QmlEaseFollow::duration() const +qreal QDeclarativeEaseFollow::duration() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->duration; } -void QmlEaseFollow::setDuration(qreal v) +void QDeclarativeEaseFollow::setDuration(qreal v) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); if (d->duration == v) return; @@ -445,9 +445,9 @@ void QmlEaseFollow::setDuration(qreal v) emit durationChanged(); } -qreal QmlEaseFollow::velocity() const +qreal QDeclarativeEaseFollow::velocity() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->velocity; } @@ -460,9 +460,9 @@ qreal QmlEaseFollow::velocity() const Setting this to -1 disables the velocity value. */ -void QmlEaseFollow::setVelocity(qreal v) +void QDeclarativeEaseFollow::setVelocity(qreal v) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); if (d->velocity == v) return; @@ -479,15 +479,15 @@ void QmlEaseFollow::setVelocity(qreal v) \qmlproperty bool EaseFollow::enabled This property holds whether the target will track the source. */ -bool QmlEaseFollow::enabled() const +bool QDeclarativeEaseFollow::enabled() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->enabled; } -void QmlEaseFollow::setEnabled(bool enabled) +void QDeclarativeEaseFollow::setEnabled(bool enabled) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); if (d->enabled == enabled) return; @@ -500,9 +500,9 @@ void QmlEaseFollow::setEnabled(bool enabled) emit enabledChanged(); } -void QmlEaseFollow::setTarget(const QmlMetaProperty &t) +void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); d->target = t; } @@ -516,15 +516,15 @@ duration. The default value is -1. */ -qreal QmlEaseFollow::maximumEasingTime() const +qreal QDeclarativeEaseFollow::maximumEasingTime() const { - Q_D(const QmlEaseFollow); + Q_D(const QDeclarativeEaseFollow); return d->maximumEasingTime; } -void QmlEaseFollow::setMaximumEasingTime(qreal v) +void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v) { - Q_D(QmlEaseFollow); + Q_D(QDeclarativeEaseFollow); d->maximumEasingTime = v; if (d->clock.state() == QAbstractAnimation::Running) diff --git a/src/declarative/util/qmleasefollow_p.h b/src/declarative/util/qdeclarativeeasefollow_p.h index dddf54f..83d1eff 100644 --- a/src/declarative/util/qmleasefollow_p.h +++ b/src/declarative/util/qdeclarativeeasefollow_p.h @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLEASEFOLLOW_H -#define QMLEASEFOLLOW_H +#ifndef QDECLARATIVEEASEFOLLOW_H +#define QDECLARATIVEEASEFOLLOW_H -#include <qml.h> -#include <qmlpropertyvaluesource.h> +#include <qdeclarative.h> +#include <qdeclarativepropertyvaluesource.h> #include <QtCore/qobject.h> @@ -53,14 +53,14 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlMetaProperty; -class QmlEaseFollowPrivate; -class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject, - public QmlPropertyValueSource +class QDeclarativeProperty; +class QDeclarativeEaseFollowPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeEaseFollow : public QObject, + public QDeclarativePropertyValueSource { Q_OBJECT - Q_DECLARE_PRIVATE(QmlEaseFollow) - Q_INTERFACES(QmlPropertyValueSource) + Q_DECLARE_PRIVATE(QDeclarativeEaseFollow) + Q_INTERFACES(QDeclarativePropertyValueSource) Q_ENUMS(ReversingMode) Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue NOTIFY sourceChanged) @@ -73,8 +73,8 @@ class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject, public: enum ReversingMode { Eased, Immediate, Sync }; - QmlEaseFollow(QObject *parent = 0); - ~QmlEaseFollow(); + QDeclarativeEaseFollow(QObject *parent = 0); + ~QDeclarativeEaseFollow(); ReversingMode reversingMode() const; void setReversingMode(ReversingMode); @@ -94,7 +94,7 @@ public: qreal maximumEasingTime() const; void setMaximumEasingTime(qreal); - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QDeclarativeProperty &); Q_SIGNALS: void sourceChanged(); @@ -107,8 +107,8 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlEaseFollow); +QML_DECLARE_TYPE(QDeclarativeEaseFollow); QT_END_HEADER -#endif // QMLEASEFOLLOW_H +#endif // QDECLARATIVEEASEFOLLOW_H diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 4599b99..ac30384 100644 --- a/src/declarative/util/qmlfontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -39,11 +39,12 @@ ** ****************************************************************************/ -#include "qmlfontloader_p.h" +#include "qdeclarativefontloader_p.h" -#include <qmlcontext.h> -#include <qmlengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeengine.h> +#include <QStringList> #include <QUrl> #include <QDebug> #include <QNetworkRequest> @@ -55,25 +56,25 @@ QT_BEGIN_NAMESPACE -class QmlFontLoaderPrivate : public QObjectPrivate +class QDeclarativeFontLoaderPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlFontLoader) + Q_DECLARE_PUBLIC(QDeclarativeFontLoader) public: - QmlFontLoaderPrivate() : reply(0), status(QmlFontLoader::Null) {} + QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null) {} void addFontToDatabase(const QByteArray &); QUrl url; QString name; QNetworkReply *reply; - QmlFontLoader::Status status; + QDeclarativeFontLoader::Status status; }; -QML_DEFINE_TYPE(Qt,4,6,FontLoader,QmlFontLoader) + /*! - \qmlclass FontLoader QmlFontLoader + \qmlclass FontLoader QDeclarativeFontLoader \ingroup group_utility \brief This item allows using fonts by name or url. @@ -86,12 +87,12 @@ QML_DEFINE_TYPE(Qt,4,6,FontLoader,QmlFontLoader) Text { text: "Fancy font"; font.family: webFont.name } \endqml */ -QmlFontLoader::QmlFontLoader(QObject *parent) - : QObject(*(new QmlFontLoaderPrivate), parent) +QDeclarativeFontLoader::QDeclarativeFontLoader(QObject *parent) + : QObject(*(new QDeclarativeFontLoaderPrivate), parent) { } -QmlFontLoader::~QmlFontLoader() +QDeclarativeFontLoader::~QDeclarativeFontLoader() { } @@ -108,15 +109,15 @@ static QString toLocalFileOrQrc(const QUrl& url) \qmlproperty url FontLoader::source The url of the font to load. */ -QUrl QmlFontLoader::source() const +QUrl QDeclarativeFontLoader::source() const { - Q_D(const QmlFontLoader); + Q_D(const QDeclarativeFontLoader); return d->url; } -void QmlFontLoader::setSource(const QUrl &url) +void QDeclarativeFontLoader::setSource(const QUrl &url) { - Q_D(QmlFontLoader); + Q_D(QDeclarativeFontLoader); if (url == d->url) return; d->url = qmlContext(this)->resolvedUrl(url); @@ -130,9 +131,9 @@ void QmlFontLoader::setSource(const QUrl &url) if (id != -1) { d->name = QFontDatabase::applicationFontFamilies(id).at(0); emit nameChanged(); - d->status = QmlFontLoader::Ready; + d->status = QDeclarativeFontLoader::Ready; } else { - d->status = QmlFontLoader::Error; + d->status = QDeclarativeFontLoader::Error; qWarning() << "Cannot load font:" << url; } emit statusChanged(); @@ -160,15 +161,15 @@ void QmlFontLoader::setSource(const QUrl &url) Text { text: "Fancy font"; font.family: webFont.name } \endqml */ -QString QmlFontLoader::name() const +QString QDeclarativeFontLoader::name() const { - Q_D(const QmlFontLoader); + Q_D(const QDeclarativeFontLoader); return d->name; } -void QmlFontLoader::setName(const QString &name) +void QDeclarativeFontLoader::setName(const QString &name) { - Q_D(QmlFontLoader); + Q_D(QDeclarativeFontLoader); if (d->name == name ) return; d->name = name; @@ -188,15 +189,15 @@ void QmlFontLoader::setName(const QString &name) \o Error - an error occurred while loading the font \endlist */ -QmlFontLoader::Status QmlFontLoader::status() const +QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const { - Q_D(const QmlFontLoader); + Q_D(const QDeclarativeFontLoader); return d->status; } -void QmlFontLoader::replyFinished() +void QDeclarativeFontLoader::replyFinished() { - Q_D(QmlFontLoader); + Q_D(QDeclarativeFontLoader); if (d->reply) { if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); @@ -210,17 +211,17 @@ void QmlFontLoader::replyFinished() } } -void QmlFontLoaderPrivate::addFontToDatabase(const QByteArray &ba) +void QDeclarativeFontLoaderPrivate::addFontToDatabase(const QByteArray &ba) { - Q_Q(QmlFontLoader); + Q_Q(QDeclarativeFontLoader); int id = QFontDatabase::addApplicationFontFromData(ba); if (id != -1) { name = QFontDatabase::applicationFontFamilies(id).at(0); emit q->nameChanged(); - status = QmlFontLoader::Ready; + status = QDeclarativeFontLoader::Ready; } else { - status = QmlFontLoader::Error; + status = QDeclarativeFontLoader::Error; qWarning() << "Cannot load font:" << url; } emit q->statusChanged(); diff --git a/src/declarative/util/qmlfontloader_p.h b/src/declarative/util/qdeclarativefontloader_p.h index 3d27452..14335ab 100644 --- a/src/declarative/util/qmlfontloader_p.h +++ b/src/declarative/util/qdeclarativefontloader_p.h @@ -39,12 +39,13 @@ ** ****************************************************************************/ -#ifndef QMLFONTLOADER_H -#define QMLFONTLOADER_H +#ifndef QDECLARATIVEFONTLOADER_H +#define QDECLARATIVEFONTLOADER_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qobject.h> +#include <QtCore/qurl.h> QT_BEGIN_HEADER @@ -52,11 +53,11 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlFontLoaderPrivate; -class Q_DECLARATIVE_EXPORT QmlFontLoader : public QObject +class QDeclarativeFontLoaderPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeFontLoader : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QmlFontLoader) + Q_DECLARE_PRIVATE(QDeclarativeFontLoader) Q_ENUMS(Status) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) @@ -66,8 +67,8 @@ class Q_DECLARATIVE_EXPORT QmlFontLoader : public QObject public: enum Status { Null = 0, Ready, Loading, Error }; - QmlFontLoader(QObject *parent = 0); - ~QmlFontLoader(); + QDeclarativeFontLoader(QObject *parent = 0); + ~QDeclarativeFontLoader(); QUrl source() const; void setSource(const QUrl &url); @@ -87,9 +88,9 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlFontLoader) +QML_DECLARE_TYPE(QDeclarativeFontLoader) QT_END_HEADER -#endif // QMLFONTLOADER_H +#endif // QDECLARATIVEFONTLOADER_H diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qdeclarativelistaccessor.cpp index abdb626..4e56909 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qdeclarativelistaccessor.cpp @@ -39,37 +39,37 @@ ** ****************************************************************************/ -#include "qmllistaccessor_p.h" +#include "qdeclarativelistaccessor_p.h" -#include <qmlmetatype.h> +#include <qdeclarativemetatype_p.h> -#include <QStringList> +#include <QtCore/qstringlist.h> #include <QtCore/qdebug.h> // ### Remove me -#include <qmlengine_p.h> +#include <qdeclarativeengine_p.h> QT_BEGIN_NAMESPACE -QmlListAccessor::QmlListAccessor() +QDeclarativeListAccessor::QDeclarativeListAccessor() : m_type(Invalid) { } -QmlListAccessor::~QmlListAccessor() +QDeclarativeListAccessor::~QDeclarativeListAccessor() { } -QVariant QmlListAccessor::list() const +QVariant QDeclarativeListAccessor::list() const { return d; } -void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) +void QDeclarativeListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine) { d = v; - QmlEnginePrivate *enginePrivate = engine?QmlEnginePrivate::get(engine):0; + QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0; if (!d.isValid()) { m_type = Invalid; @@ -79,19 +79,19 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) m_type = VariantList; } else if (d.canConvert(QVariant::Int)) { m_type = Integer; - } else if ((!enginePrivate && QmlMetaType::isQObject(d.userType())) || + } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) || (enginePrivate && enginePrivate->isQObject(d.userType()))) { - QObject *data = enginePrivate?enginePrivate->toQObject(v):QmlMetaType::toQObject(v); + QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v); d = QVariant::fromValue(data); m_type = Instance; - } else if (d.userType() == qMetaTypeId<QmlListReference>()) { + } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) { m_type = ListProperty; } else { m_type = Instance; } } -int QmlListAccessor::count() const +int QDeclarativeListAccessor::count() const { switch(m_type) { case StringList: @@ -99,7 +99,7 @@ int QmlListAccessor::count() const case VariantList: return qvariant_cast<QVariantList>(d).count(); case ListProperty: - return ((QmlListReference *)d.constData())->count(); + return ((QDeclarativeListReference *)d.constData())->count(); case Instance: return 1; case Integer: @@ -110,7 +110,7 @@ int QmlListAccessor::count() const } } -QVariant QmlListAccessor::at(int idx) const +QVariant QDeclarativeListAccessor::at(int idx) const { Q_ASSERT(idx >= 0 && idx < count()); switch(m_type) { @@ -119,7 +119,7 @@ QVariant QmlListAccessor::at(int idx) const case VariantList: return qvariant_cast<QVariantList>(d).at(idx); case ListProperty: - return QVariant::fromValue(((QmlListReference *)d.constData())->at(idx)); + return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx)); case Instance: return d; case Integer: @@ -130,7 +130,7 @@ QVariant QmlListAccessor::at(int idx) const } } -bool QmlListAccessor::isValid() const +bool QDeclarativeListAccessor::isValid() const { return m_type != Invalid; } diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qdeclarativelistaccessor_p.h index 611eebb..d8bb8af 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qdeclarativelistaccessor_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLLISTACCESSOR_H -#define QMLLISTACCESSOR_H +#ifndef QDECLARATIVELISTACCESSOR_H +#define QDECLARATIVELISTACCESSOR_H #include <QtCore/QVariant> @@ -50,15 +50,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlEngine; -class Q_DECLARATIVE_EXPORT QmlListAccessor +class QDeclarativeEngine; +class Q_DECLARATIVE_EXPORT QDeclarativeListAccessor { public: - QmlListAccessor(); - ~QmlListAccessor(); + QDeclarativeListAccessor(); + ~QDeclarativeListAccessor(); QVariant list() const; - void setList(const QVariant &, QmlEngine * = 0); + void setList(const QVariant &, QDeclarativeEngine * = 0); bool isValid() const; @@ -77,4 +77,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QMLLISTACCESSOR_H +#endif // QDECLARATIVELISTACCESSOR_H diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 8fda3ae..e78e0e1 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "qmllistmodel_p.h" +#include "qdeclarativelistmodel_p.h" -#include "qmlopenmetaobject_p.h" +#include "qdeclarativeopenmetaobject_p.h" -#include <qmlcustomparser_p.h> -#include <qmlparser_p.h> -#include <qmlengine_p.h> -#include <qmlcontext.h> -#include <qmlinfo.h> +#include <qdeclarativecustomparser_p.h> +#include <qdeclarativeparser_p.h> +#include <qdeclarativeengine_p.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeinfo.h> #include <QtCore/qdebug.h> #include <QtCore/qstack.h> @@ -61,23 +61,15 @@ QT_BEGIN_NAMESPACE #define DATA_ROLE_ID 1 #define DATA_ROLE_NAME "data" -struct ListInstruction +QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListModelData::instructions() const { - enum { Push, Pop, Value, Set } type; - int dataIdx; -}; - -struct ListModelData -{ - int dataOffset; - int instrCount; - ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); } -}; + return (QDeclarativeListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData)); +} static void dump(ModelNode *node, int ind); /*! - \qmlclass ListModel QmlListModel + \qmlclass ListModel QDeclarativeListModel \brief The ListModel element defines a free-form list data source. The ListModel is a simple hierarchy of elements containing data roles. The contents can @@ -215,7 +207,7 @@ public: } private: - QmlOpenMetaObject *_mo; + QDeclarativeOpenMetaObject *_mo; }; struct ModelNode @@ -226,17 +218,17 @@ struct ModelNode QList<QVariant> values; QHash<QString, ModelNode *> properties; - QmlListModel *model(const QmlListModel *parent) { + QDeclarativeListModel *model(const QDeclarativeListModel *parent) { if (!modelCache) { - modelCache = new QmlListModel; - QmlEngine::setContextForObject(modelCache,QmlEngine::contextForObject(parent)); + modelCache = new QDeclarativeListModel; + QDeclarativeEngine::setContextForObject(modelCache,QDeclarativeEngine::contextForObject(parent)); modelCache->_root = this; } return modelCache; } - ModelObject *object(const QmlListModel *parent) { + ModelObject *object(const QDeclarativeListModel *parent) { if (!objectCache) { objectCache = new ModelObject(); QHash<QString, ModelNode *>::iterator it; @@ -263,7 +255,7 @@ struct ModelNode objectCache->setValue(prop.toUtf8(), val); } - QmlListModel *modelCache; + QDeclarativeListModel *modelCache; ModelObject *objectCache; bool isArray; }; @@ -312,21 +304,21 @@ void ModelNode::setListValue(const QScriptValue& valuelist) { ModelObject::ModelObject() -: _mo(new QmlOpenMetaObject(this)) +: _mo(new QDeclarativeOpenMetaObject(this)) { } -QmlListModel::QmlListModel(QObject *parent) +QDeclarativeListModel::QDeclarativeListModel(QObject *parent) : QListModelInterface(parent), _rolesOk(false), _root(0) { } -QmlListModel::~QmlListModel() +QDeclarativeListModel::~QDeclarativeListModel() { delete _root; } -void QmlListModel::checkRoles() const +void QDeclarativeListModel::checkRoles() const { if (_rolesOk || !_root) return; @@ -342,13 +334,13 @@ void QmlListModel::checkRoles() const _rolesOk = true; } -void QmlListModel::addRole(const QString &role) const +void QDeclarativeListModel::addRole(const QString &role) const { if (!roleStrings.contains(role)) roleStrings << role; } -QList<int> QmlListModel::roles() const +QList<int> QDeclarativeListModel::roles() const { checkRoles(); QList<int> rv; @@ -357,7 +349,7 @@ QList<int> QmlListModel::roles() const return rv; } -QString QmlListModel::toString(int role) const +QString QDeclarativeListModel::toString(int role) const { checkRoles(); if (role < roleStrings.count()) @@ -366,7 +358,7 @@ QString QmlListModel::toString(int role) const return QString(); } -QVariant QmlListModel::valueForNode(ModelNode *node) const +QVariant QDeclarativeListModel::valueForNode(ModelNode *node) const { QObject *rv = 0; @@ -401,7 +393,7 @@ QVariant QmlListModel::valueForNode(ModelNode *node) const return QVariant(); } -QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const +QHash<int,QVariant> QDeclarativeListModel::data(int index, const QList<int> &roles) const { checkRoles(); QHash<int, QVariant> rv; @@ -426,7 +418,7 @@ QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const return rv; } -QVariant QmlListModel::data(int index, int role) const +QVariant QDeclarativeListModel::data(int index, int role) const { checkRoles(); QVariant rv; @@ -453,7 +445,7 @@ QVariant QmlListModel::data(int index, int role) const \qmlproperty int ListModel::count The number of data entries in the model. */ -int QmlListModel::count() const +int QDeclarativeListModel::count() const { if (!_root) return 0; return _root->values.count(); @@ -467,7 +459,7 @@ int QmlListModel::count() const \sa append() remove() */ -void QmlListModel::clear() +void QDeclarativeListModel::clear() { int cleared = count(); _rolesOk = false; @@ -485,7 +477,7 @@ void QmlListModel::clear() \sa clear() */ -void QmlListModel::remove(int index) +void QDeclarativeListModel::remove(int index) { if (!_root || index < 0 || index >= _root->values.count()) { qmlInfo(this) << tr("remove: index %1 out of range").arg(index); @@ -515,7 +507,7 @@ void QmlListModel::remove(int index) \sa set() append() */ -void QmlListModel::insert(int index, const QScriptValue& valuemap) +void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap) { if (!valuemap.isObject() || valuemap.isArray()) { qmlInfo(this) << tr("insert: value is not an object"); @@ -551,7 +543,7 @@ void QmlListModel::insert(int index, const QScriptValue& valuemap) \sa append() */ -void QmlListModel::move(int from, int to, int n) +void QDeclarativeListModel::move(int from, int to, int n) { if (n==0 || from==to) return; @@ -602,7 +594,7 @@ void QmlListModel::move(int from, int to, int n) \sa set() remove() */ -void QmlListModel::append(const QScriptValue& valuemap) +void QDeclarativeListModel::append(const QScriptValue& valuemap) { if (!valuemap.isObject() || valuemap.isArray()) { qmlInfo(this) << tr("append: value is not an object"); @@ -641,7 +633,7 @@ void QmlListModel::append(const QScriptValue& valuemap) \sa append() */ -QScriptValue QmlListModel::get(int index) const +QScriptValue QDeclarativeListModel::get(int index) const { if (index >= count() || index < 0) { qmlInfo(this) << tr("get: index %1 out of range").arg(index); @@ -651,12 +643,12 @@ QScriptValue QmlListModel::get(int index) const ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); if (!node) return 0; - QmlEngine *eng = qmlEngine(this); + QDeclarativeEngine *eng = qmlEngine(this); if (!eng) { - qWarning("Cannot call QmlListModel::get() without a QmlEngine"); + qWarning("Cannot call QDeclarativeListModel::get() without a QDeclarativeEngine"); return 0; } - return QmlEnginePrivate::qmlScriptObject(node->object(this), eng); + return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); } /*! @@ -674,7 +666,7 @@ QScriptValue QmlListModel::get(int index) const \sa append() */ -void QmlListModel::set(int index, const QScriptValue& valuemap) +void QDeclarativeListModel::set(int index, const QScriptValue& valuemap) { if (!valuemap.isObject() || valuemap.isArray()) { qmlInfo(this) << tr("set: value is not an object"); @@ -717,7 +709,7 @@ void QmlListModel::set(int index, const QScriptValue& valuemap) \sa append() */ -void QmlListModel::setProperty(int index, const QString& property, const QVariant& value) +void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value) { if ( !_root || index >= _root->values.count() || index < 0) { qmlInfo(this) << tr("set: index %1 out of range").arg(index); @@ -737,26 +729,15 @@ void QmlListModel::setProperty(int index, const QString& property, const QVarian emit itemsChanged(index,1,roles); } -class QmlListModelParser : public QmlCustomParser -{ -public: - QByteArray compile(const QList<QmlCustomParserProperty> &); - bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data); - void setCustomData(QObject *, const QByteArray &); - -private: - bool definesEmptyList(const QString &); -}; - -bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) +bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) { QList<QVariant> values = prop.assignedValues(); for(int ii = 0; ii < values.count(); ++ii) { const QVariant &value = values.at(ii); - if(value.userType() == qMetaTypeId<QmlCustomParserNode>()) { - QmlCustomParserNode node = - qvariant_cast<QmlCustomParserNode>(value); + if(value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) { + QDeclarativeCustomParserNode node = + qvariant_cast<QDeclarativeCustomParserNode>(value); { ListInstruction li; @@ -765,15 +746,15 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL instr << li; } - QList<QmlCustomParserProperty> props = node.properties(); + QList<QDeclarativeCustomParserProperty> props = node.properties(); for(int jj = 0; jj < props.count(); ++jj) { - const QmlCustomParserProperty &nodeProp = props.at(jj); + const QDeclarativeCustomParserProperty &nodeProp = props.at(jj); if (nodeProp.name() == "") { - error(nodeProp, QmlListModel::tr("ListElement: cannot use default property")); + error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use default property")); return false; } if (nodeProp.name() == "id") { - error(nodeProp, QmlListModel::tr("ListElement: cannot use reserved \"id\" property")); + error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use reserved \"id\" property")); return false; } @@ -802,8 +783,8 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL } else { - QmlParser::Variant variant = - qvariant_cast<QmlParser::Variant>(value); + QDeclarativeParser::Variant variant = + qvariant_cast<QDeclarativeParser::Variant>(value); int ref = data.count(); @@ -817,9 +798,9 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL d += char(variant.asBoolean()); } else if (variant.isScript()) { if (definesEmptyList(variant.asScript())) { - d[0] = 0; // QmlParser::Variant::Invalid - marks empty list + d[0] = 0; // QDeclarativeParser::Variant::Invalid - marks empty list } else { - error(prop, QmlListModel::tr("ListElement: cannot use script for property value")); + error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); return false; } } @@ -836,15 +817,15 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL return true; } -QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps) +QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomParserProperty> &customProps) { QList<ListInstruction> instr; QByteArray data; for(int ii = 0; ii < customProps.count(); ++ii) { - const QmlCustomParserProperty &prop = customProps.at(ii); + const QDeclarativeCustomParserProperty &prop = customProps.at(ii); if(prop.name() != "") { // isn't default property - error(prop, QmlListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); + error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); return QByteArray(); } @@ -871,9 +852,9 @@ QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &cus return rv; } -void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) +void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &d) { - QmlListModel *rv = static_cast<QmlListModel *>(obj); + QDeclarativeListModel *rv = static_cast<QDeclarativeListModel *>(obj); ModelNode *root = new ModelNode; rv->_root = root; @@ -907,17 +888,17 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) case ListInstruction::Value: { ModelNode *n = nodes.top(); - switch (QmlParser::Variant::Type(data[instr.dataIdx])) { - case QmlParser::Variant::Invalid: + switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) { + case QDeclarativeParser::Variant::Invalid: n->isArray = true; break; - case QmlParser::Variant::Boolean: + case QDeclarativeParser::Variant::Boolean: n->values.append(bool(data[1 + instr.dataIdx])); break; - case QmlParser::Variant::Number: + case QDeclarativeParser::Variant::Number: n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble()); break; - case QmlParser::Variant::String: + case QDeclarativeParser::Variant::String: n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx)); break; default: @@ -941,7 +922,7 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) } } -bool QmlListModelParser::definesEmptyList(const QString &s) +bool QDeclarativeListModelParser::definesEmptyList(const QString &s) { if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) { for (int i=1; i<s.length()-1; i++) { @@ -953,20 +934,12 @@ bool QmlListModelParser::definesEmptyList(const QString &s) return false; } -QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, ListModel, QmlListModel, QmlListModelParser) - /*! \qmlclass ListElement \brief The ListElement element defines a data item in a ListModel. \sa ListModel */ -// ### FIXME -class QmlListElement : public QObject -{ -Q_OBJECT -}; -QML_DEFINE_TYPE(Qt,4,6,ListElement,QmlListElement) static void dump(ModelNode *node, int ind) { @@ -1007,6 +980,4 @@ ModelNode::~ModelNode() QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlListElement) - -#include <qmllistmodel.moc> +#include <qdeclarativelistmodel.moc> diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h index 4cf6746..251a31f 100644 --- a/src/declarative/util/qmllistmodel_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p.h @@ -39,10 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLLISTMODEL_H -#define QMLLISTMODEL_H +#ifndef QDECLARATIVELISTMODEL_H +#define QDECLARATIVELISTMODEL_H -#include <qml.h> +#include <qdeclarative.h> +#include <private/qdeclarativecustomparser_p.h> #include <QtCore/QObject> #include <QtCore/QStringList> @@ -59,14 +60,14 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) struct ModelNode; -class Q_DECLARATIVE_EXPORT QmlListModel : public QListModelInterface +class Q_DECLARATIVE_EXPORT QDeclarativeListModel : public QListModelInterface { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) public: - QmlListModel(QObject *parent=0); - ~QmlListModel(); + QDeclarativeListModel(QObject *parent=0); + ~QDeclarativeListModel(); virtual QList<int> roles() const; virtual QString toString(int role) const; @@ -89,7 +90,7 @@ Q_SIGNALS: private: QVariant valueForNode(ModelNode *) const; mutable QStringList roleStrings; - friend class QmlListModelParser; + friend class QDeclarativeListModelParser; friend struct ModelNode; void checkRoles() const; @@ -98,10 +99,41 @@ private: ModelNode *_root; }; +// ### FIXME +class QDeclarativeListElement : public QObject +{ +Q_OBJECT +}; + +class QDeclarativeListModelParser : public QDeclarativeCustomParser +{ +public: + QByteArray compile(const QList<QDeclarativeCustomParserProperty> &); + void setCustomData(QObject *, const QByteArray &); + +private: + struct ListInstruction + { + enum { Push, Pop, Value, Set } type; + int dataIdx; + }; + struct ListModelData + { + int dataOffset; + int instrCount; + ListInstruction *instructions() const; + }; + bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data); + + bool definesEmptyList(const QString &); +}; + + QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlListModel) +QML_DECLARE_TYPE(QDeclarativeListModel) +QML_DECLARE_TYPE(QDeclarativeListElement) QT_END_HEADER -#endif // QMLLISTMODEL_H +#endif // QDECLARATIVELISTMODEL_H diff --git a/src/declarative/util/qmlnullablevalue_p_p.h b/src/declarative/util/qdeclarativenullablevalue_p_p.h index c426258..fc3f8af 100644 --- a/src/declarative/util/qmlnullablevalue_p_p.h +++ b/src/declarative/util/qdeclarativenullablevalue_p_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLNULLABLEVALUE_P_H -#define QMLNULLABLEVALUE_P_H +#ifndef QDECLARATIVENULLABLEVALUE_P_H +#define QDECLARATIVENULLABLEVALUE_P_H // // W A R N I N G @@ -56,17 +56,17 @@ QT_BEGIN_NAMESPACE template<typename T> -struct QmlNullableValue +struct QDeclarativeNullableValue { - QmlNullableValue() + QDeclarativeNullableValue() : isNull(true), value(T()) {} - QmlNullableValue(const QmlNullableValue<T> &o) + QDeclarativeNullableValue(const QDeclarativeNullableValue<T> &o) : isNull(o.isNull), value(o.value) {} - QmlNullableValue(const T &t) + QDeclarativeNullableValue(const T &t) : isNull(false), value(t) {} - QmlNullableValue<T> &operator=(const T &t) + QDeclarativeNullableValue<T> &operator=(const T &t) { isNull = false; value = t; return *this; } - QmlNullableValue<T> &operator=(const QmlNullableValue<T> &o) + QDeclarativeNullableValue<T> &operator=(const QDeclarativeNullableValue<T> &o) { isNull = o.isNull; value = o.value; return *this; } operator T() const { return value; } @@ -78,4 +78,4 @@ struct QmlNullableValue QT_END_NAMESPACE -#endif // QMLNULLABLEVALUE_P_H +#endif // QDECLARATIVENULLABLEVALUE_P_H diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qdeclarativenumberformatter.cpp index 0845d0c..5d81958 100644 --- a/src/declarative/util/qmlnumberformatter.cpp +++ b/src/declarative/util/qdeclarativenumberformatter.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmlnumberformatter_p.h" +#include "qdeclarativenumberformatter_p.h" #include <private/qobject_p.h> @@ -50,11 +50,11 @@ QT_BEGIN_NAMESPACE // this is a wrapper around qnumberformat (test integration) // if number or format haven't been explictly set, text should be an empty string -class QmlNumberFormatterPrivate : public QObjectPrivate +class QDeclarativeNumberFormatterPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlNumberFormatter) + Q_DECLARE_PUBLIC(QDeclarativeNumberFormatter) public: - QmlNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {} + QDeclarativeNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {} void updateText(); @@ -81,17 +81,17 @@ public: */ /*! \internal - \class QmlNumberFormatter + \class QDeclarativeNumberFormatter \ingroup group_utility - \brief The QmlNumberFormatter class allows you to format a number to a particular string format/locale specific number format. + \brief The QDeclarativeNumberFormatter class allows you to format a number to a particular string format/locale specific number format. */ -QmlNumberFormatter::QmlNumberFormatter(QObject *parent) -: QObject(*(new QmlNumberFormatterPrivate), parent) +QDeclarativeNumberFormatter::QDeclarativeNumberFormatter(QObject *parent) +: QObject(*(new QDeclarativeNumberFormatterPrivate), parent) { } -QmlNumberFormatter::~QmlNumberFormatter() +QDeclarativeNumberFormatter::~QDeclarativeNumberFormatter() { } @@ -103,9 +103,9 @@ QmlNumberFormatter::~QmlNumberFormatter() If no format is specified the text will be empty. */ -QString QmlNumberFormatter::text() const +QString QDeclarativeNumberFormatter::text() const { - Q_D(const QmlNumberFormatter); + Q_D(const QDeclarativeNumberFormatter); return d->text; } @@ -115,9 +115,9 @@ QString QmlNumberFormatter::text() const A single point precision number. (Doubles are not yet supported) */ -qreal QmlNumberFormatter::number() const +qreal QDeclarativeNumberFormatter::number() const { - Q_D(const QmlNumberFormatter); + Q_D(const QDeclarativeNumberFormatter); return d->number; } @@ -203,24 +203,24 @@ qreal QmlNumberFormatter::number() const \endtable */ -QString QmlNumberFormatter::format() const +QString QDeclarativeNumberFormatter::format() const { - Q_D(const QmlNumberFormatter); + Q_D(const QDeclarativeNumberFormatter); return d->format; } -void QmlNumberFormatter::setNumber(const qreal &number) +void QDeclarativeNumberFormatter::setNumber(const qreal &number) { - Q_D(QmlNumberFormatter); + Q_D(QDeclarativeNumberFormatter); if (d->number == number) return; d->number = number; d->updateText(); } -void QmlNumberFormatter::setFormat(const QString &format) +void QDeclarativeNumberFormatter::setFormat(const QString &format) { - Q_D(QmlNumberFormatter); + Q_D(QDeclarativeNumberFormatter); //no format checking if (format.isEmpty()) d->format = QString::null; @@ -229,9 +229,9 @@ void QmlNumberFormatter::setFormat(const QString &format) d->updateText(); } -void QmlNumberFormatterPrivate::updateText() +void QDeclarativeNumberFormatterPrivate::updateText() { - Q_Q(QmlNumberFormatter); + Q_Q(QDeclarativeNumberFormatter); if (!componentComplete) return; @@ -244,18 +244,18 @@ void QmlNumberFormatterPrivate::updateText() emit q->textChanged(); } -void QmlNumberFormatter::classBegin() +void QDeclarativeNumberFormatter::classBegin() { - Q_D(QmlNumberFormatter); + Q_D(QDeclarativeNumberFormatter); d->componentComplete = false; } -void QmlNumberFormatter::componentComplete() +void QDeclarativeNumberFormatter::componentComplete() { - Q_D(QmlNumberFormatter); + Q_D(QDeclarativeNumberFormatter); d->componentComplete = true; d->updateText(); } -QML_DEFINE_TYPE(Qt,4,6,NumberFormatter,QmlNumberFormatter); + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlnumberformatter_p.h b/src/declarative/util/qdeclarativenumberformatter_p.h index d08885b..3b8c7e1 100644 --- a/src/declarative/util/qmlnumberformatter_p.h +++ b/src/declarative/util/qdeclarativenumberformatter_p.h @@ -39,12 +39,12 @@ ** ****************************************************************************/ -#ifndef QMLNUMBERFORMATTER_H -#define QMLNUMBERFORMATTER_H +#ifndef QDECLARATIVENUMBERFORMATTER_H +#define QDECLARATIVENUMBERFORMATTER_H #include "qnumberformat_p.h" -#include <qml.h> +#include <qdeclarative.h> QT_BEGIN_HEADER @@ -52,18 +52,18 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlNumberFormatterPrivate; -class Q_DECLARATIVE_EXPORT QmlNumberFormatter : public QObject, public QmlParserStatus +class QDeclarativeNumberFormatterPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeNumberFormatter : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QString text READ text NOTIFY textChanged) Q_PROPERTY(QString format READ format WRITE setFormat) Q_PROPERTY(qreal number READ number WRITE setNumber) public: - QmlNumberFormatter(QObject *parent=0); - ~QmlNumberFormatter(); + QDeclarativeNumberFormatter(QObject *parent=0); + ~QDeclarativeNumberFormatter(); QString text() const; @@ -80,13 +80,13 @@ Q_SIGNALS: void textChanged(); private: - Q_DISABLE_COPY(QmlNumberFormatter) - Q_DECLARE_PRIVATE(QmlNumberFormatter) + Q_DISABLE_COPY(QDeclarativeNumberFormatter) + Q_DECLARE_PRIVATE(QDeclarativeNumberFormatter) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlNumberFormatter) +QML_DECLARE_TYPE(QDeclarativeNumberFormatter) QT_END_HEADER diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp index 0847c47..8c23354 100644 --- a/src/declarative/util/qmlopenmetaobject.cpp +++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp @@ -39,19 +39,19 @@ ** ****************************************************************************/ -#include "qmlopenmetaobject_p.h" -#include "qmlpropertycache_p.h" -#include "qmldeclarativedata_p.h" +#include "qdeclarativeopenmetaobject_p.h" +#include "qdeclarativepropertycache_p.h" +#include "qdeclarativedeclarativedata_p.h" #include <qmetaobjectbuilder_p.h> #include <qdebug.h> QT_BEGIN_NAMESPACE -class QmlOpenMetaObjectTypePrivate +class QDeclarativeOpenMetaObjectTypePrivate { public: - QmlOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {} + QDeclarativeOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {} void init(const QMetaObject *metaObj); @@ -60,19 +60,19 @@ public: QHash<QByteArray, int> names; QMetaObjectBuilder mob; QMetaObject *mem; - QmlPropertyCache *cache; - QmlEngine *engine; - QSet<QmlOpenMetaObject*> referers; + QDeclarativePropertyCache *cache; + QDeclarativeEngine *engine; + QSet<QDeclarativeOpenMetaObject*> referers; }; -QmlOpenMetaObjectType::QmlOpenMetaObjectType(const QMetaObject *base, QmlEngine *engine) - : d(new QmlOpenMetaObjectTypePrivate) +QDeclarativeOpenMetaObjectType::QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine) + : d(new QDeclarativeOpenMetaObjectTypePrivate) { d->engine = engine; d->init(base); } -QmlOpenMetaObjectType::~QmlOpenMetaObjectType() +QDeclarativeOpenMetaObjectType::~QDeclarativeOpenMetaObjectType() { if (d->mem) qFree(d->mem); @@ -82,17 +82,17 @@ QmlOpenMetaObjectType::~QmlOpenMetaObjectType() } -int QmlOpenMetaObjectType::propertyOffset() const +int QDeclarativeOpenMetaObjectType::propertyOffset() const { return d->propertyOffset; } -int QmlOpenMetaObjectType::signalOffset() const +int QDeclarativeOpenMetaObjectType::signalOffset() const { return d->signalOffset; } -int QmlOpenMetaObjectType::createProperty(const QByteArray &name) +int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name) { int id = d->mob.propertyCount(); d->mob.addSignal("__" + QByteArray::number(id) + "()"); @@ -102,9 +102,9 @@ int QmlOpenMetaObjectType::createProperty(const QByteArray &name) qFree(d->mem); d->mem = d->mob.toMetaObject(); d->names.insert(name, id); - QSet<QmlOpenMetaObject*>::iterator it = d->referers.begin(); + QSet<QDeclarativeOpenMetaObject*>::iterator it = d->referers.begin(); while (it != d->referers.end()) { - QmlOpenMetaObject *omo = *it; + QDeclarativeOpenMetaObject *omo = *it; *static_cast<QMetaObject *>(omo) = *d->mem; if (d->cache) d->cache->update(d->engine, omo); @@ -114,13 +114,13 @@ int QmlOpenMetaObjectType::createProperty(const QByteArray &name) return d->propertyOffset + id; } -void QmlOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder) +void QDeclarativeOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder) { if (d->referers.count()) (*d->referers.begin())->propertyCreated(id, builder); } -void QmlOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj) +void QDeclarativeOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj) { if (!mem) { mob.setSuperClass(metaObj); @@ -136,10 +136,10 @@ void QmlOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj) //---------------------------------------------------------------------------- -class QmlOpenMetaObjectPrivate +class QDeclarativeOpenMetaObjectPrivate { public: - QmlOpenMetaObjectPrivate(QmlOpenMetaObject *_q) + QDeclarativeOpenMetaObjectPrivate(QDeclarativeOpenMetaObject *_q) : q(_q), parent(0), type(0), cacheProperties(false) {} inline QVariant &getData(int idx) { @@ -162,21 +162,21 @@ public: } bool autoCreate; - QmlOpenMetaObject *q; + QDeclarativeOpenMetaObject *q; QAbstractDynamicMetaObject *parent; QList<QPair<QVariant, bool> > data; QObject *object; - QmlOpenMetaObjectType *type; + QDeclarativeOpenMetaObjectType *type; bool cacheProperties; }; -QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, bool automatic) -: d(new QmlOpenMetaObjectPrivate(this)) +QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, bool automatic) +: d(new QDeclarativeOpenMetaObjectPrivate(this)) { d->autoCreate = automatic; d->object = obj; - d->type = new QmlOpenMetaObjectType(obj->metaObject(), 0); + d->type = new QDeclarativeOpenMetaObjectType(obj->metaObject(), 0); d->type->d->referers.insert(this); QObjectPrivate *op = QObjectPrivate::get(obj); @@ -184,8 +184,8 @@ QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, bool automatic) op->metaObject = this; } -QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, QmlOpenMetaObjectType *type, bool automatic) -: d(new QmlOpenMetaObjectPrivate(this)) +QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, QDeclarativeOpenMetaObjectType *type, bool automatic) +: d(new QDeclarativeOpenMetaObjectPrivate(this)) { d->autoCreate = automatic; d->object = obj; @@ -199,7 +199,7 @@ QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, QmlOpenMetaObjectType *type, op->metaObject = this; } -QmlOpenMetaObject::~QmlOpenMetaObject() +QDeclarativeOpenMetaObject::~QDeclarativeOpenMetaObject() { if (d->parent) delete d->parent; @@ -208,12 +208,12 @@ QmlOpenMetaObject::~QmlOpenMetaObject() delete d; } -QmlOpenMetaObjectType *QmlOpenMetaObject::type() const +QDeclarativeOpenMetaObjectType *QDeclarativeOpenMetaObject::type() const { return d->type; } -int QmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) +int QDeclarativeOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) { if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) && id >= d->type->d->propertyOffset) { @@ -237,23 +237,23 @@ int QmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) } } -QAbstractDynamicMetaObject *QmlOpenMetaObject::parent() const +QAbstractDynamicMetaObject *QDeclarativeOpenMetaObject::parent() const { return d->parent; } -QVariant QmlOpenMetaObject::value(int id) const +QVariant QDeclarativeOpenMetaObject::value(int id) const { return d->getData(id); } -void QmlOpenMetaObject::setValue(int id, const QVariant &value) +void QDeclarativeOpenMetaObject::setValue(int id, const QVariant &value) { d->writeData(id, value); activate(d->object, id + d->type->d->signalOffset, 0); } -QVariant QmlOpenMetaObject::value(const QByteArray &name) const +QVariant QDeclarativeOpenMetaObject::value(const QByteArray &name) const { QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name); if (iter == d->type->d->names.end()) @@ -262,7 +262,7 @@ QVariant QmlOpenMetaObject::value(const QByteArray &name) const return d->getData(*iter); } -QVariant &QmlOpenMetaObject::operator[](const QByteArray &name) +QVariant &QDeclarativeOpenMetaObject::operator[](const QByteArray &name) { QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name); Q_ASSERT(iter != d->type->d->names.end()); @@ -270,7 +270,7 @@ QVariant &QmlOpenMetaObject::operator[](const QByteArray &name) return d->getData(*iter); } -void QmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val) +void QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant &val) { QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name); @@ -289,17 +289,17 @@ void QmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val) activate(d->object, id + d->type->d->signalOffset, 0); } -void QmlOpenMetaObject::setCached(bool c) +void QDeclarativeOpenMetaObject::setCached(bool c) { if (c == d->cacheProperties || !d->type->d->engine) return; d->cacheProperties = c; - QmlDeclarativeData *qmldata = QmlDeclarativeData::get(d->object, true); + QDeclarativeDeclarativeData *qmldata = QDeclarativeDeclarativeData::get(d->object, true); if (d->cacheProperties) { if (!d->type->d->cache) - d->type->d->cache = QmlPropertyCache::create(d->type->d->engine, this); + d->type->d->cache = QDeclarativePropertyCache::create(d->type->d->engine, this); qmldata->propertyCache = d->type->d->cache; d->type->d->cache->addref(); } else { @@ -310,7 +310,7 @@ void QmlOpenMetaObject::setCached(bool c) } -int QmlOpenMetaObject::createProperty(const char *name, const char *) +int QDeclarativeOpenMetaObject::createProperty(const char *name, const char *) { if (d->autoCreate) return d->type->createProperty(name); @@ -318,36 +318,36 @@ int QmlOpenMetaObject::createProperty(const char *name, const char *) return -1; } -void QmlOpenMetaObject::propertyRead(int) +void QDeclarativeOpenMetaObject::propertyRead(int) { } -void QmlOpenMetaObject::propertyWrite(int) +void QDeclarativeOpenMetaObject::propertyWrite(int) { } -void QmlOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &) +void QDeclarativeOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &) { } -QVariant QmlOpenMetaObject::initialValue(int) +QVariant QDeclarativeOpenMetaObject::initialValue(int) { return QVariant(); } -int QmlOpenMetaObject::count() const +int QDeclarativeOpenMetaObject::count() const { return d->type->d->names.count(); } -QByteArray QmlOpenMetaObject::name(int idx) const +QByteArray QDeclarativeOpenMetaObject::name(int idx) const { Q_ASSERT(idx >= 0 && idx < d->type->d->names.count()); return d->type->d->mob.property(idx).name(); } -QObject *QmlOpenMetaObject::object() const +QObject *QDeclarativeOpenMetaObject::object() const { return d->object; } diff --git a/src/declarative/util/qmlopenmetaobject_p.h b/src/declarative/util/qdeclarativeopenmetaobject_p.h index 3f9450d..ec5ac17 100644 --- a/src/declarative/util/qmlopenmetaobject_p.h +++ b/src/declarative/util/qdeclarativeopenmetaobject_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLOPENMETAOBJECT_H -#define QMLOPENMETAOBJECT_H +#ifndef QDECLARATIVEOPENMETAOBJECT_H +#define QDECLARATIVEOPENMETAOBJECT_H -#include <private/qmlrefcount_p.h> +#include <private/qdeclarativerefcount_p.h> #include <QtCore/QMetaObject> #include <QtCore/QObject> @@ -54,14 +54,14 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlEngine; +class QDeclarativeEngine; class QMetaPropertyBuilder; -class QmlOpenMetaObjectTypePrivate; -class Q_DECLARATIVE_EXPORT QmlOpenMetaObjectType : public QmlRefCount +class QDeclarativeOpenMetaObjectTypePrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObjectType : public QDeclarativeRefCount { public: - QmlOpenMetaObjectType(const QMetaObject *base, QmlEngine *engine); - ~QmlOpenMetaObjectType(); + QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine); + ~QDeclarativeOpenMetaObjectType(); int createProperty(const QByteArray &name); @@ -72,18 +72,18 @@ protected: virtual void propertyCreated(int, QMetaPropertyBuilder &); private: - QmlOpenMetaObjectTypePrivate *d; - friend class QmlOpenMetaObject; - friend class QmlOpenMetaObjectPrivate; + QDeclarativeOpenMetaObjectTypePrivate *d; + friend class QDeclarativeOpenMetaObject; + friend class QDeclarativeOpenMetaObjectPrivate; }; -class QmlOpenMetaObjectPrivate; -class Q_DECLARATIVE_EXPORT QmlOpenMetaObject : public QAbstractDynamicMetaObject +class QDeclarativeOpenMetaObjectPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObject : public QAbstractDynamicMetaObject { public: - QmlOpenMetaObject(QObject *, bool = true); - QmlOpenMetaObject(QObject *, QmlOpenMetaObjectType *, bool = true); - ~QmlOpenMetaObject(); + QDeclarativeOpenMetaObject(QObject *, bool = true); + QDeclarativeOpenMetaObject(QObject *, QDeclarativeOpenMetaObjectType *, bool = true); + ~QDeclarativeOpenMetaObject(); QVariant value(const QByteArray &) const; void setValue(const QByteArray &, const QVariant &); @@ -101,7 +101,7 @@ public: // longer automatically called for new properties. void setCached(bool); - QmlOpenMetaObjectType *type() const; + QDeclarativeOpenMetaObjectType *type() const; protected: virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); @@ -114,12 +114,12 @@ protected: QAbstractDynamicMetaObject *parent() const; private: - QmlOpenMetaObjectPrivate *d; - friend class QmlOpenMetaObjectType; + QDeclarativeOpenMetaObjectPrivate *d; + friend class QDeclarativeOpenMetaObjectType; }; QT_END_NAMESPACE QT_END_HEADER -#endif // QMLOPENMETAOBJECT_H +#endif // QDECLARATIVEOPENMETAOBJECT_H diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 82f776f..34ae466 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -39,21 +39,48 @@ ** ****************************************************************************/ -#include "qmlpackage_p.h" +#include "qdeclarativepackage_p.h" #include <private/qobject_p.h> -#include "private/qmlguard_p.h" +#include "private/qdeclarativeguard_p.h" QT_BEGIN_NAMESPACE -class QmlPackagePrivate : public QObjectPrivate +/*! + \qmlclass Package QDeclarativePackage + \brief Package provides a collection of named items + + The Package class is currently used in conjunction with + VisualDataModel to enable delegates with a shared context + to be provided to multiple views. + + Any item within a Package may be assigned a name via the + \e {Package.name} attached property. + + The example below creates a Package containing two named items; + \e list and \e grid. The third element in the package is parented to whichever + delegate it should appear in. This allows an item to move + between views. + + \snippet examples/declarative/package/Delegate.qml 0 + + These named items are used as the delegates by the two views who + reference the special VisualDataModel.parts property to select + a model which provides the chosen delegate. + + \snippet examples/declarative/package/view.qml 0 + +*/ + + +class QDeclarativePackagePrivate : public QObjectPrivate { public: - QmlPackagePrivate() {} + QDeclarativePackagePrivate() {} - struct DataGuard : public QmlGuard<QObject> + struct DataGuard : public QDeclarativeGuard<QObject> { - DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; } + DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; } QList<DataGuard> *list; void objectDestroyed(QObject *) { // we assume priv will always be destroyed after objectDestroyed calls @@ -62,107 +89,91 @@ public: }; QList<DataGuard> dataList; - static void data_append(QmlListProperty<QObject> *prop, QObject *o) { + static void data_append(QDeclarativeListProperty<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) { + static void data_clear(QDeclarativeListProperty<QObject> *prop) { QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data); list->clear(); } - static QObject *data_at(QmlListProperty<QObject> *prop, int index) { + static QObject *data_at(QDeclarativeListProperty<QObject> *prop, int index) { QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data); return list->at(index); } - static int data_count(QmlListProperty<QObject> *prop) { + static int data_count(QDeclarativeListProperty<QObject> *prop) { QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data); return list->count(); } }; -class QmlPackageAttached : public QObject -{ -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -public: - QmlPackageAttached(QObject *parent); - virtual ~QmlPackageAttached(); - - QString name() const; - void setName(const QString &n); - - static QHash<QObject *, QmlPackageAttached *> attached; -private: - QString _name; -}; - -QHash<QObject *, QmlPackageAttached *> QmlPackageAttached::attached; +QHash<QObject *, QDeclarativePackageAttached *> QDeclarativePackageAttached::attached; -QmlPackageAttached::QmlPackageAttached(QObject *parent) +QDeclarativePackageAttached::QDeclarativePackageAttached(QObject *parent) : QObject(parent) { attached.insert(parent, this); } -QmlPackageAttached::~QmlPackageAttached() +QDeclarativePackageAttached::~QDeclarativePackageAttached() { attached.remove(parent()); } -QString QmlPackageAttached::name() const +QString QDeclarativePackageAttached::name() const { return _name; } -void QmlPackageAttached::setName(const QString &n) +void QDeclarativePackageAttached::setName(const QString &n) { _name = n; } -QmlPackage::QmlPackage(QObject *parent) - : QObject(*(new QmlPackagePrivate), parent) +QDeclarativePackage::QDeclarativePackage(QObject *parent) + : QObject(*(new QDeclarativePackagePrivate), parent) { } -QmlPackage::~QmlPackage() +QDeclarativePackage::~QDeclarativePackage() { - Q_D(QmlPackage); + Q_D(QDeclarativePackage); for (int ii = 0; ii < d->dataList.count(); ++ii) { QObject *obj = d->dataList.at(ii); obj->setParent(this); } } -QmlListProperty<QObject> QmlPackage::data() +QDeclarativeListProperty<QObject> QDeclarativePackage::data() { - Q_D(QmlPackage); - return QmlListProperty<QObject>(this, &d->dataList, QmlPackagePrivate::data_append, - QmlPackagePrivate::data_count, - QmlPackagePrivate::data_at, - QmlPackagePrivate::data_clear); + Q_D(QDeclarativePackage); + return QDeclarativeListProperty<QObject>(this, &d->dataList, QDeclarativePackagePrivate::data_append, + QDeclarativePackagePrivate::data_count, + QDeclarativePackagePrivate::data_at, + QDeclarativePackagePrivate::data_clear); } -bool QmlPackage::hasPart(const QString &name) +bool QDeclarativePackage::hasPart(const QString &name) { - Q_D(QmlPackage); + Q_D(QDeclarativePackage); for (int ii = 0; ii < d->dataList.count(); ++ii) { QObject *obj = d->dataList.at(ii); - QmlPackageAttached *a = QmlPackageAttached::attached.value(obj); + QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj); if (a && a->name() == name) return true; } return false; } -QObject *QmlPackage::part(const QString &name) +QObject *QDeclarativePackage::part(const QString &name) { - Q_D(QmlPackage); + Q_D(QDeclarativePackage); if (name.isEmpty() && !d->dataList.isEmpty()) return d->dataList.at(0); for (int ii = 0; ii < d->dataList.count(); ++ii) { QObject *obj = d->dataList.at(ii); - QmlPackageAttached *a = QmlPackageAttached::attached.value(obj); + QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj); if (a && a->name() == name) return obj; } @@ -173,13 +184,11 @@ QObject *QmlPackage::part(const QString &name) return 0; } -QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o) +QDeclarativePackageAttached *QDeclarativePackage::qmlAttachedProperties(QObject *o) { - return new QmlPackageAttached(o); + return new QDeclarativePackageAttached(o); } -QML_DEFINE_TYPE(Qt,4,6,Package,QmlPackage) -QT_END_NAMESPACE -#include <qmlpackage.moc> +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpackage_p.h b/src/declarative/util/qdeclarativepackage_p.h index 29b6bbe..87d9b80 100644 --- a/src/declarative/util/qmlpackage_p.h +++ b/src/declarative/util/qdeclarativepackage_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLPACKAGE_H -#define QMLPACKAGE_H +#ifndef QDECLARATIVEPACKAGE_H +#define QDECLARATIVEPACKAGE_H -#include <qml.h> +#include <qdeclarative.h> QT_BEGIN_HEADER @@ -56,33 +56,49 @@ QT_MODULE(Declarative) ***************************************************************************** *****************************************************************************/ -class QmlPackagePrivate; -class QmlPackageAttached; -class QmlPackage : public QObject +class QDeclarativePackagePrivate; +class QDeclarativePackageAttached; +class QDeclarativePackage : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPackage) + Q_DECLARE_PRIVATE(QDeclarativePackage) Q_CLASSINFO("DefaultProperty", "data") - Q_PROPERTY(QmlListProperty<QObject> data READ data SCRIPTABLE false) + Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data SCRIPTABLE false) public: - QmlPackage(QObject *parent=0); - virtual ~QmlPackage(); + QDeclarativePackage(QObject *parent=0); + virtual ~QDeclarativePackage(); - QmlListProperty<QObject> data(); + QDeclarativeListProperty<QObject> data(); QObject *part(const QString & = QString()); bool hasPart(const QString &); - static QmlPackageAttached *qmlAttachedProperties(QObject *); + static QDeclarativePackageAttached *qmlAttachedProperties(QObject *); +}; + +class QDeclarativePackageAttached : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString name READ name WRITE setName) +public: + QDeclarativePackageAttached(QObject *parent); + virtual ~QDeclarativePackageAttached(); + + QString name() const; + void setName(const QString &n); + + static QHash<QObject *, QDeclarativePackageAttached *> attached; +private: + QString _name; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlPackage) -QML_DECLARE_TYPEINFO(QmlPackage, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarativePackage) +QML_DECLARE_TYPEINFO(QDeclarativePackage, QML_HAS_ATTACHED_PROPERTIES) QT_END_HEADER -#endif // QMLPACKAGE_H +#endif // QDECLARATIVEPACKAGE_H diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 2459651..cfb25dd 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "qmlpixmapcache_p.h" -#include "qmlnetworkaccessmanagerfactory.h" -#include "qmlimageprovider.h" +#include "qdeclarativepixmapcache_p.h" +#include "qdeclarativenetworkaccessmanagerfactory.h" +#include "qdeclarativeimageprovider.h" #include "qfxperf_p_p.h" -#include <qmlengine.h> -#include <private/qmlglobal_p.h> -#include <private/qmlengine_p.h> +#include <qdeclarativeengine.h> +#include <private/qdeclarativeglobal_p.h> +#include <private/qdeclarativeengine_p.h> #include <QCoreApplication> #include <QImageReader> @@ -79,12 +79,20 @@ inline uint qHash(const QUrl &uri) } #endif -class QmlImageReaderEvent : public QEvent +static QString toLocalFileOrQrc(const QUrl& url) +{ + QString r = url.toLocalFile(); + if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) + r = QLatin1Char(':') + url.path(); + return r; +} + +class QDeclarativeImageReaderEvent : public QEvent { public: enum ReadError { NoError, Loading, Decoding }; - QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img) + QDeclarativeImageReaderEvent(QDeclarativeImageReaderEvent::ReadError err, const QString &errStr, const QImage &img) : QEvent(QEvent::User), error(err), errorString(errStr), image(img) {} ReadError error; @@ -92,50 +100,50 @@ public: QImage image; }; -class QmlImageRequestHandler; -class QmlImageReader : public QThread +class QDeclarativeImageRequestHandler; +class QDeclarativeImageReader : public QThread { Q_OBJECT public: - QmlImageReader(QmlEngine *eng); - ~QmlImageReader(); + QDeclarativeImageReader(QDeclarativeEngine *eng); + ~QDeclarativeImageReader(); - QmlPixmapReply *getImage(const QUrl &url); - void cancel(QmlPixmapReply *rep); + QDeclarativePixmapReply *getImage(const QUrl &url); + void cancel(QDeclarativePixmapReply *rep); - static QmlImageReader *instance(QmlEngine *engine); + static QDeclarativeImageReader *instance(QDeclarativeEngine *engine); protected: void run(); private: - QList<QmlPixmapReply*> jobs; - QList<QmlPixmapReply*> cancelled; - QmlEngine *engine; - QmlImageRequestHandler *handler; + QList<QDeclarativePixmapReply*> jobs; + QList<QDeclarativePixmapReply*> cancelled; + QDeclarativeEngine *engine; + QDeclarativeImageRequestHandler *handler; QMutex mutex; - static QHash<QmlEngine *,QmlImageReader*> readers; + static QHash<QDeclarativeEngine *,QDeclarativeImageReader*> readers; static QMutex readerMutex; - friend class QmlImageRequestHandler; + friend class QDeclarativeImageRequestHandler; }; -QHash<QmlEngine *,QmlImageReader*> QmlImageReader::readers; -QMutex QmlImageReader::readerMutex; +QHash<QDeclarativeEngine *,QDeclarativeImageReader*> QDeclarativeImageReader::readers; +QMutex QDeclarativeImageReader::readerMutex; -class QmlImageRequestHandler : public QObject +class QDeclarativeImageRequestHandler : public QObject { Q_OBJECT public: - QmlImageRequestHandler(QmlImageReader *read, QmlEngine *eng) + QDeclarativeImageRequestHandler(QDeclarativeImageReader *read, QDeclarativeEngine *eng) : QObject(), accessManager(0), engine(eng), reader(read) { QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } - QmlPixmapReply *getImage(const QUrl &url); - void cancel(QmlPixmapReply *reply); + QDeclarativePixmapReply *getImage(const QUrl &url); + void cancel(QDeclarativePixmapReply *reply); protected: bool event(QEvent *event); @@ -146,19 +154,19 @@ private slots: private: QNetworkAccessManager *networkAccessManager() { if (!accessManager) - accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this); + accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(this); return accessManager; } - QHash<QNetworkReply*,QmlPixmapReply*> replies; + QHash<QNetworkReply*,QDeclarativePixmapReply*> replies; QNetworkAccessManager *accessManager; - QmlEngine *engine; - QmlImageReader *reader; + QDeclarativeEngine *engine; + QDeclarativeImageReader *reader; }; //=========================================================================== -bool QmlImageRequestHandler::event(QEvent *event) +bool QDeclarativeImageRequestHandler::event(QEvent *event) { if (event->type() == QEvent::User) { static int replyDownloadProgress = -1; @@ -169,8 +177,8 @@ bool QmlImageRequestHandler::event(QEvent *event) if (replyDownloadProgress == -1) { replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()"); - downloadProgress = QmlPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); - thisNetworkRequestDone = QmlImageRequestHandler::staticMetaObject.indexOfSlot("networkRequestDone()"); + downloadProgress = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); + thisNetworkRequestDone = QDeclarativeImageRequestHandler::staticMetaObject.indexOfSlot("networkRequestDone()"); } while (1) { @@ -178,7 +186,7 @@ bool QmlImageRequestHandler::event(QEvent *event) if (reader->cancelled.count()) { for (int i = 0; i < reader->cancelled.count(); ++i) { - QmlPixmapReply *job = reader->cancelled.at(i); + QDeclarativePixmapReply *job = reader->cancelled.at(i); // cancel any jobs already started QNetworkReply *reply = replies.key(job, 0); if (reply && reply->isRunning()) { @@ -202,29 +210,52 @@ bool QmlImageRequestHandler::event(QEvent *event) break; } - QmlPixmapReply *runningJob = reader->jobs.takeLast(); + QDeclarativePixmapReply *runningJob = reader->jobs.takeLast(); QUrl url = runningJob->url(); reader->mutex.unlock(); // fetch if (url.scheme() == QLatin1String("image")) { - QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url); - QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError; + // Use QmlImageProvider + QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url); + QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError; QString errorStr; if (image.isNull()) { - errorCode = QmlImageReaderEvent::Loading; + errorCode = QDeclarativeImageReaderEvent::Loading; errorStr = QLatin1String("Failed to get image from provider: ") + url.toString(); } - QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image)); + QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); } else { - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - QNetworkReply *reply = networkAccessManager()->get(req); + QString lf = toLocalFileOrQrc(url); + if (!lf.isEmpty()) { + // Image is local - load/decode immediately + QImage image; + QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError; + QString errorStr; + QFile f(lf); + if (f.open(QIODevice::ReadOnly)) { + QImageReader imgio(&f); + if (!imgio.read(&image)) { + errorStr = QLatin1String("Error decoding: ") + url.toString() + + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); + errorCode = QDeclarativeImageReaderEvent::Loading; + } + } else { + errorStr = QLatin1String("Cannot open: ") + url.toString(); + errorCode = QDeclarativeImageReaderEvent::Loading; + } + QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); + } else { + // Network resource + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + QNetworkReply *reply = networkAccessManager()->get(req); - QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); - QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); + QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); + QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); - replies.insert(reply, runningJob); + replies.insert(reply, runningJob); + } } } return true; @@ -233,29 +264,29 @@ bool QmlImageRequestHandler::event(QEvent *event) return QObject::event(event); } -void QmlImageRequestHandler::networkRequestDone() +void QDeclarativeImageRequestHandler::networkRequestDone() { QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); - QmlPixmapReply *job = replies.take(reply); + QDeclarativePixmapReply *job = replies.take(reply); if (job) { QImage image; - QmlImageReaderEvent::ReadError error; + QDeclarativeImageReaderEvent::ReadError error; QString errorString; if (reply->error()) { - error = QmlImageReaderEvent::Loading; + error = QDeclarativeImageReaderEvent::Loading; errorString = reply->errorString(); } else { QImageReader imgio(reply); if (imgio.read(&image)) { - error = QmlImageReaderEvent::NoError; + error = QDeclarativeImageReaderEvent::NoError; } else { errorString = QLatin1String("Error decoding: ") + reply->url().toString() + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); - error = QmlImageReaderEvent::Decoding; + error = QDeclarativeImageReaderEvent::Decoding; } } - // send completion event to the QmlPixmapReply - QCoreApplication::postEvent(job, new QmlImageReaderEvent(error, errorString, image)); + // send completion event to the QDeclarativePixmapReply + QCoreApplication::postEvent(job, new QDeclarativeImageReaderEvent(error, errorString, image)); } // kick off event loop again if we have dropped below max request count if (replies.count() == maxImageRequestCount) @@ -265,13 +296,13 @@ void QmlImageRequestHandler::networkRequestDone() //=========================================================================== -QmlImageReader::QmlImageReader(QmlEngine *eng) +QDeclarativeImageReader::QDeclarativeImageReader(QDeclarativeEngine *eng) : QThread(eng), engine(eng), handler(0) { start(QThread::LowPriority); } -QmlImageReader::~QmlImageReader() +QDeclarativeImageReader::~QDeclarativeImageReader() { readerMutex.lock(); readers.remove(engine); @@ -281,12 +312,12 @@ QmlImageReader::~QmlImageReader() wait(); } -QmlImageReader *QmlImageReader::instance(QmlEngine *engine) +QDeclarativeImageReader *QDeclarativeImageReader::instance(QDeclarativeEngine *engine) { readerMutex.lock(); - QmlImageReader *reader = readers.value(engine); + QDeclarativeImageReader *reader = readers.value(engine); if (!reader) { - reader = new QmlImageReader(engine); + reader = new QDeclarativeImageReader(engine); readers.insert(engine, reader); } readerMutex.unlock(); @@ -294,10 +325,10 @@ QmlImageReader *QmlImageReader::instance(QmlEngine *engine) return reader; } -QmlPixmapReply *QmlImageReader::getImage(const QUrl &url) +QDeclarativePixmapReply *QDeclarativeImageReader::getImage(const QUrl &url) { mutex.lock(); - QmlPixmapReply *reply = new QmlPixmapReply(this, url); + QDeclarativePixmapReply *reply = new QDeclarativePixmapReply(this, url); reply->addRef(); reply->setLoading(); jobs.append(reply); @@ -307,7 +338,7 @@ QmlPixmapReply *QmlImageReader::getImage(const QUrl &url) return reply; } -void QmlImageReader::cancel(QmlPixmapReply *reply) +void QDeclarativeImageReader::cancel(QDeclarativePixmapReply *reply) { mutex.lock(); if (reply->isLoading()) { @@ -319,7 +350,7 @@ void QmlImageReader::cancel(QmlPixmapReply *reply) mutex.unlock(); } -void QmlImageReader::run() +void QDeclarativeImageReader::run() { #if defined(Q_OS_LINUX) && defined(SCHED_IDLE) struct sched_param param; @@ -329,7 +360,7 @@ void QmlImageReader::run() pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m); #endif - handler = new QmlImageRequestHandler(this, engine); + handler = new QDeclarativeImageRequestHandler(this, engine); exec(); @@ -375,64 +406,56 @@ static bool readImage(QIODevice *dev, QPixmap *pixmap, QString &errorString) /*! \internal - \class QmlPixmapCache - \brief Enacapsultes a pixmap for QmlGraphics items. + \class QDeclarativePixmapCache + \brief Enacapsultes a pixmap for QDeclarativeGraphics items. This class is NOT reentrant. */ -static QString toLocalFileOrQrc(const QUrl& url) -{ - QString r = url.toLocalFile(); - if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) - r = QLatin1Char(':') + url.path(); - return r; -} +typedef QHash<QUrl, QDeclarativePixmapReply *> QDeclarativePixmapReplyHash; +Q_GLOBAL_STATIC(QDeclarativePixmapReplyHash, qmlActivePixmapReplies); -typedef QHash<QUrl, QmlPixmapReply *> QmlPixmapReplyHash; -Q_GLOBAL_STATIC(QmlPixmapReplyHash, qmlActivePixmapReplies); - -class QmlPixmapReplyPrivate : public QObjectPrivate +class QDeclarativePixmapReplyPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlPixmapReply) + Q_DECLARE_PUBLIC(QDeclarativePixmapReply) public: - QmlPixmapReplyPrivate(QmlImageReader *r, const QUrl &u) - : QObjectPrivate(), refCount(1), url(u), status(QmlPixmapReply::Loading), loading(false), reader(r) { + QDeclarativePixmapReplyPrivate(QDeclarativeImageReader *r, const QUrl &u) + : QObjectPrivate(), refCount(1), url(u), status(QDeclarativePixmapReply::Loading), loading(false), reader(r) { } int refCount; QUrl url; QPixmap pixmap; // ensure reference to pixmap so QPixmapCache does not discard - QmlPixmapReply::Status status; + QDeclarativePixmapReply::Status status; bool loading; - QmlImageReader *reader; + QDeclarativeImageReader *reader; }; -QmlPixmapReply::QmlPixmapReply(QmlImageReader *reader, const QUrl &url) - : QObject(*new QmlPixmapReplyPrivate(reader, url), 0) +QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url) + : QObject(*new QDeclarativePixmapReplyPrivate(reader, url), 0) { } -QmlPixmapReply::~QmlPixmapReply() +QDeclarativePixmapReply::~QDeclarativePixmapReply() { } -const QUrl &QmlPixmapReply::url() const +const QUrl &QDeclarativePixmapReply::url() const { - Q_D(const QmlPixmapReply); + Q_D(const QDeclarativePixmapReply); return d->url; } -bool QmlPixmapReply::event(QEvent *event) +bool QDeclarativePixmapReply::event(QEvent *event) { - Q_D(QmlPixmapReply); + Q_D(QDeclarativePixmapReply); if (event->type() == QEvent::User) { d->loading = false; if (!release(true)) { - QmlImageReaderEvent *de = static_cast<QmlImageReaderEvent*>(event); - d->status = (de->error == QmlImageReaderEvent::NoError) ? Ready : Error; + QDeclarativeImageReaderEvent *de = static_cast<QDeclarativeImageReaderEvent*>(event); + d->status = (de->error == QDeclarativeImageReaderEvent::NoError) ? Ready : Error; if (d->status == Ready) d->pixmap = QPixmap::fromImage(de->image); else @@ -448,33 +471,33 @@ bool QmlPixmapReply::event(QEvent *event) return QObject::event(event); } -QmlPixmapReply::Status QmlPixmapReply::status() const +QDeclarativePixmapReply::Status QDeclarativePixmapReply::status() const { - Q_D(const QmlPixmapReply); + Q_D(const QDeclarativePixmapReply); return d->status; } -bool QmlPixmapReply::isLoading() const +bool QDeclarativePixmapReply::isLoading() const { - Q_D(const QmlPixmapReply); + Q_D(const QDeclarativePixmapReply); return d->loading; } -void QmlPixmapReply::setLoading() +void QDeclarativePixmapReply::setLoading() { - Q_D(QmlPixmapReply); + Q_D(QDeclarativePixmapReply); d->loading = true; } -void QmlPixmapReply::addRef() +void QDeclarativePixmapReply::addRef() { - Q_D(QmlPixmapReply); + Q_D(QDeclarativePixmapReply); ++d->refCount; } -bool QmlPixmapReply::release(bool defer) +bool QDeclarativePixmapReply::release(bool defer) { - Q_D(QmlPixmapReply); + Q_D(QDeclarativePixmapReply); Q_ASSERT(d->refCount > 0); --d->refCount; if (d->refCount == 0) { @@ -500,42 +523,50 @@ bool QmlPixmapReply::release(bool defer) Returns Ready, or Error if the image has been retrieved, otherwise the current retrieval status. + + If \a async is false the image will be loaded and decoded immediately; + otherwise the image will be loaded and decoded in a separate thread. + + Note that images sourced from the network will always be loaded and + decoded asynchonously. */ -QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) +QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, bool async) { - QmlPixmapReply::Status status = QmlPixmapReply::Unrequested; + QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested; + QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); + QString strKey = QString::fromLatin1(key.constData(), key.count()); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = toLocalFileOrQrc(url); - if (!lf.isEmpty()) { - status = QmlPixmapReply::Ready; - if (!QPixmapCache::find(lf,pixmap)) { - QFile f(lf); - if (f.open(QIODevice::ReadOnly)) { - QString errorString; - if (!readImage(&f, pixmap, errorString)) { - errorString = QLatin1String("Error decoding: ") + url.toString() - + QLatin1String(" \"") + errorString + QLatin1String("\""); - qWarning() << errorString; + if (!async) { + QString lf = toLocalFileOrQrc(url); + if (!lf.isEmpty()) { + status = QDeclarativePixmapReply::Ready; + if (!QPixmapCache::find(strKey,pixmap)) { + QFile f(lf); + if (f.open(QIODevice::ReadOnly)) { + QString errorString; + if (!readImage(&f, pixmap, errorString)) { + errorString = QLatin1String("Error decoding: ") + url.toString() + + QLatin1String(" \"") + errorString + QLatin1String("\""); + qWarning() << errorString; + *pixmap = QPixmap(); + status = QDeclarativePixmapReply::Error; + } + } else { + qWarning() << "Cannot open" << url; *pixmap = QPixmap(); - status = QmlPixmapReply::Error; + status = QDeclarativePixmapReply::Error; } - } else { - qWarning() << "Cannot open" << url; - *pixmap = QPixmap(); - status = QmlPixmapReply::Error; + if (status == QDeclarativePixmapReply::Ready) + QPixmapCache::insert(strKey, *pixmap); } - if (status == QmlPixmapReply::Ready) - QPixmapCache::insert(lf, *pixmap); + return status; } - return status; } #endif - QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); - QString strKey = QString::fromLatin1(key.constData(), key.count()); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); - if (iter != qmlActivePixmapReplies()->end() && (*iter)->status() == QmlPixmapReply::Ready) { + QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter != qmlActivePixmapReplies()->end() && (*iter)->status() == QDeclarativePixmapReply::Ready) { // Must check this, since QPixmapCache::insert may have failed. *pixmap = (*iter)->d_func()->pixmap; status = (*iter)->status(); @@ -545,10 +576,10 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) status = (*iter)->status(); (*iter)->release(); } else { - status = pixmap->isNull() ? QmlPixmapReply::Error : QmlPixmapReply::Ready; + status = pixmap->isNull() ? QDeclarativePixmapReply::Error : QDeclarativePixmapReply::Ready; } } else if (iter != qmlActivePixmapReplies()->end()) { - status = QmlPixmapReply::Loading; + status = QDeclarativePixmapReply::Loading; } return status; @@ -557,18 +588,18 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) /*! Starts a network request to load \a url. - Returns a QmlPixmapReply. Caller should connect to QmlPixmapReply::finished() + Returns a QDeclarativePixmapReply. Caller should connect to QDeclarativePixmapReply::finished() and call get() when the image is available. - The returned QmlPixmapReply will be deleted when all request() calls are + The returned QDeclarativePixmapReply will be deleted when all request() calls are matched by a corresponding get() call. */ -QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) +QDeclarativePixmapReply *QDeclarativePixmapCache::request(QDeclarativeEngine *engine, const QUrl &url) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); if (iter == qmlActivePixmapReplies()->end()) { - QmlImageReader *reader = QmlImageReader::instance(engine); - QmlPixmapReply *item = reader->getImage(url); + QDeclarativeImageReader *reader = QDeclarativeImageReader::instance(engine); + QDeclarativePixmapReply *item = reader->getImage(url); iter = qmlActivePixmapReplies()->insert(url, item); } else { (*iter)->addRef(); @@ -582,16 +613,16 @@ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) May also cancel loading (eg. if no other pending request). - Any connections from the QmlPixmapReply returned by request() to \a obj will be + Any connections from the QDeclarativePixmapReply returned by request() to \a obj will be disconnected. */ -void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) +void QDeclarativePixmapCache::cancel(const QUrl& url, QObject *obj) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); if (iter == qmlActivePixmapReplies()->end()) return; - QmlPixmapReply *reply = *iter; + QDeclarativePixmapReply *reply = *iter; if (obj) QObject::disconnect(reply, 0, obj, 0); reply->release(); @@ -601,11 +632,11 @@ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) This function is mainly for test verification. It returns the number of requests that are still unfinished. */ -int QmlPixmapCache::pendingRequests() +int QDeclarativePixmapCache::pendingRequests() { return qmlActivePixmapReplies()->count(); } QT_END_NAMESPACE -#include <qmlpixmapcache.moc> +#include <qdeclarativepixmapcache.moc> diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index 86908cc..b8949db 100644 --- a/src/declarative/util/qmlpixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLPIXMAPCACHE_H -#define QMLPIXMAPCACHE_H +#ifndef QDECLARATIVEPIXMAPCACHE_H +#define QDECLARATIVEPIXMAPCACHE_H #include <QtCore/QString> #include <QtGui/QPixmap> @@ -51,16 +51,16 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlEngine; +class QDeclarativeEngine; class QNetworkReply; -class QmlImageReader; +class QDeclarativeImageReader; -class QmlPixmapReplyPrivate; -class Q_DECLARATIVE_EXPORT QmlPixmapReply : public QObject +class QDeclarativePixmapReplyPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativePixmapReply : public QObject { Q_OBJECT public: - ~QmlPixmapReply(); + ~QDeclarativePixmapReply(); enum Status { Ready, Error, Unrequested, Loading }; Status status() const; @@ -81,19 +81,19 @@ private: void setLoading(); private: - QmlPixmapReply(QmlImageReader *reader, const QUrl &url); - Q_DISABLE_COPY(QmlPixmapReply) - Q_DECLARE_PRIVATE(QmlPixmapReply) - friend class QmlImageRequestHandler; - friend class QmlImageReader; - friend class QmlPixmapCache; + QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url); + Q_DISABLE_COPY(QDeclarativePixmapReply) + Q_DECLARE_PRIVATE(QDeclarativePixmapReply) + friend class QDeclarativeImageRequestHandler; + friend class QDeclarativeImageReader; + friend class QDeclarativePixmapCache; }; -class Q_DECLARATIVE_EXPORT QmlPixmapCache +class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { public: - static QmlPixmapReply::Status get(const QUrl& url, QPixmap *pixmap); - static QmlPixmapReply *request(QmlEngine *, const QUrl& url); + static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, bool async=false); + static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url); static void cancel(const QUrl& url, QObject *obj); static int pendingRequests(); }; @@ -104,4 +104,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QMLPIXMAPCACHE_H +#endif // QDECLARATIVEPIXMAPCACHE_H diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index fba22f9..9c2b1e6 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -39,17 +39,18 @@ ** ****************************************************************************/ -#include "qmlpropertychanges_p.h" +#include "qdeclarativepropertychanges_p.h" -#include "qmlopenmetaobject_p.h" +#include "qdeclarativeopenmetaobject_p.h" -#include <qmlinfo.h> -#include <qmlcustomparser_p.h> -#include <qmlparser_p.h> -#include <qmlexpression.h> -#include <qmlbinding.h> -#include <qmlcontext.h> -#include <qmlguard_p.h> +#include <qdeclarativeinfo.h> +#include <qdeclarativecustomparser_p.h> +#include <qdeclarativeparser_p.h> +#include <qdeclarativeexpression.h> +#include <qdeclarativebinding_p.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeguard_p.h> +#include <qdeclarativeproperty_p.h> #include <QtCore/qdebug.h> @@ -58,8 +59,8 @@ QT_BEGIN_NAMESPACE /*! - \qmlclass PropertyChanges QmlPropertyChanges - \since 4.7 + \qmlclass PropertyChanges QDeclarativePropertyChanges + \since 4.7 \brief The PropertyChanges element describes new property values for a state. PropertyChanges provides a state change that modifies the properties of an item. @@ -97,6 +98,33 @@ QT_BEGIN_NAMESPACE } \endqml + You can reset a property in a state change by assigning \c undefined. In the following + example we reset \c theText's width when we enter state1. This will give the text its + natural width (which is the whole string on one line). + + \qml + import Qt 4.6 + + Rectangle { + width: 640 + height: 480 + Text { + id: theText + width: 50 + wrap: true + text: "a text string that is longer than 50 pixels" + } + + states: State { + name: "state1" + PropertyChanges { + target: theText + width: undefined + } + } + } + \endqml + Changes to an Item's parent or anchors should be done using the associated change elements (ParentChange and AnchorChanges, respectively) rather than PropertyChanges. @@ -105,8 +133,8 @@ QT_BEGIN_NAMESPACE /*! \internal - \class QmlPropertyChanges - \brief The QmlPropertyChanges class describes new property values for a state. + \class QDeclarativePropertyChanges + \brief The QDeclarativePropertyChanges class describes new property values for a state. */ /*! @@ -114,30 +142,30 @@ QT_BEGIN_NAMESPACE This property holds the object which contains the properties to be changed. */ -class QmlReplaceSignalHandler : public QmlActionEvent +class QDeclarativeReplaceSignalHandler : public QDeclarativeActionEvent { public: - QmlReplaceSignalHandler() : expression(0), reverseExpression(0), + QDeclarativeReplaceSignalHandler() : expression(0), reverseExpression(0), rewindExpression(0), ownedExpression(0) {} - ~QmlReplaceSignalHandler() { + ~QDeclarativeReplaceSignalHandler() { delete ownedExpression; } virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); } - QmlMetaProperty property; - QmlExpression *expression; - QmlExpression *reverseExpression; - QmlExpression *rewindExpression; - QmlGuard<QmlExpression> ownedExpression; + QDeclarativeProperty property; + QDeclarativeExpression *expression; + QDeclarativeExpression *reverseExpression; + QDeclarativeExpression *rewindExpression; + QDeclarativeGuard<QDeclarativeExpression> ownedExpression; virtual void execute() { - ownedExpression = property.setSignalExpression(expression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression); } virtual bool isReversable() { return true; } virtual void reverse() { - ownedExpression = property.setSignalExpression(reverseExpression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); } virtual void saveOriginals() { @@ -146,27 +174,29 @@ public: } virtual void rewind() { - ownedExpression = property.setSignalExpression(rewindExpression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); + } + virtual void saveCurrentValues() { + rewindExpression = QDeclarativePropertyPrivate::signalExpression(property); } - virtual void saveCurrentValues() { rewindExpression = property.signalExpression(); } - virtual bool override(QmlActionEvent*other) { + virtual bool override(QDeclarativeActionEvent*other) { if (other == this) return true; if (other->typeName() != typeName()) return false; - if (static_cast<QmlReplaceSignalHandler*>(other)->property == property) + if (static_cast<QDeclarativeReplaceSignalHandler*>(other)->property == property) return true; return false; } }; -class QmlPropertyChangesPrivate : public QObjectPrivate +class QDeclarativePropertyChangesPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlPropertyChanges) + Q_DECLARE_PUBLIC(QDeclarativePropertyChanges) public: - QmlPropertyChangesPrivate() : object(0), decoded(true), restore(true), + QDeclarativePropertyChangesPrivate() : object(0), decoded(true), restore(true), isExplicit(false) {} QObject *object; @@ -179,25 +209,16 @@ public: void decode(); QList<QPair<QByteArray, QVariant> > properties; - QList<QPair<QByteArray, QmlExpression *> > expressions; - QList<QmlReplaceSignalHandler*> signalReplacements; + QList<QPair<QByteArray, QDeclarativeExpression *> > expressions; + QList<QDeclarativeReplaceSignalHandler*> signalReplacements; - QmlMetaProperty property(const QByteArray &); -}; - -class QmlPropertyChangesParser : public QmlCustomParser -{ -public: - void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QmlCustomParserProperty &prop); - - virtual QByteArray compile(const QList<QmlCustomParserProperty> &); - virtual void setCustomData(QObject *, const QByteArray &); + QDeclarativeProperty property(const QByteArray &); }; void -QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list, +QDeclarativePropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, - const QmlCustomParserProperty &prop) + const QDeclarativeCustomParserProperty &prop) { QByteArray propName = pre + prop.name(); @@ -205,12 +226,12 @@ QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list, for (int ii = 0; ii < values.count(); ++ii) { const QVariant &value = values.at(ii); - if (value.userType() == qMetaTypeId<QmlCustomParserNode>()) { + if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) { continue; - } else if(value.userType() == qMetaTypeId<QmlCustomParserProperty>()) { + } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) { - QmlCustomParserProperty prop = - qvariant_cast<QmlCustomParserProperty>(value); + QDeclarativeCustomParserProperty prop = + qvariant_cast<QDeclarativeCustomParserProperty>(value); QByteArray pre = propName + '.'; compileList(list, pre, prop); @@ -221,7 +242,7 @@ QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list, } QByteArray -QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props) +QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props) { QList<QPair<QByteArray, QVariant> > data; for(int ii = 0; ii < props.count(); ++ii) @@ -232,21 +253,21 @@ QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props) ds << data.count(); for(int ii = 0; ii < data.count(); ++ii) { - QmlParser::Variant v = qvariant_cast<QmlParser::Variant>(data.at(ii).second); + QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(data.at(ii).second); QVariant var; bool isScript = v.isScript(); switch(v.type()) { - case QmlParser::Variant::Boolean: + case QDeclarativeParser::Variant::Boolean: var = QVariant(v.asBoolean()); break; - case QmlParser::Variant::Number: + case QDeclarativeParser::Variant::Number: var = QVariant(v.asNumber()); break; - case QmlParser::Variant::String: + case QDeclarativeParser::Variant::String: var = QVariant(v.asString()); break; - case QmlParser::Variant::Invalid: - case QmlParser::Variant::Script: + case QDeclarativeParser::Variant::Invalid: + case QDeclarativeParser::Variant::Script: var = QVariant(v.asScript()); break; } @@ -257,9 +278,9 @@ QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props) return rv; } -void QmlPropertyChangesPrivate::decode() +void QDeclarativePropertyChangesPrivate::decode() { - Q_Q(QmlPropertyChanges); + Q_Q(QDeclarativePropertyChanges); if (decoded) return; @@ -275,17 +296,15 @@ void QmlPropertyChangesPrivate::decode() ds >> isScript; ds >> data; - QmlMetaProperty prop = property(name); //### better way to check for signal property? - if (prop.type() & QmlMetaProperty::SignalProperty) { - QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object); - expression->setTrackChange(false); - QmlReplaceSignalHandler *handler = new QmlReplaceSignalHandler; + QDeclarativeProperty prop = property(name); //### better way to check for signal property? + if (prop.type() & QDeclarativeProperty::SignalProperty) { + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeReplaceSignalHandler *handler = new QDeclarativeReplaceSignalHandler; handler->property = prop; handler->expression = expression; signalReplacements << handler; } else if (isScript) { - QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object); - expression->setTrackChange(false); + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); expressions << qMakePair(name, expression); } else { properties << qMakePair(name, data); @@ -296,38 +315,38 @@ void QmlPropertyChangesPrivate::decode() data.clear(); } -void QmlPropertyChangesParser::setCustomData(QObject *object, +void QDeclarativePropertyChangesParser::setCustomData(QObject *object, const QByteArray &data) { - QmlPropertyChangesPrivate *p = - static_cast<QmlPropertyChangesPrivate *>(QObjectPrivate::get(object)); + QDeclarativePropertyChangesPrivate *p = + static_cast<QDeclarativePropertyChangesPrivate *>(QObjectPrivate::get(object)); p->data = data; p->decoded = false; } -QmlPropertyChanges::QmlPropertyChanges() -: QmlStateOperation(*(new QmlPropertyChangesPrivate)) +QDeclarativePropertyChanges::QDeclarativePropertyChanges() +: QDeclarativeStateOperation(*(new QDeclarativePropertyChangesPrivate)) { } -QmlPropertyChanges::~QmlPropertyChanges() +QDeclarativePropertyChanges::~QDeclarativePropertyChanges() { - Q_D(QmlPropertyChanges); + Q_D(QDeclarativePropertyChanges); for(int ii = 0; ii < d->expressions.count(); ++ii) delete d->expressions.at(ii).second; for(int ii = 0; ii < d->signalReplacements.count(); ++ii) delete d->signalReplacements.at(ii); } -QObject *QmlPropertyChanges::object() const +QObject *QDeclarativePropertyChanges::object() const { - Q_D(const QmlPropertyChanges); + Q_D(const QDeclarativePropertyChanges); return d->object; } -void QmlPropertyChanges::setObject(QObject *o) +void QDeclarativePropertyChanges::setObject(QObject *o) { - Q_D(QmlPropertyChanges); + Q_D(QDeclarativePropertyChanges); d->object = o; } @@ -340,36 +359,36 @@ void QmlPropertyChanges::setObject(QObject *o) By setting restoreEntryValues to false, you can create a temporary state that has permanent effects on property values. */ -bool QmlPropertyChanges::restoreEntryValues() const +bool QDeclarativePropertyChanges::restoreEntryValues() const { - Q_D(const QmlPropertyChanges); + Q_D(const QDeclarativePropertyChanges); return d->restore; } -void QmlPropertyChanges::setRestoreEntryValues(bool v) +void QDeclarativePropertyChanges::setRestoreEntryValues(bool v) { - Q_D(QmlPropertyChanges); + Q_D(QDeclarativePropertyChanges); d->restore = v; } -QmlMetaProperty -QmlPropertyChangesPrivate::property(const QByteArray &property) +QDeclarativeProperty +QDeclarativePropertyChangesPrivate::property(const QByteArray &property) { - Q_Q(QmlPropertyChanges); - QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property)); + Q_Q(QDeclarativePropertyChanges); + QDeclarativeProperty prop(object, QString::fromUtf8(property)); if (!prop.isValid()) { - 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)); - return QmlMetaProperty(); + qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property)); + return QDeclarativeProperty(); + } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) { + qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property)); + return QDeclarativeProperty(); } return prop; } -QmlPropertyChanges::ActionList QmlPropertyChanges::actions() +QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions() { - Q_D(QmlPropertyChanges); + Q_D(QDeclarativePropertyChanges); d->decode(); @@ -379,7 +398,7 @@ QmlPropertyChanges::ActionList QmlPropertyChanges::actions() QByteArray property = d->properties.at(ii).first; - QmlAction a(d->object, QString::fromLatin1(property), + QDeclarativeAction a(d->object, QString::fromLatin1(property), d->properties.at(ii).second); if (a.property.isValid()) { @@ -395,10 +414,10 @@ QmlPropertyChanges::ActionList QmlPropertyChanges::actions() for (int ii = 0; ii < d->signalReplacements.count(); ++ii) { - QmlReplaceSignalHandler *handler = d->signalReplacements.at(ii); + QDeclarativeReplaceSignalHandler *handler = d->signalReplacements.at(ii); if (handler->property.isValid()) { - QmlAction a; + QDeclarativeAction a; a.event = handler; list << a; } @@ -407,10 +426,10 @@ QmlPropertyChanges::ActionList QmlPropertyChanges::actions() for (int ii = 0; ii < d->expressions.count(); ++ii) { QByteArray property = d->expressions.at(ii).first; - QmlMetaProperty prop = d->property(property); + QDeclarativeProperty prop = d->property(property); if (prop.isValid()) { - QmlAction a; + QDeclarativeAction a; a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); @@ -420,7 +439,7 @@ QmlPropertyChanges::ActionList QmlPropertyChanges::actions() if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->value(); } else { - QmlBinding *newBinding = new QmlBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); newBinding->setTarget(prop); a.toBinding = newBinding; a.deletableToBinding = true; @@ -452,18 +471,16 @@ QmlPropertyChanges::ActionList QmlPropertyChanges::actions() By default, explicit is false. */ -bool QmlPropertyChanges::isExplicit() const +bool QDeclarativePropertyChanges::isExplicit() const { - Q_D(const QmlPropertyChanges); + Q_D(const QDeclarativePropertyChanges); return d->isExplicit; } -void QmlPropertyChanges::setIsExplicit(bool e) +void QDeclarativePropertyChanges::setIsExplicit(bool e) { - Q_D(QmlPropertyChanges); + Q_D(QDeclarativePropertyChanges); d->isExplicit = e; } -QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QmlPropertyChanges, QmlPropertyChangesParser) - QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpropertychanges_p.h b/src/declarative/util/qdeclarativepropertychanges_p.h index 19dcf9d..1274b0c 100644 --- a/src/declarative/util/qmlpropertychanges_p.h +++ b/src/declarative/util/qdeclarativepropertychanges_p.h @@ -39,10 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLPROPERTYCHANGES_H -#define QMLPROPERTYCHANGES_H +#ifndef QDECLARATIVEPROPERTYCHANGES_H +#define QDECLARATIVEPROPERTYCHANGES_H -#include "qmlstateoperations_p.h" +#include "qdeclarativestateoperations_p.h" +#include <private/qdeclarativecustomparser_p.h> QT_BEGIN_HEADER @@ -50,18 +51,18 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlPropertyChangesPrivate; -class Q_DECLARATIVE_EXPORT QmlPropertyChanges : public QmlStateOperation +class QDeclarativePropertyChangesPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativePropertyChanges : public QDeclarativeStateOperation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlPropertyChanges) + Q_DECLARE_PRIVATE(QDeclarativePropertyChanges) Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit) public: - QmlPropertyChanges(); - ~QmlPropertyChanges(); + QDeclarativePropertyChanges(); + ~QDeclarativePropertyChanges(); QObject *object() const; void setObject(QObject *); @@ -75,10 +76,20 @@ public: virtual ActionList actions(); }; +class QDeclarativePropertyChangesParser : public QDeclarativeCustomParser +{ +public: + void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop); + + virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &); + virtual void setCustomData(QObject *, const QByteArray &); +}; + + QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlPropertyChanges) +QML_DECLARE_TYPE(QDeclarativePropertyChanges) QT_END_HEADER -#endif // QMLPROPERTYCHANGES_H +#endif // QDECLARATIVEPROPERTYCHANGES_H diff --git a/src/declarative/util/qmlpropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp index 317896e..fcea515 100644 --- a/src/declarative/util/qmlpropertymap.cpp +++ b/src/declarative/util/qdeclarativepropertymap.cpp @@ -39,73 +39,73 @@ ** ****************************************************************************/ -#include "qmlpropertymap.h" +#include "qdeclarativepropertymap.h" -#include "qmlopenmetaobject_p.h" +#include "qdeclarativeopenmetaobject_p.h" #include <QDebug> QT_BEGIN_NAMESPACE -//QmlPropertyMapMetaObject lets us listen for changes coming from QML +//QDeclarativePropertyMapMetaObject lets us listen for changes coming from QML //so we can emit the changed signal. -class QmlPropertyMapMetaObject : public QmlOpenMetaObject +class QDeclarativePropertyMapMetaObject : public QDeclarativeOpenMetaObject { public: - QmlPropertyMapMetaObject(QmlPropertyMap *obj, QmlPropertyMapPrivate *objPriv); + QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv); protected: virtual void propertyWrite(int index); private: - QmlPropertyMap *map; - QmlPropertyMapPrivate *priv; + QDeclarativePropertyMap *map; + QDeclarativePropertyMapPrivate *priv; }; -class QmlPropertyMapPrivate : public QObjectPrivate +class QDeclarativePropertyMapPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlPropertyMap) + Q_DECLARE_PUBLIC(QDeclarativePropertyMap) public: - QmlPropertyMapMetaObject *mo; + QDeclarativePropertyMapMetaObject *mo; QStringList keys; void emitChanged(const QString &key); }; -void QmlPropertyMapPrivate::emitChanged(const QString &key) +void QDeclarativePropertyMapPrivate::emitChanged(const QString &key) { - Q_Q(QmlPropertyMap); + Q_Q(QDeclarativePropertyMap); emit q->valueChanged(key); } -QmlPropertyMapMetaObject::QmlPropertyMapMetaObject(QmlPropertyMap *obj, QmlPropertyMapPrivate *objPriv) : QmlOpenMetaObject(obj) +QDeclarativePropertyMapMetaObject::QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv) : QDeclarativeOpenMetaObject(obj) { map = obj; priv = objPriv; } -void QmlPropertyMapMetaObject::propertyWrite(int index) +void QDeclarativePropertyMapMetaObject::propertyWrite(int index) { priv->emitChanged(QString::fromUtf8(name(index))); } /*! - \class QmlPropertyMap + \class QDeclarativePropertyMap \since 4.7 - \brief The QmlPropertyMap class allows you to set key-value pairs that can be used in bindings. + \brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in bindings. - QmlPropertyMap provides a convenient way to expose domain data to the UI layer. + QDeclarativePropertyMap provides a convenient way to expose domain data to the UI layer. The following example shows how you might declare data in C++ and then access it in QML. Setup in C++: \code //create our data - QmlPropertyMap ownerData; + QDeclarativePropertyMap ownerData; ownerData.insert("name", QVariant(QString("John Smith"))); ownerData.insert("phone", QVariant(QString("555-5555"))); //expose it to the UI layer - QmlContext *ctxt = view->bindContext(); + QDeclarativeContext *ctxt = view->bindContext(); ctxt->setProperty("owner", &data); \endcode @@ -129,26 +129,26 @@ void QmlPropertyMapMetaObject::propertyWrite(int index) /*! Constructs a bindable map with parent object \a parent. */ -QmlPropertyMap::QmlPropertyMap(QObject *parent) -: QObject(*(new QmlPropertyMapPrivate), parent) +QDeclarativePropertyMap::QDeclarativePropertyMap(QObject *parent) +: QObject(*(new QDeclarativePropertyMapPrivate), parent) { - Q_D(QmlPropertyMap); - d->mo = new QmlPropertyMapMetaObject(this, d); + Q_D(QDeclarativePropertyMap); + d->mo = new QDeclarativePropertyMapMetaObject(this, d); } /*! Destroys the bindable map. */ -QmlPropertyMap::~QmlPropertyMap() +QDeclarativePropertyMap::~QDeclarativePropertyMap() { } /*! Clears the value (if any) associated with \a key. */ -void QmlPropertyMap::clear(const QString &key) +void QDeclarativePropertyMap::clear(const QString &key) { - Q_D(QmlPropertyMap); + Q_D(QDeclarativePropertyMap); d->mo->setValue(key.toUtf8(), QVariant()); } @@ -158,9 +158,9 @@ void QmlPropertyMap::clear(const QString &key) If no value has been set for this key (or if the value has been cleared), an invalid QVariant is returned. */ -QVariant QmlPropertyMap::value(const QString &key) const +QVariant QDeclarativePropertyMap::value(const QString &key) const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->mo->value(key.toUtf8()); } @@ -169,9 +169,9 @@ QVariant QmlPropertyMap::value(const QString &key) const If the key doesn't exist, it is automatically created. */ -void QmlPropertyMap::insert(const QString &key, const QVariant &value) +void QDeclarativePropertyMap::insert(const QString &key, const QVariant &value) { - Q_D(QmlPropertyMap); + Q_D(QDeclarativePropertyMap); if (!d->keys.contains(key)) d->keys.append(key); d->mo->setValue(key.toUtf8(), value); @@ -183,9 +183,9 @@ void QmlPropertyMap::insert(const QString &key, const QVariant &value) Keys that have been cleared will still appear in this list, even though their associated values are invalid QVariants. */ -QStringList QmlPropertyMap::keys() const +QStringList QDeclarativePropertyMap::keys() const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->keys; } @@ -194,9 +194,9 @@ QStringList QmlPropertyMap::keys() const Same as size(). */ -int QmlPropertyMap::count() const +int QDeclarativePropertyMap::count() const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->keys.count(); } @@ -205,9 +205,9 @@ int QmlPropertyMap::count() const \sa isEmpty(), count() */ -int QmlPropertyMap::size() const +int QDeclarativePropertyMap::size() const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->keys.size(); } @@ -217,9 +217,9 @@ int QmlPropertyMap::size() const \sa size() */ -bool QmlPropertyMap::isEmpty() const +bool QDeclarativePropertyMap::isEmpty() const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->keys.isEmpty(); } @@ -228,9 +228,9 @@ bool QmlPropertyMap::isEmpty() const \sa size() */ -bool QmlPropertyMap::contains(const QString &key) const +bool QDeclarativePropertyMap::contains(const QString &key) const { - Q_D(const QmlPropertyMap); + Q_D(const QDeclarativePropertyMap); return d->keys.contains(key); } @@ -244,10 +244,10 @@ bool QmlPropertyMap::contains(const QString &key) const \sa insert(), value() */ -QVariant &QmlPropertyMap::operator[](const QString &key) +QVariant &QDeclarativePropertyMap::operator[](const QString &key) { //### optimize - Q_D(QmlPropertyMap); + Q_D(QDeclarativePropertyMap); QByteArray utf8key = key.toUtf8(); if (!d->keys.contains(key)) { d->keys.append(key); @@ -262,13 +262,13 @@ QVariant &QmlPropertyMap::operator[](const QString &key) Same as value(). */ -const QVariant QmlPropertyMap::operator[](const QString &key) const +const QVariant QDeclarativePropertyMap::operator[](const QString &key) const { return value(key); } /*! - \fn void QmlPropertyMap::valueChanged(const QString &key) + \fn void QDeclarativePropertyMap::valueChanged(const QString &key) This signal is emitted whenever one of the values in the map is changed. \a key is the key corresponding to the value that was changed. diff --git a/src/declarative/util/qmlpropertymap.h b/src/declarative/util/qdeclarativepropertymap.h index a56ed0f..513089f 100644 --- a/src/declarative/util/qmlpropertymap.h +++ b/src/declarative/util/qdeclarativepropertymap.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLPROPERTYMAP_H -#define QMLPROPERTYMAP_H +#ifndef QDECLARATIVEPROPERTYMAP_H +#define QDECLARATIVEPROPERTYMAP_H #include <QtCore/QObject> #include <QtCore/QHash> @@ -53,13 +53,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlPropertyMapPrivate; -class Q_DECLARATIVE_EXPORT QmlPropertyMap : public QObject +class QDeclarativePropertyMapPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativePropertyMap : public QObject { Q_OBJECT public: - QmlPropertyMap(QObject *parent = 0); - virtual ~QmlPropertyMap(); + QDeclarativePropertyMap(QObject *parent = 0); + virtual ~QDeclarativePropertyMap(); QVariant value(const QString &key) const; void insert(const QString &key, const QVariant &value); @@ -79,8 +79,8 @@ Q_SIGNALS: void valueChanged(const QString &key); private: - Q_DECLARE_PRIVATE(QmlPropertyMap) - Q_DISABLE_COPY(QmlPropertyMap) + Q_DECLARE_PRIVATE(QDeclarativePropertyMap) + Q_DISABLE_COPY(QDeclarativePropertyMap) }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp index 6d4ecf2..012e6a0 100644 --- a/src/declarative/util/qmlspringfollow.cpp +++ b/src/declarative/util/qdeclarativespringfollow.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "qmlspringfollow_p.h" +#include "qdeclarativespringfollow_p.h" -#include "qmlanimation_p_p.h" +#include "qdeclarativeanimation_p_p.h" #include <QtCore/qdebug.h> @@ -52,18 +52,18 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,SpringFollow,QmlSpringFollow) -class QmlSpringFollowPrivate : public QObjectPrivate + +class QDeclarativeSpringFollowPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlSpringFollow) + Q_DECLARE_PUBLIC(QDeclarativeSpringFollow) public: - QmlSpringFollowPrivate() + QDeclarativeSpringFollowPrivate() : currentValue(0), sourceValue(0), maxVelocity(0), lastTime(0) , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01) , modulus(0.0), useMass(false), haveModulus(false), enabled(true), mode(Track), clock(this) {} - QmlMetaProperty property; + QDeclarativeProperty property; qreal currentValue; qreal sourceValue; qreal maxVelocity; @@ -92,12 +92,12 @@ public: void start(); void stop(); - QTickAnimationProxy<QmlSpringFollowPrivate, &QmlSpringFollowPrivate::tick> clock; + QTickAnimationProxy<QDeclarativeSpringFollowPrivate, &QDeclarativeSpringFollowPrivate::tick> clock; }; -void QmlSpringFollowPrivate::tick(int time) +void QDeclarativeSpringFollowPrivate::tick(int time) { - Q_Q(QmlSpringFollow); + Q_Q(QDeclarativeSpringFollow); int elapsed = time - lastTime; if (!elapsed) @@ -179,7 +179,7 @@ void QmlSpringFollowPrivate::tick(int time) emit q->syncChanged(); } -void QmlSpringFollowPrivate::updateMode() +void QDeclarativeSpringFollowPrivate::updateMode() { if (spring == 0. && maxVelocity == 0.) mode = Track; @@ -189,13 +189,13 @@ void QmlSpringFollowPrivate::updateMode() mode = Velocity; } -void QmlSpringFollowPrivate::start() +void QDeclarativeSpringFollowPrivate::start() { if (!enabled) return; - Q_Q(QmlSpringFollow); - if (mode == QmlSpringFollowPrivate::Track) { + Q_Q(QDeclarativeSpringFollow); + if (mode == QDeclarativeSpringFollowPrivate::Track) { currentValue = sourceValue; property.write(currentValue); } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) { @@ -206,13 +206,13 @@ void QmlSpringFollowPrivate::start() } } -void QmlSpringFollowPrivate::stop() +void QDeclarativeSpringFollowPrivate::stop() { clock.stop(); } /*! - \qmlclass SpringFollow QmlSpringFollow + \qmlclass SpringFollow QDeclarativeSpringFollow \brief The SpringFollow element allows a property to track a value. In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200: @@ -245,25 +245,25 @@ void QmlSpringFollowPrivate::stop() \sa EaseFollow */ -QmlSpringFollow::QmlSpringFollow(QObject *parent) -: QObject(*(new QmlSpringFollowPrivate),parent) +QDeclarativeSpringFollow::QDeclarativeSpringFollow(QObject *parent) +: QObject(*(new QDeclarativeSpringFollowPrivate),parent) { } -QmlSpringFollow::~QmlSpringFollow() +QDeclarativeSpringFollow::~QDeclarativeSpringFollow() { } -void QmlSpringFollow::setTarget(const QmlMetaProperty &property) +void QDeclarativeSpringFollow::setTarget(const QDeclarativeProperty &property) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); d->property = property; d->currentValue = property.read().toReal(); } -qreal QmlSpringFollow::sourceValue() const +qreal QDeclarativeSpringFollow::sourceValue() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->sourceValue; } @@ -274,9 +274,9 @@ qreal QmlSpringFollow::sourceValue() const Bind to a property in order to track its changes. */ -void QmlSpringFollow::setSourceValue(qreal value) +void QDeclarativeSpringFollow::setSourceValue(qreal value) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value) return; @@ -289,15 +289,15 @@ void QmlSpringFollow::setSourceValue(qreal value) This property holds the maximum velocity allowed when tracking the source. */ -qreal QmlSpringFollow::velocity() const +qreal QDeclarativeSpringFollow::velocity() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->maxVelocity; } -void QmlSpringFollow::setVelocity(qreal velocity) +void QDeclarativeSpringFollow::setVelocity(qreal velocity) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); d->maxVelocity = velocity; d->velocityms = velocity / 1000.0; d->updateMode(); @@ -313,15 +313,15 @@ void QmlSpringFollow::setVelocity(qreal velocity) When a spring constant is set and the velocity property is greater than 0, velocity limits the maximum speed. */ -qreal QmlSpringFollow::spring() const +qreal QDeclarativeSpringFollow::spring() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->spring; } -void QmlSpringFollow::setSpring(qreal spring) +void QDeclarativeSpringFollow::setSpring(qreal spring) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); d->spring = spring; d->updateMode(); } @@ -333,15 +333,15 @@ void QmlSpringFollow::setSpring(qreal spring) The damping constant describes how quickly a sprung follower comes to rest. Useful range is 0 - 1.0 */ -qreal QmlSpringFollow::damping() const +qreal QDeclarativeSpringFollow::damping() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->damping; } -void QmlSpringFollow::setDamping(qreal damping) +void QDeclarativeSpringFollow::setDamping(qreal damping) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); if (damping > 1.) damping = 1.; @@ -359,15 +359,15 @@ void QmlSpringFollow::setDamping(qreal damping) The default is 0.01. Tuning this value can provide small performance improvements. */ -qreal QmlSpringFollow::epsilon() const +qreal QDeclarativeSpringFollow::epsilon() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->epsilon; } -void QmlSpringFollow::setEpsilon(qreal epsilon) +void QDeclarativeSpringFollow::setEpsilon(qreal epsilon) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); d->epsilon = epsilon; } @@ -378,15 +378,15 @@ void QmlSpringFollow::setEpsilon(qreal epsilon) Setting a \a modulus forces the target value to "wrap around" at the modulus. For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10. */ -qreal QmlSpringFollow::modulus() const +qreal QDeclarativeSpringFollow::modulus() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->modulus; } -void QmlSpringFollow::setModulus(qreal modulus) +void QDeclarativeSpringFollow::setModulus(qreal modulus) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); if (d->modulus != modulus) { d->haveModulus = modulus != 0.0; d->modulus = modulus; @@ -401,15 +401,15 @@ void QmlSpringFollow::setModulus(qreal modulus) mass is 1.0 by default. Setting a different mass changes the dynamics of a \l spring follow. */ -qreal QmlSpringFollow::mass() const +qreal QDeclarativeSpringFollow::mass() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->mass; } -void QmlSpringFollow::setMass(qreal mass) +void QDeclarativeSpringFollow::setMass(qreal mass) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); if (d->mass != mass && mass > 0.0) { d->useMass = mass != 1.0; d->mass = mass; @@ -426,15 +426,15 @@ void QmlSpringFollow::setMass(qreal mass) \qmlproperty bool SpringFollow::enabled This property holds whether the target will track the source. */ -bool QmlSpringFollow::enabled() const +bool QDeclarativeSpringFollow::enabled() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->enabled; } -void QmlSpringFollow::setEnabled(bool enabled) +void QDeclarativeSpringFollow::setEnabled(bool enabled) { - Q_D(QmlSpringFollow); + Q_D(QDeclarativeSpringFollow); d->enabled = enabled; if (enabled) d->start(); @@ -449,15 +449,15 @@ void QmlSpringFollow::setEnabled(bool enabled) If \l enabled is false then inSync will also be false. */ -bool QmlSpringFollow::inSync() const +bool QDeclarativeSpringFollow::inSync() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->enabled && d->clock.state() != QAbstractAnimation::Running; } -qreal QmlSpringFollow::value() const +qreal QDeclarativeSpringFollow::value() const { - Q_D(const QmlSpringFollow); + Q_D(const QDeclarativeSpringFollow); return d->currentValue; } diff --git a/src/declarative/util/qmlspringfollow_p.h b/src/declarative/util/qdeclarativespringfollow_p.h index 4a0ed1c..2ac0d82 100644 --- a/src/declarative/util/qmlspringfollow_p.h +++ b/src/declarative/util/qdeclarativespringfollow_p.h @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLSMOOTHFOLLOW_H -#define QMLSMOOTHFOLLOW_H +#ifndef QDECLARATIVESMOOTHFOLLOW_H +#define QDECLARATIVESMOOTHFOLLOW_H -#include <qmlpropertyvaluesource.h> -#include <qml.h> +#include <qdeclarativepropertyvaluesource.h> +#include <qdeclarative.h> QT_BEGIN_HEADER @@ -51,13 +51,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlSpringFollowPrivate; -class Q_DECLARATIVE_EXPORT QmlSpringFollow : public QObject, - public QmlPropertyValueSource +class QDeclarativeSpringFollowPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeSpringFollow : public QObject, + public QDeclarativePropertyValueSource { Q_OBJECT - Q_DECLARE_PRIVATE(QmlSpringFollow) - Q_INTERFACES(QmlPropertyValueSource) + Q_DECLARE_PRIVATE(QDeclarativeSpringFollow) + Q_INTERFACES(QDeclarativePropertyValueSource) Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue) Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) @@ -71,10 +71,10 @@ class Q_DECLARATIVE_EXPORT QmlSpringFollow : public QObject, Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged) public: - QmlSpringFollow(QObject *parent=0); - ~QmlSpringFollow(); + QDeclarativeSpringFollow(QObject *parent=0); + ~QDeclarativeSpringFollow(); - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QDeclarativeProperty &); qreal sourceValue() const; void setSourceValue(qreal value); @@ -105,8 +105,8 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlSpringFollow) +QML_DECLARE_TYPE(QDeclarativeSpringFollow) QT_END_HEADER -#endif // QMLSMOOTHFOLLOW_H +#endif // QDECLARATIVESMOOTHFOLLOW_H diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qdeclarativestate.cpp index c743e0b..1d70d33 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include "qmlstate_p_p.h" -#include "qmlstate_p.h" +#include "qdeclarativestate_p_p.h" +#include "qdeclarativestate_p.h" -#include "qmltransition_p.h" -#include "qmlstategroup_p.h" -#include "qmlstateoperations_p.h" -#include "qmlanimation_p.h" -#include "qmlanimation_p_p.h" +#include "qdeclarativetransition_p.h" +#include "qdeclarativestategroup_p.h" +#include "qdeclarativestateoperations_p.h" +#include "qdeclarativeanimation_p.h" +#include "qdeclarativeanimation_p_p.h" -#include <qmlbinding.h> -#include <qmlglobal_p.h> +#include <qdeclarativebinding_p.h> +#include <qdeclarativeglobal_p.h> #include <QtCore/qdebug.h> @@ -57,64 +57,64 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -QmlAction::QmlAction() +QDeclarativeAction::QDeclarativeAction() : restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } -QmlAction::QmlAction(QObject *target, const QString &propertyName, +QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName, const QVariant &value) -: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), toValue(value), fromBinding(0), - toBinding(0), event(0), specifiedObject(target), - specifiedProperty(propertyName) +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), + property(target, propertyName), toValue(value), + fromBinding(0), toBinding(0), event(0), + specifiedObject(target), specifiedProperty(propertyName) { - property = QmlMetaProperty::createProperty(target, propertyName); if (property.isValid()) fromValue = property.read(); } -QmlActionEvent::~QmlActionEvent() +QDeclarativeActionEvent::~QDeclarativeActionEvent() { } -QString QmlActionEvent::typeName() const +QString QDeclarativeActionEvent::typeName() const { return QString(); } -void QmlActionEvent::execute() +void QDeclarativeActionEvent::execute() { } -bool QmlActionEvent::isReversable() +bool QDeclarativeActionEvent::isReversable() { return false; } -void QmlActionEvent::reverse() +void QDeclarativeActionEvent::reverse() { } -QList<QmlAction> QmlActionEvent::extraActions() +QList<QDeclarativeAction> QDeclarativeActionEvent::extraActions() { - return QList<QmlAction>(); + return QList<QDeclarativeAction>(); } -bool QmlActionEvent::changesBindings() +bool QDeclarativeActionEvent::changesBindings() { return false; } -void QmlActionEvent::clearForwardBindings() +void QDeclarativeActionEvent::clearForwardBindings() { } -void QmlActionEvent::clearReverseBindings() +void QDeclarativeActionEvent::clearReverseBindings() { } -bool QmlActionEvent::override(QmlActionEvent *other) +bool QDeclarativeActionEvent::override(QDeclarativeActionEvent *other) { Q_UNUSED(other); return false; @@ -123,13 +123,13 @@ bool QmlActionEvent::override(QmlActionEvent *other) /*! \internal */ -QmlStateOperation::QmlStateOperation(QObjectPrivate &dd, QObject *parent) +QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent) : QObject(dd, parent) { } /*! - \qmlclass State QmlState + \qmlclass State QDeclarativeState \since 4.7 \brief The State element defines configurations of objects and properties. @@ -144,28 +144,28 @@ QmlStateOperation::QmlStateOperation(QObjectPrivate &dd, QObject *parent) /*! \internal - \class QmlState - \brief The QmlState class allows you to define configurations of objects and properties. + \class QDeclarativeState + \brief The QDeclarativeState class allows you to define configurations of objects and properties. \ingroup group_states - QmlState allows you to specify a state as a set of batched changes from the default + QDeclarativeState allows you to specify a state as a set of batched changes from the default configuration. \sa {states-transitions}{States and Transitions} */ -QML_DEFINE_TYPE(Qt,4,6,State,QmlState) -QmlState::QmlState(QObject *parent) -: QObject(*(new QmlStatePrivate), parent) + +QDeclarativeState::QDeclarativeState(QObject *parent) +: QObject(*(new QDeclarativeStatePrivate), parent) { - Q_D(QmlState); + Q_D(QDeclarativeState); d->transitionManager.setState(this); } -QmlState::~QmlState() +QDeclarativeState::~QDeclarativeState() { - Q_D(QmlState); + Q_D(QDeclarativeState); if (d->group) d->group->removeState(this); } @@ -176,21 +176,21 @@ QmlState::~QmlState() Each state should have a unique name. */ -QString QmlState::name() const +QString QDeclarativeState::name() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->name; } -void QmlState::setName(const QString &n) +void QDeclarativeState::setName(const QString &n) { - Q_D(QmlState); + Q_D(QDeclarativeState); d->name = n; } -bool QmlState::isWhenKnown() const +bool QDeclarativeState::isWhenKnown() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->when != 0; } @@ -201,15 +201,15 @@ bool QmlState::isWhenKnown() const This should be set to an expression that evaluates to true when you want the state to be applied. */ -QmlBinding *QmlState::when() const +QDeclarativeBinding *QDeclarativeState::when() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->when; } -void QmlState::setWhen(QmlBinding *when) +void QDeclarativeState::setWhen(QDeclarativeBinding *when) { - Q_D(QmlState); + Q_D(QDeclarativeState); d->when = when; if (d->group) d->group->updateAutoState(); @@ -222,15 +222,15 @@ void QmlState::setWhen(QmlBinding *when) The state being extended is treated as the base state in regards to the changes specified by the extending state. */ -QString QmlState::extends() const +QString QDeclarativeState::extends() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->extends; } -void QmlState::setExtends(const QString &extends) +void QDeclarativeState::setExtends(const QString &extends) { - Q_D(QmlState); + Q_D(QDeclarativeState); d->extends = extends; } @@ -243,36 +243,36 @@ void QmlState::setExtends(const QString &extends) extends another state, then the changes are applied against the state being extended. */ -QmlListProperty<QmlStateOperation> QmlState::changes() +QDeclarativeListProperty<QDeclarativeStateOperation> QDeclarativeState::changes() { - Q_D(QmlState); - return QmlListProperty<QmlStateOperation>(this, &d->operations, QmlStatePrivate::operations_append, - QmlStatePrivate::operations_count, QmlStatePrivate::operations_at, - QmlStatePrivate::operations_clear); + Q_D(QDeclarativeState); + return QDeclarativeListProperty<QDeclarativeStateOperation>(this, &d->operations, QDeclarativeStatePrivate::operations_append, + QDeclarativeStatePrivate::operations_count, QDeclarativeStatePrivate::operations_at, + QDeclarativeStatePrivate::operations_clear); } -int QmlState::operationCount() const +int QDeclarativeState::operationCount() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->operations.count(); } -QmlStateOperation *QmlState::operationAt(int index) const +QDeclarativeStateOperation *QDeclarativeState::operationAt(int index) const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->operations.at(index); } -QmlState &QmlState::operator<<(QmlStateOperation *op) +QDeclarativeState &QDeclarativeState::operator<<(QDeclarativeStateOperation *op) { - Q_D(QmlState); - d->operations.append(QmlStatePrivate::OperationGuard(op, &d->operations)); + Q_D(QDeclarativeState); + d->operations.append(QDeclarativeStatePrivate::OperationGuard(op, &d->operations)); return *this; } -void QmlStatePrivate::complete() +void QDeclarativeStatePrivate::complete() { - Q_Q(QmlState); + Q_Q(QDeclarativeState); for (int ii = 0; ii < reverting.count(); ++ii) { for (int jj = 0; jj < revertList.count(); ++jj) { @@ -289,10 +289,10 @@ void QmlStatePrivate::complete() // Generate a list of actions for this state. This includes coelescing state // actions that this state "extends" -QmlStateOperation::ActionList -QmlStatePrivate::generateActionList(QmlStateGroup *group) const +QDeclarativeStateOperation::ActionList +QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) const { - QmlStateOperation::ActionList applyList; + QDeclarativeStateOperation::ActionList applyList; if (inState) return applyList; @@ -300,49 +300,49 @@ QmlStatePrivate::generateActionList(QmlStateGroup *group) const inState = true; if (!extends.isEmpty()) { - QList<QmlState *> states = group->states(); + QList<QDeclarativeState *> states = group->states(); for (int ii = 0; ii < states.count(); ++ii) if (states.at(ii)->name() == extends) - applyList = static_cast<QmlStatePrivate*>(states.at(ii)->d_func())->generateActionList(group); + applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList(group); } - foreach(QmlStateOperation *op, operations) + foreach(QDeclarativeStateOperation *op, operations) applyList << op->actions(); inState = false; return applyList; } -QmlStateGroup *QmlState::stateGroup() const +QDeclarativeStateGroup *QDeclarativeState::stateGroup() const { - Q_D(const QmlState); + Q_D(const QDeclarativeState); return d->group; } -void QmlState::setStateGroup(QmlStateGroup *group) +void QDeclarativeState::setStateGroup(QDeclarativeStateGroup *group) { - Q_D(QmlState); + Q_D(QDeclarativeState); d->group = group; } -void QmlState::cancel() +void QDeclarativeState::cancel() { - Q_D(QmlState); + Q_D(QDeclarativeState); d->transitionManager.cancel(); } -void QmlAction::deleteFromBinding() +void QDeclarativeAction::deleteFromBinding() { if (fromBinding) { - property.setBinding(0); + QDeclarativePropertyPrivate::setBinding(property, 0); fromBinding->destroy(); fromBinding = 0; } } -void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *revert) +void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransition *trans, QDeclarativeState *revert) { - Q_D(QmlState); + Q_D(QDeclarativeState); qmlExecuteDeferred(this); @@ -353,20 +353,20 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->reverting.clear(); if (revert) { - QmlStatePrivate *revertPrivate = - static_cast<QmlStatePrivate*>(revert->d_func()); + QDeclarativeStatePrivate *revertPrivate = + static_cast<QDeclarativeStatePrivate*>(revert->d_func()); d->revertList = revertPrivate->revertList; revertPrivate->revertList.clear(); } // List of actions caused by this state - QmlStateOperation::ActionList applyList = d->generateActionList(group); + QDeclarativeStateOperation::ActionList applyList = d->generateActionList(group); // List of actions that need to be reverted to roll back (just) this state - QmlStatePrivate::SimpleActionList additionalReverts; + QDeclarativeStatePrivate::SimpleActionList additionalReverts; // First add the reverse of all the applyList actions for (int ii = 0; ii < applyList.count(); ++ii) { - QmlAction &action = applyList[ii]; + QDeclarativeAction &action = applyList[ii]; bool found = false; @@ -375,7 +375,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever if (!action.event->isReversable()) continue; for (jj = 0; jj < d->revertList.count(); ++jj) { - QmlActionEvent *event = d->revertList.at(jj).event; + QDeclarativeActionEvent *event = d->revertList.at(jj).event; if (event && event->typeName() == action.event->typeName()) { if (action.event->override(event)) { found = true; @@ -388,7 +388,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever else if (action.event->isRewindable()) action.event->saveCurrentValues(); } else { - action.fromBinding = action.property.binding(); + action.fromBinding = QDeclarativePropertyPrivate::binding(action.property); for (jj = 0; jj < d->revertList.count(); ++jj) { if (d->revertList.at(jj).property == action.property) { @@ -404,7 +404,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } else { // Only need to revert the applyList action if the previous // state doesn't have a higher priority revert already - QmlSimpleAction r(action); + QDeclarativeSimpleAction r(action); additionalReverts << r; } } else if (d->revertList.at(jj).binding != action.fromBinding) { @@ -417,11 +417,11 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever for (int ii = 0; ii < d->revertList.count(); ++ii) { bool found = false; if (d->revertList.at(ii).event) { - QmlActionEvent *event = d->revertList.at(ii).event; + QDeclarativeActionEvent *event = d->revertList.at(ii).event; if (!event->isReversable()) continue; for (int jj = 0; !found && jj < applyList.count(); ++jj) { - const QmlAction &action = applyList.at(jj); + const QDeclarativeAction &action = applyList.at(jj); if (action.event && action.event->typeName() == event->typeName()) { if (action.event->override(event)) found = true; @@ -429,18 +429,19 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } } else { for (int jj = 0; !found && jj < applyList.count(); ++jj) { - const QmlAction &action = applyList.at(jj); + const QDeclarativeAction &action = applyList.at(jj); if (action.property == d->revertList.at(ii).property) found = true; } } if (!found) { QVariant cur = d->revertList.at(ii).property.read(); - QmlAbstractBinding *delBinding = d->revertList.at(ii).property.setBinding(0); + QDeclarativeAbstractBinding *delBinding = + QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property, 0); if (delBinding) delBinding->destroy(); - QmlAction a; + QDeclarativeAction a; a.property = d->revertList.at(ii).property; a.fromValue = cur; a.toValue = d->revertList.at(ii).value; @@ -461,11 +462,11 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever // Output for debugging if (stateChangeDebug()) { - foreach(const QmlAction &action, applyList) { + foreach(const QDeclarativeAction &action, applyList) { if (action.event) - qWarning() << " QmlAction event:" << action.event->typeName(); + qWarning() << " QDeclarativeAction event:" << action.event->typeName(); else - qWarning() << " QmlAction:" << action.property.object() + qWarning() << " QDeclarativeAction:" << action.property.object() << action.property.name() << "From:" << action.fromValue << "To:" << action.toValue; } @@ -474,8 +475,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->transitionManager.transition(applyList, trans); } -QML_DEFINE_NOCREATE_TYPE(QmlStateOperation) -QmlStateOperation::ActionList QmlStateOperation::actions() +QDeclarativeStateOperation::ActionList QDeclarativeStateOperation::actions() { return ActionList(); } diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qdeclarativestate_p.h index 2c92387..abdbec5 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#ifndef QMLSTATE_H -#define QMLSTATE_H - -#include <qml.h> +#ifndef QDECLARATIVESTATE_H +#define QDECLARATIVESTATE_H +#include <qdeclarative.h> +#include <qdeclarativeproperty.h> #include <QtCore/qobject.h> QT_BEGIN_HEADER @@ -52,26 +52,26 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlActionEvent; -class QmlBinding; -class Q_DECLARATIVE_EXPORT QmlAction +class QDeclarativeActionEvent; +class QDeclarativeBinding; +class Q_DECLARATIVE_EXPORT QDeclarativeAction { public: - QmlAction(); - QmlAction(QObject *, const QString &, const QVariant &); + QDeclarativeAction(); + QDeclarativeAction(QObject *, const QString &, const QVariant &); bool restore:1; bool actionDone:1; bool reverseEvent:1; bool deletableToBinding:1; - QmlMetaProperty property; + QDeclarativeProperty property; QVariant fromValue; QVariant toValue; - QmlAbstractBinding *fromBinding; - QmlAbstractBinding *toBinding; - QmlActionEvent *event; + QDeclarativeAbstractBinding *fromBinding; + QDeclarativeAbstractBinding *toBinding; + QDeclarativeActionEvent *event; //strictly for matching QObject *specifiedObject; @@ -80,10 +80,10 @@ public: void deleteFromBinding(); }; -class QmlActionEvent +class QDeclarativeActionEvent { public: - virtual ~QmlActionEvent(); + virtual ~QDeclarativeActionEvent(); virtual QString typeName() const; virtual void execute(); @@ -96,86 +96,86 @@ public: virtual void saveCurrentValues() {} //virtual bool hasExtraActions(); - virtual QList<QmlAction> extraActions(); + virtual QList<QDeclarativeAction> extraActions(); virtual bool changesBindings(); virtual void clearForwardBindings(); virtual void clearReverseBindings(); - virtual bool override(QmlActionEvent*other); + virtual bool override(QDeclarativeActionEvent*other); }; -//### rename to QmlStateChange? -class QmlStateGroup; -class Q_DECLARATIVE_EXPORT QmlStateOperation : public QObject +//### rename to QDeclarativeStateChange? +class QDeclarativeStateGroup; +class Q_DECLARATIVE_EXPORT QDeclarativeStateOperation : public QObject { Q_OBJECT public: - QmlStateOperation(QObject *parent = 0) + QDeclarativeStateOperation(QObject *parent = 0) : QObject(parent) {} - typedef QList<QmlAction> ActionList; + typedef QList<QDeclarativeAction> ActionList; virtual ActionList actions(); protected: - QmlStateOperation(QObjectPrivate &dd, QObject *parent = 0); + QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0); }; -typedef QmlStateOperation::ActionList QmlStateActions; +typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions; -class QmlTransition; -class QmlStatePrivate; -class Q_DECLARATIVE_EXPORT QmlState : public QObject +class QDeclarativeTransition; +class QDeclarativeStatePrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeState : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QmlBinding *when READ when WRITE setWhen) + Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen) Q_PROPERTY(QString extend READ extends WRITE setExtends) - Q_PROPERTY(QmlListProperty<QmlStateOperation> changes READ changes) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes) Q_CLASSINFO("DefaultProperty", "changes") Q_CLASSINFO("DeferredPropertyNames", "changes") public: - QmlState(QObject *parent=0); - virtual ~QmlState(); + QDeclarativeState(QObject *parent=0); + virtual ~QDeclarativeState(); QString name() const; void setName(const QString &); - /*'when' is a QmlBinding to limit state changes oscillation + /*'when' is a QDeclarativeBinding to limit state changes oscillation due to the unpredictable order of evaluation of bound expressions*/ bool isWhenKnown() const; - QmlBinding *when() const; - void setWhen(QmlBinding *); + QDeclarativeBinding *when() const; + void setWhen(QDeclarativeBinding *); QString extends() const; void setExtends(const QString &); - QmlListProperty<QmlStateOperation> changes(); + QDeclarativeListProperty<QDeclarativeStateOperation> changes(); int operationCount() const; - QmlStateOperation *operationAt(int) const; + QDeclarativeStateOperation *operationAt(int) const; - QmlState &operator<<(QmlStateOperation *); + QDeclarativeState &operator<<(QDeclarativeStateOperation *); - void apply(QmlStateGroup *, QmlTransition *, QmlState *revert); + void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert); void cancel(); - QmlStateGroup *stateGroup() const; - void setStateGroup(QmlStateGroup *); + QDeclarativeStateGroup *stateGroup() const; + void setStateGroup(QDeclarativeStateGroup *); Q_SIGNALS: void completed(); private: - Q_DECLARE_PRIVATE(QmlState) - Q_DISABLE_COPY(QmlState) + Q_DECLARE_PRIVATE(QDeclarativeState) + Q_DISABLE_COPY(QDeclarativeState) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlStateOperation) -QML_DECLARE_TYPE(QmlState) +QML_DECLARE_TYPE(QDeclarativeStateOperation) +QML_DECLARE_TYPE(QDeclarativeState) QT_END_HEADER -#endif // QMLSTATE_H +#endif // QDECLARATIVESTATE_H diff --git a/src/declarative/util/qmlstate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h index d138e4e..6f52219 100644 --- a/src/declarative/util/qmlstate_p_p.h +++ b/src/declarative/util/qdeclarativestate_p_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLSTATE_P_H -#define QMLSTATE_P_H +#ifndef QDECLARATIVESTATE_P_H +#define QDECLARATIVESTATE_P_H // // W A R N I N G @@ -53,22 +53,23 @@ // We mean it. // -#include "qmlstate_p.h" +#include "qdeclarativestate_p.h" -#include "qmlanimation_p_p.h" -#include "qmltransitionmanager_p_p.h" +#include "qdeclarativeanimation_p_p.h" +#include "qdeclarativetransitionmanager_p_p.h" -#include <qmlguard_p.h> +#include <qdeclarativeproperty_p.h> +#include <qdeclarativeguard_p.h> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE -class QmlSimpleAction +class QDeclarativeSimpleAction { public: enum State { StartState, EndState }; - QmlSimpleAction(const QmlAction &a, State state = StartState) + QDeclarativeSimpleAction(const QDeclarativeAction &a, State state = StartState) { property = a.property; specifiedObject = a.specifiedObject; @@ -76,7 +77,7 @@ public: event = a.event; if (state == StartState) { value = a.fromValue; - binding = property.binding(); + binding = QDeclarativePropertyPrivate::binding(property); reverseEvent = true; } else { value = a.toValue; @@ -85,68 +86,68 @@ public: } } - QmlMetaProperty property; + QDeclarativeProperty property; QVariant value; - QmlAbstractBinding *binding; + QDeclarativeAbstractBinding *binding; QObject *specifiedObject; QString specifiedProperty; - QmlActionEvent *event; + QDeclarativeActionEvent *event; bool reverseEvent; }; -class QmlStatePrivate : public QObjectPrivate +class QDeclarativeStatePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlState) + Q_DECLARE_PUBLIC(QDeclarativeState) public: - QmlStatePrivate() + QDeclarativeStatePrivate() : when(0), inState(false), group(0) {} - typedef QList<QmlSimpleAction> SimpleActionList; + typedef QList<QDeclarativeSimpleAction> SimpleActionList; QString name; - QmlBinding *when; + QDeclarativeBinding *when; - struct OperationGuard : public QmlGuard<QmlStateOperation> + struct OperationGuard : public QDeclarativeGuard<QDeclarativeStateOperation> { - OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; } + OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; } QList<OperationGuard> *list; - void objectDestroyed(QmlStateOperation *) { + void objectDestroyed(QDeclarativeStateOperation *) { // we assume priv will always be destroyed after objectDestroyed calls list->removeOne(*this); } }; QList<OperationGuard> operations; - static void operations_append(QmlListProperty<QmlStateOperation> *prop, QmlStateOperation *op) { + static void operations_append(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, QDeclarativeStateOperation *op) { QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); list->append(OperationGuard(op, list)); } - static void operations_clear(QmlListProperty<QmlStateOperation> *prop) { + static void operations_clear(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) { QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); list->clear(); } - static int operations_count(QmlListProperty<QmlStateOperation> *prop) { + static int operations_count(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) { QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); return list->count(); } - static QmlStateOperation *operations_at(QmlListProperty<QmlStateOperation> *prop, int index) { + static QDeclarativeStateOperation *operations_at(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, int index) { QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); return list->at(index); } - QmlTransitionManager transitionManager; + QDeclarativeTransitionManager transitionManager; SimpleActionList revertList; - QList<QmlMetaProperty> reverting; + QList<QDeclarativeProperty> reverting; QString extends; mutable bool inState; - QmlStateGroup *group; + QDeclarativeStateGroup *group; - QmlStateOperation::ActionList generateActionList(QmlStateGroup *) const; + QDeclarativeStateOperation::ActionList generateActionList(QDeclarativeStateGroup *) const; void complete(); }; QT_END_NAMESPACE -#endif // QMLSTATE_P_H +#endif // QDECLARATIVESTATE_P_H diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 4ad77c8..1a7c256 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -39,13 +39,13 @@ ** ****************************************************************************/ -#include "qmlstategroup_p.h" +#include "qdeclarativestategroup_p.h" -#include "qmltransition_p.h" -#include "qmlstate_p_p.h" +#include "qdeclarativetransition_p.h" +#include "qdeclarativestate_p_p.h" -#include <qmlbinding.h> -#include <qmlglobal_p.h> +#include <qdeclarativebinding_p.h> +#include <qdeclarativeglobal_p.h> #include <QtCore/qdebug.h> @@ -55,35 +55,35 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -class QmlStateGroupPrivate : public QObjectPrivate +class QDeclarativeStateGroupPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlStateGroup) + Q_DECLARE_PUBLIC(QDeclarativeStateGroup) public: - QmlStateGroupPrivate(QmlStateGroup *p) + QDeclarativeStateGroupPrivate() : nullState(0), componentComplete(true), ignoreTrans(false), applyingState(false) {} QString currentState; - QmlState *nullState; + QDeclarativeState *nullState; - 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); + static void append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state); + static int count_state(QDeclarativeListProperty<QDeclarativeState> *list); + static QDeclarativeState *at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index); - QList<QmlState *> states; - QList<QmlTransition *> transitions; + QList<QDeclarativeState *> states; + QList<QDeclarativeTransition *> transitions; bool componentComplete; bool ignoreTrans; bool applyingState; - QmlTransition *findTransition(const QString &from, const QString &to); + QDeclarativeTransition *findTransition(const QString &from, const QString &to); void setCurrentStateInternal(const QString &state, bool = false); bool updateAutoState(); }; /*! - \qmlclass StateGroup QmlStateGroup + \qmlclass StateGroup QDeclarativeStateGroup \brief The StateGroup element provides state support for non-Item elements. Item (and all dervied elements) provides built in support for states and transitions @@ -110,21 +110,21 @@ public: \sa {qmlstate}{States} {state-transitions}{Transitions} */ -QmlStateGroup::QmlStateGroup(QObject *parent) - : QObject(*(new QmlStateGroupPrivate(this)), parent) +QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent) + : QObject(*(new QDeclarativeStateGroupPrivate), parent) { } -QmlStateGroup::~QmlStateGroup() +QDeclarativeStateGroup::~QDeclarativeStateGroup() { - Q_D(const QmlStateGroup); + Q_D(const QDeclarativeStateGroup); for (int i = 0; i < d->states.count(); ++i) d->states.at(i)->setStateGroup(0); } -QList<QmlState *> QmlStateGroup::states() const +QList<QDeclarativeState *> QDeclarativeStateGroup::states() const { - Q_D(const QmlStateGroup); + Q_D(const QDeclarativeStateGroup); return d->states; } @@ -144,17 +144,17 @@ QList<QmlState *> QmlStateGroup::states() const \sa {qmlstate}{States} */ -QmlListProperty<QmlState> QmlStateGroup::statesProperty() +QDeclarativeListProperty<QDeclarativeState> QDeclarativeStateGroup::statesProperty() { - Q_D(QmlStateGroup); - return QmlListProperty<QmlState>(this, &d->states, &QmlStateGroupPrivate::append_state, - &QmlStateGroupPrivate::count_state, - &QmlStateGroupPrivate::at_state); + Q_D(QDeclarativeStateGroup); + return QDeclarativeListProperty<QDeclarativeState>(this, &d->states, &QDeclarativeStateGroupPrivate::append_state, + &QDeclarativeStateGroupPrivate::count_state, + &QDeclarativeStateGroupPrivate::at_state); } -void QmlStateGroupPrivate::append_state(QmlListProperty<QmlState> *list, QmlState *state) +void QDeclarativeStateGroupPrivate::append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state) { - QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object); + QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object); if (state) { _this->d_func()->states.append(state); state->setStateGroup(_this); @@ -162,15 +162,15 @@ void QmlStateGroupPrivate::append_state(QmlListProperty<QmlState> *list, QmlStat } -int QmlStateGroupPrivate::count_state(QmlListProperty<QmlState> *list) +int QDeclarativeStateGroupPrivate::count_state(QDeclarativeListProperty<QDeclarativeState> *list) { - QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object); + QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object); return _this->d_func()->states.count(); } -QmlState *QmlStateGroupPrivate::at_state(QmlListProperty<QmlState> *list, int index) +QDeclarativeState *QDeclarativeStateGroupPrivate::at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index) { - QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object); + QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object); return _this->d_func()->states.at(index); } @@ -190,10 +190,10 @@ QmlState *QmlStateGroupPrivate::at_state(QmlListProperty<QmlState> *list, int in \sa {state-transitions}{Transitions} */ -QmlListProperty<QmlTransition> QmlStateGroup::transitionsProperty() +QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty() { - Q_D(QmlStateGroup); - return QmlListProperty<QmlTransition>(this, d->transitions); + Q_D(QDeclarativeStateGroup); + return QDeclarativeListProperty<QDeclarativeTransition>(this, d->transitions); } /*! @@ -221,30 +221,30 @@ QmlListProperty<QmlTransition> QmlStateGroup::transitionsProperty() \sa {qmlstates}{States} */ -QString QmlStateGroup::state() const +QString QDeclarativeStateGroup::state() const { - Q_D(const QmlStateGroup); + Q_D(const QDeclarativeStateGroup); return d->currentState; } -void QmlStateGroup::setState(const QString &state) +void QDeclarativeStateGroup::setState(const QString &state) { - Q_D(QmlStateGroup); + Q_D(QDeclarativeStateGroup); if (d->currentState == state) return; d->setCurrentStateInternal(state); } -void QmlStateGroup::classBegin() +void QDeclarativeStateGroup::classBegin() { - Q_D(QmlStateGroup); + Q_D(QDeclarativeStateGroup); d->componentComplete = false; } -void QmlStateGroup::componentComplete() +void QDeclarativeStateGroup::componentComplete() { - Q_D(QmlStateGroup); + Q_D(QDeclarativeStateGroup); d->componentComplete = true; if (d->updateAutoState()) { @@ -259,21 +259,21 @@ void QmlStateGroup::componentComplete() /*! Returns true if the state was changed, otherwise false. */ -bool QmlStateGroup::updateAutoState() +bool QDeclarativeStateGroup::updateAutoState() { - Q_D(QmlStateGroup); + Q_D(QDeclarativeStateGroup); return d->updateAutoState(); } -bool QmlStateGroupPrivate::updateAutoState() +bool QDeclarativeStateGroupPrivate::updateAutoState() { - Q_Q(QmlStateGroup); + Q_Q(QDeclarativeStateGroup); if (!componentComplete) return false; bool revert = false; for (int ii = 0; ii < states.count(); ++ii) { - QmlState *state = states.at(ii); + QDeclarativeState *state = states.at(ii); if (state->isWhenKnown()) { if (!state->name().isEmpty()) { if (state->when() && state->when()->value().toBool()) { @@ -301,15 +301,15 @@ bool QmlStateGroupPrivate::updateAutoState() } } -QmlTransition *QmlStateGroupPrivate::findTransition(const QString &from, const QString &to) +QDeclarativeTransition *QDeclarativeStateGroupPrivate::findTransition(const QString &from, const QString &to) { - QmlTransition *highest = 0; + QDeclarativeTransition *highest = 0; int score = 0; bool reversed = false; bool done = false; for (int ii = 0; !done && ii < transitions.count(); ++ii) { - QmlTransition *t = transitions.at(ii); + QDeclarativeTransition *t = transitions.at(ii); for (int ii = 0; ii < 2; ++ii) { if (ii && (!t->reversible() || @@ -360,10 +360,10 @@ QmlTransition *QmlStateGroupPrivate::findTransition(const QString &from, const Q return highest; } -void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, +void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state, bool ignoreTrans) { - Q_Q(QmlStateGroup); + Q_Q(QDeclarativeStateGroup); if (!componentComplete) { currentState = state; return; @@ -376,7 +376,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, applyingState = true; - QmlTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state); + QDeclarativeTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state); if (stateChangeDebug()) { qWarning() << this << "Changing state. From" << currentState << ". To" << state; if (transition) @@ -384,7 +384,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, << transition->toState(); } - QmlState *oldState = 0; + QDeclarativeState *oldState = 0; if (!currentState.isEmpty()) { for (int ii = 0; ii < states.count(); ++ii) { if (states.at(ii)->name() == currentState) { @@ -397,7 +397,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, currentState = state; emit q->stateChanged(currentState); - QmlState *newState = 0; + QDeclarativeState *newState = 0; for (int ii = 0; ii < states.count(); ++ii) { if (states.at(ii)->name() == currentState) { newState = states.at(ii); @@ -406,7 +406,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, } if (oldState == 0 || newState == 0) { - if (!nullState) { nullState = new QmlState; QmlGraphics_setParent_noEvent(nullState, q); } + if (!nullState) { nullState = new QDeclarativeState; QDeclarativeGraphics_setParent_noEvent(nullState, q); } if (!oldState) oldState = nullState; if (!newState) newState = nullState; } @@ -414,14 +414,14 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, newState->apply(q, transition, oldState); applyingState = false; if (!transition) - static_cast<QmlStatePrivate*>(QObjectPrivate::get(newState))->complete(); + static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(newState))->complete(); } -QmlState *QmlStateGroup::findState(const QString &name) const +QDeclarativeState *QDeclarativeStateGroup::findState(const QString &name) const { - Q_D(const QmlStateGroup); + Q_D(const QDeclarativeStateGroup); for (int i = 0; i < d->states.count(); ++i) { - QmlState *state = d->states.at(i); + QDeclarativeState *state = d->states.at(i); if (state->name() == name) return state; } @@ -429,12 +429,12 @@ QmlState *QmlStateGroup::findState(const QString &name) const return 0; } -void QmlStateGroup::removeState(QmlState *state) +void QDeclarativeStateGroup::removeState(QDeclarativeState *state) { - Q_D(QmlStateGroup); + Q_D(QDeclarativeStateGroup); d->states.removeOne(state); } QT_END_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) + diff --git a/src/declarative/util/qmlstategroup_p.h b/src/declarative/util/qdeclarativestategroup_p.h index d39ca03..9650199 100644 --- a/src/declarative/util/qmlstategroup_p.h +++ b/src/declarative/util/qdeclarativestategroup_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLSTATEGROUP_H -#define QMLSTATEGROUP_H +#ifndef QDECLARATIVESTATEGROUP_H +#define QDECLARATIVESTATEGROUP_H -#include "qmlstate_p.h" +#include "qdeclarativestate_p.h" QT_BEGIN_HEADER @@ -50,30 +50,30 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlStateGroupPrivate; -class Q_DECLARATIVE_EXPORT QmlStateGroup : public QObject, public QmlParserStatus +class QDeclarativeStateGroupPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_INTERFACES(QmlParserStatus) - Q_DECLARE_PRIVATE(QmlStateGroup) + Q_INTERFACES(QDeclarativeParserStatus) + Q_DECLARE_PRIVATE(QDeclarativeStateGroup) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QmlListProperty<QmlState> states READ statesProperty DESIGNABLE false) - Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitionsProperty DESIGNABLE false) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeState> states READ statesProperty DESIGNABLE false) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitionsProperty DESIGNABLE false) public: - QmlStateGroup(QObject * = 0); - virtual ~QmlStateGroup(); + QDeclarativeStateGroup(QObject * = 0); + virtual ~QDeclarativeStateGroup(); QString state() const; void setState(const QString &); - QmlListProperty<QmlState> statesProperty(); - QList<QmlState *> states() const; + QDeclarativeListProperty<QDeclarativeState> statesProperty(); + QList<QDeclarativeState *> states() const; - QmlListProperty<QmlTransition> transitionsProperty(); + QDeclarativeListProperty<QDeclarativeTransition> transitionsProperty(); - QmlState *findState(const QString &name) const; + QDeclarativeState *findState(const QString &name) const; virtual void classBegin(); virtual void componentComplete(); @@ -81,15 +81,15 @@ Q_SIGNALS: void stateChanged(const QString &); private: - friend class QmlState; + friend class QDeclarativeState; bool updateAutoState(); - void removeState(QmlState *state); + void removeState(QDeclarativeState *state); }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlStateGroup) +QML_DECLARE_TYPE(QDeclarativeStateGroup) QT_END_HEADER -#endif // QMLSTATEGROUP_H +#endif // QDECLARATIVESTATEGROUP_H diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index bd1f5f0..9df8658 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "qmlstateoperations_p.h" +#include "qdeclarativestateoperations_p.h" -#include <qml.h> -#include <qmlcontext.h> -#include <qmlexpression.h> -#include <qmlinfo.h> -#include <qmlgraphicsanchors_p_p.h> -#include <qmlgraphicsitem_p.h> -#include <qmlguard_p.h> +#include <qdeclarative.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeexpression.h> +#include <qdeclarativeinfo.h> +#include <qdeclarativeanchors_p_p.h> +#include <qdeclarativeitem_p.h> +#include <qdeclarativeguard_p.h> #include <QtCore/qdebug.h> #include <QtGui/qgraphicsitem.h> @@ -57,32 +57,32 @@ QT_BEGIN_NAMESPACE -class QmlParentChangePrivate : public QObjectPrivate +class QDeclarativeParentChangePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlParentChange) + Q_DECLARE_PUBLIC(QDeclarativeParentChange) public: - QmlParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0), + QDeclarativeParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0), rewindParent(0), rewindStackBefore(0) {} - QmlGraphicsItem *target; - QmlGraphicsItem *parent; - QmlGuard<QmlGraphicsItem> origParent; - QmlGuard<QmlGraphicsItem> origStackBefore; - QmlGraphicsItem *rewindParent; - QmlGraphicsItem *rewindStackBefore; + QDeclarativeItem *target; + QDeclarativeItem *parent; + QDeclarativeGuard<QDeclarativeItem> origParent; + QDeclarativeGuard<QDeclarativeItem> origStackBefore; + QDeclarativeItem *rewindParent; + QDeclarativeItem *rewindStackBefore; - void doChange(QmlGraphicsItem *targetParent, QmlGraphicsItem *stackBefore = 0); + void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0); }; -void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphicsItem *stackBefore) +void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore) { if (targetParent && target && target->parentItem()) { //### for backwards direction, can we just restore original x, y, scale, rotation - Q_Q(QmlParentChange); + Q_Q(QDeclarativeParentChange); bool ok; - const QTransform &transform = target->itemTransform(targetParent, &ok); + const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under complex transform"); + qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under complex transform"); ok = false; } @@ -92,28 +92,29 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics if (transform.m11() == transform.m22()) scale = transform.m11(); else { - qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QDeclarativeParentChange::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) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QDeclarativeParentChange::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) << QmlParentChange::tr("Unable to preserve appearance under scale of 0"); + qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under scale of 0"); ok = false; } } - qreal xt = transform.dx(); - qreal yt = transform.dy(); - if (ok && target->transformOrigin() != QmlGraphicsItem::TopLeft) { + const QPointF &point = transform.map(QPointF(target->x(),target->y())); + qreal x = point.x(); + qreal y = point.y(); + if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { qreal tempxt = target->transformOriginPoint().x(); qreal tempyt = target->transformOriginPoint().y(); QTransform t; @@ -121,18 +122,18 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics t.rotate(rotation); t.scale(scale, scale); t.translate(tempxt, tempyt); - QPointF offset = t.map(QPointF(0,0)); - xt += offset.x(); - yt += offset.y(); + const QPointF &offset = t.map(QPointF(0,0)); + x += offset.x(); + y += offset.y(); } target->setParentItem(targetParent); if (ok) { - //qDebug() << xt << yt << rotation << scale; - target->setX(xt); - target->setY(yt); - target->setRotation(rotation); - target->setScale(scale); + //qDebug() << x << y << rotation << scale; + target->setX(x); + target->setY(y); + target->setRotation(target->rotation() + rotation); + target->setScale(target->scale() * scale); } } else if (target) { target->setParentItem(targetParent); @@ -146,7 +147,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics /*! \preliminary - \qmlclass ParentChange QmlParentChange + \qmlclass ParentChange QDeclarativeParentChange \brief The ParentChange element allows you to reparent an Item in a state change. ParentChange reparents an Item while preserving its visual appearance (position, rotation, @@ -162,13 +163,13 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics using a ParentAction. */ -QML_DEFINE_TYPE(Qt,4,6,ParentChange,QmlParentChange) -QmlParentChange::QmlParentChange(QObject *parent) - : QmlStateOperation(*(new QmlParentChangePrivate), parent) + +QDeclarativeParentChange::QDeclarativeParentChange(QObject *parent) + : QDeclarativeStateOperation(*(new QDeclarativeParentChangePrivate), parent) { } -QmlParentChange::~QmlParentChange() +QDeclarativeParentChange::~QDeclarativeParentChange() { } @@ -177,15 +178,15 @@ QmlParentChange::~QmlParentChange() This property holds the item to be reparented */ -QmlGraphicsItem *QmlParentChange::object() const +QDeclarativeItem *QDeclarativeParentChange::object() const { - Q_D(const QmlParentChange); + Q_D(const QDeclarativeParentChange); return d->target; } -void QmlParentChange::setObject(QmlGraphicsItem *target) +void QDeclarativeParentChange::setObject(QDeclarativeItem *target) { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); d->target = target; } @@ -194,84 +195,84 @@ void QmlParentChange::setObject(QmlGraphicsItem *target) This property holds the parent for the item in this state */ -QmlGraphicsItem *QmlParentChange::parent() const +QDeclarativeItem *QDeclarativeParentChange::parent() const { - Q_D(const QmlParentChange); + Q_D(const QDeclarativeParentChange); return d->parent; } -void QmlParentChange::setParent(QmlGraphicsItem *parent) +void QDeclarativeParentChange::setParent(QDeclarativeItem *parent) { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); d->parent = parent; } -QmlStateOperation::ActionList QmlParentChange::actions() +QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); if (!d->target || !d->parent) return ActionList(); - QmlAction a; + QDeclarativeAction a; a.event = this; return ActionList() << a; } -class AccessibleFxItem : public QmlGraphicsItem +class AccessibleFxItem : public QDeclarativeItem { Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsItem) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) public: int siblingIndex() { - Q_D(QmlGraphicsItem); + Q_D(QDeclarativeItem); return d->siblingIndex; } }; -void QmlParentChange::saveOriginals() +void QDeclarativeParentChange::saveOriginals() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); saveCurrentValues(); d->origParent = d->rewindParent; d->origStackBefore = d->rewindStackBefore; } -void QmlParentChange::execute() +void QDeclarativeParentChange::execute() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); d->doChange(d->parent); } -bool QmlParentChange::isReversable() +bool QDeclarativeParentChange::isReversable() { return true; } -void QmlParentChange::reverse() +void QDeclarativeParentChange::reverse() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); d->doChange(d->origParent, d->origStackBefore); } -QString QmlParentChange::typeName() const +QString QDeclarativeParentChange::typeName() const { return QLatin1String("ParentChange"); } -bool QmlParentChange::override(QmlActionEvent*other) +bool QDeclarativeParentChange::override(QDeclarativeActionEvent*other) { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); if (other->typeName() != QLatin1String("ParentChange")) return false; - if (QmlParentChange *otherPC = static_cast<QmlParentChange*>(other)) + if (QDeclarativeParentChange *otherPC = static_cast<QDeclarativeParentChange*>(other)) return (d->target == otherPC->object()); return false; } -void QmlParentChange::saveCurrentValues() +void QDeclarativeParentChange::saveCurrentValues() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); if (!d->target) { d->rewindParent = 0; d->rewindStackBefore = 0; @@ -289,7 +290,7 @@ void QmlParentChange::saveCurrentValues() int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1; QList<QGraphicsItem*> children = d->rewindParent->childItems(); for (int i = 0; i < children.count(); ++i) { - QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem*>(children.at(i)); + QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(children.at(i)); if (!child) continue; if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) { @@ -299,36 +300,36 @@ void QmlParentChange::saveCurrentValues() } } -void QmlParentChange::rewind() +void QDeclarativeParentChange::rewind() { - Q_D(QmlParentChange); + Q_D(QDeclarativeParentChange); d->doChange(d->rewindParent, d->rewindStackBefore); } -class QmlStateChangeScriptPrivate : public QObjectPrivate +class QDeclarativeStateChangeScriptPrivate : public QObjectPrivate { public: - QmlStateChangeScriptPrivate() {} + QDeclarativeStateChangeScriptPrivate() {} - QmlScriptString script; + QDeclarativeScriptString script; QString name; }; /*! - \qmlclass StateChangeScript QmlStateChangeScript + \qmlclass StateChangeScript QDeclarativeStateChangeScript \brief The StateChangeScript element allows you to run a script in a state. The script specified will be run immediately when the state is made current. Alternatively you can use a ScriptAction to specify at which point in the transition you want the StateChangeScript to be run. */ -QML_DEFINE_TYPE(Qt,4,6,StateChangeScript,QmlStateChangeScript) -QmlStateChangeScript::QmlStateChangeScript(QObject *parent) -: QmlStateOperation(*(new QmlStateChangeScriptPrivate), parent) + +QDeclarativeStateChangeScript::QDeclarativeStateChangeScript(QObject *parent) +: QDeclarativeStateOperation(*(new QDeclarativeStateChangeScriptPrivate), parent) { } -QmlStateChangeScript::~QmlStateChangeScript() +QDeclarativeStateChangeScript::~QDeclarativeStateChangeScript() { } @@ -336,15 +337,15 @@ QmlStateChangeScript::~QmlStateChangeScript() \qmlproperty script StateChangeScript::script This property holds the script to run when the state is current. */ -QmlScriptString QmlStateChangeScript::script() const +QDeclarativeScriptString QDeclarativeStateChangeScript::script() const { - Q_D(const QmlStateChangeScript); + Q_D(const QDeclarativeStateChangeScript); return d->script; } -void QmlStateChangeScript::setScript(const QmlScriptString &s) +void QDeclarativeStateChangeScript::setScript(const QDeclarativeScriptString &s) { - Q_D(QmlStateChangeScript); + Q_D(QDeclarativeStateChangeScript); d->script = s; } @@ -355,45 +356,44 @@ void QmlStateChangeScript::setScript(const QmlScriptString &s) \sa ScriptAction::stateChangeScriptName */ -QString QmlStateChangeScript::name() const +QString QDeclarativeStateChangeScript::name() const { - Q_D(const QmlStateChangeScript); + Q_D(const QDeclarativeStateChangeScript); return d->name; } -void QmlStateChangeScript::setName(const QString &n) +void QDeclarativeStateChangeScript::setName(const QString &n) { - Q_D(QmlStateChangeScript); + Q_D(QDeclarativeStateChangeScript); d->name = n; } -void QmlStateChangeScript::execute() +void QDeclarativeStateChangeScript::execute() { - Q_D(QmlStateChangeScript); + Q_D(QDeclarativeStateChangeScript); const QString &script = d->script.script(); if (!script.isEmpty()) { - QmlExpression expr(d->script.context(), script, d->script.scopeObject()); - expr.setTrackChange(false); + QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); expr.value(); } } -QmlStateChangeScript::ActionList QmlStateChangeScript::actions() +QDeclarativeStateChangeScript::ActionList QDeclarativeStateChangeScript::actions() { ActionList rv; - QmlAction a; + QDeclarativeAction a; a.event = this; rv << a; return rv; } -QString QmlStateChangeScript::typeName() const +QString QDeclarativeStateChangeScript::typeName() const { return QLatin1String("StateChangeScript"); } /*! - \qmlclass AnchorChanges QmlAnchorChanges + \qmlclass AnchorChanges QDeclarativeAnchorChanges \brief The AnchorChanges element allows you to change the anchors of an item in a state. In the following example we change the top and bottom anchors of an item: @@ -409,40 +409,40 @@ QString QmlStateChangeScript::typeName() const For more information on anchors see \l {anchor-layout}{Anchor Layouts}. */ -QML_DEFINE_TYPE(Qt,4,6,AnchorChanges,QmlAnchorChanges) -class QmlAnchorChangesPrivate : public QObjectPrivate + +class QDeclarativeAnchorChangesPrivate : public QObjectPrivate { public: - QmlAnchorChangesPrivate() : target(0) {} + QDeclarativeAnchorChangesPrivate() : target(0) {} QString name; - QmlGraphicsItem *target; + QDeclarativeItem *target; QString resetString; QStringList resetList; - QmlGraphicsAnchorLine left; - QmlGraphicsAnchorLine right; - QmlGraphicsAnchorLine horizontalCenter; - QmlGraphicsAnchorLine top; - QmlGraphicsAnchorLine bottom; - QmlGraphicsAnchorLine verticalCenter; - QmlGraphicsAnchorLine baseline; - - QmlGraphicsAnchorLine origLeft; - QmlGraphicsAnchorLine origRight; - QmlGraphicsAnchorLine origHCenter; - QmlGraphicsAnchorLine origTop; - QmlGraphicsAnchorLine origBottom; - QmlGraphicsAnchorLine origVCenter; - QmlGraphicsAnchorLine origBaseline; - - QmlGraphicsAnchorLine rewindLeft; - QmlGraphicsAnchorLine rewindRight; - QmlGraphicsAnchorLine rewindHCenter; - QmlGraphicsAnchorLine rewindTop; - QmlGraphicsAnchorLine rewindBottom; - QmlGraphicsAnchorLine rewindVCenter; - QmlGraphicsAnchorLine rewindBaseline; + QDeclarativeAnchorLine left; + QDeclarativeAnchorLine right; + QDeclarativeAnchorLine horizontalCenter; + QDeclarativeAnchorLine top; + QDeclarativeAnchorLine bottom; + QDeclarativeAnchorLine verticalCenter; + QDeclarativeAnchorLine baseline; + + QDeclarativeAnchorLine origLeft; + QDeclarativeAnchorLine origRight; + QDeclarativeAnchorLine origHCenter; + QDeclarativeAnchorLine origTop; + QDeclarativeAnchorLine origBottom; + QDeclarativeAnchorLine origVCenter; + QDeclarativeAnchorLine origBaseline; + + QDeclarativeAnchorLine rewindLeft; + QDeclarativeAnchorLine rewindRight; + QDeclarativeAnchorLine rewindHCenter; + QDeclarativeAnchorLine rewindTop; + QDeclarativeAnchorLine rewindBottom; + QDeclarativeAnchorLine rewindVCenter; + QDeclarativeAnchorLine rewindBaseline; qreal fromX; qreal fromY; @@ -455,43 +455,43 @@ public: This property holds the Item whose anchors will change */ -QmlAnchorChanges::QmlAnchorChanges(QObject *parent) - : QmlStateOperation(*(new QmlAnchorChangesPrivate), parent) +QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent) + : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent) { } -QmlAnchorChanges::~QmlAnchorChanges() +QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges() { } -QmlAnchorChanges::ActionList QmlAnchorChanges::actions() +QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions() { - QmlAction a; + QDeclarativeAction a; a.event = this; return ActionList() << a; } -QmlGraphicsItem *QmlAnchorChanges::object() const +QDeclarativeItem *QDeclarativeAnchorChanges::object() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->target; } -void QmlAnchorChanges::setObject(QmlGraphicsItem *target) +void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->target = target; } -QString QmlAnchorChanges::reset() const +QString QDeclarativeAnchorChanges::reset() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->resetString; } -void QmlAnchorChanges::setReset(const QString &reset) +void QDeclarativeAnchorChanges::setReset(const QString &reset) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->resetString = reset; d->resetList = d->resetString.split(QLatin1Char(',')); for (int i = 0; i < d->resetList.count(); ++i) @@ -510,184 +510,184 @@ void QmlAnchorChanges::setReset(const QString &reset) These properties change the respective anchors of the item. */ -QmlGraphicsAnchorLine QmlAnchorChanges::left() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::left() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->left; } -void QmlAnchorChanges::setLeft(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setLeft(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->left = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::right() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::right() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->right; } -void QmlAnchorChanges::setRight(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setRight(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->right = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::horizontalCenter() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::horizontalCenter() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->horizontalCenter; } -void QmlAnchorChanges::setHorizontalCenter(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setHorizontalCenter(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->horizontalCenter = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::top() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::top() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->top; } -void QmlAnchorChanges::setTop(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setTop(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->top = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::bottom() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::bottom() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->bottom; } -void QmlAnchorChanges::setBottom(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setBottom(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->bottom = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::verticalCenter() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::verticalCenter() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->verticalCenter; } -void QmlAnchorChanges::setVerticalCenter(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setVerticalCenter(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->verticalCenter = edge; } -QmlGraphicsAnchorLine QmlAnchorChanges::baseline() const +QDeclarativeAnchorLine QDeclarativeAnchorChanges::baseline() const { - Q_D(const QmlAnchorChanges); + Q_D(const QDeclarativeAnchorChanges); return d->baseline; } -void QmlAnchorChanges::setBaseline(const QmlGraphicsAnchorLine &edge) +void QDeclarativeAnchorChanges::setBaseline(const QDeclarativeAnchorLine &edge) { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->baseline = edge; } -void QmlAnchorChanges::execute() +void QDeclarativeAnchorChanges::execute() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); if (!d->target) return; //set any anchors that have been specified - if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setLeft(d->left); - if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setRight(d->right); - if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setHorizontalCenter(d->horizontalCenter); - if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setTop(d->top); - if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBottom(d->bottom); - if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setVerticalCenter(d->verticalCenter); - if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBaseline(d->baseline); } -bool QmlAnchorChanges::isReversable() +bool QDeclarativeAnchorChanges::isReversable() { return true; } -void QmlAnchorChanges::reverse() +void QDeclarativeAnchorChanges::reverse() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); if (!d->target) return; //restore previous anchors - if (d->origLeft.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origLeft.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setLeft(d->origLeft); - if (d->origRight.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origRight.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setRight(d->origRight); - if (d->origHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setHorizontalCenter(d->origHCenter); - if (d->origTop.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origTop.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setTop(d->origTop); - if (d->origBottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origBottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBottom(d->origBottom); - if (d->origVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setVerticalCenter(d->origVCenter); - if (d->origBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBaseline(d->origBaseline); } -QString QmlAnchorChanges::typeName() const +QString QDeclarativeAnchorChanges::typeName() const { return QLatin1String("AnchorChanges"); } -QList<QmlAction> QmlAnchorChanges::extraActions() +QList<QDeclarativeAction> QDeclarativeAnchorChanges::extraActions() { - Q_D(QmlAnchorChanges); - QList<QmlAction> extra; + Q_D(QDeclarativeAnchorChanges); + QList<QDeclarativeAction> extra; //### try to be smarter about which ones we add. // or short-circuit later on if they haven't actually changed. // we shouldn't set explicit width if there wasn't one before. if (d->target) { - QmlAction a; + QDeclarativeAction a; a.fromValue = d->fromX; - a.property = QmlMetaProperty(d->target, QLatin1String("x")); + a.property = QDeclarativeProperty(d->target, QLatin1String("x")); extra << a; a.fromValue = d->fromY; - a.property = QmlMetaProperty(d->target, QLatin1String("y")); + a.property = QDeclarativeProperty(d->target, QLatin1String("y")); extra << a; a.fromValue = d->fromWidth; - a.property = QmlMetaProperty(d->target, QLatin1String("width")); + a.property = QDeclarativeProperty(d->target, QLatin1String("width")); extra << a; a.fromValue = d->fromHeight; - a.property = QmlMetaProperty(d->target, QLatin1String("height")); + a.property = QDeclarativeProperty(d->target, QLatin1String("height")); extra << a; } return extra; } -bool QmlAnchorChanges::changesBindings() +bool QDeclarativeAnchorChanges::changesBindings() { return true; } -void QmlAnchorChanges::saveOriginals() +void QDeclarativeAnchorChanges::saveOriginals() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->origLeft = d->target->anchors()->left(); d->origRight = d->target->anchors()->right(); d->origHCenter = d->target->anchors()->horizontalCenter(); @@ -699,9 +699,9 @@ void QmlAnchorChanges::saveOriginals() saveCurrentValues(); } -void QmlAnchorChanges::clearForwardBindings() +void QDeclarativeAnchorChanges::clearForwardBindings() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->fromX = d->target->x(); d->fromY = d->target->y(); d->fromWidth = d->target->width(); @@ -724,100 +724,100 @@ void QmlAnchorChanges::clearForwardBindings() d->target->anchors()->resetBaseline(); //reset any anchors that we'll be setting in the state - if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetLeft(); - if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetRight(); - if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetHorizontalCenter(); - if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetTop(); - if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBottom(); - if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetVerticalCenter(); - if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBaseline(); } -void QmlAnchorChanges::clearReverseBindings() +void QDeclarativeAnchorChanges::clearReverseBindings() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->fromX = d->target->x(); d->fromY = d->target->y(); d->fromWidth = d->target->width(); d->fromHeight = d->target->height(); //reset any anchors that were set in the state - if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetLeft(); - if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetRight(); - if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetHorizontalCenter(); - if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetTop(); - if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBottom(); - if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetVerticalCenter(); - if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBaseline(); //reset any anchors that were set in the original state - if (d->origLeft.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origLeft.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetLeft(); - if (d->origRight.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origRight.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetRight(); - if (d->origHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetHorizontalCenter(); - if (d->origTop.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origTop.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetTop(); - if (d->origBottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origBottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBottom(); - if (d->origVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetVerticalCenter(); - if (d->origBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->origBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBaseline(); } -bool QmlAnchorChanges::override(QmlActionEvent*other) +bool QDeclarativeAnchorChanges::override(QDeclarativeActionEvent*other) { if (other->typeName() != QLatin1String("AnchorChanges")) return false; - if (static_cast<QmlActionEvent*>(this) == other) + if (static_cast<QDeclarativeActionEvent*>(this) == other) return true; - if (static_cast<QmlAnchorChanges*>(other)->object() == object()) + if (static_cast<QDeclarativeAnchorChanges*>(other)->object() == object()) return true; return false; } -void QmlAnchorChanges::rewind() +void QDeclarativeAnchorChanges::rewind() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); if (!d->target) return; //restore previous anchors - if (d->rewindLeft.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setLeft(d->rewindLeft); - if (d->rewindRight.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setRight(d->rewindRight); - if (d->rewindHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setHorizontalCenter(d->rewindHCenter); - if (d->rewindTop.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setTop(d->rewindTop); - if (d->rewindBottom.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBottom(d->rewindBottom); - if (d->rewindVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setVerticalCenter(d->rewindVCenter); - if (d->rewindBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid) + if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->setBaseline(d->rewindBaseline); } -void QmlAnchorChanges::saveCurrentValues() +void QDeclarativeAnchorChanges::saveCurrentValues() { - Q_D(QmlAnchorChanges); + Q_D(QDeclarativeAnchorChanges); d->rewindLeft = d->target->anchors()->left(); d->rewindRight = d->target->anchors()->right(); d->rewindHCenter = d->target->anchors()->horizontalCenter(); @@ -827,8 +827,8 @@ void QmlAnchorChanges::saveCurrentValues() d->rewindBaseline = d->target->anchors()->baseline(); } -#include <qmlstateoperations.moc> -#include <moc_qmlstateoperations_p.cpp> +#include <qdeclarativestateoperations.moc> +#include <moc_qdeclarativestateoperations_p.cpp> QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h new file mode 100644 index 0000000..9204a58 --- /dev/null +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTATEOPERATIONS_H +#define QDECLARATIVESTATEOPERATIONS_H + +#include "qdeclarativestate_p.h" + +#include <qdeclarativeitem.h> +#include "private/qdeclarativeanchors_p.h" +#include <qdeclarativescriptstring.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeParentChangePrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeParentChange : public QDeclarativeStateOperation, public QDeclarativeActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarativeParentChange) + + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) +public: + QDeclarativeParentChange(QObject *parent=0); + ~QDeclarativeParentChange(); + + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); + + QDeclarativeItem *parent() const; + void setParent(QDeclarativeItem *); + + virtual ActionList actions(); + + virtual void saveOriginals(); + virtual void execute(); + virtual bool isReversable(); + virtual void reverse(); + virtual QString typeName() const; + virtual bool override(QDeclarativeActionEvent*other); + virtual void rewind(); + virtual void saveCurrentValues(); +}; + +class QDeclarativeStateChangeScriptPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeStateChangeScript : public QDeclarativeStateOperation, public QDeclarativeActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarativeStateChangeScript) + + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + QDeclarativeStateChangeScript(QObject *parent=0); + ~QDeclarativeStateChangeScript(); + + virtual ActionList actions(); + + virtual QString typeName() const; + + QDeclarativeScriptString script() const; + void setScript(const QDeclarativeScriptString &); + + QString name() const; + void setName(const QString &); + + virtual void execute(); +}; + +class QDeclarativeAnchorChangesPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges) + + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QString reset READ reset WRITE setReset) + Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft) + Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight) + Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter) + Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop) + Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom) + Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter) + Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline) + +public: + QDeclarativeAnchorChanges(QObject *parent=0); + ~QDeclarativeAnchorChanges(); + + virtual ActionList actions(); + + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); + + QString reset() const; + void setReset(const QString &); + + QDeclarativeAnchorLine left() const; + void setLeft(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine right() const; + void setRight(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine horizontalCenter() const; + void setHorizontalCenter(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine top() const; + void setTop(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine bottom() const; + void setBottom(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine verticalCenter() const; + void setVerticalCenter(const QDeclarativeAnchorLine &edge); + + QDeclarativeAnchorLine baseline() const; + void setBaseline(const QDeclarativeAnchorLine &edge); + + virtual void execute(); + virtual bool isReversable(); + virtual void reverse(); + virtual QString typeName() const; + virtual bool override(QDeclarativeActionEvent*other); + virtual QList<QDeclarativeAction> extraActions(); + virtual bool changesBindings(); + virtual void saveOriginals(); + virtual void clearForwardBindings(); + virtual void clearReverseBindings(); + virtual void rewind(); + virtual void saveCurrentValues(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeParentChange) +QML_DECLARE_TYPE(QDeclarativeStateChangeScript) +QML_DECLARE_TYPE(QDeclarativeAnchorChanges) + +QT_END_HEADER + +#endif // QDECLARATIVESTATEOPERATIONS_H diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qdeclarativestyledtext.cpp index 1f31214..461de12 100644 --- a/src/declarative/util/qmlstyledtext.cpp +++ b/src/declarative/util/qdeclarativestyledtext.cpp @@ -45,10 +45,10 @@ #include <QTextLayout> #include <QDebug> #include <qmath.h> -#include "qmlstyledtext_p.h" +#include "qdeclarativestyledtext_p.h" /* - QmlStyledText supports few tags: + QDeclarativeStyledText supports few tags: <b></b> - bold <i></i> - italic @@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE -class QmlStyledTextPrivate +class QDeclarativeStyledTextPrivate { public: - QmlStyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {} + QDeclarativeStyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {} void parse(); bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format); @@ -91,31 +91,33 @@ public: static const QChar ampersand; }; -const QChar QmlStyledTextPrivate::lessThan(QLatin1Char('<')); -const QChar QmlStyledTextPrivate::greaterThan(QLatin1Char('>')); -const QChar QmlStyledTextPrivate::equals(QLatin1Char('=')); -const QChar QmlStyledTextPrivate::singleQuote(QLatin1Char('\'')); -const QChar QmlStyledTextPrivate::doubleQuote(QLatin1Char('\"')); -const QChar QmlStyledTextPrivate::slash(QLatin1Char('/')); -const QChar QmlStyledTextPrivate::ampersand(QLatin1Char('&')); +const QChar QDeclarativeStyledTextPrivate::lessThan(QLatin1Char('<')); +const QChar QDeclarativeStyledTextPrivate::greaterThan(QLatin1Char('>')); +const QChar QDeclarativeStyledTextPrivate::equals(QLatin1Char('=')); +const QChar QDeclarativeStyledTextPrivate::singleQuote(QLatin1Char('\'')); +const QChar QDeclarativeStyledTextPrivate::doubleQuote(QLatin1Char('\"')); +const QChar QDeclarativeStyledTextPrivate::slash(QLatin1Char('/')); +const QChar QDeclarativeStyledTextPrivate::ampersand(QLatin1Char('&')); -QmlStyledText::QmlStyledText(const QString &string, QTextLayout &layout) -: d(new QmlStyledTextPrivate(string, layout)) +QDeclarativeStyledText::QDeclarativeStyledText(const QString &string, QTextLayout &layout) +: d(new QDeclarativeStyledTextPrivate(string, layout)) { } -QmlStyledText::~QmlStyledText() +QDeclarativeStyledText::~QDeclarativeStyledText() { delete d; } -void QmlStyledText::parse(const QString &string, QTextLayout &layout) +void QDeclarativeStyledText::parse(const QString &string, QTextLayout &layout) { - QmlStyledText styledText(string, layout); + if (string.isEmpty()) + return; + QDeclarativeStyledText styledText(string, layout); styledText.d->parse(); } -void QmlStyledTextPrivate::parse() +void QDeclarativeStyledTextPrivate::parse() { QList<QTextLayout::FormatRange> ranges; QStack<QTextCharFormat> formatStack; @@ -142,8 +144,10 @@ void QmlStyledTextPrivate::parse() ++ch; if (*ch == slash) { ++ch; - if (parseCloseTag(ch, text)) - formatStack.pop(); + if (parseCloseTag(ch, text)) { + if (formatStack.count()) + formatStack.pop(); + } } else { QTextCharFormat format; if (formatStack.count()) @@ -164,7 +168,8 @@ void QmlStyledTextPrivate::parse() } else { ++textLength; } - ++ch; + if (!ch->isNull()) + ++ch; } if (textLength) drawText.append(QStringRef(&text, textStart, textLength)); @@ -180,7 +185,7 @@ void QmlStyledTextPrivate::parse() layout.setAdditionalFormats(ranges); } -bool QmlStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) +bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) { skipSpace(ch); @@ -191,20 +196,15 @@ bool QmlStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QSt QStringRef tag(&textIn, tagStart, tagLength); const QChar char0 = tag.at(0); if (char0 == QLatin1Char('b')) { - if (tagLength == 1) { + if (tagLength == 1) format.setFontWeight(QFont::Bold); - return true; - } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) { + else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) textOut.append(QChar(QChar::LineSeparator)); - return true; - } } else if (char0 == QLatin1Char('i')) { - if (tagLength == 1) { + if (tagLength == 1) format.setFontItalic(true); - return true; - } } - return false; + return true; } else if (ch->isSpace()) { // may have params. QStringRef tag(&textIn, tagStart, tagLength); @@ -221,7 +221,7 @@ bool QmlStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QSt return false; } -bool QmlStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn) +bool QDeclarativeStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn) { skipSpace(ch); @@ -252,7 +252,7 @@ bool QmlStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn return false; } -void QmlStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut) +void QDeclarativeStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut) { int entityStart = ch - textIn.constData(); int entityLength = 0; @@ -272,7 +272,7 @@ void QmlStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, } } -bool QmlStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) +bool QDeclarativeStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) { bool valid = false; QPair<QStringRef,QStringRef> attr; @@ -296,7 +296,7 @@ bool QmlStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString & return valid; } -QPair<QStringRef,QStringRef> QmlStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn) +QPair<QStringRef,QStringRef> QDeclarativeStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn) { skipSpace(ch); @@ -329,7 +329,7 @@ QPair<QStringRef,QStringRef> QmlStyledTextPrivate::parseAttribute(const QChar *& return QPair<QStringRef,QStringRef>(); } -QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn) +QStringRef QDeclarativeStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn) { int valStart = ch - textIn.constData(); int valLength = 0; diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qdeclarativestyledtext_p.h index 4698279..8d2c42d 100644 --- a/src/declarative/util/qmlstyledtext_p.h +++ b/src/declarative/util/qdeclarativestyledtext_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLSTYLEDTEXT_H -#define QMLSTYLEDTEXT_H +#ifndef QDECLARATIVESTYLEDTEXT_H +#define QDECLARATIVESTYLEDTEXT_H #include <QSizeF> @@ -49,18 +49,19 @@ QT_BEGIN_NAMESPACE class QPainter; class QPointF; class QString; -class QmlStyledTextPrivate; +class QDeclarativeStyledTextPrivate; +class QTextLayout; -class Q_DECLARATIVE_EXPORT QmlStyledText +class Q_DECLARATIVE_EXPORT QDeclarativeStyledText { public: static void parse(const QString &string, QTextLayout &layout); private: - QmlStyledText(const QString &string, QTextLayout &layout); - ~QmlStyledText(); + QDeclarativeStyledText(const QString &string, QTextLayout &layout); + ~QDeclarativeStyledText(); - QmlStyledTextPrivate *d; + QDeclarativeStyledTextPrivate *d; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp index cc4fb3e..1e00f22 100644 --- a/src/declarative/util/qmlsystempalette.cpp +++ b/src/declarative/util/qdeclarativesystempalette.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmlsystempalette_p.h" +#include "qdeclarativesystempalette_p.h" #include <QApplication> @@ -47,17 +47,17 @@ QT_BEGIN_NAMESPACE -class QmlSystemPalettePrivate : public QObjectPrivate +class QDeclarativeSystemPalettePrivate : public QObjectPrivate { public: QPalette palette; QPalette::ColorGroup group; }; -QML_DEFINE_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette) + /*! - \qmlclass SystemPalette QmlSystemPalette + \qmlclass SystemPalette QDeclarativeSystemPalette \ingroup group_utility \brief The SystemPalette item gives access to the Qt palettes. \sa QPalette @@ -76,16 +76,16 @@ QML_DEFINE_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette) } \endqml */ -QmlSystemPalette::QmlSystemPalette(QObject *parent) - : QObject(*(new QmlSystemPalettePrivate), parent) +QDeclarativeSystemPalette::QDeclarativeSystemPalette(QObject *parent) + : QObject(*(new QDeclarativeSystemPalettePrivate), parent) { - Q_D(QmlSystemPalette); + Q_D(QDeclarativeSystemPalette); d->palette = QApplication::palette(); d->group = QPalette::Active; qApp->installEventFilter(this); } -QmlSystemPalette::~QmlSystemPalette() +QDeclarativeSystemPalette::~QDeclarativeSystemPalette() { } @@ -95,9 +95,9 @@ QmlSystemPalette::~QmlSystemPalette() \sa QPalette::ColorRole */ -QColor QmlSystemPalette::window() const +QColor QDeclarativeSystemPalette::window() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Window); } @@ -107,9 +107,9 @@ QColor QmlSystemPalette::window() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::windowText() const +QColor QDeclarativeSystemPalette::windowText() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::WindowText); } @@ -119,9 +119,9 @@ QColor QmlSystemPalette::windowText() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::base() const +QColor QDeclarativeSystemPalette::base() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Base); } @@ -131,9 +131,9 @@ QColor QmlSystemPalette::base() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::text() const +QColor QDeclarativeSystemPalette::text() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Text); } @@ -143,9 +143,9 @@ QColor QmlSystemPalette::text() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::alternateBase() const +QColor QDeclarativeSystemPalette::alternateBase() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::AlternateBase); } @@ -155,9 +155,9 @@ QColor QmlSystemPalette::alternateBase() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::button() const +QColor QDeclarativeSystemPalette::button() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Button); } @@ -167,9 +167,9 @@ QColor QmlSystemPalette::button() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::buttonText() const +QColor QDeclarativeSystemPalette::buttonText() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::ButtonText); } @@ -179,9 +179,9 @@ QColor QmlSystemPalette::buttonText() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::light() const +QColor QDeclarativeSystemPalette::light() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Light); } @@ -191,9 +191,9 @@ QColor QmlSystemPalette::light() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::midlight() const +QColor QDeclarativeSystemPalette::midlight() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Midlight); } @@ -203,9 +203,9 @@ QColor QmlSystemPalette::midlight() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::dark() const +QColor QDeclarativeSystemPalette::dark() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Dark); } @@ -215,9 +215,9 @@ QColor QmlSystemPalette::dark() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::mid() const +QColor QDeclarativeSystemPalette::mid() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Mid); } @@ -227,9 +227,9 @@ QColor QmlSystemPalette::mid() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::shadow() const +QColor QDeclarativeSystemPalette::shadow() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Shadow); } @@ -239,9 +239,9 @@ QColor QmlSystemPalette::shadow() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::highlight() const +QColor QDeclarativeSystemPalette::highlight() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::Highlight); } @@ -251,34 +251,34 @@ QColor QmlSystemPalette::highlight() const \sa QPalette::ColorRole */ -QColor QmlSystemPalette::highlightedText() const +QColor QDeclarativeSystemPalette::highlightedText() const { - Q_D(const QmlSystemPalette); + Q_D(const QDeclarativeSystemPalette); return d->palette.color(d->group, QPalette::HighlightedText); } /*! - \qmlproperty QmlSystemPalette::ColorGroup SystemPalette::colorGroup + \qmlproperty QDeclarativeSystemPalette::ColorGroup SystemPalette::colorGroup The color group of the palette. It can be Active, Inactive or Disabled. Active is the default. \sa QPalette::ColorGroup */ -QmlSystemPalette::ColorGroup QmlSystemPalette::colorGroup() const +QDeclarativeSystemPalette::ColorGroup QDeclarativeSystemPalette::colorGroup() const { - Q_D(const QmlSystemPalette); - return (QmlSystemPalette::ColorGroup)d->group; + Q_D(const QDeclarativeSystemPalette); + return (QDeclarativeSystemPalette::ColorGroup)d->group; } -void QmlSystemPalette::setColorGroup(QmlSystemPalette::ColorGroup colorGroup) +void QDeclarativeSystemPalette::setColorGroup(QDeclarativeSystemPalette::ColorGroup colorGroup) { - Q_D(QmlSystemPalette); + Q_D(QDeclarativeSystemPalette); d->group = (QPalette::ColorGroup)colorGroup; emit paletteChanged(); } -bool QmlSystemPalette::eventFilter(QObject *watched, QEvent *event) +bool QDeclarativeSystemPalette::eventFilter(QObject *watched, QEvent *event) { if (watched == qApp) { if (event->type() == QEvent::ApplicationPaletteChange) { @@ -289,9 +289,9 @@ bool QmlSystemPalette::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); } -bool QmlSystemPalette::event(QEvent *event) +bool QDeclarativeSystemPalette::event(QEvent *event) { - Q_D(QmlSystemPalette); + Q_D(QDeclarativeSystemPalette); if (event->type() == QEvent::ApplicationPaletteChange) { d->palette = QApplication::palette(); emit paletteChanged(); diff --git a/src/declarative/util/qmlsystempalette_p.h b/src/declarative/util/qdeclarativesystempalette_p.h index e25bf7f..9fa6b08 100644 --- a/src/declarative/util/qmlsystempalette_p.h +++ b/src/declarative/util/qdeclarativesystempalette_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLSYSTEMPALETTE_H -#define QMLSYSTEMPALETTE_H +#ifndef QDECLARATIVESYSTEMPALETTE_H +#define QDECLARATIVESYSTEMPALETTE_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qobject.h> #include <QPalette> @@ -53,14 +53,14 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlSystemPalettePrivate; -class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject +class QDeclarativeSystemPalettePrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeSystemPalette : public QObject { Q_OBJECT Q_ENUMS(ColorGroup) - Q_DECLARE_PRIVATE(QmlSystemPalette) + Q_DECLARE_PRIVATE(QDeclarativeSystemPalette) - Q_PROPERTY(QmlSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) + Q_PROPERTY(QDeclarativeSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) @@ -77,8 +77,8 @@ class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) public: - QmlSystemPalette(QObject *parent=0); - ~QmlSystemPalette(); + QDeclarativeSystemPalette(QObject *parent=0); + ~QDeclarativeSystemPalette(); enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled }; @@ -101,8 +101,8 @@ public: QColor highlight() const; QColor highlightedText() const; - QmlSystemPalette::ColorGroup colorGroup() const; - void setColorGroup(QmlSystemPalette::ColorGroup); + QDeclarativeSystemPalette::ColorGroup colorGroup() const; + void setColorGroup(QDeclarativeSystemPalette::ColorGroup); Q_SIGNALS: void paletteChanged(); @@ -115,8 +115,8 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlSystemPalette) +QML_DECLARE_TYPE(QDeclarativeSystemPalette) QT_END_HEADER -#endif // QMLSYSTEMPALETTE_H +#endif // QDECLARATIVESYSTEMPALETTE_H diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qdeclarativetimeline.cpp index 5c5df40..8e133b6 100644 --- a/src/declarative/util/qmltimeline.cpp +++ b/src/declarative/util/qdeclarativetimeline.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmltimeline_p_p.h" +#include "qdeclarativetimeline_p_p.h" #include <QDebug> #include <QMutex> @@ -53,19 +53,19 @@ QT_BEGIN_NAMESPACE struct Update { - Update(QmlTimeLineValue *_g, qreal _v) + Update(QDeclarativeTimeLineValue *_g, qreal _v) : g(_g), v(_v) {} - Update(const QmlTimeLineCallback &_e) + Update(const QDeclarativeTimeLineCallback &_e) : g(0), v(0), e(_e) {} - QmlTimeLineValue *g; + QDeclarativeTimeLineValue *g; qreal v; - QmlTimeLineCallback e; + QDeclarativeTimeLineCallback e; }; -struct QmlTimeLinePrivate +struct QDeclarativeTimeLinePrivate { - QmlTimeLinePrivate(QmlTimeLine *); + QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *); struct Op { enum Type { @@ -79,7 +79,7 @@ struct QmlTimeLinePrivate }; Op() {} Op(Type t, int l, qreal v, qreal v2, int o, - const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve()) + const QDeclarativeTimeLineCallback &ev = QDeclarativeTimeLineCallback(), 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; - QmlTimeLineCallback event; + QDeclarativeTimeLineCallback event; QEasingCurve easing; }; struct TimeLine @@ -112,11 +112,11 @@ struct QmlTimeLinePrivate int length; int syncPoint; - typedef QHash<QmlTimeLineObject *, TimeLine> Ops; + typedef QHash<QDeclarativeTimeLineObject *, TimeLine> Ops; Ops ops; - QmlTimeLine *q; + QDeclarativeTimeLine *q; - void add(QmlTimeLineObject &, const Op &); + void add(QDeclarativeTimeLineObject &, const Op &); qreal value(const Op &op, int time, qreal base, bool *) const; int advance(int); @@ -126,20 +126,20 @@ struct QmlTimeLinePrivate int order; - QmlTimeLine::SyncMode syncMode; + QDeclarativeTimeLine::SyncMode syncMode; int syncAdj; QList<QPair<int, Update> > *updateQueue; }; -QmlTimeLinePrivate::QmlTimeLinePrivate(QmlTimeLine *parent) -: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QmlTimeLine::LocalSync), syncAdj(0), updateQueue(0) +QDeclarativeTimeLinePrivate::QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *parent) +: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarativeTimeLine::LocalSync), syncAdj(0), updateQueue(0) { } -void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o) +void QDeclarativeTimeLinePrivate::add(QDeclarativeTimeLineObject &g, const Op &o) { if (g._t && g._t != q) { - qWarning() << "QmlTimeLine: Cannot modify a QmlTimeLineValue owned by" + qWarning() << "QDeclarativeTimeLine: Cannot modify a QDeclarativeTimeLineValue owned by" << "another timeline."; return; } @@ -169,14 +169,14 @@ void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o) prevTime = 0; clockRunning = true; - if (syncMode == QmlTimeLine::LocalSync) { + if (syncMode == QDeclarativeTimeLine::LocalSync) { syncAdj = -1; } else { syncAdj = 0; } q->start(); /* q->tick(0); - if (syncMode == QmlTimeLine::LocalSync) { + if (syncMode == QDeclarativeTimeLine::LocalSync) { syncAdj = -1; } else { syncAdj = 0; @@ -185,7 +185,7 @@ void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o) } } -qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const +qreal QDeclarativeTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const { Q_ASSERT(time >= 0); Q_ASSERT(time <= op.length); @@ -254,28 +254,28 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change /*! \internal - \class QmlTimeLine + \class QDeclarativeTimeLine \ingroup group_animation - \brief The QmlTimeLine class provides a timeline for controlling animations. + \brief The QDeclarativeTimeLine class provides a timeline for controlling animations. - QmlTimeLine is similar to QTimeLine except: + QDeclarativeTimeLine is similar to QTimeLine except: \list - \i It updates QmlTimeLineValue instances directly, rather than maintaining a single + \i It updates QDeclarativeTimeLineValue instances directly, rather than maintaining a single current value. For example, the following animates a simple value over 200 milliseconds: \code - QmlTimeLineValue v(<starting value>); - QmlTimeLine tl; + QDeclarativeTimeLineValue v(<starting value>); + QDeclarativeTimeLine tl; tl.move(v, 100., 200); tl.start() \endcode If your program needs to know when values are changed, it can either - connect to the QmlTimeLine's updated() signal, or inherit from QmlTimeLineValue - and reimplement the QmlTimeLineValue::setValue() method. + connect to the QDeclarativeTimeLine's updated() signal, or inherit from QDeclarativeTimeLineValue + and reimplement the QDeclarativeTimeLineValue::setValue() method. - \i Supports multiple QmlTimeLineValue, arbitrary start and end values and allows + \i Supports multiple QDeclarativeTimeLineValue, arbitrary start and end values and allows animations to be strung together for more complex effects. For example, the following animation moves the x and y coordinates of @@ -284,10 +284,10 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change milliseconds: \code - QmlTimeLineValue x(<starting value>); - QmlTimeLineValue y(<starting value>); + QDeclarativeTimeLineValue x(<starting value>); + QDeclarativeTimeLineValue y(<starting value>); - QmlTimeLine tl; + QDeclarativeTimeLine tl; tl.start(); tl.move(x, 100., 50); @@ -295,12 +295,12 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change tl.move(y, 200., 50); \endcode - \i All QmlTimeLine instances share a single, synchronized clock. + \i All QDeclarativeTimeLine instances share a single, synchronized clock. Actions scheduled within the same event loop tick are scheduled synchronously against each other, regardless of the wall time between the scheduling. Synchronized scheduling applies both to within the same - QmlTimeLine and across separate QmlTimeLine's within the same process. + QDeclarativeTimeLine and across separate QDeclarativeTimeLine's within the same process. \endlist @@ -309,21 +309,21 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change /*! - Construct a new QmlTimeLine with the specified \a parent. + Construct a new QDeclarativeTimeLine with the specified \a parent. */ -QmlTimeLine::QmlTimeLine(QObject *parent) +QDeclarativeTimeLine::QDeclarativeTimeLine(QObject *parent) : QAbstractAnimation(parent) { - d = new QmlTimeLinePrivate(this); + d = new QDeclarativeTimeLinePrivate(this); } /*! Destroys the time line. Any inprogress animations are canceled, but not completed. */ -QmlTimeLine::~QmlTimeLine() +QDeclarativeTimeLine::~QDeclarativeTimeLine() { - for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) iter.key()->_t = 0; @@ -332,13 +332,13 @@ QmlTimeLine::~QmlTimeLine() } /*! - \enum QmlTimeLine::SyncMode + \enum QDeclarativeTimeLine::SyncMode */ /*! Return the timeline's synchronization mode. */ -QmlTimeLine::SyncMode QmlTimeLine::syncMode() const +QDeclarativeTimeLine::SyncMode QDeclarativeTimeLine::syncMode() const { return d->syncMode; } @@ -346,7 +346,7 @@ QmlTimeLine::SyncMode QmlTimeLine::syncMode() const /*! Set the timeline's synchronization mode to \a syncMode. */ -void QmlTimeLine::setSyncMode(SyncMode syncMode) +void QDeclarativeTimeLine::setSyncMode(SyncMode syncMode) { d->syncMode = syncMode; } @@ -354,45 +354,45 @@ void QmlTimeLine::setSyncMode(SyncMode syncMode) /*! Pause \a obj for \a time milliseconds. */ -void QmlTimeLine::pause(QmlTimeLineObject &obj, int time) +void QDeclarativeTimeLine::pause(QDeclarativeTimeLineObject &obj, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Pause, time, 0., 0., d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Pause, time, 0., 0., d->order++); d->add(obj, op); } /*! Execute the \a event. */ -void QmlTimeLine::callback(const QmlTimeLineCallback &callback) +void QDeclarativeTimeLine::callback(const QDeclarativeTimeLineCallback &callback) { - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback); d->add(*callback.callbackObject(), op); } /*! Set the \a value of \a timeLineValue. */ -void QmlTimeLine::set(QmlTimeLineValue &timeLineValue, qreal value) +void QDeclarativeTimeLine::set(QDeclarativeTimeLineValue &timeLineValue, qreal value) { - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Set, 0, value, 0., d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Set, 0, value, 0., d->order++); d->add(timeLineValue, op); } /*! Decelerate \a timeLineValue from the starting \a velocity to zero at the given \a acceleration rate. Although the \a acceleration is technically - a deceleration, it should always be positive. The QmlTimeLine will ensure + a deceleration, it should always be positive. The QDeclarativeTimeLine will ensure that the deceleration is in the opposite direction to the initial velocity. */ -int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration) +int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration) { if ((velocity > 0.0f) == (acceleration > 0.0f)) acceleration = acceleration * -1.0f; int time = static_cast<int>(-1000 * velocity / acceleration); - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); d->add(timeLineValue, op); return time; @@ -404,11 +404,11 @@ int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal ac Decelerate \a timeLineValue from the starting \a velocity to zero at the given \a acceleration rate over a maximum distance of maxDistance. - If necessary, QmlTimeLine will reduce the acceleration to ensure that the + If necessary, QDeclarativeTimeLine will reduce the acceleration to ensure that the entire operation does not require a move of more than \a maxDistance. \a maxDistance should always be positive. */ -int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) +int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) { Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f); @@ -421,7 +421,7 @@ int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal ac int time = static_cast<int>(-1000 * velocity / acceleration); - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); d->add(timeLineValue, op); return time; @@ -429,12 +429,12 @@ int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal ac /*! Decelerate \a timeLineValue from the starting \a velocity to zero over the given - \a distance. This is like accel(), but the QmlTimeLine calculates the exact + \a distance. This is like accel(), but the QDeclarativeTimeLine calculates the exact deceleration to use. \a distance should be positive. */ -int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, qreal distance) +int QDeclarativeTimeLine::accelDistance(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal distance) { if (distance == 0.0f || velocity == 0.0f) return -1; @@ -442,7 +442,7 @@ int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, int time = static_cast<int>(1000 * (2.0f * distance) / velocity); - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++); d->add(timeLineValue, op); return time; @@ -452,10 +452,10 @@ int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, Linearly change the \a timeLineValue from its current value to the given \a destination value over \a time milliseconds. */ -void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int time) +void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++); d->add(timeLineValue, op); } @@ -463,10 +463,10 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int t Change the \a timeLineValue from its current value to the given \a destination value over \a time milliseconds using the \a easing curve. */ -void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time) +void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing); d->add(timeLineValue, op); } @@ -474,10 +474,10 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const Linearly change the \a timeLineValue from its current value by the \a change amount over \a time milliseconds. */ -void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time) +void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++); d->add(timeLineValue, op); } @@ -485,29 +485,29 @@ void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time Change the \a timeLineValue from its current value by the \a change amount over \a time milliseconds using the \a easing curve. */ -void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time) +void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing); + QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing); d->add(timeLineValue, op); } /*! Cancel (but don't complete) all scheduled actions for \a timeLineValue. */ -void QmlTimeLine::reset(QmlTimeLineValue &timeLineValue) +void QDeclarativeTimeLine::reset(QDeclarativeTimeLineValue &timeLineValue) { if (!timeLineValue._t) return; if (timeLineValue._t != this) { - qWarning() << "QmlTimeLine: Cannot reset a QmlTimeLineValue owned by another timeline."; + qWarning() << "QDeclarativeTimeLine: Cannot reset a QDeclarativeTimeLineValue owned by another timeline."; return; } remove(&timeLineValue); timeLineValue._t = 0; } -int QmlTimeLine::duration() const +int QDeclarativeTimeLine::duration() const { return -1; } @@ -520,12 +520,12 @@ int QmlTimeLine::duration() const all the currently scheduled actions on \a syncTo are complete. In psuedo-code this is equivalent to: \code - QmlTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue))) + QDeclarativeTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue))) \endcode */ -void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo) +void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue, QDeclarativeTimeLineValue &syncTo) { - QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo); + QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo); if (iter == d->ops.end()) return; int length = iter->length; @@ -545,12 +545,12 @@ void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo In psuedo-code, this is equivalent to: \code - QmlTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue)) + QDeclarativeTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue)) \endcode */ -void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue) +void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue) { - QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue); + QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue); if (iter == d->ops.end()) { pause(timeLineValue, d->length); } else { @@ -567,7 +567,7 @@ void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue) value1->setValue(0.); value2->setValue(0.); value3->setValue(0.); - QmlTimeLine tl; + QDeclarativeTimeLine tl; ... tl.move(value1, 10, 200); tl.move(value2, 10, 100); @@ -586,9 +586,9 @@ void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue) \endtable */ -/*void QmlTimeLine::sync() +/*void QDeclarativeTimeLine::sync() { - for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) pause(*iter.key(), d->length - iter->length); @@ -600,7 +600,7 @@ void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue) Temporary hack. */ -void QmlTimeLine::setSyncPoint(int sp) +void QDeclarativeTimeLine::setSyncPoint(int sp) { d->syncPoint = sp; } @@ -610,16 +610,16 @@ void QmlTimeLine::setSyncPoint(int sp) Temporary hack. */ -int QmlTimeLine::syncPoint() const +int QDeclarativeTimeLine::syncPoint() const { return d->syncPoint; } /*! Returns true if the timeline is active. An active timeline is one where - QmlTimeLineValue actions are still pending. + QDeclarativeTimeLineValue actions are still pending. */ -bool QmlTimeLine::isActive() const +bool QDeclarativeTimeLine::isActive() const { return !d->ops.isEmpty(); } @@ -627,8 +627,8 @@ bool QmlTimeLine::isActive() const /*! Completes the timeline. All queued actions are played to completion, and then discarded. For example, \code - QmlTimeLineValue v(0.); - QmlTimeLine tl; + QDeclarativeTimeLineValue v(0.); + QDeclarativeTimeLine tl; tl.move(v, 100., 1000.); // 500 ms passes // v.value() == 50. @@ -636,16 +636,16 @@ bool QmlTimeLine::isActive() const // v.value() == 100. \endcode */ -void QmlTimeLine::complete() +void QDeclarativeTimeLine::complete() { d->advance(d->length); } /*! - Resets the timeline. All queued actions are discarded and QmlTimeLineValue's retain their current value. For example, + Resets the timeline. All queued actions are discarded and QDeclarativeTimeLineValue's retain their current value. For example, \code - QmlTimeLineValue v(0.); - QmlTimeLine tl; + QDeclarativeTimeLineValue v(0.); + QDeclarativeTimeLine tl; tl.move(v, 100., 1000.); // 500 ms passes // v.value() == 50. @@ -653,9 +653,9 @@ void QmlTimeLine::complete() // v.value() == 50. \endcode */ -void QmlTimeLine::clear() +void QDeclarativeTimeLine::clear() { - for (QmlTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) + for (QDeclarativeTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) iter.key()->_t = 0; d->ops.clear(); d->length = 0; @@ -663,19 +663,19 @@ void QmlTimeLine::clear() //XXX need stop here? } -int QmlTimeLine::time() const +int QDeclarativeTimeLine::time() const { return d->prevTime; } /*! - \fn void QmlTimeLine::updated() + \fn void QDeclarativeTimeLine::updated() - Emitted each time the timeline modifies QmlTimeLineValues. Even if multiple - QmlTimeLineValues are changed, this signal is only emitted once for each clock tick. + Emitted each time the timeline modifies QDeclarativeTimeLineValues. Even if multiple + QDeclarativeTimeLineValues are changed, this signal is only emitted once for each clock tick. */ -void QmlTimeLine::updateCurrentTime(int v) +void QDeclarativeTimeLine::updateCurrentTime(int v) { if (d->syncAdj == -1) d->syncAdj = v; @@ -717,7 +717,7 @@ bool operator<(const QPair<int, Update> &lhs, return lhs.first < rhs.first; } -int QmlTimeLinePrivate::advance(int t) +int QDeclarativeTimeLinePrivate::advance(int t) { int pauseTime = -1; @@ -744,7 +744,7 @@ int QmlTimeLinePrivate::advance(int t) QList<QPair<int, Update> > updates; for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) { - QmlTimeLineValue *v = static_cast<QmlTimeLineValue *>(iter.key()); + QDeclarativeTimeLineValue *v = static_cast<QDeclarativeTimeLineValue *>(iter.key()); TimeLine &tl = *iter; Q_ASSERT(!tl.ops.isEmpty()); @@ -817,9 +817,9 @@ int QmlTimeLinePrivate::advance(int t) return pauseTime; } -void QmlTimeLine::remove(QmlTimeLineObject *v) +void QDeclarativeTimeLine::remove(QDeclarativeTimeLineObject *v) { - QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(v); + QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(v); Q_ASSERT(iter != d->ops.end()); int len = iter->length; @@ -827,7 +827,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v) if (len == d->length) { // We need to recalculate the length d->length = 0; - for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) { @@ -844,7 +844,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v) d->prevTime = 0; d->clockRunning = true; - if (d->syncMode == QmlTimeLine::LocalSync) { + if (d->syncMode == QDeclarativeTimeLine::LocalSync) { d->syncAdj = -1; } else { d->syncAdj = 0; @@ -867,43 +867,43 @@ void QmlTimeLine::remove(QmlTimeLineObject *v) /*! \internal - \class QmlTimeLineValue + \class QDeclarativeTimeLineValue \ingroup group_animation - \brief The QmlTimeLineValue class provides a value that can be modified by QmlTimeLine. + \brief The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine. */ /*! - \fn QmlTimeLineValue::QmlTimeLineValue(qreal value = 0) + \fn QDeclarativeTimeLineValue::QDeclarativeTimeLineValue(qreal value = 0) - Construct a new QmlTimeLineValue with an initial \a value. + Construct a new QDeclarativeTimeLineValue with an initial \a value. */ /*! - \fn qreal QmlTimeLineValue::value() const + \fn qreal QDeclarativeTimeLineValue::value() const Return the current value. */ /*! - \fn void QmlTimeLineValue::setValue(qreal value) + \fn void QDeclarativeTimeLineValue::setValue(qreal value) Set the current \a value. */ /*! - \fn QmlTimeLine *QmlTimeLineValue::timeLine() const + \fn QDeclarativeTimeLine *QDeclarativeTimeLineValue::timeLine() const - If a QmlTimeLine is operating on this value, return a pointer to it, + If a QDeclarativeTimeLine is operating on this value, return a pointer to it, otherwise return null. */ -QmlTimeLineObject::QmlTimeLineObject() +QDeclarativeTimeLineObject::QDeclarativeTimeLineObject() : _t(0) { } -QmlTimeLineObject::~QmlTimeLineObject() +QDeclarativeTimeLineObject::~QDeclarativeTimeLineObject() { if (_t) { _t->remove(this); @@ -911,22 +911,22 @@ QmlTimeLineObject::~QmlTimeLineObject() } } -QmlTimeLineCallback::QmlTimeLineCallback() +QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback() : d0(0), d1(0), d2(0) { } -QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d) +QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback f, void *d) : d0(f), d1(d), d2(b) { } -QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o) +QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o) : d0(o.d0), d1(o.d1), d2(o.d2) { } -QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o) +QDeclarativeTimeLineCallback &QDeclarativeTimeLineCallback::operator=(const QDeclarativeTimeLineCallback &o) { d0 = o.d0; d1 = o.d1; @@ -934,7 +934,7 @@ QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o return *this; } -QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const +QDeclarativeTimeLineObject *QDeclarativeTimeLineCallback::callbackObject() const { return d2; } diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h index 076355d..c08c07c 100644 --- a/src/declarative/util/qmltimeline_p_p.h +++ b/src/declarative/util/qdeclarativetimeline_p_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLTIMELINE_H -#define QMLTIMELINE_H +#ifndef QDECLARATIVETIMELINE_H +#define QDECLARATIVETIMELINE_H // // W A R N I N G @@ -59,42 +59,42 @@ QT_BEGIN_NAMESPACE class QEasingCurve; -class QmlTimeLineValue; -class QmlTimeLineCallback; -struct QmlTimeLinePrivate; -class QmlTimeLineObject; -class QmlTimeLine : public QAbstractAnimation +class QDeclarativeTimeLineValue; +class QDeclarativeTimeLineCallback; +struct QDeclarativeTimeLinePrivate; +class QDeclarativeTimeLineObject; +class QDeclarativeTimeLine : public QAbstractAnimation { Q_OBJECT public: - QmlTimeLine(QObject *parent = 0); - ~QmlTimeLine(); + QDeclarativeTimeLine(QObject *parent = 0); + ~QDeclarativeTimeLine(); enum SyncMode { LocalSync, GlobalSync }; SyncMode syncMode() const; void setSyncMode(SyncMode); - void pause(QmlTimeLineObject &, int); - void callback(const QmlTimeLineCallback &); - void set(QmlTimeLineValue &, qreal); + void pause(QDeclarativeTimeLineObject &, int); + void callback(const QDeclarativeTimeLineCallback &); + void set(QDeclarativeTimeLineValue &, qreal); - int accel(QmlTimeLineValue &, qreal velocity, qreal accel); - int accel(QmlTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance); - int accelDistance(QmlTimeLineValue &, qreal velocity, qreal distance); + int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel); + int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance); + int accelDistance(QDeclarativeTimeLineValue &, qreal velocity, qreal distance); - void move(QmlTimeLineValue &, qreal destination, int time = 500); - void move(QmlTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500); - void moveBy(QmlTimeLineValue &, qreal change, int time = 500); - void moveBy(QmlTimeLineValue &, qreal change, const QEasingCurve &, int time = 500); + void move(QDeclarativeTimeLineValue &, qreal destination, int time = 500); + void move(QDeclarativeTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500); + void moveBy(QDeclarativeTimeLineValue &, qreal change, int time = 500); + void moveBy(QDeclarativeTimeLineValue &, qreal change, const QEasingCurve &, int time = 500); void sync(); void setSyncPoint(int); int syncPoint() const; - void sync(QmlTimeLineValue &); - void sync(QmlTimeLineValue &, QmlTimeLineValue &); + void sync(QDeclarativeTimeLineValue &); + void sync(QDeclarativeTimeLineValue &, QDeclarativeTimeLineValue &); - void reset(QmlTimeLineValue &); + void reset(QDeclarativeTimeLineValue &); void complete(); void clear(); @@ -111,80 +111,80 @@ protected: virtual void updateCurrentTime(int); private: - void remove(QmlTimeLineObject *); - friend class QmlTimeLineObject; - friend struct QmlTimeLinePrivate; - QmlTimeLinePrivate *d; + void remove(QDeclarativeTimeLineObject *); + friend class QDeclarativeTimeLineObject; + friend struct QDeclarativeTimeLinePrivate; + QDeclarativeTimeLinePrivate *d; }; -class QmlTimeLineObject +class QDeclarativeTimeLineObject { public: - QmlTimeLineObject(); - virtual ~QmlTimeLineObject(); + QDeclarativeTimeLineObject(); + virtual ~QDeclarativeTimeLineObject(); protected: - friend class QmlTimeLine; - friend struct QmlTimeLinePrivate; - QmlTimeLine *_t; + friend class QDeclarativeTimeLine; + friend struct QDeclarativeTimeLinePrivate; + QDeclarativeTimeLine *_t; }; -class QmlTimeLineValue : public QmlTimeLineObject +class QDeclarativeTimeLineValue : public QDeclarativeTimeLineObject { public: - QmlTimeLineValue(qreal v = 0.) : _v(v) {} + QDeclarativeTimeLineValue(qreal v = 0.) : _v(v) {} virtual qreal value() const { return _v; } virtual void setValue(qreal v) { _v = v; } - QmlTimeLine *timeLine() const { return _t; } + QDeclarativeTimeLine *timeLine() const { return _t; } operator qreal() const { return _v; } - QmlTimeLineValue &operator=(qreal v) { setValue(v); return *this; } + QDeclarativeTimeLineValue &operator=(qreal v) { setValue(v); return *this; } private: - friend class QmlTimeLine; - friend struct QmlTimeLinePrivate; + friend class QDeclarativeTimeLine; + friend struct QDeclarativeTimeLinePrivate; qreal _v; }; -class QmlTimeLineCallback +class QDeclarativeTimeLineCallback { public: typedef void (*Callback)(void *); - QmlTimeLineCallback(); - QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0); - QmlTimeLineCallback(const QmlTimeLineCallback &o); + QDeclarativeTimeLineCallback(); + QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback, void * = 0); + QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o); - QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o); - QmlTimeLineObject *callbackObject() const; + QDeclarativeTimeLineCallback &operator=(const QDeclarativeTimeLineCallback &o); + QDeclarativeTimeLineObject *callbackObject() const; private: - friend class QmlTimeLinePrivate; + friend class QDeclarativeTimeLinePrivate; Callback d0; void *d1; - QmlTimeLineObject *d2; + QDeclarativeTimeLineObject *d2; }; template<class T> -class QmlTimeLineValueProxy : public QmlTimeLineValue +class QDeclarativeTimeLineValueProxy : public QDeclarativeTimeLineValue { public: - QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) - : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) + QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) + : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) { Q_ASSERT(_class); } - QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) - : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) + QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) + : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) { Q_ASSERT(_class); } virtual void setValue(qreal v) { - QmlTimeLineValue::setValue(v); + QDeclarativeTimeLineValue::setValue(v); if (_setFunctionReal) (_class->*_setFunctionReal)(v); else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v); } diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qdeclarativetimer.cpp index d3a1a7c..89c461b 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qdeclarativetimer.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmltimer_p.h" +#include "qdeclarativetimer_p.h" #include <QtCore/qcoreapplication.h> #include <QtCore/qpauseanimation.h> @@ -49,13 +49,13 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Timer,QmlTimer) -class QmlTimerPrivate : public QObjectPrivate + +class QDeclarativeTimerPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlTimer) + Q_DECLARE_PUBLIC(QDeclarativeTimer) public: - QmlTimerPrivate() + QDeclarativeTimerPrivate() : interval(1000), running(false), repeating(false), triggeredOnStart(false) , classBegun(false), componentComplete(false), firstTick(true) {} int interval; @@ -69,7 +69,7 @@ public: }; /*! - \qmlclass Timer QmlTimer + \qmlclass Timer QDeclarativeTimer \brief The Timer item triggers a handler at a specified interval. A timer can be used to trigger an action either once, or repeatedly @@ -88,8 +88,8 @@ public: } \endqml - QmlTimer is synchronized with the animation timer. Since the animation - timer is usually set to 60fps, the resolution of QmlTimer will be + QDeclarativeTimer is synchronized with the animation timer. Since the animation + timer is usually set to 60fps, the resolution of QDeclarativeTimer will be at best 16ms. If the Timer is running and one of its properties is changed, the @@ -99,10 +99,10 @@ public: 1000ms later. */ -QmlTimer::QmlTimer(QObject *parent) - : QObject(*(new QmlTimerPrivate), parent) +QDeclarativeTimer::QDeclarativeTimer(QObject *parent) + : QObject(*(new QDeclarativeTimerPrivate), parent) { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); connect(&d->pause, SIGNAL(finished()), this, SLOT(finished())); d->pause.setLoopCount(1); @@ -116,18 +116,18 @@ QmlTimer::QmlTimer(QObject *parent) The default interval is 1000 milliseconds. */ -void QmlTimer::setInterval(int interval) +void QDeclarativeTimer::setInterval(int interval) { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (interval != d->interval) { d->interval = interval; update(); } } -int QmlTimer::interval() const +int QDeclarativeTimer::interval() const { - Q_D(const QmlTimer); + Q_D(const QDeclarativeTimer); return d->interval; } @@ -142,15 +142,15 @@ int QmlTimer::interval() const \sa repeat */ -bool QmlTimer::isRunning() const +bool QDeclarativeTimer::isRunning() const { - Q_D(const QmlTimer); + Q_D(const QDeclarativeTimer); return d->running; } -void QmlTimer::setRunning(bool running) +void QDeclarativeTimer::setRunning(bool running) { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (d->running != running) { d->running = running; d->firstTick = true; @@ -170,15 +170,15 @@ void QmlTimer::setRunning(bool running) \sa running */ -bool QmlTimer::isRepeating() const +bool QDeclarativeTimer::isRepeating() const { - Q_D(const QmlTimer); + Q_D(const QDeclarativeTimer); return d->repeating; } -void QmlTimer::setRepeating(bool repeating) +void QDeclarativeTimer::setRepeating(bool repeating) { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (repeating != d->repeating) { d->repeating = repeating; update(); @@ -202,15 +202,15 @@ void QmlTimer::setRepeating(bool repeating) \sa running */ -bool QmlTimer::triggeredOnStart() const +bool QDeclarativeTimer::triggeredOnStart() const { - Q_D(const QmlTimer); + Q_D(const QDeclarativeTimer); return d->triggeredOnStart; } -void QmlTimer::setTriggeredOnStart(bool triggeredOnStart) +void QDeclarativeTimer::setTriggeredOnStart(bool triggeredOnStart) { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (d->triggeredOnStart != triggeredOnStart) { d->triggeredOnStart = triggeredOnStart; update(); @@ -224,7 +224,7 @@ void QmlTimer::setTriggeredOnStart(bool triggeredOnStart) If the timer is already running, calling this method has no effect. The \c running property will be true following a call to \c start(). */ -void QmlTimer::start() +void QDeclarativeTimer::start() { setRunning(true); } @@ -236,7 +236,7 @@ void QmlTimer::start() If the timer is not running, calling this method has no effect. The \c running property will be false following a call to \c stop(). */ -void QmlTimer::stop() +void QDeclarativeTimer::stop() { setRunning(false); } @@ -249,15 +249,15 @@ void QmlTimer::stop() stopped, reset to initial state and started. The \c running property will be true following a call to \c restart(). */ -void QmlTimer::restart() +void QDeclarativeTimer::restart() { setRunning(false); setRunning(true); } -void QmlTimer::update() +void QDeclarativeTimer::update() { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (d->classBegun && !d->componentComplete) return; d->pause.stop(); @@ -273,15 +273,15 @@ void QmlTimer::update() } } -void QmlTimer::classBegin() +void QDeclarativeTimer::classBegin() { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); d->classBegun = true; } -void QmlTimer::componentComplete() +void QDeclarativeTimer::componentComplete() { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); d->componentComplete = true; update(); } @@ -291,17 +291,17 @@ void QmlTimer::componentComplete() This handler is called when the Timer is triggered. */ -void QmlTimer::ticked() +void QDeclarativeTimer::ticked() { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick))) emit triggered(); d->firstTick = false; } -void QmlTimer::finished() +void QDeclarativeTimer::finished() { - Q_D(QmlTimer); + Q_D(QDeclarativeTimer); if (d->repeating || !d->running) return; emit triggered(); diff --git a/src/declarative/util/qmltimer_p.h b/src/declarative/util/qdeclarativetimer_p.h index d1c5ee5..e063657 100644 --- a/src/declarative/util/qmltimer_p.h +++ b/src/declarative/util/qdeclarativetimer_p.h @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMLTIMER_H -#define QMLTIMER_H +#ifndef QDECLARATIVETIMER_H +#define QDECLARATIVETIMER_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qobject.h> #include <QtCore/qabstractanimation.h> @@ -53,19 +53,19 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlTimerPrivate; -class Q_DECLARATIVE_EXPORT QmlTimer : public QObject, public QmlParserStatus +class QDeclarativeTimerPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_DECLARE_PRIVATE(QmlTimer) - Q_INTERFACES(QmlParserStatus) + Q_DECLARE_PRIVATE(QDeclarativeTimer) + Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(int interval READ interval WRITE setInterval) Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating) Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart) public: - QmlTimer(QObject *parent=0); + QDeclarativeTimer(QObject *parent=0); void setInterval(int interval); int interval() const; @@ -102,7 +102,7 @@ private Q_SLOTS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlTimer) +QML_DECLARE_TYPE(QDeclarativeTimer) QT_END_HEADER diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index e2ce417..ac07b10 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -39,20 +39,20 @@ ** ****************************************************************************/ -#include "qmlstate_p.h" -#include "qmlstategroup_p.h" -#include "qmlstate_p_p.h" -#include "qmlstateoperations_p.h" -#include "qmlanimation_p.h" -#include "qmlanimation_p_p.h" -#include "qmltransitionmanager_p_p.h" +#include "qdeclarativestate_p.h" +#include "qdeclarativestategroup_p.h" +#include "qdeclarativestate_p_p.h" +#include "qdeclarativestateoperations_p.h" +#include "qdeclarativeanimation_p.h" +#include "qdeclarativeanimation_p_p.h" +#include "qdeclarativetransitionmanager_p_p.h" #include <QParallelAnimationGroup> QT_BEGIN_NAMESPACE /*! - \qmlclass Transition QmlTransition + \qmlclass Transition QDeclarativeTransition \since 4.7 \brief The Transition element defines animated transitions that occur on state changes. @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE /*! \internal - \class QmlTransition - \brief The QmlTransition class allows you to define animated transitions that occur on state changes. + \class QDeclarativeTransition + \brief The QDeclarativeTransition class allows you to define animated transitions that occur on state changes. \ingroup group_states */ @@ -74,16 +74,16 @@ class ParallelAnimationWrapper : public QParallelAnimationGroup Q_OBJECT public: ParallelAnimationWrapper(QObject *parent = 0) : QParallelAnimationGroup(parent) {} - QmlTransitionPrivate *trans; + QDeclarativeTransitionPrivate *trans; protected: virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); }; -class QmlTransitionPrivate : public QObjectPrivate +class QDeclarativeTransitionPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlTransition) + Q_DECLARE_PUBLIC(QDeclarativeTransition) public: - QmlTransitionPrivate() + QDeclarativeTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*")), reversed(false), reversible(false), endState(0) { @@ -95,19 +95,19 @@ public: bool reversed; bool reversible; ParallelAnimationWrapper group; - QmlTransitionManager *endState; + QDeclarativeTransitionManager *endState; void complete() { endState->complete(); } - static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a); - QList<QmlAbstractAnimation *> animations; + static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a); + QList<QDeclarativeAbstractAnimation *> animations; }; -void QmlTransitionPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a) +void QDeclarativeTransitionPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a) { - QmlTransition *q = static_cast<QmlTransition *>(list->object); + QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object); q->d_func()->animations.append(a); q->d_func()->group.addAnimation(a->qtAnimation()); a->setDisableUserControl(); @@ -125,43 +125,43 @@ void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, Q } -QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition) -QmlTransition::QmlTransition(QObject *parent) - : QObject(*(new QmlTransitionPrivate), parent) + +QDeclarativeTransition::QDeclarativeTransition(QObject *parent) + : QObject(*(new QDeclarativeTransitionPrivate), parent) { } -QmlTransition::~QmlTransition() +QDeclarativeTransition::~QDeclarativeTransition() { } -void QmlTransition::stop() +void QDeclarativeTransition::stop() { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); d->group.stop(); } -void QmlTransition::setReversed(bool r) +void QDeclarativeTransition::setReversed(bool r) { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); d->reversed = r; } -void QmlTransition::prepare(QmlStateOperation::ActionList &actions, - QList<QmlMetaProperty> &after, - QmlTransitionManager *endState) +void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &actions, + QList<QDeclarativeProperty> &after, + QDeclarativeTransitionManager *endState) { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); qmlExecuteDeferred(this); if (d->reversed) { for (int ii = d->animations.count() - 1; ii >= 0; --ii) { - d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Backward); + d->animations.at(ii)->transition(actions, after, QDeclarativeAbstractAnimation::Backward); } } else { for (int ii = 0; ii < d->animations.count(); ++ii) { - d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward); + d->animations.at(ii)->transition(actions, after, QDeclarativeAbstractAnimation::Forward); } } @@ -186,15 +186,15 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } \endcode */ -QString QmlTransition::fromState() const +QString QDeclarativeTransition::fromState() const { - Q_D(const QmlTransition); + Q_D(const QDeclarativeTransition); return d->fromState; } -void QmlTransition::setFromState(const QString &f) +void QDeclarativeTransition::setFromState(const QString &f) { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); d->fromState = f; } @@ -204,27 +204,27 @@ void QmlTransition::setFromState(const QString &f) The default value is false. */ -bool QmlTransition::reversible() const +bool QDeclarativeTransition::reversible() const { - Q_D(const QmlTransition); + Q_D(const QDeclarativeTransition); return d->reversible; } -void QmlTransition::setReversible(bool r) +void QDeclarativeTransition::setReversible(bool r) { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); d->reversible = r; } -QString QmlTransition::toState() const +QString QDeclarativeTransition::toState() const { - Q_D(const QmlTransition); + Q_D(const QDeclarativeTransition); return d->toState; } -void QmlTransition::setToState(const QString &t) +void QDeclarativeTransition::setToState(const QString &t) { - Q_D(QmlTransition); + Q_D(QDeclarativeTransition); d->toState = t; } @@ -238,12 +238,12 @@ void QmlTransition::setToState(const QString &t) and assign that to animations the animations property. \default */ -QmlListProperty<QmlAbstractAnimation> QmlTransition::animations() +QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeTransition::animations() { - Q_D(QmlTransition); - return QmlListProperty<QmlAbstractAnimation>(this, &d->animations, QmlTransitionPrivate::append_animation); + Q_D(QDeclarativeTransition); + return QDeclarativeListProperty<QDeclarativeAbstractAnimation>(this, &d->animations, QDeclarativeTransitionPrivate::append_animation); } QT_END_NAMESPACE -#include <qmltransition.moc> +#include <qdeclarativetransition.moc> diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qdeclarativetransition_p.h index ea02a33..861111a 100644 --- a/src/declarative/util/qmltransition_p.h +++ b/src/declarative/util/qdeclarativetransition_p.h @@ -39,12 +39,12 @@ ** ****************************************************************************/ -#ifndef QMLTRANSITION_H -#define QMLTRANSITION_H +#ifndef QDECLARATIVETRANSITION_H +#define QDECLARATIVETRANSITION_H -#include "qmlstate_p.h" +#include "qdeclarativestate_p.h" -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/qobject.h> @@ -54,24 +54,24 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlAbstractAnimation; -class QmlTransitionPrivate; -class QmlTransitionManager; -class Q_DECLARATIVE_EXPORT QmlTransition : public QObject +class QDeclarativeAbstractAnimation; +class QDeclarativeTransitionPrivate; +class QDeclarativeTransitionManager; +class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QmlTransition) + Q_DECLARE_PRIVATE(QDeclarativeTransition) 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(QmlListProperty<QmlAbstractAnimation> animations READ animations) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations) Q_CLASSINFO("DefaultProperty", "animations") Q_CLASSINFO("DeferredPropertyNames", "animations") public: - QmlTransition(QObject *parent=0); - ~QmlTransition(); + QDeclarativeTransition(QObject *parent=0); + ~QDeclarativeTransition(); QString fromState() const; void setFromState(const QString &); @@ -82,11 +82,11 @@ public: bool reversible() const; void setReversible(bool); - QmlListProperty<QmlAbstractAnimation> animations(); + QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations(); - void prepare(QmlStateOperation::ActionList &actions, - QList<QmlMetaProperty> &after, - QmlTransitionManager *end); + void prepare(QDeclarativeStateOperation::ActionList &actions, + QList<QDeclarativeProperty> &after, + QDeclarativeTransitionManager *end); void setReversed(bool r); void stop(); @@ -94,8 +94,8 @@ public: QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlTransition) +QML_DECLARE_TYPE(QDeclarativeTransition) QT_END_HEADER -#endif // QMLTRANSITION_H +#endif // QDECLARATIVETRANSITION_H diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp index f2a4d64..e1143fa 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qdeclarativetransitionmanager.cpp @@ -39,66 +39,67 @@ ** ****************************************************************************/ -#include "qmltransitionmanager_p_p.h" +#include "qdeclarativetransitionmanager_p_p.h" -#include "qmlstate_p_p.h" +#include "qdeclarativestate_p_p.h" -#include <qmlbinding.h> -#include <qmlglobal_p.h> +#include <qdeclarativebinding_p.h> +#include <qdeclarativeglobal_p.h> +#include <qdeclarativeproperty_p.h> QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -class QmlTransitionManagerPrivate +class QDeclarativeTransitionManagerPrivate { public: - QmlTransitionManagerPrivate() + QDeclarativeTransitionManagerPrivate() : state(0), transition(0) {} void applyBindings(); - typedef QList<QmlSimpleAction> SimpleActionList; - QmlState *state; - QmlTransition *transition; - QmlStateOperation::ActionList bindingsList; + typedef QList<QDeclarativeSimpleAction> SimpleActionList; + QDeclarativeState *state; + QDeclarativeTransition *transition; + QDeclarativeStateOperation::ActionList bindingsList; SimpleActionList completeList; }; -QmlTransitionManager::QmlTransitionManager() -: d(new QmlTransitionManagerPrivate) +QDeclarativeTransitionManager::QDeclarativeTransitionManager() +: d(new QDeclarativeTransitionManagerPrivate) { } -void QmlTransitionManager::setState(QmlState *s) +void QDeclarativeTransitionManager::setState(QDeclarativeState *s) { d->state = s; } -QmlTransitionManager::~QmlTransitionManager() +QDeclarativeTransitionManager::~QDeclarativeTransitionManager() { delete d; d = 0; } -void QmlTransitionManager::complete() +void QDeclarativeTransitionManager::complete() { d->applyBindings(); for (int ii = 0; ii < d->completeList.count(); ++ii) { - const QmlMetaProperty &prop = d->completeList.at(ii).property; + const QDeclarativeProperty &prop = d->completeList.at(ii).property; prop.write(d->completeList.at(ii).value); } d->completeList.clear(); if (d->state) - static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete(); + static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(d->state))->complete(); } -void QmlTransitionManagerPrivate::applyBindings() +void QDeclarativeTransitionManagerPrivate::applyBindings() { - foreach(const QmlAction &action, bindingsList) { + foreach(const QDeclarativeAction &action, bindingsList) { if (action.toBinding) { - action.property.setBinding(action.toBinding); + QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding); } else if (action.event) { if (action.reverseEvent) action.event->reverse(); @@ -111,18 +112,18 @@ void QmlTransitionManagerPrivate::applyBindings() bindingsList.clear(); } -void QmlTransitionManager::transition(const QList<QmlAction> &list, - QmlTransition *transition) +void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &list, + QDeclarativeTransition *transition) { cancel(); - QmlStateOperation::ActionList applyList = list; + QDeclarativeStateOperation::ActionList applyList = list; // Determine which actions are binding changes. - foreach(const QmlAction &action, applyList) { + foreach(const QDeclarativeAction &action, applyList) { if (action.toBinding) d->bindingsList << action; if (action.fromBinding) - action.property.setBinding(0); // Disable current binding + QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding if (action.event && action.event->changesBindings()) { //### assume isReversable()? d->bindingsList << action; if (action.reverseEvent) @@ -147,11 +148,11 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, // Apply all the property and binding changes for (int ii = 0; ii < applyList.size(); ++ii) { - const QmlAction &action = applyList.at(ii); + const QDeclarativeAction &action = applyList.at(ii); if (action.toBinding) { - action.property.setBinding(action.toBinding, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } else if (!action.event) { - action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } else if (action.event->isReversable()) { if (action.reverseEvent) action.event->reverse(); @@ -163,17 +164,17 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, // Read all the end values for binding changes for (int ii = 0; ii < applyList.size(); ++ii) { - QmlAction *action = &applyList[ii]; + QDeclarativeAction *action = &applyList[ii]; if (action->event) continue; - const QmlMetaProperty &prop = action->property; + const QDeclarativeProperty &prop = action->property; if (action->toBinding || !action->toValue.isValid()) { //### is this always right (used for exta actions) action->toValue = prop.read(); } } // Revert back to the original values - foreach(const QmlAction &action, applyList) { + foreach(const QDeclarativeAction &action, applyList) { if (action.event) { if (action.event->isReversable()) { if (action.reverseEvent) { //reverse the reverse @@ -190,20 +191,20 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, } if (action.toBinding) - action.property.setBinding(0); // Make sure this is disabled during the transition + QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition - action.property.write(action.fromValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } } if (transition) { - QList<QmlMetaProperty> touched; + QList<QDeclarativeProperty> touched; d->transition = transition; d->transition->prepare(applyList, touched, this); // Modify the action list to remove actions handled in the transition for (int ii = 0; ii < applyList.count(); ++ii) { - const QmlAction &action = applyList.at(ii); + const QDeclarativeAction &action = applyList.at(ii); if (action.event) { @@ -217,7 +218,7 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, if (touched.contains(action.property)) { if (action.toValue != action.fromValue) d->completeList << - QmlSimpleAction(action, QmlSimpleAction::EndState); + QDeclarativeSimpleAction(action, QDeclarativeSimpleAction::EndState); applyList.removeAt(ii); --ii; @@ -231,7 +232,7 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, // be applied immediately. We skip applying bindings, as they are all // applied at the end in applyBindings() to avoid any nastiness mid // transition - foreach(const QmlAction &action, applyList) { + foreach(const QDeclarativeAction &action, applyList) { if (action.event && !action.event->changesBindings()) { if (action.event->isReversable() && action.reverseEvent) action.event->reverse(); @@ -242,7 +243,7 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, } } if (stateChangeDebug()) { - foreach(const QmlAction &action, applyList) { + foreach(const QDeclarativeAction &action, applyList) { if (action.event) qWarning() << " No transition for event:" << action.event->typeName(); else @@ -255,7 +256,7 @@ void QmlTransitionManager::transition(const QList<QmlAction> &list, d->applyBindings(); } -void QmlTransitionManager::cancel() +void QDeclarativeTransitionManager::cancel() { if (d->transition) { // ### this could potentially trigger a complete in rare circumstances @@ -264,9 +265,9 @@ void QmlTransitionManager::cancel() } for(int i = 0; i < d->bindingsList.count(); ++i) { - QmlAction action = d->bindingsList[i]; + QDeclarativeAction action = d->bindingsList[i]; if (action.toBinding && action.deletableToBinding) { - action.property.setBinding(0); + QDeclarativePropertyPrivate::setBinding(action.property, 0); action.toBinding->destroy(); action.toBinding = 0; action.deletableToBinding = false; diff --git a/src/declarative/util/qmltransitionmanager_p_p.h b/src/declarative/util/qdeclarativetransitionmanager_p_p.h index 19ee706..d6e626e 100644 --- a/src/declarative/util/qmltransitionmanager_p_p.h +++ b/src/declarative/util/qdeclarativetransitionmanager_p_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLTRANSITIONMANAGER_P_H -#define QMLTRANSITIONMANAGER_P_H +#ifndef QDECLARATIVETRANSITIONMANAGER_P_H +#define QDECLARATIVETRANSITIONMANAGER_P_H // // W A R N I N G @@ -53,33 +53,33 @@ // We mean it. // -#include "qmlstateoperations_p.h" +#include "qdeclarativestateoperations_p.h" QT_BEGIN_NAMESPACE -class QmlStatePrivate; -class QmlTransitionManagerPrivate; -class QmlTransitionManager +class QDeclarativeStatePrivate; +class QDeclarativeTransitionManagerPrivate; +class QDeclarativeTransitionManager { public: - QmlTransitionManager(); - ~QmlTransitionManager(); + QDeclarativeTransitionManager(); + ~QDeclarativeTransitionManager(); - void transition(const QList<QmlAction> &, QmlTransition *transition); + void transition(const QList<QDeclarativeAction> &, QDeclarativeTransition *transition); void cancel(); private: - Q_DISABLE_COPY(QmlTransitionManager); - QmlTransitionManagerPrivate *d; + Q_DISABLE_COPY(QDeclarativeTransitionManager); + QDeclarativeTransitionManagerPrivate *d; void complete(); - void setState(QmlState *); + void setState(QDeclarativeState *); - friend class QmlState; - friend class QmlTransitionPrivate; + friend class QDeclarativeState; + friend class QDeclarativeTransitionPrivate; }; QT_END_NAMESPACE -#endif // QMLTRANSITIONMANAGER_P_H +#endif // QDECLARATIVETRANSITIONMANAGER_P_H diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp new file mode 100644 index 0000000..ecaa607c --- /dev/null +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativeutilmodule_p.h" +#include "qfxperf_p_p.h" +#include "qdeclarativeanimation_p.h" +#include "qdeclarativeanimation_p_p.h" +#include "qdeclarativebehavior_p.h" +#include "qdeclarativebind_p.h" +#include "qdeclarativeconnection_p.h" +#include "qdeclarativedatetimeformatter_p.h" +#include "qdeclarativeeasefollow_p.h" +#include "qdeclarativefontloader_p.h" +#include "qdeclarativelistaccessor_p.h" +#include "qdeclarativelistmodel_p.h" +#include "qdeclarativenullablevalue_p_p.h" +#include "qdeclarativenumberformatter_p.h" +#include "qdeclarativeopenmetaobject_p.h" +#include "qdeclarativepackage_p.h" +#include "qdeclarativepixmapcache_p.h" +#include "qdeclarativepropertychanges_p.h" +#include "qdeclarativepropertymap.h" +#include "qdeclarativespringfollow_p.h" +#include "qdeclarativestategroup_p.h" +#include "qdeclarativestateoperations_p.h" +#include "qdeclarativestate_p.h" +#include "qdeclarativestate_p_p.h" +#include "qdeclarativestyledtext_p.h" +#include "qdeclarativesystempalette_p.h" +#include "qdeclarativetimeline_p_p.h" +#include "qdeclarativetimer_p.h" +#include "qdeclarativetransitionmanager_p_p.h" +#include "qdeclarativetransition_p.h" +#include "qdeclarativeview.h" +#include "qdeclarativexmllistmodel_p.h" +#include "qnumberformat_p.h" +#include "qperformancelog_p_p.h" + +void QDeclarativeUtilModule::defineModule() +{ + QML_REGISTER_TYPE(Qt,4,6,AnchorChanges,QDeclarativeAnchorChanges); + QML_REGISTER_TYPE(Qt,4,6,Behavior,QDeclarativeBehavior); + QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind); + QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation); + QML_REGISTER_TYPE(Qt,4,6,Connection,QDeclarativeConnection); + QML_REGISTER_TYPE(Qt,4,6,DateTimeFormatter,QDeclarativeDateTimeFormatter); + QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);; + QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader); + QML_REGISTER_TYPE(Qt,4,6,ListElement,QDeclarativeListElement); + QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QDeclarativeNumberAnimation); + QML_REGISTER_TYPE(Qt,4,6,NumberFormatter,QDeclarativeNumberFormatter);; + QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage); + QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation); + QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction); + QML_REGISTER_TYPE(Qt,4,6,ParentChange,QDeclarativeParentChange); + QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QDeclarativePauseAnimation); + QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QDeclarativePropertyAction); + QML_REGISTER_TYPE(Qt,4,6,PropertyAnimation,QDeclarativePropertyAnimation); + QML_REGISTER_TYPE(Qt,4,6,RotationAnimation,QDeclarativeRotationAnimation); + QML_REGISTER_TYPE(Qt,4,6,ScriptAction,QDeclarativeScriptAction); + QML_REGISTER_TYPE(Qt,4,6,SequentialAnimation,QDeclarativeSequentialAnimation); + QML_REGISTER_TYPE(Qt,4,6,SpringFollow,QDeclarativeSpringFollow); + QML_REGISTER_TYPE(Qt,4,6,StateChangeScript,QDeclarativeStateChangeScript); + QML_REGISTER_TYPE(Qt,4,6,StateGroup,QDeclarativeStateGroup); + QML_REGISTER_TYPE(Qt,4,6,State,QDeclarativeState); + QML_REGISTER_TYPE(Qt,4,6,SystemPalette,QDeclarativeSystemPalette); + QML_REGISTER_TYPE(Qt,4,6,Timer,QDeclarativeTimer); + QML_REGISTER_TYPE(Qt,4,6,Transition,QDeclarativeTransition); + QML_REGISTER_TYPE(Qt,4,6,Vector3dAnimation,QDeclarativeVector3dAnimation); +#ifndef QT_NO_XMLPATTERNS + QML_REGISTER_TYPE(Qt,4,6,XmlListModel,QDeclarativeXmlListModel); + QML_REGISTER_TYPE(Qt,4,6,XmlRole,QDeclarativeXmlListModelRole); +#endif + + QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors); + QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation); + QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation); + QML_REGISTER_NOCREATE_TYPE(QNumberFormat); + + QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser); + QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser); +} diff --git a/src/declarative/util/qdeclarativeutilmodule_p.h b/src/declarative/util/qdeclarativeutilmodule_p.h new file mode 100644 index 0000000..602c8c5 --- /dev/null +++ b/src/declarative/util/qdeclarativeutilmodule_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEUTILMODULE_H +#define QDECLARATIVEUTILMODULE_H + +#include <qdeclarative.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeUtilModule +{ +public: + static void defineModule(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEUTILMODULE_H diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qdeclarativeview.cpp index 632e8e2..6fe5bf3 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -39,18 +39,18 @@ ** ****************************************************************************/ -#include "qmlview.h" +#include "qdeclarativeview.h" #include "qperformancelog_p_p.h" #include "qfxperf_p_p.h" -#include <qml.h> -#include <qmlgraphicsitem.h> -#include <qmlengine.h> -#include <qmlcontext.h> -#include <qmldebug_p.h> -#include <qmldebugservice_p.h> -#include <qmlglobal_p.h> +#include <qdeclarative.h> +#include <qdeclarativeitem.h> +#include <qdeclarativeengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarativedebug_p.h> +#include <qdeclarativedebugservice_p.h> +#include <qdeclarativeglobal_p.h> #include <qscriptvalueiterator.h> #include <qdebug.h> @@ -70,11 +70,11 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) -class QmlViewDebugServer; +class QDeclarativeViewDebugServer; class FrameBreakAnimation : public QAbstractAnimation { public: - FrameBreakAnimation(QmlViewDebugServer *s) + FrameBreakAnimation(QDeclarativeViewDebugServer *s) : QAbstractAnimation((QObject*)s), server(s) { start(); @@ -84,13 +84,13 @@ public: virtual void updateCurrentTime(int msecs); private: - QmlViewDebugServer *server; + QDeclarativeViewDebugServer *server; }; -class QmlViewDebugServer : public QmlDebugService +class QDeclarativeViewDebugServer : public QDeclarativeDebugService { public: - QmlViewDebugServer(QObject *parent = 0) : QmlDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0) + QDeclarativeViewDebugServer(QObject *parent = 0) : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0) { timer.start(); new FrameBreakAnimation(this); @@ -118,7 +118,7 @@ private: int breaks; }; -Q_GLOBAL_STATIC(QmlViewDebugServer, qfxViewDebugServer); +Q_GLOBAL_STATIC(QDeclarativeViewDebugServer, qfxViewDebugServer); void FrameBreakAnimation::updateCurrentTime(int msecs) { @@ -126,25 +126,27 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QmlViewPrivate +class QDeclarativeViewPrivate { public: - QmlViewPrivate(QmlView *view) - : q(view), root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {} + QDeclarativeViewPrivate(QDeclarativeView *view) + : q(view), root(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} - QmlView *q; + void execute(); + + QDeclarativeView *q; QGuard<QGraphicsObject> root; - QGuard<QmlGraphicsItem> qmlRoot; + QGuard<QDeclarativeItem> qmlRoot; QUrl source; - QmlEngine engine; - QmlComponent *component; + QDeclarativeEngine engine; + QDeclarativeComponent *component; QBasicTimer resizetimer; mutable QSize initialSize; - QmlView::ResizeMode resizeMode; + QDeclarativeView::ResizeMode resizeMode; QTime frameTimer; void init(); @@ -152,22 +154,36 @@ public: QGraphicsScene scene; }; +void QDeclarativeViewPrivate::execute() +{ + delete root; + delete component; + component = new QDeclarativeComponent(&engine, source, q); + + if (!component->isLoading()) { + q->continueExecute(); + } else { + QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute())); + } +} + + /*! - \class QmlView + \class QDeclarativeView \since 4.7 - \brief The QmlView class provides a widget for displaying a Qt Declarative user interface. + \brief The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface. - Any QGraphicsObject or QmlGraphicsItem + Any QGraphicsObject or QDeclarativeItem 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 + QDeclarativeView 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: + QDeclarativeView performs the following functions: \list - \o Manages QmlComponent loading and object creation. + \o Manages QDeclarativeComponent loading and object creation. \o Initializes QGraphicsView for optimal performance with QML: \list \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState); @@ -184,48 +200,58 @@ public: Typical usage: \code ... - QmlView *view = new QmlView(this); + QDeclarativeView *view = new QDeclarativeView(this); vbox->addWidget(view); QUrl url(fileName); view->setSource(url); - ... - view->execute(); - ... view->show(); \endcode - To receive errors related to loading and executing QML with QmlView, - you can connect to the statusChanged() signal and monitor for QmlView::Error. - The errors are available via QmlView::errors(). + To receive errors related to loading and executing QML with QDeclarativeView, + you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error. + The errors are available via QDeclarativeView::errors(). */ -/*! \fn void QmlView::sceneResized(QSize size) +/*! \fn void QDeclarativeView::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. +/*! \fn void QDeclarativeView::statusChanged(QDeclarativeView::Status status) + This signal is emitted when the component's current \l{QDeclarativeView::Status} {status} changes. */ /*! - \fn QmlView::QmlView(QWidget *parent) + \fn QDeclarativeView::QDeclarativeView(QWidget *parent) - Constructs a QmlView with the given \a parent. + Constructs a QDeclarativeView with the given \a parent. */ -QmlView::QmlView(QWidget *parent) -: QGraphicsView(parent), d(new QmlViewPrivate(this)) +QDeclarativeView::QDeclarativeView(QWidget *parent) +: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) { setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); } -void QmlViewPrivate::init() +/*! + \fn QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) + + Constructs a QDeclarativeView with the given QML \a source and \a parent. +*/ +QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) +: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) +{ + setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + d->init(); + setSource(source); +} + +void QDeclarativeViewPrivate::init() { #ifdef Q_ENABLE_PERFORMANCE_LOG { - QmlPerfTimer<QmlPerf::FontDatabase> perf; + QDeclarativePerfTimer<QDeclarativePerf::FontDatabase> perf; QFontDatabase database; } #endif @@ -249,21 +275,20 @@ void QmlViewPrivate::init() The destructor clears the view's \l {QGraphicsObject} {items} and deletes the internal representation. */ -QmlView::~QmlView() +QDeclarativeView::~QDeclarativeView() { delete d->root; } /*! - Sets the source to the \a url. - - Call \l execute() to load the QML and instantiate the component. - - \sa execute() + Sets the source to the \a url, loads the QML component and instantiates it. */ -void QmlView::setSource(const QUrl& url) +void QDeclarativeView::setSource(const QUrl& url) { - d->source = url; + if (url != d->source) { + d->source = url; + d->execute(); + } } /*! @@ -271,88 +296,71 @@ void QmlView::setSource(const QUrl& url) \sa setSource() */ -QUrl QmlView::source() const +QUrl QDeclarativeView::source() const { return d->source; } /*! - Returns a pointer to the QmlEngine used for instantiating + Returns a pointer to the QDeclarativeEngine used for instantiating QML Components. */ -QmlEngine* QmlView::engine() +QDeclarativeEngine* QDeclarativeView::engine() { return &d->engine; } /*! This function returns the root of the context hierarchy. Each QML - component is instantiated in a QmlContext. QmlContext's are + component is instantiated in a QDeclarativeContext. QDeclarativeContext's are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the - QmlEngine. + QDeclarativeEngine. */ -QmlContext* QmlView::rootContext() +QDeclarativeContext* QDeclarativeView::rootContext() { return d->engine.rootContext(); } -/*! - Loads and instantiates the QML component set by the \l setSource() method. - - \sa setSource() -*/ -void QmlView::execute() -{ - delete d->root; - delete d->component; - d->component = new QmlComponent(&d->engine, d->source, this); - - if (!d->component->isLoading()) { - continueExecute(); - } else { - connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - } -} /*! - \enum QmlView::Status + \enum QDeclarativeView::Status - Specifies the loading status of the QmlView. + Specifies the loading status of the QDeclarativeView. - \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 Null This QDeclarativeView has no source set. + \value Ready This QDeclarativeView has loaded and created the QML component. + \value Loading This QDeclarativeView 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}. + \property QDeclarativeView::status + The component's current \l{QDeclarativeView::Status} {status}. */ -QmlView::Status QmlView::status() const +QDeclarativeView::Status QDeclarativeView::status() const { if (!d->component) - return QmlView::Null; + return QDeclarativeView::Null; - return QmlView::Status(d->component->status()); + return QDeclarativeView::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 +QList<QDeclarativeError> QDeclarativeView::errors() const { if (d->component) return d->component->errors(); - return QList<QmlError>(); + return QList<QDeclarativeError>(); } /*! - \property QmlView::resizeMode + \property QDeclarativeView::resizeMode \brief whether the view should resize the canvas contents If this property is set to SizeViewToRootObject (the default), the view @@ -368,7 +376,7 @@ QList<QmlError> QmlView::errors() const \sa initialSize() */ -void QmlView::setResizeMode(ResizeMode mode) +void QDeclarativeView::setResizeMode(ResizeMode mode) { if (d->resizeMode == mode) return; @@ -385,7 +393,7 @@ void QmlView::setResizeMode(ResizeMode mode) } } -QmlView::ResizeMode QmlView::resizeMode() const +QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const { return d->resizeMode; } @@ -393,14 +401,14 @@ QmlView::ResizeMode QmlView::resizeMode() const /*! \internal */ -void QmlView::continueExecute() +void QDeclarativeView::continueExecute() { - disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); + disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute())); if (d->component->isError()) { - QList<QmlError> errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { + QList<QDeclarativeError> errorList = d->component->errors(); + foreach (const QDeclarativeError &error, errorList) { qWarning() << error; } emit statusChanged(status()); @@ -410,66 +418,72 @@ void QmlView::continueExecute() QObject *obj = d->component->create(); if(d->component->isError()) { - QList<QmlError> errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { + QList<QDeclarativeError> errorList = d->component->errors(); + foreach (const QDeclarativeError &error, errorList) { qWarning() << error; } emit statusChanged(status()); return; } - if (obj) { - if (QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(obj)) { - - d->scene.addItem(item); - - 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->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->resizeMode == SizeRootObjectToView) { - d->qmlRoot->setWidth(width()); - d->qmlRoot->setHeight(height()); - } else { - QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); - emit sceneResized(sz); - resize(sz); - } - updateGeometry(); - } 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); - if (!layout()) { - setLayout(new QVBoxLayout); - layout()->setContentsMargins(0, 0, 0, 0); - } else if (layout()->count()) { - // Hide the QGraphicsView in GV mode. - QLayoutItem *item = layout()->itemAt(0); - if (item->widget()) - item->widget()->hide(); - } - layout()->addWidget(wid); - emit sceneResized(wid->size()); + setRootObject(obj); + emit statusChanged(status()); +} + + +/*! + \internal +*/ +void QDeclarativeView::setRootObject(QObject *obj) +{ + if (QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(obj)) { + d->scene.addItem(item); + + 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->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->resizeMode == SizeRootObjectToView) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); + } else { + QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); + emit sceneResized(sz); + resize(sz); } + updateGeometry(); + } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) { + d->scene.addItem(item); + qWarning() << "QDeclarativeView::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); + if (!layout()) { + setLayout(new QVBoxLayout); + layout()->setContentsMargins(0, 0, 0, 0); + } else if (layout()->count()) { + // Hide the QGraphicsView in GV mode. + QLayoutItem *item = layout()->itemAt(0); + if (item->widget()) + item->widget()->hide(); + } + layout()->addWidget(wid); + emit sceneResized(wid->size()); } - emit statusChanged(status()); } /*! \internal */ -void QmlView::sizeChanged() +void QDeclarativeView::sizeChanged() { // delay, so we catch both width and height changing. d->resizetimer.start(0,this); @@ -480,7 +494,7 @@ void QmlView::sizeChanged() If the \l {QTimerEvent} {timer event} \a e is this view's resize timer, sceneResized() is emitted. */ -void QmlView::timerEvent(QTimerEvent* e) +void QDeclarativeView::timerEvent(QTimerEvent* e) { if (!e || e->timerId() == d->resizetimer.timerId()) { if (d->qmlRoot) { @@ -498,7 +512,7 @@ void QmlView::timerEvent(QTimerEvent* e) \internal The size hint is the size of the root item. */ -QSize QmlView::sizeHint() const +QSize QDeclarativeView::sizeHint() const { if (d->qmlRoot) { if (d->initialSize.width() <= 0) @@ -512,7 +526,7 @@ QSize QmlView::sizeHint() const /*! Returns the view's root \l {QGraphicsObject} {item}. */ -QGraphicsObject *QmlView::rootObject() const +QGraphicsObject *QDeclarativeView::rootObject() const { return d->root; } @@ -522,7 +536,7 @@ QGraphicsObject *QmlView::rootObject() const This function handles the \l {QResizeEvent} {resize event} \a e. */ -void QmlView::resizeEvent(QResizeEvent *e) +void QDeclarativeView::resizeEvent(QResizeEvent *e) { if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) { d->qmlRoot->setWidth(width()); @@ -541,13 +555,13 @@ void QmlView::resizeEvent(QResizeEvent *e) /*! \internal */ -void QmlView::paintEvent(QPaintEvent *event) +void QDeclarativeView::paintEvent(QPaintEvent *event) { int time = 0; - if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled()) + if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled()) time = d->frameTimer.restart(); QGraphicsView::paintEvent(event); - if (QmlViewDebugServer::isDebuggingEnabled()) + if (QDeclarativeViewDebugServer::isDebuggingEnabled()) qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time); if (frameRateDebug()) qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qdeclarativeview.h index 1d6ef1c..03d8db3 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLVIEW_H -#define QMLVIEW_H +#ifndef QDECLARATIVEVIEW_H +#define QDECLARATIVEVIEW_H #include <QtCore/qdatetime.h> #include <QtGui/qgraphicssceneevent.h> @@ -54,27 +54,27 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QGraphicsObject; -class QmlEngine; -class QmlContext; -class QmlError; +class QDeclarativeEngine; +class QDeclarativeContext; +class QDeclarativeError; -class QmlViewPrivate; -class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView +class QDeclarativeViewPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeView : public QGraphicsView { Q_OBJECT Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) Q_PROPERTY(Status status READ status NOTIFY statusChanged) public: - explicit QmlView(QWidget *parent = 0); - virtual ~QmlView(); + explicit QDeclarativeView(QWidget *parent = 0); + QDeclarativeView(const QUrl &source, QWidget *parent = 0); + virtual ~QDeclarativeView(); QUrl source() const; void setSource(const QUrl&); - QmlEngine* engine(); - QmlContext* rootContext(); - void execute(); + QDeclarativeEngine* engine(); + QDeclarativeContext* rootContext(); QGraphicsObject *rootObject() const; @@ -85,13 +85,13 @@ public: enum Status { Null, Ready, Loading, Error }; Status status() const; - QList<QmlError> errors() const; + QList<QDeclarativeError> errors() const; QSize sizeHint() const; Q_SIGNALS: void sceneResized(QSize size); // ??? - void statusChanged(QmlView::Status); + void statusChanged(QDeclarativeView::Status); private Q_SLOTS: void continueExecute(); @@ -100,13 +100,15 @@ private Q_SLOTS: protected: virtual void resizeEvent(QResizeEvent *); virtual void paintEvent(QPaintEvent *event); - void timerEvent(QTimerEvent*); + virtual void timerEvent(QTimerEvent*); + virtual void setRootObject(QObject *obj); - QmlViewPrivate *d; + friend class QDeclarativeViewPrivate; + QDeclarativeViewPrivate *d; }; QT_END_NAMESPACE QT_END_HEADER -#endif // QMLVIEW_H +#endif // QDECLARATIVEVIEW_H diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 58caf12..386df46 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -39,12 +39,13 @@ ** ****************************************************************************/ -#include "qmlxmllistmodel_p.h" +#include "qdeclarativexmllistmodel_p.h" -#include <qmlcontext.h> -#include <qmlengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeengine.h> #include <QDebug> +#include <QStringList> #include <QApplication> #include <QThread> #include <QMutex> @@ -60,11 +61,13 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,XmlRole,QmlXmlListModelRole) -QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel) + + + +typedef QPair<int, int> QDeclarativeXmlListRange; /*! - \qmlclass XmlRole QmlXmlListModelRole + \qmlclass XmlRole QDeclarativeXmlListModelRole \since 4.7 \brief The XmlRole element allows you to specify a role for an XmlListModel. */ @@ -95,50 +98,26 @@ QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel) \endqml */ -class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString query READ query WRITE setQuery) - -public: - QmlXmlListModelRole() {} - ~QmlXmlListModelRole() {} - - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } - - QString query() const { return m_query; } - void setQuery(const QString &query) - { - if (query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << tr("An XmlRole query must not start with '/'"); - return; - } - m_query = query; - } - - bool isValid() { - return !m_name.isEmpty() && !m_query.isEmpty(); - } - -private: - QString m_name; - QString m_query; -}; -QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlXmlListModelRole) -QT_BEGIN_NAMESPACE +/*! + \qmlproperty bool XmlRole::isKey + Defines whether this is a key role. + + Key roles are used to to determine whether a set of values should + be updated or added to the XML list model when XmlListModel::reload() + is called. + + \sa XmlListModel +*/ -class QmlXmlQuery : public QThread +class QDeclarativeXmlQuery : public QThread { Q_OBJECT public: - QmlXmlQuery(QObject *parent=0) + QDeclarativeXmlQuery(QObject *parent=0) : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) { } - ~QmlXmlQuery() { + ~QDeclarativeXmlQuery() { m_mutex.lock(); m_quit = true; m_condition.wakeOne(); @@ -152,9 +131,8 @@ public: m_abort = true; } - int doQuery(QString query, QString namespaces, QByteArray data, QList<QmlXmlListModelRole *> *roleObjects) { + int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *> *roleObjects) { QMutexLocker locker(&m_mutex); - m_modelData.clear(); m_size = 0; m_data = data; m_query = QLatin1String("doc($src)") + query; @@ -176,6 +154,16 @@ public: return m_modelData; } + QList<QDeclarativeXmlListRange> insertedItemRanges() { + QMutexLocker locker(&m_mutex); + return m_insertedItemRanges; + } + + QList<QDeclarativeXmlListRange> removedItemRanges() { + QMutexLocker locker(&m_mutex); + return m_removedItemRanges; + } + Q_SIGNALS: void queryCompleted(int queryId, int size); @@ -185,13 +173,12 @@ protected: m_mutex.lock(); int queryId = m_queryId; doQueryJob(); - if (m_size > 0) - doSubQueryJob(); + doSubQueryJob(); m_data.clear(); // no longer needed m_mutex.unlock(); m_mutex.lock(); - if (!m_abort && m_size > 0) + if (!m_abort) emit queryCompleted(queryId, m_size); if (!m_restart) m_condition.wait(&m_mutex); @@ -204,6 +191,8 @@ protected: private: void doQueryJob(); void doSubQueryJob(); + void getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const; + void addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const; private: QMutex m_mutex; @@ -217,11 +206,14 @@ private: QString m_prefix; int m_size; int m_queryId; - const QList<QmlXmlListModelRole *> *m_roleObjects; + const QList<QDeclarativeXmlListModelRole *> *m_roleObjects; QList<QList<QVariant> > m_modelData; + QStringList m_keysValues; + QList<QDeclarativeXmlListRange> m_insertedItemRanges; + QList<QDeclarativeXmlListRange> m_removedItemRanges; }; -void QmlXmlQuery::doQueryJob() +void QDeclarativeXmlQuery::doQueryJob() { QString r; QXmlQuery query; @@ -263,7 +255,41 @@ void QmlXmlQuery::doQueryJob() m_size = count; } -void QmlXmlQuery::doSubQueryJob() +void QDeclarativeXmlQuery::getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const +{ + QStringList keysQueries; + for (int i=0; i<m_roleObjects->count(); i++) { + if (m_roleObjects->at(i)->isKey()) + keysQueries << m_roleObjects->at(i)->query(); + } + QString keysQuery; + if (keysQueries.count() == 1) + keysQuery = m_prefix + keysQueries[0]; + else if (keysQueries.count() > 1) + keysQuery = m_prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")"); + + if (!keysQuery.isEmpty()) { + query->setQuery(keysQuery); + QXmlResultItems resultItems; + query->evaluateTo(&resultItems); + QXmlItem item(resultItems.next()); + while (!item.isNull()) { + values->append(item.toAtomicValue().toString()); + item = resultItems.next(); + } + } +} + +void QDeclarativeXmlQuery::addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const { + if (ranges->isEmpty()) + ranges->append(qMakePair(index, 1)); + else if (ranges->last().first + ranges->last().second == index) + ranges->last().second += 1; + else + ranges->append(qMakePair(index, 1)); +} + +void QDeclarativeXmlQuery::doSubQueryJob() { m_modelData.clear(); @@ -273,9 +299,38 @@ void QmlXmlQuery::doSubQueryJob() QXmlQuery subquery; subquery.bindVariable(QLatin1String("inputDocument"), &b); + QStringList keysValues; + getValuesOfKeyRoles(&keysValues, &subquery); + + // See if any values of key roles have been inserted or removed. + m_insertedItemRanges.clear(); + m_removedItemRanges.clear(); + if (m_keysValues.isEmpty()) { + m_insertedItemRanges << qMakePair(0, m_size); + } else { + if (keysValues != m_keysValues) { + QStringList temp; + for (int i=0; i<m_keysValues.count(); i++) { + if (!keysValues.contains(m_keysValues[i])) + addIndexToRangeList(&m_removedItemRanges, i); + else + temp << m_keysValues[i]; + } + + for (int i=0; i<keysValues.count(); i++) { + if (temp.count() == i || keysValues[i] != temp[i]) { + temp.insert(i, keysValues[i]); + addIndexToRangeList(&m_insertedItemRanges, i); + } + } + } + } + m_keysValues = keysValues; + + // Get the new values for each role. //### we might be able to condense even further (query for everything in one go) for (int i = 0; i < m_roleObjects->size(); ++i) { - QmlXmlListModelRole *role = m_roleObjects->at(i); + QDeclarativeXmlListModelRole *role = m_roleObjects->at(i); if (!role->isValid()) { QList<QVariant> resultList; for (int j = 0; j < m_size; ++j) @@ -284,13 +339,13 @@ void QmlXmlQuery::doSubQueryJob() continue; } subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")")); - QXmlResultItems output3; - subquery.evaluateTo(&output3); - QXmlItem item(output3.next()); + QXmlResultItems resultItems; + subquery.evaluateTo(&resultItems); + QXmlItem item(resultItems.next()); QList<QVariant> resultList; while (!item.isNull()) { resultList << item.toAtomicValue(); //### we used to trim strings - item = output3.next(); + item = resultItems.next(); } //### should warn here if things have gone wrong. while (resultList.count() < m_size) @@ -303,7 +358,7 @@ void QmlXmlQuery::doSubQueryJob() /*for (int j = 0; j < m_size; ++j) { QList<QVariant> resultList; for (int i = 0; i < m_roleObjects->size(); ++i) { - QmlXmlListModelRole *role = m_roleObjects->at(i); + QDeclarativeXmlListModelRole *role = m_roleObjects->at(i); subquery.setQuery(m_prefix.arg(j+1) + role->query()); if (role->isStringList()) { QStringList data; @@ -328,13 +383,13 @@ void QmlXmlQuery::doSubQueryJob() }*/ } -class QmlXmlListModelPrivate : public QObjectPrivate +class QDeclarativeXmlListModelPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlXmlListModel) + Q_DECLARE_PUBLIC(QDeclarativeXmlListModel) public: - QmlXmlListModelPrivate() + QDeclarativeXmlListModelPrivate() : isComponentComplete(true), size(-1), highestRole(Qt::UserRole) - , reply(0), status(QmlXmlListModel::Null), progress(0.0) + , reply(0), status(QDeclarativeXmlListModel::Null), progress(0.0) , queryId(-1), roleObjects() {} bool isComponentComplete; @@ -347,22 +402,22 @@ public: QStringList roleNames; int highestRole; QNetworkReply *reply; - QmlXmlListModel::Status status; + QDeclarativeXmlListModel::Status status; qreal progress; - QmlXmlQuery qmlXmlQuery; + QDeclarativeXmlQuery qmlXmlQuery; int queryId; - 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<QDeclarativeXmlListModelRole *> roleObjects; + static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role); + static void clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list); + static void removeAt_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i); + static void insert_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i, QDeclarativeXmlListModelRole *role); QList<QList<QVariant> > data; }; -void QmlXmlListModelPrivate::append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role) +void QDeclarativeXmlListModelPrivate::append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role) { - QmlXmlListModel *_this = qobject_cast<QmlXmlListModel *>(list->object); + QDeclarativeXmlListModel *_this = qobject_cast<QDeclarativeXmlListModel *>(list->object); if (_this) { int i = _this->d_func()->roleObjects.count(); _this->d_func()->roleObjects.append(role); @@ -378,52 +433,67 @@ void QmlXmlListModelPrivate::append_role(QmlListProperty<QmlXmlListModelRole> *l //### clear needs to invalidate any cached data (in data table) as well // (and the model should emit the appropriate signals) -void QmlXmlListModelPrivate::clear_role(QmlListProperty<QmlXmlListModelRole> *list) +void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list) { - QmlXmlListModel *_this = static_cast<QmlXmlListModel *>(list->object); + QDeclarativeXmlListModel *_this = static_cast<QDeclarativeXmlListModel *>(list->object); _this->d_func()->roles.clear(); _this->d_func()->roleNames.clear(); _this->d_func()->roleObjects.clear(); } /*! - \class QmlXmlListModel + \class QDeclarativeXmlListModel \internal */ /*! - \qmlclass XmlListModel QmlXmlListModel + \qmlclass XmlListModel QDeclarativeXmlListModel \since 4.7 - \brief The XmlListModel element allows you to specify a model using XPath expressions. + \brief The XmlListModel element is used to specify a model using XPath expressions. - XmlListModel allows you to construct a model from XML data that can then be used as a data source - for the view classes (ListView, PathView, GridView) and any other classes that interact with model - data (like Repeater). + XmlListModel is used to create a model from XML data that can be used as a data source + for the view classes (such as ListView, PathView, GridView) and other classes that interact with model + data (such as Repeater). - The following is an example of a model containing news from a Yahoo RSS feed: + Here is an example of a model containing news from a Yahoo RSS feed: \qml XmlListModel { id: feedModel source: "http://rss.news.yahoo.com/rss/oceania" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "pubDate"; query: "pubDate/string()" } XmlRole { name: "description"; query: "description/string()" } } \endqml - \note The model is currently static, so the above is really just a snapshot of an RSS feed. To force a - reload of the entire model, you can call the reload function. + + You can also define certain roles as "keys" so that the model only adds data + that contains new values for these keys when reload() is called. + + For example, if the roles above were defined like this: + + \qml + XmlRole { name: "title"; query: "title/string()"; isKey: true } + XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true } + \endqml + + Then when reload() is called, the model will only add new items with a + "title" and "pubDate" value combination that is not already present in + the model. + + This is useful to provide incremental updates and avoid repainting an + entire model in a view. */ -QmlXmlListModel::QmlXmlListModel(QObject *parent) - : QListModelInterface(*(new QmlXmlListModelPrivate), parent) +QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) + : QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)), this, SLOT(queryCompleted(int,int))); } -QmlXmlListModel::~QmlXmlListModel() +QDeclarativeXmlListModel::~QDeclarativeXmlListModel() { } @@ -432,18 +502,18 @@ QmlXmlListModel::~QmlXmlListModel() The roles to make available for this model. */ -QmlListProperty<QmlXmlListModelRole> QmlXmlListModel::roleObjects() +QDeclarativeListProperty<QDeclarativeXmlListModelRole> QDeclarativeXmlListModel::roleObjects() { - Q_D(QmlXmlListModel); - QmlListProperty<QmlXmlListModelRole> list(this, d->roleObjects); - list.append = &QmlXmlListModelPrivate::append_role; - list.clear = &QmlXmlListModelPrivate::clear_role; + Q_D(QDeclarativeXmlListModel); + QDeclarativeListProperty<QDeclarativeXmlListModelRole> list(this, d->roleObjects); + list.append = &QDeclarativeXmlListModelPrivate::append_role; + list.clear = &QDeclarativeXmlListModelPrivate::clear_role; return list; } -QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) const +QHash<int,QVariant> QDeclarativeXmlListModel::data(int index, const QList<int> &roles) const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); QHash<int, QVariant> rv; for (int i = 0; i < roles.size(); ++i) { int role = roles.at(i); @@ -453,9 +523,9 @@ QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) co return rv; } -QVariant QmlXmlListModel::data(int index, int role) const +QVariant QDeclarativeXmlListModel::data(int index, int role) const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); int roleIndex = d->roles.indexOf(role); return (roleIndex == -1) ? QVariant() : d->data.at(roleIndex).at(index); } @@ -464,21 +534,21 @@ QVariant QmlXmlListModel::data(int index, int role) const \qmlproperty int XmlListModel::count The number of data entries in the model. */ -int QmlXmlListModel::count() const +int QDeclarativeXmlListModel::count() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->size; } -QList<int> QmlXmlListModel::roles() const +QList<int> QDeclarativeXmlListModel::roles() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->roles; } -QString QmlXmlListModel::toString(int role) const +QString QDeclarativeXmlListModel::toString(int role) const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); int index = d->roles.indexOf(role); if (index == -1) return QString(); @@ -491,15 +561,15 @@ QString QmlXmlListModel::toString(int role) const If both source and xml are set, xml will be used. */ -QUrl QmlXmlListModel::source() const +QUrl QDeclarativeXmlListModel::source() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->src; } -void QmlXmlListModel::setSource(const QUrl &src) +void QDeclarativeXmlListModel::setSource(const QUrl &src) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (d->src != src) { d->src = src; reload(); @@ -514,35 +584,35 @@ void QmlXmlListModel::setSource(const QUrl &src) If both source and xml are set, xml will be used. */ -QString QmlXmlListModel::xml() const +QString QDeclarativeXmlListModel::xml() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->xml; } -void QmlXmlListModel::setXml(const QString &xml) +void QDeclarativeXmlListModel::setXml(const QString &xml) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); d->xml = xml; reload(); } /*! - \qmlproperty url XmlListModel::query + \qmlproperty string XmlListModel::query An absolute XPath query representing the base query for the model items. The query should start with - a '/' or '//'. + '/' or '//'. */ -QString QmlXmlListModel::query() const +QString QDeclarativeXmlListModel::query() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->query; } -void QmlXmlListModel::setQuery(const QString &query) +void QDeclarativeXmlListModel::setQuery(const QString &query) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (!query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << QCoreApplication::translate("QmlXmlRoleList", "An XmlListModel query must start with '/' or \"//\""); + qmlInfo(this) << QCoreApplication::translate("QDeclarativeXmlRoleList", "An XmlListModel query must start with '/' or \"//\""); return; } @@ -556,15 +626,15 @@ void QmlXmlListModel::setQuery(const QString &query) \qmlproperty string XmlListModel::namespaceDeclarations A set of declarations for the namespaces used in the query. */ -QString QmlXmlListModel::namespaceDeclarations() const +QString QDeclarativeXmlListModel::namespaceDeclarations() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->namespaces; } -void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations) +void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarations) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (d->namespaces != declarations) { d->namespaces = declarations; reload(); @@ -585,9 +655,9 @@ void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations) \sa progress */ -QmlXmlListModel::Status QmlXmlListModel::status() const +QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->status; } @@ -599,21 +669,21 @@ QmlXmlListModel::Status QmlXmlListModel::status() const \sa status */ -qreal QmlXmlListModel::progress() const +qreal QDeclarativeXmlListModel::progress() const { - Q_D(const QmlXmlListModel); + Q_D(const QDeclarativeXmlListModel); return d->progress; } -void QmlXmlListModel::classBegin() +void QDeclarativeXmlListModel::classBegin() { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); d->isComponentComplete = false; } -void QmlXmlListModel::componentComplete() +void QDeclarativeXmlListModel::componentComplete() { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); d->isComponentComplete = true; reload(); } @@ -621,12 +691,17 @@ void QmlXmlListModel::componentComplete() /*! \qmlmethod XmlListModel::reload() - Reloads the model. All the existing model data will be removed, and the model - will be rebuilt from scratch. + Reloads the model. + + If no key roles have been specified, all existing model + data is removed, and the model is rebuilt from scratch. + + Otherwise, items are only added if the model does not already + contain items with matching key role values. */ -void QmlXmlListModel::reload() +void QDeclarativeXmlListModel::reload() { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (!d->isComponentComplete) return; @@ -634,12 +709,8 @@ void QmlXmlListModel::reload() d->qmlXmlQuery.abort(); d->queryId = -1; - //clear existing data - int count = d->size; - d->size = 0; - d->data.clear(); - if (count > 0) - emit itemsRemoved(0, count); + if (d->size < 0) + d->size = 0; if (d->src.isEmpty() && d->xml.isEmpty()) return; @@ -671,9 +742,9 @@ void QmlXmlListModel::reload() this, SLOT(requestProgress(qint64,qint64))); } -void QmlXmlListModel::requestFinished() +void QDeclarativeXmlListModel::requestFinished() { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (d->reply->error() != QNetworkReply::NoError) { disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); @@ -692,28 +763,35 @@ void QmlXmlListModel::requestFinished() emit statusChanged(d->status); } -void QmlXmlListModel::requestProgress(qint64 received, qint64 total) +void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (d->status == Loading && total > 0) { d->progress = qreal(received)/total; emit progressChanged(d->progress); } } -void QmlXmlListModel::queryCompleted(int id, int size) +void QDeclarativeXmlListModel::queryCompleted(int id, int size) { - Q_D(QmlXmlListModel); + Q_D(QDeclarativeXmlListModel); if (id != d->queryId) return; + bool sizeChanged = size != d->size; d->size = size; - if (size > 0) { - d->data = d->qmlXmlQuery.modelData(); - emit itemsInserted(0, d->size); + d->data = d->qmlXmlQuery.modelData(); + + QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges(); + for (int i=0; i<removed.count(); i++) + emit itemsRemoved(removed[i].first, removed[i].second); + QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges(); + for (int i=0; i<inserted.count(); i++) + emit itemsInserted(inserted[i].first, inserted[i].second); + + if (sizeChanged) emit countChanged(); - } } QT_END_NAMESPACE -#include <qmlxmllistmodel.moc> +#include <qdeclarativexmllistmodel.moc> diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index a6627e2..132a53c 100644 --- a/src/declarative/util/qmlxmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -39,11 +39,13 @@ ** ****************************************************************************/ -#ifndef QMLXMLLISTMODEL_H -#define QMLXMLLISTMODEL_H +#ifndef QDECLARATIVEXMLLISTMODEL_H +#define QDECLARATIVEXMLLISTMODEL_H -#include <qml.h> -#include <qmlinfo.h> +#include <qdeclarative.h> +#include <qdeclarativeinfo.h> + +#include <QtCore/qurl.h> #include "../3rdparty/qlistmodelinterface_p.h" @@ -53,15 +55,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlContext; +class QDeclarativeContext; -class QmlXmlListModelRole; +class QDeclarativeXmlListModelRole; -class QmlXmlListModelPrivate; -class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus +class QDeclarativeXmlListModelPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus { Q_OBJECT - Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QDeclarativeParserStatus) Q_ENUMS(Status) Q_PROPERTY(Status status READ status NOTIFY statusChanged) @@ -70,13 +72,13 @@ 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(QmlListProperty<QmlXmlListModelRole> roles READ roleObjects) + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeXmlListModelRole> roles READ roleObjects) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_CLASSINFO("DefaultProperty", "roles") public: - QmlXmlListModel(QObject *parent = 0); - ~QmlXmlListModel(); + QDeclarativeXmlListModel(QObject *parent = 0); + ~QDeclarativeXmlListModel(); virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; virtual QVariant data(int index, int role) const; @@ -84,7 +86,7 @@ public: virtual QList<int> roles() const; virtual QString toString(int role) const; - QmlListProperty<QmlXmlListModelRole> roleObjects(); + QDeclarativeListProperty<QDeclarativeXmlListModelRole> roleObjects(); QUrl source() const; void setSource(const QUrl&); @@ -123,14 +125,52 @@ private Q_SLOTS: void queryCompleted(int,int); private: - Q_DECLARE_PRIVATE(QmlXmlListModel) - Q_DISABLE_COPY(QmlXmlListModel) + Q_DECLARE_PRIVATE(QDeclarativeXmlListModel) + Q_DISABLE_COPY(QDeclarativeXmlListModel) +}; + +class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModelRole : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString query READ query WRITE setQuery) + Q_PROPERTY(bool isKey READ isKey WRITE setIsKey) + +public: + QDeclarativeXmlListModelRole() : m_isKey(false) {} + ~QDeclarativeXmlListModelRole() {} + + QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } + + QString query() const { return m_query; } + void setQuery(const QString &query) + { + if (query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << tr("An XmlRole query must not start with '/'"); + return; + } + m_query = query; + } + + bool isKey() const { return m_isKey; } + void setIsKey(bool b) { m_isKey = b; } + + bool isValid() { + return !m_name.isEmpty() && !m_query.isEmpty(); + } + +private: + QString m_name; + QString m_query; + bool m_isKey; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlXmlListModel) +QML_DECLARE_TYPE(QDeclarativeXmlListModel) +QML_DECLARE_TYPE(QDeclarativeXmlListModelRole) QT_END_HEADER -#endif // QMLXMLLISTMODEL_H +#endif // QDECLARATIVEXMLLISTMODEL_H diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index 8f5617c..5611c49 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -43,25 +43,25 @@ QT_BEGIN_NAMESPACE -Q_DEFINE_PERFORMANCE_LOG(QmlPerf, "QmlGraphics") { - Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing") +Q_DEFINE_PERFORMANCE_LOG(QDeclarativePerf, "QDeclarativeGraphics") { + Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeParsing, "Compilation: QML Parsing") Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation") Q_DEFINE_PERFORMANCE_METRIC(VMEExecution, "Execution: QML VME Execution") Q_DEFINE_PERFORMANCE_METRIC(BindInit, "BindValue Initialization") Q_DEFINE_PERFORMANCE_METRIC(BindValue, "BindValue execution") Q_DEFINE_PERFORMANCE_METRIC(BindValueSSE, "BindValue execution SSE") Q_DEFINE_PERFORMANCE_METRIC(BindValueQt, "BindValue execution QtScript") - Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QmlBinding::update") + Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QDeclarativeBinding::update") Q_DEFINE_PERFORMANCE_METRIC(PixmapLoad, "Pixmap loading") Q_DEFINE_PERFORMANCE_METRIC(FontDatabase, "Font database creation") - Q_DEFINE_PERFORMANCE_METRIC(QmlGraphicsPathViewPathCache, "FX Items: QmlGraphicsPathView: Path cache") - Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QmlGraphicsParticles: Particle creation") - Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QmlGraphicsItem::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QmlGraphicsImage::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QmlGraphicsBasePositioner::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QmlGraphicsText::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(QmlGraphicsText_setText, " QmlGraphicsText::setText") - Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine") + Q_DEFINE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache, "FX Items: QDeclarativePathView: Path cache") + Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QDeclarativeParticles: Particle creation") + Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QDeclarativeItem::componentComplete") + Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QDeclarativeImage::componentComplete") + Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QDeclarativeBasePositioner::componentComplete") + Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QDeclarativeText::componentComplete") + Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeText_setText, " QDeclarativeText::setText") + Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QDeclarativeScript::addScriptToEngine") } QT_END_NAMESPACE diff --git a/src/declarative/util/qfxperf_p_p.h b/src/declarative/util/qfxperf_p_p.h index 106f761..8b65821 100644 --- a/src/declarative/util/qfxperf_p_p.h +++ b/src/declarative/util/qfxperf_p_p.h @@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -Q_DECLARE_PERFORMANCE_LOG(QmlPerf) { - Q_DECLARE_PERFORMANCE_METRIC(QmlParsing) +Q_DECLARE_PERFORMANCE_LOG(QDeclarativePerf) { + Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeParsing) Q_DECLARE_PERFORMANCE_METRIC(Compilation) Q_DECLARE_PERFORMANCE_METRIC(VMEExecution) @@ -73,13 +73,13 @@ Q_DECLARE_PERFORMANCE_LOG(QmlPerf) { Q_DECLARE_PERFORMANCE_METRIC(BindableValueUpdate) Q_DECLARE_PERFORMANCE_METRIC(PixmapLoad) Q_DECLARE_PERFORMANCE_METRIC(FontDatabase) - Q_DECLARE_PERFORMANCE_METRIC(QmlGraphicsPathViewPathCache) + Q_DECLARE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache) Q_DECLARE_PERFORMANCE_METRIC(CreateParticle) Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete) - Q_DECLARE_PERFORMANCE_METRIC(QmlGraphicsText_setText) + Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeText_setText) Q_DECLARE_PERFORMANCE_METRIC(AddScript) } diff --git a/src/declarative/util/qmlstateoperations_p.h b/src/declarative/util/qmlstateoperations_p.h deleted file mode 100644 index dc1974b..0000000 --- a/src/declarative/util/qmlstateoperations_p.h +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLSTATEOPERATIONS_H -#define QMLSTATEOPERATIONS_H - -#include "qmlstate_p.h" - -#include <qmlgraphicsitem.h> -#include "private/qmlgraphicsanchors_p.h" -#include <qmlscriptstring.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlParentChangePrivate; -class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation, public QmlActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlParentChange) - - Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject) - Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) -public: - QmlParentChange(QObject *parent=0); - ~QmlParentChange(); - - QmlGraphicsItem *object() const; - void setObject(QmlGraphicsItem *); - - QmlGraphicsItem *parent() const; - void setParent(QmlGraphicsItem *); - - virtual ActionList actions(); - - virtual void saveOriginals(); - virtual void execute(); - virtual bool isReversable(); - virtual void reverse(); - virtual QString typeName() const; - virtual bool override(QmlActionEvent*other); - virtual void rewind(); - virtual void saveCurrentValues(); -}; - -class QmlStateChangeScriptPrivate; -class Q_DECLARATIVE_EXPORT QmlStateChangeScript : public QmlStateOperation, public QmlActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlStateChangeScript) - - Q_PROPERTY(QmlScriptString script READ script WRITE setScript) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - QmlStateChangeScript(QObject *parent=0); - ~QmlStateChangeScript(); - - virtual ActionList actions(); - - virtual QString typeName() const; - - QmlScriptString script() const; - void setScript(const QmlScriptString &); - - QString name() const; - void setName(const QString &); - - virtual void execute(); -}; - -class QmlAnchorChangesPrivate; -class Q_DECLARATIVE_EXPORT QmlAnchorChanges : public QmlStateOperation, public QmlActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlAnchorChanges) - - Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject) - Q_PROPERTY(QString reset READ reset WRITE setReset) - Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft) - Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight) - Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter) - Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop) - Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom) - Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter) - Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline) - -public: - QmlAnchorChanges(QObject *parent=0); - ~QmlAnchorChanges(); - - virtual ActionList actions(); - - QmlGraphicsItem *object() const; - void setObject(QmlGraphicsItem *); - - QString reset() const; - void setReset(const QString &); - - QmlGraphicsAnchorLine left() const; - void setLeft(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine right() const; - void setRight(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine horizontalCenter() const; - void setHorizontalCenter(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine top() const; - void setTop(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine bottom() const; - void setBottom(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine verticalCenter() const; - void setVerticalCenter(const QmlGraphicsAnchorLine &edge); - - QmlGraphicsAnchorLine baseline() const; - void setBaseline(const QmlGraphicsAnchorLine &edge); - - virtual void execute(); - virtual bool isReversable(); - virtual void reverse(); - virtual QString typeName() const; - virtual bool override(QmlActionEvent*other); - virtual QList<QmlAction> extraActions(); - virtual bool changesBindings(); - virtual void saveOriginals(); - virtual void clearForwardBindings(); - virtual void clearReverseBindings(); - virtual void rewind(); - virtual void saveCurrentValues(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlParentChange) -QML_DECLARE_TYPE(QmlStateChangeScript) -QML_DECLARE_TYPE(QmlAnchorChanges) - -QT_END_HEADER - -#endif // QMLSTATEOPERATIONS_H diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp index 42c12fe..81d0b90 100644 --- a/src/declarative/util/qnumberformat.cpp +++ b/src/declarative/util/qnumberformat.cpp @@ -40,11 +40,10 @@ ****************************************************************************/ #include "qnumberformat_p.h" +#include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE -QML_DEFINE_NOCREATE_TYPE(QNumberFormat) - QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal), _groupingSize(0) { diff --git a/src/declarative/util/qnumberformat_p.h b/src/declarative/util/qnumberformat_p.h index 902dcde..ced4442 100644 --- a/src/declarative/util/qnumberformat_p.h +++ b/src/declarative/util/qnumberformat_p.h @@ -42,7 +42,7 @@ #ifndef NUMBERFORMAT_H #define NUMBERFORMAT_H -#include <qml.h> +#include <qdeclarative.h> #include <QtCore/QLocale> #include <QtCore/QTime> diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index b6a5c90..610eb3f 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -1,72 +1,74 @@ INCLUDEPATH += $$PWD SOURCES += \ - $$PWD/qmlview.cpp \ + $$PWD/qdeclarativeutilmodule.cpp\ + $$PWD/qdeclarativeview.cpp \ $$PWD/qfxperf.cpp \ $$PWD/qperformancelog.cpp \ - $$PWD/qmlconnection.cpp \ - $$PWD/qmlpackage.cpp \ - $$PWD/qmlanimation.cpp \ - $$PWD/qmlsystempalette.cpp \ - $$PWD/qmlspringfollow.cpp \ - $$PWD/qmleasefollow.cpp \ - $$PWD/qmlstate.cpp\ - $$PWD/qmltransitionmanager.cpp \ - $$PWD/qmlstateoperations.cpp \ - $$PWD/qmlpropertychanges.cpp \ - $$PWD/qmlstategroup.cpp \ - $$PWD/qmltransition.cpp \ - $$PWD/qmllistmodel.cpp\ - $$PWD/qmllistaccessor.cpp \ - $$PWD/qmlopenmetaobject.cpp \ - $$PWD/qmltimeline.cpp \ - $$PWD/qmltimer.cpp \ - $$PWD/qmlbind.cpp \ - $$PWD/qmlpropertymap.cpp \ - $$PWD/qmlpixmapcache.cpp \ + $$PWD/qdeclarativeconnection.cpp \ + $$PWD/qdeclarativepackage.cpp \ + $$PWD/qdeclarativeanimation.cpp \ + $$PWD/qdeclarativesystempalette.cpp \ + $$PWD/qdeclarativespringfollow.cpp \ + $$PWD/qdeclarativeeasefollow.cpp \ + $$PWD/qdeclarativestate.cpp\ + $$PWD/qdeclarativetransitionmanager.cpp \ + $$PWD/qdeclarativestateoperations.cpp \ + $$PWD/qdeclarativepropertychanges.cpp \ + $$PWD/qdeclarativestategroup.cpp \ + $$PWD/qdeclarativetransition.cpp \ + $$PWD/qdeclarativelistmodel.cpp\ + $$PWD/qdeclarativelistaccessor.cpp \ + $$PWD/qdeclarativeopenmetaobject.cpp \ + $$PWD/qdeclarativetimeline.cpp \ + $$PWD/qdeclarativetimer.cpp \ + $$PWD/qdeclarativebind.cpp \ + $$PWD/qdeclarativepropertymap.cpp \ + $$PWD/qdeclarativepixmapcache.cpp \ $$PWD/qnumberformat.cpp \ - $$PWD/qmlnumberformatter.cpp \ - $$PWD/qmldatetimeformatter.cpp \ - $$PWD/qmlbehavior.cpp \ - $$PWD/qmlfontloader.cpp \ - $$PWD/qmlstyledtext.cpp + $$PWD/qdeclarativenumberformatter.cpp \ + $$PWD/qdeclarativedatetimeformatter.cpp \ + $$PWD/qdeclarativebehavior.cpp \ + $$PWD/qdeclarativefontloader.cpp \ + $$PWD/qdeclarativestyledtext.cpp HEADERS += \ - $$PWD/qmlview.h \ + $$PWD/qdeclarativeutilmodule_p.h\ + $$PWD/qdeclarativeview.h \ $$PWD/qfxperf_p_p.h \ $$PWD/qperformancelog_p_p.h \ - $$PWD/qmlconnection_p.h \ - $$PWD/qmlpackage_p.h \ - $$PWD/qmlanimation_p.h \ - $$PWD/qmlanimation_p_p.h \ - $$PWD/qmlsystempalette_p.h \ - $$PWD/qmlspringfollow_p.h \ - $$PWD/qmleasefollow_p.h \ - $$PWD/qmlstate_p.h\ - $$PWD/qmlstateoperations_p.h \ - $$PWD/qmlpropertychanges_p.h \ - $$PWD/qmlstate_p_p.h\ - $$PWD/qmltransitionmanager_p_p.h \ - $$PWD/qmlstategroup_p.h \ - $$PWD/qmltransition_p.h \ - $$PWD/qmllistmodel_p.h\ - $$PWD/qmllistaccessor_p.h \ - $$PWD/qmlopenmetaobject_p.h \ - $$PWD/qmlnullablevalue_p_p.h \ - $$PWD/qmltimeline_p_p.h \ - $$PWD/qmltimer_p.h \ - $$PWD/qmlbind_p.h \ - $$PWD/qmlpropertymap.h \ - $$PWD/qmlpixmapcache_p.h \ + $$PWD/qdeclarativeconnection_p.h \ + $$PWD/qdeclarativepackage_p.h \ + $$PWD/qdeclarativeanimation_p.h \ + $$PWD/qdeclarativeanimation_p_p.h \ + $$PWD/qdeclarativesystempalette_p.h \ + $$PWD/qdeclarativespringfollow_p.h \ + $$PWD/qdeclarativeeasefollow_p.h \ + $$PWD/qdeclarativestate_p.h\ + $$PWD/qdeclarativestateoperations_p.h \ + $$PWD/qdeclarativepropertychanges_p.h \ + $$PWD/qdeclarativestate_p_p.h\ + $$PWD/qdeclarativetransitionmanager_p_p.h \ + $$PWD/qdeclarativestategroup_p.h \ + $$PWD/qdeclarativetransition_p.h \ + $$PWD/qdeclarativelistmodel_p.h\ + $$PWD/qdeclarativelistaccessor_p.h \ + $$PWD/qdeclarativeopenmetaobject_p.h \ + $$PWD/qdeclarativenullablevalue_p_p.h \ + $$PWD/qdeclarativetimeline_p_p.h \ + $$PWD/qdeclarativetimer_p.h \ + $$PWD/qdeclarativebind_p.h \ + $$PWD/qdeclarativepropertymap.h \ + $$PWD/qdeclarativepixmapcache_p.h \ $$PWD/qnumberformat_p.h \ - $$PWD/qmlnumberformatter_p.h \ - $$PWD/qmldatetimeformatter_p.h \ - $$PWD/qmlbehavior_p.h \ - $$PWD/qmlfontloader_p.h \ - $$PWD/qmlstyledtext_p.h + $$PWD/qdeclarativenumberformatter_p.h \ + $$PWD/qdeclarativedatetimeformatter_p.h \ + $$PWD/qdeclarativebehavior_p.h \ + $$PWD/qdeclarativefontloader_p.h \ + $$PWD/qdeclarativestyledtext_p.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns - SOURCES += $$PWD/qmlxmllistmodel.cpp - HEADERS += $$PWD/qmlxmllistmodel_p.h + SOURCES += $$PWD/qdeclarativexmllistmodel.cpp + HEADERS += $$PWD/qdeclarativexmllistmodel_p.h } |