diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-06-08 08:18:59 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-11 09:49:24 (GMT) |
commit | 15366ae05397cdf322e0a34e729eb5db2bae9c2a (patch) | |
tree | a4d93bb38e566be3240c6dac4b63f3ffb4d1c53a /src | |
parent | b3ff3392128c9c701b687887ef2c21b000209908 (diff) | |
download | Qt-15366ae05397cdf322e0a34e729eb5db2bae9c2a.zip Qt-15366ae05397cdf322e0a34e729eb5db2bae9c2a.tar.gz Qt-15366ae05397cdf322e0a34e729eb5db2bae9c2a.tar.bz2 |
add parent and id properties to QGraphicsObject
In addition added documentation for the other properties.
Reviewed-by: Andreas
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 73 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.h | 6 |
2 files changed, 76 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3622c82..0390a83 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -959,6 +959,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) // Deliver post-change notification q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant); + + if (isObject) + emit static_cast<QGraphicsObject *>(q)->parentChanged(); } /*! @@ -1213,6 +1216,20 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const /*! \since 4.4 + Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item + is not a QGraphicsObject. + + \sa parentItem(), childItems() +*/ +QGraphicsObject *QGraphicsItem::parentObject() const +{ + QGraphicsItem *p = d_ptr->parent; + return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0; +} + +/*! + \since 4.4 + Returns a pointer to the item's parent widget. The item's parent widget is the closest parent item that is a widget. @@ -6417,6 +6434,14 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent } /*! + \property QGraphicsObject::parent + \brief the parent of the item + + \sa QGraphicsItem::setParentItem, QGraphicsItem::parentObject +*/ + + +/*! \property QGraphicsObject::opacity \brief the opacity of the item @@ -6441,13 +6466,57 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent */ /*! - \fn QGraphicsObject::positionChanged() + \property QGraphicsObject::x + \brief the x position of the item + + Describes the items x position. + + \sa QGraphicsItem::setX, setPos, xChanged +*/ + +/*! + \fn QGraphicsObject::xChanged() + + This signal gets emitted whenever the x position of the item changes + + \sa pos +*/ + +/*! + \property QGraphicsObject:y + \brief the y position of the item + + Describes the items y position. + + \sa QGraphicsItem::setY, setPos, yChanged +*/ + +/*! + \fn QGraphicsObject::yChanged() + + This signal gets emitted whenever the y position of the item changes + + \sa pos +*/ + +/*! + \property QGraphicsObject::z + \brief the z value of the item - This signal gets emitted whenever the position of the item changes + Describes the items z value. + + \sa QGraphicsItem::setZValue, zValue, zChanged +*/ + +/*! + \fn QGraphicsObject::zChanged() + + This signal gets emitted whenever the z value of the item changes \sa pos */ + /*! \property QGraphicsObject::enabled \brief whether the item is enabled or not diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index a69eced..6ea17c2 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -151,6 +151,7 @@ public: QGraphicsItem *parentItem() const; QGraphicsItem *topLevelItem() const; + QGraphicsObject *parentObject() const; QGraphicsWidget *parentWidget() const; QGraphicsWidget *topLevelWidget() const; QGraphicsWidget *window() const; @@ -494,10 +495,12 @@ inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem { Q_OBJECT + Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) + Q_PROPERTY(QString id READ objectName WRITE setObjectName) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged) @@ -505,6 +508,7 @@ public: QGraphicsObject(QGraphicsItem *parent = 0); Q_SIGNALS: + void parentChanged(); void opacityChanged(); void visibleChanged(); void enabledChanged(); |