summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h5
2 files changed, 40 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 04c1f85..14f6b4a 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -237,7 +237,7 @@ QDeclarativeContents::~QDeclarativeContents()
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
continue;
- QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed);
}
}
@@ -333,7 +333,7 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item)
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
continue;
- QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed);
//###what about changes to visibility?
}
@@ -350,6 +350,30 @@ void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const
calcHeight(changed);
}
+void QDeclarativeContents::itemDestroyed(QDeclarativeItem *item)
+{
+ if (item)
+ QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed);
+ calcWidth();
+ calcHeight();
+}
+
+void QDeclarativeContents::childRemoved(QDeclarativeItem *item)
+{
+ if (item)
+ QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed);
+ calcWidth();
+ calcHeight();
+}
+
+void QDeclarativeContents::childAdded(QDeclarativeItem *item)
+{
+ if (item)
+ QDeclarativeItemPrivate::get(item)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed);
+ calcWidth(item);
+ calcHeight(item);
+}
+
QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item)
: m_next(0)
{
@@ -2551,6 +2575,16 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
}
}
break;
+ case ItemChildAddedChange:
+ if (d->_contents)
+ d->_contents->childAdded(qobject_cast<QDeclarativeItem*>(
+ value.value<QGraphicsItem*>()));
+ break;
+ case ItemChildRemovedChange:
+ if (d->_contents)
+ d->_contents->childRemoved(qobject_cast<QDeclarativeItem*>(
+ value.value<QGraphicsItem*>()));
+ break;
default:
break;
}
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 467d58a..516d6d0 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -90,12 +90,15 @@ public:
void setItem(QDeclarativeItem *item);
+ void childRemoved(QDeclarativeItem *item);
+ void childAdded(QDeclarativeItem *item);
+
Q_SIGNALS:
void rectChanged(QRectF);
protected:
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
- //void itemDestroyed(QDeclarativeItem *item);
+ void itemDestroyed(QDeclarativeItem *item);
//void itemVisibilityChanged(QDeclarativeItem *item)
private: