From 880e4935410769b8337d75f219bef70493c4bb2c Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 31 Mar 2010 02:31:23 +0200 Subject: Revert "Add a children private property needed for QML to support QGraphicsObject" This reverts commit 4be83fa7337c5a4eb7b0ce085aa5854af5d33252. Conflicts: src/gui/graphicsview/qgraphicswidget.cpp This drops the support of QML on top of 4.6 --- src/gui/graphicsview/qgraphicsitem.cpp | 103 --------------------- src/gui/graphicsview/qgraphicsitem.h | 7 -- src/gui/graphicsview/qgraphicsitem_p.h | 67 -------------- src/gui/graphicsview/qgraphicswidget.cpp | 8 -- src/gui/graphicsview/qgraphicswidget_p.cpp | 51 ---------- src/gui/graphicsview/qgraphicswidget_p.h | 9 -- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 28 ------ 7 files changed, 273 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1b707b0..42abe59 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5225,8 +5225,6 @@ void QGraphicsItemPrivate::addChild(QGraphicsItem *child) needSortChildren = 1; // ### maybe 0 child->d_ptr->siblingIndex = children.size(); children.append(child); - if (isObject) - emit static_cast(q_ptr)->childrenChanged(); } /*! @@ -5249,8 +5247,6 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) // the child is not guaranteed to be at the index after the list is sorted. // (see ensureSortedChildren()). child->d_ptr->siblingIndex = -1; - if (isObject) - emit static_cast(q_ptr)->childrenChanged(); } /*! @@ -7458,88 +7454,6 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) } } -void QGraphicsItemPrivate::append(QDeclarativeListProperty *list, QGraphicsObject *item) -{ - QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0); -} - -/*! - Returns a list of this item's children. - - The items are sorted by stacking order. This takes into account both the - items' insertion order and their Z-values. - -*/ -QDeclarativeListProperty QGraphicsItemPrivate::childrenList() -{ - Q_Q(QGraphicsItem); - if (isObject) { - QGraphicsObject *that = static_cast(q); - return QDeclarativeListProperty(that, &children, QGraphicsItemPrivate::append); - } else { - //QGraphicsItem is not supported for this property - return QDeclarativeListProperty(); - } -} - -/*! - \internal - Returns the width of the item - Reimplemented by QGraphicsWidget -*/ -qreal QGraphicsItemPrivate::width() const -{ - return 0; -} - -/*! - \internal - Set the width of the item - Reimplemented by QGraphicsWidget -*/ -void QGraphicsItemPrivate::setWidth(qreal w) -{ - Q_UNUSED(w); -} - -/*! - \internal - Reset the width of the item - Reimplemented by QGraphicsWidget -*/ -void QGraphicsItemPrivate::resetWidth() -{ -} - -/*! - \internal - Returns the height of the item - Reimplemented by QGraphicsWidget -*/ -qreal QGraphicsItemPrivate::height() const -{ - return 0; -} - -/*! - \internal - Set the height of the item - Reimplemented by QGraphicsWidget -*/ -void QGraphicsItemPrivate::setHeight(qreal h) -{ - Q_UNUSED(h); -} - -/*! - \internal - Reset the height of the item - Reimplemented by QGraphicsWidget -*/ -void QGraphicsItemPrivate::resetHeight() -{ -} - /*! \property QGraphicsObject::parent \brief the parent of the item @@ -7726,23 +7640,6 @@ void QGraphicsItemPrivate::resetHeight() \sa scale, rotation, QGraphicsItem::transformOriginPoint() */ -/*! - \fn void QGraphicsObject::widthChanged() - \internal -*/ - -/*! - \fn void QGraphicsObject::heightChanged() - \internal -*/ - -/*! - - \fn QGraphicsObject::childrenChanged() - - This signal gets emitted whenever the children list changes - \internal -*/ /*! \class QAbstractGraphicsShapeItem diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 5023f60..d72833b 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -547,10 +547,6 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) - Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty children READ childrenList DESIGNABLE false NOTIFY childrenChanged) - Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) - Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) - Q_CLASSINFO("DefaultProperty", "children") Q_INTERFACES(QGraphicsItem) public: QGraphicsObject(QGraphicsItem *parent = 0); @@ -575,9 +571,6 @@ Q_SIGNALS: void zChanged(); void rotationChanged(); void scaleChanged(); - void childrenChanged(); - void widthChanged(); - void heightChanged(); protected: QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 669ae1b..ea04e0b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -71,62 +71,6 @@ QT_BEGIN_NAMESPACE class QGraphicsItemPrivate; -#ifndef QDECLARATIVELISTPROPERTY -#define QDECLARATIVELISTPROPERTY -template -struct QDeclarativeListProperty { - typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); - typedef int (*CountFunction)(QDeclarativeListProperty *); - typedef T *(*AtFunction)(QDeclarativeListProperty *, int); - typedef void (*ClearFunction)(QDeclarativeListProperty *); - - QDeclarativeListProperty() - : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} - QDeclarativeListProperty(QObject *o, QList &list) - : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), dummy1(0), dummy2(0) {} - QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, - ClearFunction r = 0) - : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} - - bool operator==(const QDeclarativeListProperty &o) const { - return object == o.object && - data == o.data && - append == o.append && - count == o.count && - at == o.at && - clear == o.clear; - } - - QObject *object; - void *data; - - AppendFunction append; - - CountFunction count; - AtFunction at; - - ClearFunction clear; - - void *dummy1; - void *dummy2; - -private: - static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList *)p->data)->append(v); - } - static int qlist_count(QDeclarativeListProperty *p) { - return ((QList *)p->data)->count(); - } - static T *qlist_at(QDeclarativeListProperty *p, int idx) { - return ((QList *)p->data)->at(idx); - } - static void qlist_clear(QDeclarativeListProperty *p) { - return ((QList *)p->data)->clear(); - } -}; -#endif - class QGraphicsItemCache { public: @@ -293,7 +237,6 @@ public: void resolveDepth(); void addChild(QGraphicsItem *child); void removeChild(QGraphicsItem *child); - QDeclarativeListProperty childrenList(); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); void childrenBoundingRectHelper(QTransform *x, QRectF *rect); @@ -480,21 +423,11 @@ public: inline QTransform transformToParent() const; inline void ensureSortedChildren(); - static void append(QDeclarativeListProperty *list, QGraphicsObject *item); static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); void ensureSequentialSiblingIndex(); inline void sendScenePosChange(); virtual void siblingOrderChange(); - // Private Properties - virtual qreal width() const; - virtual void setWidth(qreal); - virtual void resetWidth(); - - virtual qreal height() const; - virtual void setHeight(qreal); - virtual void resetHeight(); - QRectF childrenBoundingRect; QRectF needsRepaint; QMap paintedViewBoundingRects; diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 3548fe3..4c5cffa 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -324,14 +324,6 @@ void QGraphicsWidget::resize(const QSizeF &size) */ /*! - - \fn QGraphicsWidget::geometryChanged() - - This signal gets emitted whenever the geometry of the item changes - \internal -*/ - -/*! \property QGraphicsWidget::geometry \brief the geometry of the widget diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 6e397b6..1835c74 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -44,7 +44,6 @@ #ifndef QT_NO_GRAPHICSVIEW #include -#include #include "qgraphicswidget_p.h" #include "qgraphicslayout.h" #include "qgraphicsscene_p.h" @@ -826,56 +825,6 @@ void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l) } } -qreal QGraphicsWidgetPrivate::width() const -{ - Q_Q(const QGraphicsWidget); - return q->geometry().width(); -} - -void QGraphicsWidgetPrivate::setWidth(qreal w) -{ - if (qIsNaN(w)) - return; - Q_Q(QGraphicsWidget); - if (q->geometry().width() == w) - return; - - QRectF oldGeom = q->geometry(); - - q->setGeometry(QRectF(q->x(), q->y(), w, height())); -} - -void QGraphicsWidgetPrivate::resetWidth() -{ - Q_Q(QGraphicsWidget); - q->setGeometry(QRectF(q->x(), q->y(), 0, height())); -} - -qreal QGraphicsWidgetPrivate::height() const -{ - Q_Q(const QGraphicsWidget); - return q->geometry().height(); -} - -void QGraphicsWidgetPrivate::setHeight(qreal h) -{ - if (qIsNaN(h)) - return; - Q_Q(QGraphicsWidget); - if (q->geometry().height() == h) - return; - - QRectF oldGeom = q->geometry(); - - q->setGeometry(QRectF(q->x(), q->y(), width(), h)); -} - -void QGraphicsWidgetPrivate::resetHeight() -{ - Q_Q(QGraphicsWidget); - q->setGeometry(QRectF(q->x(), q->y(), width(), 0)); -} - QT_END_NAMESPACE #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index f34a755..2c5b3bf 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -130,15 +130,6 @@ public: void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event); bool hasDecoration() const; - // Private Properties - qreal width() const; - void setWidth(qreal); - void resetWidth(); - - qreal height() const; - void setHeight(qreal); - void resetHeight(); - // State inline int attributeToBitIndex(Qt::WidgetAttribute att) const { diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index e04d99d..4a874be 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -111,8 +111,6 @@ private slots: void fontPropagationSceneChange(); void geometry_data(); void geometry(); - void width(); - void height(); void getContentsMargins_data(); void getContentsMargins(); void initStyleOption_data(); @@ -775,32 +773,6 @@ void tst_QGraphicsWidget::geometry() QCOMPARE(widget.geometry(), QRectF(pos, size)); } -void tst_QGraphicsWidget::width() -{ - QGraphicsWidget w; - QCOMPARE(w.property("width").toReal(), qreal(0)); - QSignalSpy spy(&w, SIGNAL(widthChanged())); - w.setProperty("width", qreal(50)); - QCOMPARE(w.property("width").toReal(), qreal(50)); - QCOMPARE(spy.count(), 1); - //calling old school setGeometry should work too - w.setGeometry(0, 0, 200, 200); - QCOMPARE(spy.count(), 2); -} - -void tst_QGraphicsWidget::height() -{ - QGraphicsWidget w; - QCOMPARE(w.property("height").toReal(), qreal(0)); - QSignalSpy spy(&w, SIGNAL(heightChanged())); - w.setProperty("height", qreal(50)); - QCOMPARE(w.property("height").toReal(), qreal(50)); - QCOMPARE(spy.count(), 1); - //calling old school setGeometry should work too - w.setGeometry(0, 0, 200, 200); - QCOMPARE(spy.count(), 2); -} - void tst_QGraphicsWidget::getContentsMargins_data() { QTest::addColumn("left"); -- cgit v0.12