diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-06-04 10:14:55 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-11 09:49:24 (GMT) |
commit | e9876fdfaece0dcb09188cb4ddd5801ebb588647 (patch) | |
tree | ab117d204e9fda36cc9f922d63bfe5ab86c4d0cf /src/gui/graphicsview/qgraphicsitem.h | |
parent | 27f602b3c6075f7f664a7d3fd71f03f795f490fb (diff) | |
download | Qt-e9876fdfaece0dcb09188cb4ddd5801ebb588647.zip Qt-e9876fdfaece0dcb09188cb4ddd5801ebb588647.tar.gz Qt-e9876fdfaece0dcb09188cb4ddd5801ebb588647.tar.bz2 |
Add some meat to QGraphicsObject
Added a toGraphicsObject() method to QGraphicsItem to allow upcasting.
Expose some of QGraphicsItems setter/getter pairs as real properties
in QGraphicsObject, including NOTIFY signals.
Reviewed-by: Andreas
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.h | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 69aab20..a5ccef2 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -63,6 +63,7 @@ class QBrush; class QCursor; class QFocusEvent; class QGraphicsItemGroup; +class QGraphicsObject; class QGraphicsSceneContextMenuEvent; class QGraphicsSceneDragDropEvent; class QGraphicsSceneEvent; @@ -159,6 +160,9 @@ public: bool isWidget() const; bool isWindow() const; + QGraphicsObject *toGraphicsObject(); + const QGraphicsObject *toGraphicsObject() const; + QGraphicsItemGroup *group() const; void setGroup(QGraphicsItemGroup *group); @@ -484,6 +488,31 @@ inline QRectF QGraphicsItem::mapRectFromParent(qreal ax, qreal ay, qreal w, qrea inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal h) const { return mapRectFromScene(QRectF(ax, ay, w, h)); } + +class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsItem) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY positionChanged) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) +public: + QGraphicsObject(QGraphicsItem *parent = 0); + +Q_SIGNALS: + void opacityChanged(); + void visibleChanged(); + void enabledChanged(); + void positionChanged(); + +protected: + QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); +private: + friend class QGraphicsItem; +}; + + class QAbstractGraphicsShapeItemPrivate; class Q_GUI_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem { @@ -832,20 +861,6 @@ private: inline void QGraphicsPixmapItem::setOffset(qreal ax, qreal ay) { setOffset(QPointF(ax, ay)); } -class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible) -public: - QGraphicsObject(QGraphicsItem *parent = 0); -protected: - QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); -}; - class QGraphicsTextItemPrivate; class QTextDocument; class QTextCursor; |