From 3aff620eda8d0c2ba2fe6e0d8fa61709cc86b5f4 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 9 Sep 2009 19:23:38 +0200 Subject: 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 --- src/svg/qgraphicssvgitem.cpp | 13 +++++++------ 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 #include #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(QObject::d_ptr.data()); } - inline const QGraphicsSvgItemPrivate *d_func() const - { return reinterpret_cast(QObject::d_ptr.data()); } - friend class QGraphicsSvgItemPrivate; + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsSvgItem) Q_PRIVATE_SLOT(d_func(), void _q_repaintItem()) }; -- cgit v0.12