From 0a74f871b21a9b7835fb1a5213bcac22ca1592cc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 18 Aug 2009 15:17:25 +1000 Subject: Rename filter to targets. --- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/flickr/flickr2.qml | 2 +- examples/declarative/flowview/flowview.qml | 4 +-- src/declarative/util/qmlanimation.cpp | 45 +++++++----------------------- src/declarative/util/qmlanimation.h | 13 +++------ src/declarative/util/qmlanimation_p.h | 5 ++-- 6 files changed, 20 insertions(+), 51 deletions(-) diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index a8d18fb..af2fda4 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -109,7 +109,7 @@ Item { SequentialAnimation { ParentChangeAction { } NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } - SetPropertyAction { filter: Wrapper; properties: "z" } + SetPropertyAction { target: Wrapper; properties: "z" } } } ] diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 5350a36..569f286 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -108,7 +108,7 @@ Item { SequentialAnimation { ParentChangeAction { } NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } - SetPropertyAction { filter: Wrapper; properties: "z" } + SetPropertyAction { target: Wrapper; properties: "z" } } } ] diff --git a/examples/declarative/flowview/flowview.qml b/examples/declarative/flowview/flowview.qml index a3d0ac5..8d1bdf6 100644 --- a/examples/declarative/flowview/flowview.qml +++ b/examples/declarative/flowview/flowview.qml @@ -25,8 +25,8 @@ Rect { fromState: "" ; toState: "rotated" reversible: true SequentialAnimation { - NumberAnimation { filter: [TopBar, BottomBar]; properties: "x,y"; easing: "easeInOutQuad" } - NumberAnimation { filter: [LeftBar, RightBar]; properties: "x,y"; easing: "easeInOutQuad"} + NumberAnimation { targets: [TopBar, BottomBar]; properties: "x,y"; easing: "easeInOutQuad" } + NumberAnimation { targets: [LeftBar, RightBar]; properties: "x,y"; easing: "easeInOutQuad"} } } diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 224f668..ee16fae 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -823,35 +823,10 @@ void QmlRunScriptAction::setScript(const QString &script) emit scriptChanged(script); } -/*! - \qmlproperty QString RunScript::script - This property holds the file containing the script to run. -*/ -QString QmlRunScriptAction::file() const -{ - Q_D(const QmlRunScriptAction); - return d->file; -} - -void QmlRunScriptAction::setFile(const QString &file) -{ - Q_D(QmlRunScriptAction); - if (file == d->file) - return; - d->file = file; - emit fileChanged(file); -} - void QmlRunScriptActionPrivate::execute() { Q_Q(QmlRunScriptAction); QString scriptStr = script; - if (!file.isEmpty()){ - QFile scriptFile(file); - if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)){ - scriptStr = QString::fromUtf8(scriptFile.readAll()); - } - } if (!scriptStr.isEmpty()) { QmlExpression expr(qmlContext(q), scriptStr, q); @@ -932,20 +907,20 @@ void QmlSetPropertyAction::setProperties(const QString &p) } /*! - \qmlproperty list SetPropertyAction::filter + \qmlproperty list SetPropertyAction::targets This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList *QmlSetPropertyAction::filter() +QList *QmlSetPropertyAction::targets() { Q_D(QmlSetPropertyAction); - return &d->filter; + return &d->targets; } /*! \qmlproperty list SetPropertyAction::exclude This property holds the items not to be affected by this animation. - \sa filter + \sa targets */ QList *QmlSetPropertyAction::exclude() { @@ -1040,7 +1015,7 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && (!target() || target() == obj || (!same && target() == sObj))) { @@ -1692,20 +1667,20 @@ void QmlPropertyAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list PropertyAnimation::filter + \qmlproperty list PropertyAnimation::targets This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList *QmlPropertyAnimation::filter() +QList *QmlPropertyAnimation::targets() { Q_D(QmlPropertyAnimation); - return &d->filter; + return &d->targets; } /*! \qmlproperty list PropertyAnimation::exclude This property holds the items not to be affected by this animation. - \sa filter + \sa targets */ QList *QmlPropertyAnimation::exclude() { @@ -1836,7 +1811,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)) || (useType && action.property.propertyType() == d->interpolatorType)) && diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 91c1898..ef7842c 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -163,7 +163,6 @@ class QmlRunScriptAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlRunScriptAction) Q_PROPERTY(QString script READ script WRITE setScript NOTIFY scriptChanged) - Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged) public: QmlRunScriptAction(QObject *parent=0); @@ -172,11 +171,7 @@ public: QString script() const; void setScript(const QString &); - QString file() const; - void setFile(const QString &); - Q_SIGNALS: - void fileChanged(const QString &); void scriptChanged(const QString &); protected: @@ -190,7 +185,7 @@ class QmlSetPropertyAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlSetPropertyAction) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* filter READ filter) + Q_PROPERTY(QList* targets READ targets) Q_PROPERTY(QList* exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) @@ -201,7 +196,7 @@ public: QString properties() const; void setProperties(const QString &); - QList *filter(); + QList *targets(); QList *exclude(); QVariant value() const; @@ -250,7 +245,7 @@ class QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* filter READ filter) + Q_PROPERTY(QList* targets READ targets) Q_PROPERTY(QList* exclude READ exclude) public: @@ -272,7 +267,7 @@ public: QString properties() const; void setProperties(const QString &); - QList *filter(); + QList *targets(); QList *exclude(); protected: diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 87d480f..3868255 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -230,7 +230,6 @@ public: void init(); QString script; - QString file; void execute(); @@ -249,7 +248,7 @@ public: void init(); QString properties; - QList filter; + QList targets; QList exclude; QmlNullableValue value; @@ -330,7 +329,7 @@ public: QString easing; QString properties; - QList filter; + QList targets; QList exclude; bool fromSourced; -- cgit v0.12 From 1ab70725f76433a0f601fdfd70abc55bd6228ac3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Aug 2009 09:05:07 +0200 Subject: Make qml metatype db fully discoverable again Allow access to all registered types, and also expose the exact version range a type is provided for. --- src/declarative/qml/qmlmetatype.cpp | 23 +++++++++++++++++++++++ src/declarative/qml/qmlmetatype.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 5ebe970..091bd1b 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -190,6 +190,21 @@ QmlType::~QmlType() delete d; } +int QmlType::majorVersion() const +{ + return d->m_version_maj; +} + +int QmlType::minMinorVersion() const +{ + return d->m_version_min_from; +} + +int QmlType::maxMinorVersion() const +{ + return d->m_version_min_to; +} + bool QmlType::availableInVersion(int vmajor, int vminor) const { return vmajor == d->m_version_maj && vminor >= d->m_version_min_from && vminor <= d->m_version_min_to; @@ -879,6 +894,14 @@ QList QmlMetaType::qmlTypeNames() return data->nameToType.keys(); } +QList QmlMetaType::qmlTypes() +{ + QReadLocker lock(metaTypeDataLock()); + QmlMetaTypeData *data = metaTypeData(); + + return data->nameToType.values(); +} + /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 94029ce..c388b1a 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -65,6 +65,7 @@ public: static bool copy(int type, void *data, const void *copy = 0); static QList qmlTypeNames(); + static QList qmlTypes(); static QmlType *qmlType(const QByteArray &, int, int); static QmlType *qmlType(const QMetaObject *); @@ -111,6 +112,10 @@ class Q_DECLARATIVE_EXPORT QmlType public: QByteArray typeName() const; QByteArray qmlTypeName() const; + + int majorVersion() const; + int minMinorVersion() const; + int maxMinorVersion() const; bool availableInVersion(int vmajor, int vminor) const; QByteArray hash() const; -- cgit v0.12 From 223746067a9a1b3f5c6195868b5e510311608ca1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 18 Aug 2009 17:59:31 +1000 Subject: Resolve attached property typenames in correct context. The imports of the component containing the reference to the attached property are used to resolve typenames, rather than assuming "Qt" namespace. --- src/declarative/qml/qmlcontext.cpp | 18 ++++++++++++++++++ src/declarative/qml/qmlcontext.h | 3 +++ src/declarative/qml/qmlengine.cpp | 5 ++++- src/declarative/qml/qmlmetaproperty.cpp | 20 +++++++++++++------- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 451dbcc..b73471a 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -451,4 +451,22 @@ void QmlContext::setBaseUrl(const QUrl &baseUrl) d_func()->url = baseUrl; } +/*! + Returns the base url of the component, or the containing component + if none is set. +*/ +QUrl QmlContext::baseUrl() const +{ + Q_D(const QmlContext); + const QmlContext* p = this; + while (p && p->d_func()->url.isEmpty()) { + p = p->parentContext(); + } + if (p) + return p->d_func()->url; + else + return QUrl(); +} + + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 70a81fc..65d711c 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -56,6 +56,8 @@ class QString; class QmlEngine; class QmlRefCount; class QmlContextPrivate; +class QmlCompositeTypeData; + class Q_DECLARATIVE_EXPORT QmlContext : public QObject { Q_OBJECT @@ -76,6 +78,7 @@ public: QUrl resolvedUrl(const QUrl &); void setBaseUrl(const QUrl &); + QUrl baseUrl() const; private: friend class QmlVME; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 6756642..558bd49 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -191,7 +191,10 @@ QmlEnginePrivate::queryObject(const QString &propName, { QScriptClass::QueryFlags rv = 0; - QmlMetaProperty prop(obj, propName, rootContext); + QmlContext *ctxt = QmlEngine::contextForObject(obj); + if (!ctxt) + ctxt = rootContext; + QmlMetaProperty prop(obj, propName, ctxt); if (prop.type() == QmlMetaProperty::Invalid) { QPair key = qMakePair(obj->metaObject(), propName); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index c1736cb..e69746e 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -41,6 +41,7 @@ #include "qmlmetaproperty.h" #include "qmlmetaproperty_p.h" +#include "qmlcompositetypedata_p.h" #include #include #include @@ -216,14 +217,19 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) if (name.isEmpty() || !obj) return; - if (name.at(0).isUpper()) { + if (enginePrivate && name.at(0).isUpper()) { // Attached property - // XXX name should be resolved with QmlEngine::resolveType(), not like this! - QmlType *t = QmlMetaType::qmlType("Qt/"+name.toLatin1(),-1,-1); - if (t && t->attachedPropertiesFunction()) { - attachedFunc = t->index(); - if (attachedFunc != -1) - type = QmlMetaProperty::Property | QmlMetaProperty::Attached; + QmlCompositeTypeData *typeData = + enginePrivate->typeManager.get(context->baseUrl()); + + if (typeData) { + QmlType *t = 0; + enginePrivate->resolveType(typeData->imports, name.toLatin1(), &t, 0); + if (t && t->attachedPropertiesFunction()) { + attachedFunc = t->index(); + if (attachedFunc != -1) + type = QmlMetaProperty::Property | QmlMetaProperty::Attached; + } } return; -- cgit v0.12 From 42291f03e1a6083dd3459224226a90717299f26e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Aug 2009 13:17:36 +0200 Subject: Fix documentation for QmlDomObject::className The name of this method is also misleading, maybe rename it to just QmlDomObject::name and QmlDomObject::objectType() to QmlDomObject::qualifiedName() ? --- src/declarative/qml/qmldom.cpp | 4 ++-- src/declarative/qml/qmldom.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index cdd5eef..2000e51 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -761,9 +761,9 @@ QByteArray QmlDomObject::objectType() const } /*! - Returns the fully-qualified type name of this object. + Returns the type name as referenced in the qml file. - For example, the type of this object would be "Qt/4.6/Rect". + For example, the type of this object would be "Rect". \qml Rect { } \endqml diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 1c70206..32ed2da 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -151,8 +151,8 @@ public: QByteArray objectType() const; QByteArray objectClassName() const; - QString objectId() const; + QString objectId() const; void setObjectId(const QByteArray &); QList properties() const; -- cgit v0.12