diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-09-09 17:23:38 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-09-09 17:29:16 (GMT) |
commit | 3aff620eda8d0c2ba2fe6e0d8fa61709cc86b5f4 (patch) | |
tree | d622b4d2aa5c0bfac4536405af0a32f236d724b5 /src/svg | |
parent | a1bb5a4713f1b8e1afe4b0a085274a0c500319f2 (diff) | |
download | Qt-3aff620eda8d0c2ba2fe6e0d8fa61709cc86b5f4.zip Qt-3aff620eda8d0c2ba2fe6e0d8fa61709cc86b5f4.tar.gz Qt-3aff620eda8d0c2ba2fe6e0d8fa61709cc86b5f4.tar.bz2 |
Make QGraphicsSvgItem a QGraphicsObject.
This item was inheriting from QObject and QGraphicsItem so there is
no point to not make it a QGraphicsObject. I have added some properties
that was specific to this class, i.e. elementId.
Reviewed-by: ogoffart
Reviewed-by: andreas
Reviewed-by: bnilsen
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qgraphicssvgitem.cpp | 13 | ||||
-rw-r--r-- | src/svg/qgraphicssvgitem.h | 13 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/svg/qgraphicssvgitem.cpp b/src/svg/qgraphicssvgitem.cpp index 7176f37..ea26c78 100644 --- a/src/svg/qgraphicssvgitem.cpp +++ b/src/svg/qgraphicssvgitem.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -class QGraphicsSvgItemPrivate : public QObjectPrivate +class QGraphicsSvgItemPrivate : public QGraphicsItemPrivate { public: Q_DECLARE_PUBLIC(QGraphicsSvgItem) @@ -62,9 +62,10 @@ public: { } - void init() + void init(QGraphicsItem *parent) { Q_Q(QGraphicsSvgItem); + q->setParentItem(parent); renderer = new QSvgRenderer(q); QObject::connect(renderer, SIGNAL(repaintNeeded()), q, SLOT(_q_repaintItem())); @@ -137,10 +138,10 @@ public: Constructs a new SVG item with the given \a parent. */ QGraphicsSvgItem::QGraphicsSvgItem(QGraphicsItem *parent) - : QObject(*new QGraphicsSvgItemPrivate(), 0), QGraphicsItem(parent) + : QGraphicsObject(*new QGraphicsSvgItemPrivate(), 0, 0) { Q_D(QGraphicsSvgItem); - d->init(); + d->init(parent); } /*! @@ -148,10 +149,10 @@ QGraphicsSvgItem::QGraphicsSvgItem(QGraphicsItem *parent) SVG file with the specified \a fileName. */ QGraphicsSvgItem::QGraphicsSvgItem(const QString &fileName, QGraphicsItem *parent) - : QObject(*new QGraphicsSvgItemPrivate(), 0), QGraphicsItem(parent) + : QGraphicsObject(*new QGraphicsSvgItemPrivate(), 0, 0) { Q_D(QGraphicsSvgItem); - d->init(); + d->init(parent); d->renderer->load(fileName); d->updateDefaultSize(); } diff --git a/src/svg/qgraphicssvgitem.h b/src/svg/qgraphicssvgitem.h index 2d0e20b..e304c0c 100644 --- a/src/svg/qgraphicssvgitem.h +++ b/src/svg/qgraphicssvgitem.h @@ -41,7 +41,6 @@ #ifndef QGRAPHICSSVGITEM_H #define QGRAPHICSSVGITEM_H -#include <QtCore/qobject.h> #include <QtGui/qgraphicsitem.h> #ifndef QT_NO_GRAPHICSSVGITEM @@ -55,10 +54,12 @@ QT_MODULE(Svg) class QSvgRenderer; class QGraphicsSvgItemPrivate; -class Q_SVG_EXPORT QGraphicsSvgItem : public QObject, public QGraphicsItem +class Q_SVG_EXPORT QGraphicsSvgItem : public QGraphicsObject { Q_OBJECT Q_INTERFACES(QGraphicsItem) + Q_PROPERTY(QString elementId READ elementId WRITE setElementId) + Q_PROPERTY(QSize maximumCacheSize READ maximumCacheSize WRITE setMaximumCacheSize) public: QGraphicsSvgItem(QGraphicsItem *parentItem=0); @@ -87,13 +88,7 @@ public: private: Q_DISABLE_COPY(QGraphicsSvgItem) - - // Q_DECLARE_PRIVATE_WITH_BASE(QGraphicsSvgItem, QObject) - inline QGraphicsSvgItemPrivate *d_func() - { return reinterpret_cast<QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); } - inline const QGraphicsSvgItemPrivate *d_func() const - { return reinterpret_cast<const QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); } - friend class QGraphicsSvgItemPrivate; + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsSvgItem) Q_PRIVATE_SLOT(d_func(), void _q_repaintItem()) }; |