summaryrefslogtreecommitdiffstats
path: root/src/declarative/widgets
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-28 01:32:24 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-28 01:32:24 (GMT)
commit4927fb460e12ee8b4dada1025ad042d2b6b9b6f4 (patch)
tree512d035357c8b56859c01ca7d211b86ec986787d /src/declarative/widgets
parenteae3489b3f2fba9d733ca50eb89dc92a6e96e6f8 (diff)
downloadQt-4927fb460e12ee8b4dada1025ad042d2b6b9b6f4.zip
Qt-4927fb460e12ee8b4dada1025ad042d2b6b9b6f4.tar.gz
Qt-4927fb460e12ee8b4dada1025ad042d2b6b9b6f4.tar.bz2
Use QObject declarative data to store attached properties.
An element's qmlAttachedProperties() function will now only ever get called once per object.
Diffstat (limited to 'src/declarative/widgets')
-rw-r--r--src/declarative/widgets/graphicslayouts.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/declarative/widgets/graphicslayouts.cpp b/src/declarative/widgets/graphicslayouts.cpp
index 1ecde71..8e0081b 100644
--- a/src/declarative/widgets/graphicslayouts.cpp
+++ b/src/declarative/widgets/graphicslayouts.cpp
@@ -150,18 +150,17 @@ void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt:
QHash<QGraphicsLayoutItem*, QObject*> QGraphicsLinearLayoutObject::attachedProperties;
QObject *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj)
{
+ // ### This is not allowed - you must attach to any object
if (!qobject_cast<QGraphicsLayoutItem*>(obj))
return 0;
- if(!attachedProperties.contains(qobject_cast<QGraphicsLayoutItem*>(obj))) {
- LinearLayoutAttached *rv = new LinearLayoutAttached(obj);
- /*if (QGraphicsLinearLayoutObject *lo = qobject_cast<QGraphicsLinearLayoutObject*>(obj->parent()))
- QObject::connect(rv, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)),
- lo, SLOT(updateStretch(QGraphicsLayoutItem*,int)));
- QObject::connect(rv, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)),
- lo, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment)));*/
- attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
- }
- return attachedProperties.value(qobject_cast<QGraphicsLayoutItem*>(obj));
+ LinearLayoutAttached *rv = new LinearLayoutAttached(obj);
+ /*if (QGraphicsLinearLayoutObject *lo = qobject_cast<QGraphicsLinearLayoutObject*>(obj->parent()))
+ QObject::connect(rv, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)),
+ lo, SLOT(updateStretch(QGraphicsLayoutItem*,int)));
+ QObject::connect(rv, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)),
+ lo, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment)));*/
+ attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
+ return rv;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -311,13 +310,12 @@ qreal QGraphicsGridLayoutObject::spacing() const
QHash<QGraphicsLayoutItem*, QObject*> QGraphicsGridLayoutObject::attachedProperties;
QObject *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj)
{
+ // ### This is not allowed - you must attach to any object
if (!qobject_cast<QGraphicsLayoutItem*>(obj))
return 0;
- if(!attachedProperties.contains(qobject_cast<QGraphicsLayoutItem*>(obj))) {
- GridLayoutAttached *rv = new GridLayoutAttached(obj);
- attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
- }
- return attachedProperties.value(qobject_cast<QGraphicsLayoutItem*>(obj));
+ GridLayoutAttached *rv = new GridLayoutAttached(obj);
+ attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
+ return rv;
}
QT_END_NAMESPACE