diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-03-24 05:33:21 +0100 |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-03-24 09:29:00 +0100 |
commit | 4be83fa7337c5a4eb7b0ce085aa5854af5d33252 (patch) | |
tree | 39771d3ff7b1c2b3f64934f0e344f50cca497610 /src/gui/graphicsview/qgraphicswidget_p.cpp | |
parent | c8fa23a5edd790d9eed0620068a29e03e4202cac (diff) | |
download | qt4-tools-4be83fa7337c5a4eb7b0ce085aa5854af5d33252.tar.gz |
Add a children private property needed for QML to support QGraphicsObject
Commit adds a private property that QML can use to add children for a given
item. This is a custom list that calls a callback which actually reparent
the item instead of just appending in the list (otherwise it will mess up
the state of QGraphicsView). This is needed because childItems() is pretty
useless you get a list but if you append something on it then it adds
that into a copy. Also the children property is the default property
a concept used by QML.
Width and Height private properties has been added in order to support
better the integration with QGraphicsWidget in QML. The actual implementation
is in the private class of QGI and QGraphicsWidget reimplements it to return
the geometry. (In 4.7 QDeclarativeItem reimplements it too).
This change should be harmless everything is private.
Task-number:QT-2757
Reviewed-by:andreas
Diffstat (limited to 'src/gui/graphicsview/qgraphicswidget_p.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget_p.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 1835c74f17..6e397b67ef 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -44,6 +44,7 @@ #ifndef QT_NO_GRAPHICSVIEW #include <QtCore/qdebug.h> +#include <QtCore/qnumeric.h> #include "qgraphicswidget_p.h" #include "qgraphicslayout.h" #include "qgraphicsscene_p.h" @@ -825,6 +826,56 @@ 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 |