From 328550ff008da53d865f3a6f245aa4753d1b3527 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 30 Jul 2012 23:36:59 +0200 Subject: Remove the obsolete scene argument for constructors of graphics items The argument has been obsoleted and not documented since 2007. Get rid of it now before Qt 5.0 Task-number: QTBUG-25089 Change-Id: I91a5508a5e1606f5b5c289501295c67be4abe6a0 Reviewed-by: Jason McDonald --- dist/changes-5.0.0 | 4 + examples/graphicsview/diagramscene/arrow.cpp | 5 +- examples/graphicsview/diagramscene/arrow.h | 2 +- examples/graphicsview/diagramscene/diagramitem.cpp | 4 +- examples/graphicsview/diagramscene/diagramitem.h | 2 +- .../graphicsview/diagramscene/diagramtextitem.cpp | 4 +- .../graphicsview/diagramscene/diagramtextitem.h | 2 +- examples/sql/drilldown/imageitem.cpp | 5 +- examples/sql/drilldown/imageitem.h | 3 +- examples/tools/undoframework/diagramitem.cpp | 5 +- examples/tools/undoframework/diagramitem.h | 3 +- src/widgets/graphicsview/qgraphicsitem.cpp | 231 +++++---------------- src/widgets/graphicsview/qgraphicsitem.h | 161 +++----------- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 2 +- src/widgets/graphicsview/qgraphicswidget.cpp | 6 +- src/widgets/graphicsview/qgraphicswidget.h | 2 +- .../qgraphicsitem/tst_qgraphicsitem.cpp | 14 +- .../qgraphicsscene/tst_qgraphicsscene.cpp | 3 +- 18 files changed, 110 insertions(+), 348 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 2c90dde12a..8daf897459 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -459,6 +459,10 @@ QtWidgets those classes are now QDate and QTime respectively, not QDateTime as they have been for the 4.7 and 4.8 releases. +* QGraphicsItem and derived classes - Passing a QGraphicsScene in the items constructor + is no longer supported. Construct the item without a scene and then call + QGraphicsScene::addItem() to add the item to the scene. + QtNetwork --------- * QHostAddress::isLoopback() API added. Returns true if the address is diff --git a/examples/graphicsview/diagramscene/arrow.cpp b/examples/graphicsview/diagramscene/arrow.cpp index 62c1c97d30..236d836e13 100644 --- a/examples/graphicsview/diagramscene/arrow.cpp +++ b/examples/graphicsview/diagramscene/arrow.cpp @@ -46,9 +46,8 @@ const qreal Pi = 3.14; //! [0] -Arrow::Arrow(DiagramItem *startItem, DiagramItem *endItem, - QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsLineItem(parent, scene) +Arrow::Arrow(DiagramItem *startItem, DiagramItem *endItem, QGraphicsItem *parent) + : QGraphicsLineItem(parent) { myStartItem = startItem; myEndItem = endItem; diff --git a/examples/graphicsview/diagramscene/arrow.h b/examples/graphicsview/diagramscene/arrow.h index 8b1c54bde3..ac09d6ad00 100644 --- a/examples/graphicsview/diagramscene/arrow.h +++ b/examples/graphicsview/diagramscene/arrow.h @@ -61,7 +61,7 @@ public: enum { Type = UserType + 4 }; Arrow(DiagramItem *startItem, DiagramItem *endItem, - QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); + QGraphicsItem *parent = 0); int type() const { return Type; } diff --git a/examples/graphicsview/diagramscene/diagramitem.cpp b/examples/graphicsview/diagramscene/diagramitem.cpp index 339d605bb7..9509c30270 100644 --- a/examples/graphicsview/diagramscene/diagramitem.cpp +++ b/examples/graphicsview/diagramscene/diagramitem.cpp @@ -45,8 +45,8 @@ //! [0] DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu, - QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsPolygonItem(parent, scene) + QGraphicsItem *parent) + : QGraphicsPolygonItem(parent) { myDiagramType = diagramType; myContextMenu = contextMenu; diff --git a/examples/graphicsview/diagramscene/diagramitem.h b/examples/graphicsview/diagramscene/diagramitem.h index 23fee9ebef..07b3b6e830 100644 --- a/examples/graphicsview/diagramscene/diagramitem.h +++ b/examples/graphicsview/diagramscene/diagramitem.h @@ -68,7 +68,7 @@ public: enum DiagramType { Step, Conditional, StartEnd, Io }; DiagramItem(DiagramType diagramType, QMenu *contextMenu, - QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); + QGraphicsItem *parent = 0); void removeArrow(Arrow *arrow); void removeArrows(); diff --git a/examples/graphicsview/diagramscene/diagramtextitem.cpp b/examples/graphicsview/diagramscene/diagramtextitem.cpp index 3b6aad2d31..1e583045da 100644 --- a/examples/graphicsview/diagramscene/diagramtextitem.cpp +++ b/examples/graphicsview/diagramscene/diagramtextitem.cpp @@ -44,8 +44,8 @@ #include "diagramscene.h" //! [0] -DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsTextItem(parent, scene) +DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) + : QGraphicsTextItem(parent) { setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemIsSelectable); diff --git a/examples/graphicsview/diagramscene/diagramtextitem.h b/examples/graphicsview/diagramscene/diagramtextitem.h index 5505886e5e..611e9b6700 100644 --- a/examples/graphicsview/diagramscene/diagramtextitem.h +++ b/examples/graphicsview/diagramscene/diagramtextitem.h @@ -59,7 +59,7 @@ class DiagramTextItem : public QGraphicsTextItem public: enum { Type = UserType + 3 }; - DiagramTextItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); + DiagramTextItem(QGraphicsItem *parent = 0); int type() const { return Type; } diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp index f712717f08..991ab98f28 100644 --- a/examples/sql/drilldown/imageitem.cpp +++ b/examples/sql/drilldown/imageitem.cpp @@ -41,9 +41,8 @@ #include "imageitem.h" //! [0] -ImageItem::ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent, - QGraphicsScene *scene) - : QGraphicsPixmapItem(pixmap, parent, scene) +ImageItem::ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent) + : QGraphicsPixmapItem(pixmap, parent) { recordId = id; setAcceptHoverEvents(true); diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h index 74bac26676..be729c2272 100644 --- a/examples/sql/drilldown/imageitem.h +++ b/examples/sql/drilldown/imageitem.h @@ -50,8 +50,7 @@ class ImageItem : public QObject, public QGraphicsPixmapItem Q_OBJECT public: - ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = 0, - QGraphicsScene *scene = 0); + ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = 0); void adjust(); int id(); diff --git a/examples/tools/undoframework/diagramitem.cpp b/examples/tools/undoframework/diagramitem.cpp index 10ade13628..4070dd158d 100644 --- a/examples/tools/undoframework/diagramitem.cpp +++ b/examples/tools/undoframework/diagramitem.cpp @@ -42,9 +42,8 @@ #include "diagramitem.h" -DiagramItem::DiagramItem(DiagramType diagramType, QGraphicsItem *item, - QGraphicsScene *scene) - : QGraphicsPolygonItem(item, scene) +DiagramItem::DiagramItem(DiagramType diagramType, QGraphicsItem *item) + : QGraphicsPolygonItem(item) { if (diagramType == Box) { boxPolygon << QPointF(0, 0) << QPointF(0, 30) << QPointF(30, 30) diff --git a/examples/tools/undoframework/diagramitem.h b/examples/tools/undoframework/diagramitem.h index f5a7eb4b62..849ef2132b 100644 --- a/examples/tools/undoframework/diagramitem.h +++ b/examples/tools/undoframework/diagramitem.h @@ -56,8 +56,7 @@ public: enum { Type = UserType + 1 }; enum DiagramType { Box, Triangle }; - DiagramItem(DiagramType diagramType, QGraphicsItem *item = 0, - QGraphicsScene *scene = 0); + DiagramItem(DiagramType diagramType, QGraphicsItem *item = 0); DiagramType diagramType() const { return polygon() == boxPolygon ? Box : Triangle; diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 9a014807dc..841caa9010 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1377,45 +1377,21 @@ void QGraphicsItemCache::purge() \sa QGraphicsScene::addItem(), setParentItem() */ -QGraphicsItem::QGraphicsItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) +QGraphicsItem::QGraphicsItem(QGraphicsItem *parent) : d_ptr(new QGraphicsItemPrivate) { d_ptr->q_ptr = this; setParentItem(parent); - - if (scene && parent && parent->scene() != scene) { - qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is" - " different from parent's scene (%p)", - scene, parent->scene()); - return; - } - if (scene && !parent) - scene->addItem(this); } /*! \internal */ -QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent, - QGraphicsScene *scene) +QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent) : d_ptr(&dd) { d_ptr->q_ptr = this; setParentItem(parent); - - if (scene && parent && parent->scene() != scene) { - qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is" - " different from parent's scene (%p)", - scene, parent->scene()); - return; - } - if (scene && !parent) - scene->addItem(this); } /*! @@ -7590,8 +7566,8 @@ QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) /*! \internal */ -QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsItem(dd, parent, scene) +QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent) + : QGraphicsItem(dd, parent) { QGraphicsItem::d_ptr->isObject = true; } @@ -8018,23 +7994,16 @@ public: Constructs a QAbstractGraphicsShapeItem. \a parent is passed to QGraphicsItem's constructor. */ -QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent, scene) +QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent) + : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent) { } /*! \internal */ -QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, - QGraphicsItem *parent, - QGraphicsScene *scene) - : QGraphicsItem(dd, parent, scene) +QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, QGraphicsItem *parent) + : QGraphicsItem(dd, parent) { } @@ -8161,13 +8130,8 @@ public: \sa QGraphicsScene::addItem() */ QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, - QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene) + QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) { if (!path.isEmpty()) setPath(path); @@ -8179,13 +8143,8 @@ QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, \sa QGraphicsScene::addItem() */ -QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene) +QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) { } @@ -8370,13 +8329,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene) +QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) { setRect(rect); } @@ -8393,13 +8347,8 @@ QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent \sa QGraphicsScene::addItem() */ QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, - QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene) + QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) { setRect(QRectF(x, y, w, h)); } @@ -8410,13 +8359,8 @@ QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, \sa QGraphicsScene::addItem() */ -QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene) +QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) { } @@ -8621,13 +8565,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene) +QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) { setRect(rect); } @@ -8643,13 +8582,8 @@ QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *pa \sa QGraphicsScene::addItem() */ QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, - QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene) + QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) { setRect(x,y,w,h); } @@ -8662,13 +8596,8 @@ QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, \sa QGraphicsScene::addItem() */ -QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene) +QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) { } @@ -8930,14 +8859,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, - QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene) +QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) { setPolygon(polygon); } @@ -8948,13 +8871,8 @@ QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, \sa QGraphicsScene::addItem() */ -QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene) +QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) { } @@ -9159,13 +9077,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene) +QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) { setLine(line); } @@ -9177,13 +9090,8 @@ QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent \sa QGraphicsScene::addItem() */ -QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene) +QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) { setLine(x1, y1, x2, y2); } @@ -9196,13 +9104,8 @@ QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGr \sa QGraphicsScene::addItem() */ -QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene) +QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) { } @@ -9490,14 +9393,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, - QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene) +QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) { setPixmap(pixmap); } @@ -9508,13 +9405,8 @@ QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, \sa QGraphicsScene::addItem() */ -QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene) +QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) { } @@ -9826,13 +9718,9 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate) +QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent) + : QGraphicsObject(*new QGraphicsItemPrivate, parent), + dd(new QGraphicsTextItemPrivate) { dd->qq = this; if (!text.isEmpty()) @@ -9848,13 +9736,9 @@ QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent \sa QGraphicsScene::addItem() */ -QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate) +QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent) + : QGraphicsObject(*new QGraphicsItemPrivate, parent), + dd(new QGraphicsTextItemPrivate) { dd->qq = this; setAcceptDrops(true); @@ -10710,13 +10594,8 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect() \sa QGraphicsScene::addItem() */ -QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene) +QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) { } @@ -10727,13 +10606,8 @@ QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent \sa QGraphicsScene::addItem() */ -QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene) +QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent) + : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) { setText(text); } @@ -10977,13 +10851,8 @@ public: \sa QGraphicsScene::addItem() */ -QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent -#ifndef Q_QDOC - // obsolete argument - , QGraphicsScene *scene -#endif - ) - : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent, scene) +QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent) + : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent) { setHandlesChildEvents(true); } diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 17857ebf06..e259ccac3c 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -162,12 +162,7 @@ public: SceneModal }; - QGraphicsItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsItem(QGraphicsItem *parent = 0); virtual ~QGraphicsItem(); QGraphicsScene *scene() const; @@ -460,8 +455,7 @@ protected: virtual QVariant extension(const QVariant &variant) const; protected: - QGraphicsItem(QGraphicsItemPrivate &dd, - QGraphicsItem *parent, QGraphicsScene *scene); + QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent); QScopedPointer d_ptr; void addToIndex(); @@ -599,7 +593,7 @@ Q_SIGNALS: void heightChanged(); protected: - QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); + QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent); private: friend class QGraphicsItem; friend class QGraphicsItemPrivate; @@ -610,12 +604,7 @@ class QAbstractGraphicsShapeItemPrivate; class Q_WIDGETS_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem { public: - QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0); ~QAbstractGraphicsShapeItem(); QPen pen() const; @@ -629,7 +618,7 @@ public: protected: QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, - QGraphicsItem *parent, QGraphicsScene *scene); + QGraphicsItem *parent); private: Q_DISABLE_COPY(QAbstractGraphicsShapeItem) @@ -640,18 +629,8 @@ class QGraphicsPathItemPrivate; class Q_WIDGETS_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem { public: - QGraphicsPathItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsPathItem(QGraphicsItem *parent = 0); + QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0); ~QGraphicsPathItem(); QPainterPath path() const; @@ -683,24 +662,9 @@ class QGraphicsRectItemPrivate; class Q_WIDGETS_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem { public: - QGraphicsRectItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsRectItem(QGraphicsItem *parent = 0); + QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0); + QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0); ~QGraphicsRectItem(); QRectF rect() const; @@ -736,24 +700,9 @@ class QGraphicsEllipseItemPrivate; class Q_WIDGETS_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem { public: - QGraphicsEllipseItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsEllipseItem(QGraphicsItem *parent = 0); + QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0); + QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0); ~QGraphicsEllipseItem(); QRectF rect() const; @@ -795,19 +744,9 @@ class QGraphicsPolygonItemPrivate; class Q_WIDGETS_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem { public: - QGraphicsPolygonItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsPolygonItem(QGraphicsItem *parent = 0); QGraphicsPolygonItem(const QPolygonF &polygon, - QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsItem *parent = 0); ~QGraphicsPolygonItem(); QPolygonF polygon() const; @@ -842,24 +781,9 @@ class QGraphicsLineItemPrivate; class Q_WIDGETS_EXPORT QGraphicsLineItem : public QGraphicsItem { public: - QGraphicsLineItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsLineItem(QGraphicsItem *parent = 0); + QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0); + QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0); ~QGraphicsLineItem(); QPen pen() const; @@ -902,18 +826,8 @@ public: HeuristicMaskShape }; - QGraphicsPixmapItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsPixmapItem(QGraphicsItem *parent = 0); + QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0); ~QGraphicsPixmapItem(); QPixmap pixmap() const; @@ -964,18 +878,8 @@ class Q_WIDGETS_EXPORT QGraphicsTextItem : public QGraphicsObject QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor) public: - QGraphicsTextItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsTextItem(QGraphicsItem *parent = 0); + QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0); ~QGraphicsTextItem(); QString toHtml() const; @@ -1065,18 +969,8 @@ class QGraphicsSimpleTextItemPrivate; class Q_WIDGETS_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem { public: - QGraphicsSimpleTextItem(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); - QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsSimpleTextItem(QGraphicsItem *parent = 0); + QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0); ~QGraphicsSimpleTextItem(); void setText(const QString &text); @@ -1111,12 +1005,7 @@ class QGraphicsItemGroupPrivate; class Q_WIDGETS_EXPORT QGraphicsItemGroup : public QGraphicsItem { public: - QGraphicsItemGroup(QGraphicsItem *parent = 0 -#ifndef Q_QDOC - // ### obsolete argument - , QGraphicsScene *scene = 0 -#endif - ); + QGraphicsItemGroup(QGraphicsItem *parent = 0); ~QGraphicsItemGroup(); void addToGroup(QGraphicsItem *item); diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index dbff872739..289a7720e5 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -501,7 +501,7 @@ QPointF QGraphicsProxyWidgetPrivate::mapToReceiver(const QPointF &pos, const QWi to QGraphicsItem's constructor. */ QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, 0, wFlags) + : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, wFlags) { Q_D(QGraphicsProxyWidget); d->init(); diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 3a3d3e34a3..560b04cca9 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -176,7 +176,7 @@ QT_BEGIN_NAMESPACE window, a tool, a popup, etc). */ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsObject(*new QGraphicsWidgetPrivate, 0, 0), QGraphicsLayoutItem(0, false) + : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); @@ -187,8 +187,8 @@ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) Constructs a new QGraphicsWidget, using \a dd as parent. */ -QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene, Qt::WindowFlags wFlags) - : QGraphicsObject(dd, 0, scene), QGraphicsLayoutItem(0, false) +QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index 01e3efcc58..09c1a2323d 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -223,7 +223,7 @@ protected: virtual void ungrabMouseEvent(QEvent *event); virtual void grabKeyboardEvent(QEvent *event); virtual void ungrabKeyboardEvent(QEvent *event); - QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, QGraphicsScene *, Qt::WindowFlags wFlags = 0); + QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, Qt::WindowFlags wFlags = 0); private: Q_DISABLE_COPY(QGraphicsWidget) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 41ef60f7d3..8dac4bdfbe 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2200,7 +2200,8 @@ void tst_QGraphicsItem::setMatrix() qRegisterMetaType >("QList"); QSignalSpy spy(&scene, SIGNAL(changed(QList))); QRectF unrotatedRect(-12, -34, 56, 78); - QGraphicsRectItem item(unrotatedRect, 0, &scene); + QGraphicsRectItem item(unrotatedRect, 0); + scene.addItem(&item); scene.update(scene.sceneRect()); QApplication::instance()->processEvents(); @@ -2467,10 +2468,13 @@ void tst_QGraphicsItem::collidesWith_item() { QGraphicsScene scene; - QGraphicsRectItem rect(20, 20, 100, 100, 0, &scene); - QGraphicsRectItem rect2(40, 40, 50, 50, 0, &scene); + QGraphicsRectItem rect(20, 20, 100, 100, 0); + scene.addItem(&rect); + QGraphicsRectItem rect2(40, 40, 50, 50, 0); + scene.addItem(&rect2); rect2.setZValue(1); - QGraphicsLineItem line(0, 0, 200, 200, 0, &scene); + QGraphicsLineItem line(0, 0, 200, 200, 0); + scene.addItem(&line); line.setZValue(2); QCOMPARE(scene.items().size(), 3); @@ -6244,7 +6248,7 @@ public slots: void newTextItem() { // Add a text item - QGraphicsItem *item = new QGraphicsTextItem("This item will not ensure that it's visible", 0, this); + QGraphicsItem *item = new QGraphicsTextItem("This item will not ensure that it's visible", 0); item->setPos(.0, .0); item->show(); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index e188805d6a..dea253d019 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3465,7 +3465,8 @@ void tst_QGraphicsScene::task139782_containsItemBoundingRect() { // The item in question has a scene bounding rect of (10, 10, 50, 50) QGraphicsScene scene(0.0, 0.0, 200.0, 200.0); - QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, 0, &scene); + QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, 0); + scene.addItem(item); item->setPos(10.0, 10.0); // The (0, 0, 50, 50) scene rect should not include the item's bounding rect -- cgit v1.2.3