diff options
author | Martin Smith <msmith@trolltech.com> | 2009-05-05 11:22:41 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2009-05-05 11:22:41 (GMT) |
commit | 98e4bd5b79f0a7ecd1381408ba95a32ae700b43d (patch) | |
tree | a46914d23468b8169a8a9f589eb7e488a6026118 /src/declarative | |
parent | 4eaf3807b6010f1b50e194d44907818ed223b925 (diff) | |
parent | a2159968f0e8787e393bf56dfcec8df84599c34f (diff) | |
download | Qt-98e4bd5b79f0a7ecd1381408ba95a32ae700b43d.zip Qt-98e4bd5b79f0a7ecd1381408ba95a32ae700b43d.tar.gz Qt-98e4bd5b79f0a7ecd1381408ba95a32ae700b43d.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 29 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext_p.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 36 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p.h | 17 |
8 files changed, 61 insertions, 34 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 838da30..106d551 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -135,7 +135,7 @@ QFxImage::~QFxImage() This property contains the image currently being displayed by this item, which may be an empty pixmap if nothing is currently displayed. If this - property is set, the src property will be unset. This property is intended + property is set, the source property will be unset. This property is intended to be used only in C++, not in QML. */ QPixmap QFxImage::pixmap() const @@ -790,7 +790,7 @@ QFxImage::Status QFxImage::status() const } /*! - \qmlproperty string Image::src + \qmlproperty string Image::source Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 816260d..f0d23ee 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -461,8 +461,7 @@ QObject *QmlComponent::beginCreate(QmlContext *context) QmlContext *ctxt = new QmlContext(context, 0); - static_cast<QmlContextPrivate*>(ctxt->d_ptr)->component = d->cc; - static_cast<QmlContextPrivate*>(ctxt->d_ptr)->component->addref(); + static_cast<QmlContextPrivate*>(ctxt->d_ptr)->url = d->cc->url; ctxt->activate(); QmlVME vme; diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 30857ad..6330eda 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -42,7 +42,6 @@ #include <qmlcontext.h> #include <private/qmlcontext_p.h> #include <private/qmlengine_p.h> -#include <private/qmlcompiledcomponent_p.h> #include <qmlengine.h> #include <qscriptengine.h> @@ -54,7 +53,7 @@ QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() - : parent(0), engine(0), highPriorityCount(0), component(0) + : parent(0), engine(0), highPriorityCount(0) { } @@ -232,8 +231,6 @@ QmlContext::QmlContext(QmlContext *parentContext, QObject *parent) */ QmlContext::~QmlContext() { - Q_D(QmlContext); - if (d->component) d->component->release(); } @@ -344,7 +341,7 @@ QmlContext *QmlContext::activeContext() simply returned. If there is no containing component, an empty URL is returned. - \sa QmlEngine::componentUrl() + \sa QmlEngine::componentUrl(), setBaseUrl */ QUrl QmlContext::resolvedUrl(const QUrl &src) { @@ -352,14 +349,14 @@ QUrl QmlContext::resolvedUrl(const QUrl &src) if (src.isRelative()) { if (ctxt) { while(ctxt) { - if (ctxt->d_func()->component) + if(ctxt->d_func()->url.isValid()) break; else ctxt = ctxt->parentContext(); } if (ctxt) - return ctxt->d_func()->component->url.resolved(src); + return ctxt->d_func()->url.resolved(src); } return QUrl(); } else { @@ -373,7 +370,7 @@ QUrl QmlContext::resolvedUrl(const QUrl &src) \l {QmlEngine::nameSpacePaths()} {namespace paths} of the context's engine, returning the resolved URL. - \sa QmlEngine::componentUrl() + \sa QmlEngine::componentUrl(), setBaseUrl */ QUrl QmlContext::resolvedUri(const QUrl &src) { @@ -381,14 +378,14 @@ QUrl QmlContext::resolvedUri(const QUrl &src) if (src.isRelative()) { if (ctxt) { while(ctxt) { - if (ctxt->d_func()->component) + if (ctxt->d_func()->url.isValid()) break; else ctxt = ctxt->parentContext(); } if (ctxt) - return ctxt->d_func()->engine->componentUrl(src, ctxt->d_func()->component->url); + return ctxt->d_func()->engine->componentUrl(src, ctxt->d_func()->url); } return QUrl(); } else { @@ -396,6 +393,18 @@ QUrl QmlContext::resolvedUri(const QUrl &src) } } +/*! + Explicitly sets the url both resolveUri() and resolveUrl() will use for relative references. + + Calling this function will override the url of the containing component used by default. + + \sa resolvedUrl, resolvedUri +*/ +void QmlContext::setBaseUrl(const QUrl &baseUrl) +{ + d_func()->url = baseUrl; +} + void QmlContext::objectDestroyed(QObject *object) { Q_D(QmlContext); diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 9e3b6d8..39d565a 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -80,6 +80,8 @@ public: QUrl resolvedUri(const QUrl &); QUrl resolvedUrl(const QUrl &); + void setBaseUrl(const QUrl &); + private Q_SLOTS: void objectDestroyed(QObject *); diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 3772885..40848fb 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -69,7 +69,8 @@ public: QScriptValueList scopeChain; - QmlCompiledComponent *component; + QUrl url; + void init(); void dump(); diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 74ed27c..daca888 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -73,7 +73,6 @@ public: int version() const; QList<QmlError> errors() const; - QString loadError() const; bool load(QmlEngine *, const QByteArray &); QByteArray save() const; diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4b8ce4e..08a7a28 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -703,9 +703,10 @@ QColor QmlColorAnimation::from() const void QmlColorAnimation::setFrom(const QColor &f) { Q_D(QmlColorAnimation); - if (d->fromValue.isValid() && f == d->fromValue) + if (d->fromIsDefined && f == d->fromValue) return; d->fromValue = f; + d->fromIsDefined = f.isValid(); emit fromChanged(f); } @@ -726,9 +727,10 @@ QColor QmlColorAnimation::to() const void QmlColorAnimation::setTo(const QColor &t) { Q_D(QmlColorAnimation); - if (d->toValue.isValid() && t == d->toValue) + if (d->toIsDefined && t == d->toValue) return; d->toValue = t; + d->toIsDefined = t.isValid(); emit toChanged(t); } @@ -860,9 +862,13 @@ void QmlColorAnimation::transition(QmlStateActions &actions, (!target() || target() == obj)) { objs.insert(obj); Action myAction = action; - if (d->fromValue.isValid()) + + if (d->fromIsDefined) { myAction.fromValue = QVariant(d->fromValue); - if (d->toValue.isValid()) + } else { + myAction.fromValue = QVariant(); + } + if (d->toIsDefined) myAction.toValue = QVariant(d->toValue); modified << action.property; @@ -877,7 +883,7 @@ void QmlColorAnimation::transition(QmlStateActions &actions, Action myAction; myAction.property = QmlMetaProperty(obj, props.at(jj)); - if (d->fromValue.isValid()) + if (d->fromIsDefined) myAction.fromValue = QVariant(d->fromValue); myAction.toValue = QVariant(d->toValue); @@ -898,7 +904,7 @@ QVariantAnimation::Interpolator QmlColorAnimationPrivate::colorInterpolator = 0; void QmlColorAnimationPrivate::valueChanged(qreal v) { if (!fromSourced) { - if (!fromValue.isValid()) { + if (!fromIsDefined) { fromValue = qvariant_cast<QColor>(property.read()); } fromSourced = true; @@ -1993,9 +1999,10 @@ QVariant QmlVariantAnimation::from() const void QmlVariantAnimation::setFrom(const QVariant &f) { Q_D(QmlVariantAnimation); - if (d->from.isValid() && f == d->from) + if (d->fromIsDefined && f == d->from) return; d->from = f; + d->fromIsDefined = f.isValid(); emit fromChanged(f); } @@ -2017,9 +2024,10 @@ QVariant QmlVariantAnimation::to() const void QmlVariantAnimation::setTo(const QVariant &t) { Q_D(QmlVariantAnimation); - if (d->to.isValid() && t == d->to) + if (d->toIsDefined && t == d->to) return; d->to = t; + d->toIsDefined = t.isValid(); emit toChanged(t); } @@ -2109,7 +2117,7 @@ QList<QObject *> *QmlVariantAnimation::exclude() void QmlVariantAnimationPrivate::valueChanged(qreal r) { if (!fromSourced) { - if (!from.isValid()) { + if (!fromIsDefined) { from = property.read(); } fromSourced = true; @@ -2138,7 +2146,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) d->property = d->userProperty; d->convertVariant(d->to, (QVariant::Type)d->property.propertyType()); - if (d->from.isValid()) + if (d->fromIsDefined) d->convertVariant(d->from, (QVariant::Type)d->property.propertyType()); d->fromSourced = false; @@ -2198,12 +2206,12 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, objs.insert(obj); Action myAction = action; - if (d->from.isValid()) { + if (d->fromIsDefined) { myAction.fromValue = d->from; } else { myAction.fromValue = QVariant(); } - if (d->to.isValid()) + if (d->toIsDefined) myAction.toValue = d->to; d->convertVariant(myAction.fromValue, (QVariant::Type)myAction.property.propertyType()); @@ -2216,13 +2224,13 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, } } - if (d->to.isValid() && target() && !objs.contains(target())) { + if (d->toIsDefined && target() && !objs.contains(target())) { QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; myAction.property = QmlMetaProperty(obj, props.at(jj)); - if (d->from.isValid()) { + if (d->fromIsDefined) { d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType()); myAction.fromValue = d->from; } diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 4fcaa47..06b7c08 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -203,7 +203,8 @@ class QmlColorAnimationPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlColorAnimation); public: QmlColorAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), ca(0), value(this, &QmlColorAnimationPrivate::valueChanged) + : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), + ca(0), value(this, &QmlColorAnimationPrivate::valueChanged) { if (!colorInterpolator) colorInterpolator = QVariantAnimationPrivate::getInterpolator(QVariant::Color); @@ -213,11 +214,16 @@ public: QString easing; + QColor fromValue; + QColor toValue; + QList<QObject *> filter; QList<QObject *> exclude; + bool fromSourced; - QColor fromValue; - QColor toValue; + bool fromIsDefined; + bool toIsDefined; + QmlTimeLineValueAnimator *ca; virtual void valueChanged(qreal); @@ -350,7 +356,8 @@ class QmlVariantAnimationPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlVariantAnimation); public: QmlVariantAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} + : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), + va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} void init(); @@ -364,6 +371,8 @@ public: QList<QObject *> exclude; bool fromSourced; + bool fromIsDefined; + bool toIsDefined; QmlTimeLineValueAnimator *va; virtual void valueChanged(qreal); |