From 0e1c97f5835ace6ce52ef6a1ae23f8e4463ba742 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 07:28:24 +0200 Subject: More cleanups in QFxItem Remove the pos, x and y properties and use the ones in QGraphicsObject instead --- src/declarative/fx/qfxitem.cpp | 45 ---------------------------------- src/declarative/fx/qfxitem.h | 14 +++-------- src/declarative/fx/qfxitem_p.h | 8 ++++++ src/gui/graphicsview/qgraphicsitem_p.h | 2 +- 4 files changed, 13 insertions(+), 56 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 90595ff..66a2d99 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1974,14 +1974,6 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *) } /*! - Returns the item's (0, 0) point relative to its parent. - */ -QPointF QFxItem::pos() const -{ - return QPointF(x(),y()); -} - -/*! Returns the item's (0, 0) point mapped to scene coordinates. */ QPointF QFxItem::scenePos() const @@ -2037,32 +2029,6 @@ qreal QFxItem::z() const return zValue(); } -void QFxItem::setX(qreal x) -{ - if (x == this->x()) - return; - - qreal oldX = this->x(); - - QGraphicsItem::setPos(x, y()); - - geometryChanged(QRectF(this->x(), y(), width(), height()), - QRectF(oldX, y(), width(), height())); -} - -void QFxItem::setY(qreal y) -{ - if (y == this->y()) - return; - - qreal oldY = this->y(); - - QGraphicsItem::setPos(x(), y); - - geometryChanged(QRectF(x(), this->y(), width(), height()), - QRectF(x(), oldY, width(), height())); -} - void QFxItem::setZ(qreal z) { if (z == this->z()) @@ -2166,17 +2132,6 @@ bool QFxItem::heightValid() const return d->heightValid; } -void QFxItem::setPos(const QPointF &point) -{ - qreal oldX = x(); - qreal oldY = y(); - - QGraphicsItem::setPos(point); - - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(oldX, oldY, width(), height())); -} - qreal QFxItem::scale() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index ddd3752..4d96076 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -111,9 +111,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class? Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) // ### use method in QGO - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) - Q_PROPERTY(qreal z READ z WRITE setZ FINAL) + Q_PROPERTY(qreal z READ z WRITE setZ FINAL) // ### use method in QGO Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) @@ -130,11 +128,11 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) Q_PROPERTY(QList* transform READ transform) // ## QGI/QGO - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // movbe to QGI + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") - typedef QHash QmlChildren; + typedef QHash QmlChildren; // ### public: enum Option { NoOption = 0x00000000, @@ -213,11 +211,7 @@ public: void setOptions(Options, bool set = true); qreal z() const; - QPointF pos() const; - void setX(qreal); - void setY(qreal); - virtual void setZ(qreal); - void setPos(const QPointF &); + void setZ(qreal); qreal width() const; void setWidth(qreal); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 1242703..1615ad8 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -205,6 +205,14 @@ public: QGraphicsItemPrivate::setFocusItemForArea(b); q->focusChanged(b); } + + virtual void setPosHelper(const QPointF &pos) + { + Q_Q(QFxItem); + QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height); + QGraphicsItemPrivate::setPosHelper(pos); + q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry); + } }; QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index d14ae7f..9e30f54 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -199,7 +199,7 @@ public: virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const; static bool movableAncestorIsSelected(const QGraphicsItem *item); - void setPosHelper(const QPointF &pos); + virtual void setPosHelper(const QPointF &pos); void setTransformHelper(const QTransform &transform); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); -- cgit v0.12