summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-08-19 00:05:55 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-08-19 00:05:55 (GMT)
commit0e1d095a281e204d31217f1e5af6f3a796a89169 (patch)
treedc78b84ad1dd8bc1688a93f1b6e2a01466ebc475
parent0a6386075faee6c1438b3ca871c0658269ff6afd (diff)
parent42291f03e1a6083dd3459224226a90717299f26e (diff)
downloadQt-0e1d095a281e204d31217f1e5af6f3a796a89169.zip
Qt-0e1d095a281e204d31217f1e5af6f3a796a89169.tar.gz
Qt-0e1d095a281e204d31217f1e5af6f3a796a89169.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/flickr/flickr.qml2
-rw-r--r--demos/declarative/flickr/flickr2.qml2
-rw-r--r--examples/declarative/flowview/flowview.qml4
-rw-r--r--src/declarative/qml/qmlcontext.cpp18
-rw-r--r--src/declarative/qml/qmlcontext.h3
-rw-r--r--src/declarative/qml/qmldom.cpp4
-rw-r--r--src/declarative/qml/qmldom.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp5
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp20
-rw-r--r--src/declarative/qml/qmlmetatype.cpp23
-rw-r--r--src/declarative/qml/qmlmetatype.h5
-rw-r--r--src/declarative/util/qmlanimation.cpp45
-rw-r--r--src/declarative/util/qmlanimation.h13
-rw-r--r--src/declarative/util/qmlanimation_p.h5
14 files changed, 89 insertions, 62 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/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 009c799..365c0e8 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -454,4 +454,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/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<QmlDomProperty> properties() const;
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<const QMetaObject *, QString> 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 <qml.h>
#include <private/qfxperf_p.h>
#include <QStringList>
@@ -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;
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<QByteArray> QmlMetaType::qmlTypeNames()
return data->nameToType.keys();
}
+QList<QmlType*> 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<QByteArray> qmlTypeNames();
+ static QList<QmlType*> 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;
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<Item> SetPropertyAction::filter
+ \qmlproperty list<Item> SetPropertyAction::targets
This property holds the items selected to be affected by this animation (all if not set).
\sa exclude
*/
-QList<QObject *> *QmlSetPropertyAction::filter()
+QList<QObject *> *QmlSetPropertyAction::targets()
{
Q_D(QmlSetPropertyAction);
- return &d->filter;
+ return &d->targets;
}
/*!
\qmlproperty list<Item> SetPropertyAction::exclude
This property holds the items not to be affected by this animation.
- \sa filter
+ \sa targets
*/
QList<QObject *> *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<Item> PropertyAnimation::filter
+ \qmlproperty list<Item> PropertyAnimation::targets
This property holds the items selected to be affected by this animation (all if not set).
\sa exclude
*/
-QList<QObject *> *QmlPropertyAnimation::filter()
+QList<QObject *> *QmlPropertyAnimation::targets()
{
Q_D(QmlPropertyAnimation);
- return &d->filter;
+ return &d->targets;
}
/*!
\qmlproperty list<Item> PropertyAnimation::exclude
This property holds the items not to be affected by this animation.
- \sa filter
+ \sa targets
*/
QList<QObject *> *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<QObject *>* filter READ filter)
+ Q_PROPERTY(QList<QObject *>* targets READ targets)
Q_PROPERTY(QList<QObject *>* 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<QObject *> *filter();
+ QList<QObject *> *targets();
QList<QObject *> *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<QObject *>* filter READ filter)
+ Q_PROPERTY(QList<QObject *>* targets READ targets)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
public:
@@ -272,7 +267,7 @@ public:
QString properties() const;
void setProperties(const QString &);
- QList<QObject *> *filter();
+ QList<QObject *> *targets();
QList<QObject *> *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<QObject *> filter;
+ QList<QObject *> targets;
QList<QObject *> exclude;
QmlNullableValue<QVariant> value;
@@ -330,7 +329,7 @@ public:
QString easing;
QString properties;
- QList<QObject *> filter;
+ QList<QObject *> targets;
QList<QObject *> exclude;
bool fromSourced;