summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-04-24 03:25:13 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-04-24 03:25:13 (GMT)
commit6ef6a8184ebb969f951a7c55127e9445eba64d35 (patch)
tree0bb0d3e549573c3e5769896ae655e7743c78de09 /src/declarative
parentce1d3e9118494e535fb3c1b4e34d8feced7afdd1 (diff)
parent53fd3ca280c85572d5f38e0f2809e7601578d41e (diff)
downloadQt-6ef6a8184ebb969f951a7c55127e9445eba64d35.zip
Qt-6ef6a8184ebb969f951a7c55127e9445eba64d35.tar.gz
Qt-6ef6a8184ebb969f951a7c55127e9445eba64d35.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/canvas/qsimplecanvasitem.cpp15
-rw-r--r--src/declarative/extra/qmlnumberformatter.cpp1
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp29
-rw-r--r--src/declarative/fx/qfxitem.cpp25
-rw-r--r--src/declarative/fx/qfxitem.h4
-rw-r--r--src/declarative/fx/qfxpainted.cpp10
-rw-r--r--src/declarative/fx/qfxparticles.cpp2
-rw-r--r--src/declarative/fx/qfxrect.cpp5
-rw-r--r--src/declarative/fx/qfxreflectionfilter.cpp3
-rw-r--r--src/declarative/fx/qfxrepeater.cpp8
-rw-r--r--src/declarative/fx/qfxtext.cpp2
-rw-r--r--src/declarative/fx/qfxtextedit.cpp4
-rw-r--r--src/declarative/fx/qfxtransform.cpp5
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.cpp2
-rw-r--r--src/declarative/qml/qmlengine.cpp16
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp250
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h8
-rw-r--r--src/declarative/util/qbindablemap.cpp3
-rw-r--r--src/declarative/util/qmlfollow.cpp16
-rw-r--r--src/declarative/util/qmlfollow.h6
20 files changed, 302 insertions, 112 deletions
diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp
index 5e4b5fa..95f7623 100644
--- a/src/declarative/canvas/qsimplecanvasitem.cpp
+++ b/src/declarative/canvas/qsimplecanvasitem.cpp
@@ -443,7 +443,16 @@ void QSimpleCanvasItem::setZ(qreal z)
return;
if(d->graphicsItem) {
+
+ if(z < 0)
+ d->graphicsItem->setFlag(QGraphicsItem::ItemStacksBehindParent,
+ true);
+ else
+ d->graphicsItem->setFlag(QGraphicsItem::ItemStacksBehindParent,
+ false);
+
d->graphicsItem->setZValue(z);
+
} else {
if(d->data()->z == z)
return;
@@ -626,12 +635,8 @@ void QSimpleCanvasItem::addChild(QSimpleCanvasItem *c)
{
Q_D(QSimpleCanvasItem);
d->children.append(c);
- if(d->graphicsItem) {
- // XXX - GraphicsView does not preserve the stacking order of items
- c->setZ(d->children.count());
- } else {
+ if(!d->graphicsItem)
d->needsZOrder = true;
- }
childrenChanged();
}
diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp
index 60b154d..8772305 100644
--- a/src/declarative/extra/qmlnumberformatter.cpp
+++ b/src/declarative/extra/qmlnumberformatter.cpp
@@ -78,6 +78,7 @@ public:
*/
/*!
+ \internal
\class QmlNumberFormatter
\ingroup group_utility
\brief The QmlNumberFormatter class allows you to format a number to a particular string format/locale specific number format.
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index 9a3bb72..b5d9a9a 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -49,12 +49,24 @@
QT_BEGIN_NAMESPACE
/*!
+ \qmlclass BlendedImage
+ \brief The BlendedImage elements blends two different images depending on a blend ratio.
+
+ This element can be used to simulate blur on slow devices by setting secondaryUrl with
+ a pre-rendered blurred version of primaryUrl.
+
+ Note that this class will only work under OpenGL. On the software canvas it will display
+ only the primary image unless the blend is > 0.75, in which case it will display only the
+ secondary image.
+*/
+
+/*!
\internal
\class QFxBlendedImage
\brief The QFxBlendedImage blends two different images depending on a blend ratio.
- This class can be used to simulate blur on slow devices by setting secondaryFile with
- a pre-rendered blurred version of primaryFile.
+ This class can be used to simulate blur on slow devices by setting secondaryUrl with
+ a pre-rendered blurred version of primaryUrl.
Note that this class will only work under OpenGL. On the software canvas it will display
only the primary image unless the blend is > 0.75, in which case it will display only the
@@ -69,8 +81,8 @@ QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
}
/*!
- \property QFxBlendedImage::primaryUrl
- \brief the URL of the first image to be displayed in this item.
+ \qmlproperty string BlendedImage::primaryUrl
+ The URL of the first image to be displayed in this item.
*/
QString QFxBlendedImage::primaryUrl() const
{
@@ -97,8 +109,8 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url)
}
/*!
- \property QFxBlendedImage::secondaryUrl
- \brief the URL of the second image to be displayed in this item.
+ \qmlproperty string BlendedImage::secondaryUrl
+ The URL of the second image to be displayed in this item.
*/
QString QFxBlendedImage::secondaryUrl() const
{
@@ -125,8 +137,8 @@ void QFxBlendedImage::setSecondaryUrl(const QString &url)
}
/*!
- \property QFxBlendedImage::blend
- \brief the ratio used to blend the two images.
+ \qmlproperty real BlendedImage::blend
+ The ratio used to blend the two images.
If blend has a value of 0, only the first image will be displayed.
If blend has a value of 1, only the second image will be displayed.
@@ -246,4 +258,5 @@ void QFxBlendedImage::paintGLContents(GLPainter &p)
#endif
QML_DEFINE_TYPE(QFxBlendedImage,BlendedImage);
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index ed65b84..9131256 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -838,23 +838,6 @@ void QFxItem::qmlLoaded()
}
/*!
- \qmlproperty Item Item::clipToItem
-
- Experimental clip to item support. Do not use.
-
- \todo complete clip to item support.
- */
-QFxItem *QFxItem::clipToItem() const
-{
- return 0;
-}
-
-void QFxItem::setClipToItem(QFxItem *)
-{
- qWarning() << "QFxItem: clipToItem not implemented";
-}
-
-/*!
\qmlproperty real Item::x
\qmlproperty real Item::y
\qmlproperty int Item::width
@@ -1361,7 +1344,7 @@ void QFxItem::setScale(qreal s)
Opacity is an \e inherited attribute. That is, the opacity is
also applied individually to child items. In almost all cases this
is what you want. If you can spot the issue in the following
- example, you might need to use an opacity filter instead.
+ example, you might need to use an opacity filter (not yet available) instead.
\table
\row
@@ -1385,8 +1368,6 @@ void QFxItem::setScale(qreal s)
</Item>
\endqml
\endtable
-
- \todo There is no such thing as an opacity filter
*/
qreal QFxItem::opacity() const
@@ -1488,8 +1469,8 @@ QmlList<QmlTransition *>* QFxItem::transitions()
\qmlproperty list<Filter> Item::filter
This property holds a list of graphical filters to be applied to the item.
- \l {qmlfilter}{Filters} include things like \l {qmlblur}{blurring}
- the item, or giving it a Reflection. Some
+ \l {Filter}{Filters} include things like \l {Blur}{blurring}
+ the item, or giving it a \l Reflection. Some
filters may not be available on all canvases; if a filter is not
available on a certain canvas, it will simply not be applied for
that canvas (but the XML will still be considered valid).
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index d3b9899..c47a1e1 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -113,7 +113,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QString qml READ qml WRITE setQml NOTIFY qmlChanged)
Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged)
- Q_PROPERTY(QFxItem *clipToItem READ clipToItem WRITE setClipToItem)
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged)
Q_PROPERTY(qreal z READ z WRITE setZ)
@@ -174,9 +173,6 @@ public:
QString qml() const;
void setQml(const QString &);
- QFxItem *clipToItem() const;
- void setClipToItem(QFxItem *i);
-
bool flipVertically() const;
void setFlipVertically(bool);
bool flipHorizontally() const;
diff --git a/src/declarative/fx/qfxpainted.cpp b/src/declarative/fx/qfxpainted.cpp
index 8109efa..ad1b3ad 100644
--- a/src/declarative/fx/qfxpainted.cpp
+++ b/src/declarative/fx/qfxpainted.cpp
@@ -77,13 +77,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- Constructs the painted item.
+ Constructs a painted item with parent object \a parent.
*/
-
-//### what options do we need to set?
QFxPainted::QFxPainted(QFxItem *parent)
: QFxItem(*(new QFxPaintedPrivate), parent)
{
+ //### what options do we need to set?
setOptions(HasContents, true);
}
@@ -105,8 +104,9 @@ QFxPainted::QFxPainted(QFxPaintedPrivate &dd, QFxItem *parent)
/*!
\fn QFxPainted::paint(QPainter *painter)
- Implement this method to paint the item. The painting will be cached and
- paint() will only be called again if \l markDirty() has been called.
+ Implement this method to paint the item using \a painter.
+ The painting will be cached and paint() will only be called again
+ if \l markDirty() has been called.
\sa markDirty()
*/
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 939afba..9319c46 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -917,7 +917,7 @@ void QFxParticles::setStreamIn(bool b)
will be produced until it is set to true.
*/
/*!
- \property bool Particles::emitting
+ \property QFxParticles::emitting
If emitting is set to false no new particles will be created. This means that
when a particle reaches the end of its lifespan it is not replaced. This
property can be used to turn particles on and off with a more natural look.
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index 2e84c74..a761ec5 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -70,10 +70,7 @@ QML_DEFINE_TYPE(QFxPen,Pen);
\brief the color of the pen.
color is most commonly specified in hexidecimal notation (#RRGGBB)
- or as an
- \htmlonly
- <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords"> SVG color keyword name</a>
- \endhtmlonly
+ or as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword name}
(as defined by the World Wide Web Consortium). For example:
\code
<!-- rect with green border using hexidecimal notation -->
diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp
index d67095b..39342d7 100644
--- a/src/declarative/fx/qfxreflectionfilter.cpp
+++ b/src/declarative/fx/qfxreflectionfilter.cpp
@@ -103,9 +103,6 @@ public:
Reflection is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
Otherwise the Reflection filter has no effect.
-
- \todo describe (and fix) reflection and bounding box interaction
-
*/
/*!
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index ec1d88c..570d54d 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -110,13 +110,7 @@ QML_DEFINE_TYPE(QFxRepeater,Repeater);
The repeater instance continues to own all items it instantiates, even
if they are otherwise manipulated. It is illegal to manually remove an item
- created by the Repeater.
-
- \todo Repeater is very conservative in how it instatiates/deletes items.
- Also new model entries will not be created and old ones will not be removed.
-
- \todo Need an example
-
+ created by the Repeater.
*/
/*!
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index bc03d7c..e7085d8 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -85,8 +85,6 @@ QML_DEFINE_TYPE(QFxText,Text);
plain text to a set width.
Text provides read-only text. For editable text, see \l TextEdit.
-
- \todo explain details of auto-sizing
*/
/*!
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 96ebe0d..7efb826 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -294,7 +294,7 @@ void QFxTextEdit::setColor(const QColor &color)
*/
/*!
- \property QFxText::hAlign
+ \property QFxTextEdit::hAlign
\brief the horizontal alignment of the text.
Valid values are \c AlignLeft, \c AlignRight, and \c AlignHCenter. The default value is \c AlignLeft.
@@ -316,7 +316,7 @@ void QFxTextEdit::setHAlign(QFxTextEdit::HAlignment alignment)
}
/*!
- \property QFxText::vAlign
+ \property QFxTextEdit::vAlign
\brief the vertical alignment of the text.
Valid values are \c AlignTop, \c AlignBottom, and \c AlignVCenter. The default value is \c AlignTop.
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 90875a6..a001214 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -56,8 +56,6 @@ QML_DEFINE_TYPE(QFxTransform,Transform);
/*!
\qmlclass Transform
\brief A transformation.
-
- \todo Document Transform.
*/
QFxTransform::QFxTransform(QObject *parent) :
QObject(parent)
@@ -334,9 +332,6 @@ public:
\endcode
\image flipable.gif
-
- \todo A lot needs to be done to get a fully-functioning Flipable. Should we simplify?
-
*/
/*!
diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp
index 44ccf0f..f86c8dc 100644
--- a/src/declarative/fx/qfxwidgetcontainer.cpp
+++ b/src/declarative/fx/qfxwidgetcontainer.cpp
@@ -73,7 +73,7 @@ QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const
}
/*!
- \property QGraphicsWidget QFxWidgetContainer::graphicsWidget
+ \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget
The QGraphicsWidget associated with this element.
*/
void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget)
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 63f45b4..5cbd02b 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -39,11 +39,7 @@
**
****************************************************************************/
-// XXX ;)
-#define private public
#include <QMetaProperty>
-#undef private
-
#include <private/qmlengine_p.h>
#include <private/qmlcontext_p.h>
@@ -308,7 +304,7 @@ bool QmlEnginePrivate::fetchCache(QmlBasicScriptNodeCache &cache, const QString
cache.object = obj;
cache.type = QmlBasicScriptNodeCache::Core;
- cache.core = prop.property().idx + prop.property().mobj->propertyOffset();
+ cache.core = prop.property().propertyIndex();
cache.coreType = prop.propertyType();
return true;
@@ -465,7 +461,7 @@ QmlContext *QmlEngine::activeContext()
/*!
Sets the mappings from namespace URIs to URL to \a map.
- \sa nameSpacePaths
+ \sa nameSpacePaths()
*/
void QmlEngine::setNameSpacePaths(const QMap<QString,QString>& map)
{
@@ -476,7 +472,7 @@ void QmlEngine::setNameSpacePaths(const QMap<QString,QString>& map)
/*!
Adds mappings (given by \a map) from namespace URIs to URL.
- \sa nameSpacePaths
+ \sa nameSpacePaths()
*/
void QmlEngine::addNameSpacePaths(const QMap<QString,QString>& map)
{
@@ -487,7 +483,7 @@ void QmlEngine::addNameSpacePaths(const QMap<QString,QString>& map)
/*!
Adds a mapping from namespace URI \a ns to URL \a path.
- \sa nameSpacePaths
+ \sa nameSpacePaths()
*/
void QmlEngine::addNameSpacePath(const QString& ns, const QString& path)
{
@@ -525,7 +521,7 @@ void QmlEngine::addNameSpacePath(const QString& ns, const QString& path)
In the above case, "xyz://abc/def/Bar.qml" would then map to
"file:///opt/jkl/def/Bar.qml".
- \sa componentUrl
+ \sa componentUrl()
*/
QMap<QString,QString> QmlEngine::nameSpacePaths() const
{
@@ -537,7 +533,7 @@ QMap<QString,QString> QmlEngine::nameSpacePaths() const
Returns the URL for the component source \a src, as mapped
by the nameSpacePaths(), resolved relative to \a baseUrl.
- \sa nameSpacePaths
+ \sa nameSpacePaths()
*/
QUrl QmlEngine::componentUrl(const QUrl& src, const QUrl& baseUrl) const
{
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 79db6ce..30e0bbc 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -231,22 +231,28 @@ QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other)
*/
QmlMetaProperty::PropertyCategory QmlMetaProperty::propertyCategory() const
{
- if(d->category == Unknown) {
+ return d->propertyCategory();
+}
+
+QmlMetaProperty::PropertyCategory
+QmlMetaPropertyPrivate::propertyCategory() const
+{
+ if(category == QmlMetaProperty::Unknown) {
int type = propertyType();
- if(!isValid())
- d->category = InvalidProperty;
+ if(type == QmlMetaProperty::Invalid)
+ category = QmlMetaProperty::InvalidProperty;
else if(type == qMetaTypeId<QmlBindableValue *>())
- d->category = Bindable;
+ category = QmlMetaProperty::Bindable;
else if(QmlMetaType::isList(type))
- d->category = List;
+ category = QmlMetaProperty::List;
else if(QmlMetaType::isQmlList(type))
- d->category = QmlList;
+ category = QmlMetaProperty::QmlList;
else if(QmlMetaType::isObject(type))
- d->category = Object;
+ category = QmlMetaProperty::Object;
else
- d->category = Normal;
+ category = QmlMetaProperty::Normal;
}
- return d->category;
+ return category;
}
/*!
@@ -310,14 +316,19 @@ bool QmlMetaProperty::operator==(const QmlMetaProperty &other) const
*/
int QmlMetaProperty::propertyType() const
{
+ return d->propertyType();
+}
+
+int QmlMetaPropertyPrivate::propertyType() const
+{
int rv = QVariant::Invalid;
- if(d->prop.name()) {
- if(d->propType == (int)QVariant::LastType)
+ if(prop.name()) {
+ if(propType == (int)QVariant::LastType)
rv = qMetaTypeId<QVariant>();
else
- rv = d->propType;
- } else if(d->attachedFunc) {
+ rv = propType;
+ } else if(attachedFunc) {
rv = qMetaTypeId<QObject *>();
}
@@ -532,34 +543,207 @@ QVariant QmlMetaProperty::read() const
}
Q_DECLARE_METATYPE(QList<QObject *>);
-/*!
- Set the property value to \a value.
-*/
-void QmlMetaProperty::write(const QVariant &value) const
+
+void QmlMetaPropertyPrivate::writeSignalProperty(const QVariant &value)
{
- if(type() & SignalProperty) {
+ QString expr = value.toString();
+ const QObjectList &children = object->children();
+
+ for(int ii = 0; ii < children.count(); ++ii) {
+ QmlBoundSignal *sig = qobject_cast<QmlBoundSignal *>(children.at(ii));
+ if(sig && sig->index() == coreIdx) {
+ if(expr.isEmpty()) {
+ sig->disconnect();
+ sig->deleteLater();
+ } else {
+ sig->setExpression(expr);
+ }
+ return;
+ }
+ }
- QString expr = value.toString();
- const QObjectList &children = object()->children();
+ if(!expr.isEmpty()) {
+ // XXX scope
+ (void *)new QmlBoundSignal(QmlContext::activeContext(), expr, object,
+ coreIdx, object);
+ }
+}
- for(int ii = 0; ii < children.count(); ++ii) {
- QmlBoundSignal *sig = qobject_cast<QmlBoundSignal *>(children.at(ii));
- if(sig && sig->index() == d->coreIdx) {
- if(expr.isEmpty()) {
- sig->disconnect();
- sig->deleteLater();
- } else {
- sig->setExpression(expr);
+void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value)
+{
+ if(prop.isEnumType()) {
+ QVariant v = value;
+ if (value.type() == QVariant::Double) { //enum values come through the script engine as doubles
+ double integral;
+ double fractional = modf(value.toDouble(), &integral);
+ if (qFuzzyCompare(fractional, (double)0.0))
+ v.convert(QVariant::Int);
+ }
+ prop.write(object, v);
+ } else {
+ if(!value.isValid())
+ return;
+
+ int t = propertyType();
+ int vt = value.type();
+
+ if(vt == t ||
+ value.userType() == t) {
+
+ void *a[1];
+ a[0] = (void *)value.constData();
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+
+ } else if(qMetaTypeId<QVariant>() == t) {
+
+ prop.write(object, value);
+
+ } else if(propertyCategory() == QmlMetaProperty::Object) {
+
+ QObject *o = QmlMetaType::toQObject(value);
+ if(o)
+ prop.write(object, QmlMetaType::fromObject(o, propertyType()));
+
+ } else if (propertyCategory() == QmlMetaProperty::List) {
+
+ int listType = QmlMetaType::listType(t);
+ if(value.userType() == qMetaTypeId<QList<QObject *> >()) {
+ const QList<QObject *> &list =
+ qvariant_cast<QList<QObject *> >(value);
+ QVariant listVar = prop.read(object);
+ QmlMetaType::clear(listVar);
+ for(int ii = 0; ii < list.count(); ++ii) {
+ QVariant v = QmlMetaType::fromObject(list.at(ii), listType);
+ QmlMetaType::append(listVar, v);
+ }
+
+ } else if(vt == listType ||
+ value.userType() == listType) {
+ QVariant listVar = prop.read(object);
+ if (!QmlMetaType::append(listVar, value)) {
+ qWarning() << "QmlMetaProperty: Unable to assign object to list";
}
- return;
}
- }
+ } else if (propertyCategory() == QmlMetaProperty::QmlList) {
+ // XXX - optimize!
+ QVariant list = prop.read(object);
+ QmlPrivate::ListInterface *li =
+ *(QmlPrivate::ListInterface **)list.constData();
+
+ int type = li->type();
+
+ if (QObject *obj = QmlMetaType::toQObject(value)) {
+ const QMetaObject *mo =
+ QmlMetaType::rawMetaObjectForType(type);
+
+ const QMetaObject *objMo = obj->metaObject();
+ bool found = false;
+ while(!found && objMo) {
+ if(objMo == mo)
+ found = true;
+ else
+ objMo = objMo->superClass();
+ }
+
+ if(!found) {
+ qWarning() << "Unable to assign object to list";
+ return;
+ }
+
+ // NOTE: This assumes a cast to QObject does not alter
+ // the object pointer
+ void *d = (void *)&obj;
+ li->append(d);
+ }
+ } else if(propertyCategory() == QmlMetaProperty::Normal) {
+
+ switch(t) {
+ case QVariant::Double:
+ {
+ qreal r;
+ bool found = true;
+ if(vt == QVariant::Int) {
+ r = value.toInt();
+ } else if(vt == QVariant::UInt) {
+ r = value.toUInt();
+ } else {
+ found = false;
+ }
- if(!expr.isEmpty()) {
- // XXX scope
- (void *)new QmlBoundSignal(QmlContext::activeContext(), expr, object(), d->coreIdx, object());
+ if(found) {
+ void *a[1];
+ a[0] = &r;
+ QMetaObject::metacall(object,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ return;
+ }
+ }
+ break;
+
+ case QVariant::Int:
+ {
+ int i;
+ bool found = true;
+ if(vt == QVariant::Double) {
+ i = (int)value.toDouble();
+ } else if(vt == QVariant::UInt) {
+ i = (int)value.toUInt();
+ } else {
+ found = false;
+ }
+
+ if(found) {
+ void *a[1];
+ a[0] = &i;
+ QMetaObject::metacall(object,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ return;
+ }
+ }
+ break;
+
+ case QVariant::String:
+ {
+ QString s;
+ bool found = true;
+ if(vt == QVariant::ByteArray) {
+ s = QLatin1String(value.toByteArray());
+ } else {
+ found = false;
+ }
+
+ if(found) {
+ void *a[1];
+ a[0] = &s;
+ QMetaObject::metacall(object,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ return;
+ }
+ }
+ break;
+
+
+ default:
+ break;
+ }
+ prop.write(object, value);
}
+ }
+}
+
+/*!
+ Set the property value to \a value.
+*/
+void QmlMetaProperty::write(const QVariant &value) const
+{
+ if(type() & SignalProperty) {
+
+ d->writeSignalProperty(value);
+
} else if(d->prop.name()) {
if(d->prop.isEnumType()) {
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index 5c13f5e..1ea38e9 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -42,6 +42,8 @@
#ifndef QMLMETAPROPERTY_P_H
#define QMLMETAPROPERTY_P_H
+#include "qmlmetaproperty.h"
+
class QmlContext;
class QmlMetaPropertyPrivate
{
@@ -69,6 +71,12 @@ public:
QObject *attachedObject() const;
void findSignalInt(QObject *, const QString &);
+
+ int propertyType() const;
+ QmlMetaProperty::PropertyCategory propertyCategory() const;
+
+ void writeSignalProperty(const QVariant &);
+ void writeValueProperty(const QVariant &);
};
#endif // QMLMETAPROPERTY_P_H
diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp
index aea2a2c..341dd31 100644
--- a/src/declarative/util/qbindablemap.cpp
+++ b/src/declarative/util/qbindablemap.cpp
@@ -117,6 +117,9 @@ QBindableMap::QBindableMap(QObject *parent)
m_mo = new QBindableMapMetaObject(this);
}
+/*!
+ Destroys the bindable map.
+*/
QBindableMap::~QBindableMap()
{
}
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index c841b85..01d8962 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -52,6 +52,7 @@ QML_DEFINE_TYPE(QmlFollow,Follow);
class QmlFollowPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QmlFollow)
public:
QmlFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
@@ -86,6 +87,8 @@ public:
void QmlFollowPrivate::tick(int time)
{
+ Q_Q(QmlFollow);
+
int elapsed = time - lastTime;
if (!elapsed)
return;
@@ -133,6 +136,7 @@ void QmlFollowPrivate::tick(int time)
}
lastTime = time;
}
+ emit q->valueChanged(currentValue);
property.write(currentValue);
}
@@ -288,6 +292,11 @@ void QmlFollow::setDamping(qreal damping)
}
/*!
+ \qmlproperty qreal Follow::followValue
+ The current value.
+*/
+
+/*!
\qmlproperty bool Follow::enabled
This property holds whether the target will track the source.
*/
@@ -306,4 +315,11 @@ void QmlFollow::setEnabled(bool enabled)
else
d->stop();
}
+
+qreal QmlFollow::value() const
+{
+ Q_D(const QmlFollow);
+ return d->currentValue;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h
index a609305..aac4c01 100644
--- a/src/declarative/util/qmlfollow.h
+++ b/src/declarative/util/qmlfollow.h
@@ -65,6 +65,7 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource,
Q_PROPERTY(qreal damping READ damping WRITE setDamping);
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled);
+ Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged);
public:
QmlFollow(QObject *parent=0);
~QmlFollow();
@@ -81,6 +82,11 @@ public:
void setDamping(qreal damping);
bool enabled() const;
void setEnabled(bool enabled);
+
+ qreal value() const;
+
+Q_SIGNALS:
+ void valueChanged(qreal);
};
QML_DECLARE_TYPE(QmlFollow);