From a49b85eac56907c45eb73ff568409a5d9d5fdd57 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 29 Jun 2011 19:34:07 +0200 Subject: [PATCH] QmlDesigner.NodeInstances: Return the implicit size if the size is invalid Task-number: QTCREATORBUG-5240 Change-Id: Ie8be3a2cc728805411a79c1f216ede566c641c17 Reviewed-on: http://codereview.qt.nokia.com/925 Reviewed-by: Qt Sanity Bot Reviewed-by: Thomas Hartmann --- .../instances/sgitemnodeinstance.cpp | 19 ++++++++++++++++++- .../instances/qmlgraphicsitemnodeinstance.cpp | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp index 3b3e7e3e549..acd46e7c164 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp @@ -271,7 +271,24 @@ bool SGItemNodeInstance::isSGItem() const QSizeF SGItemNodeInstance::size() const { - return QSizeF(sgItem()->width(), sgItem()->height()); + double width; + + if (QSGItemPrivate::get(sgItem())->widthValid) { + width = sgItem()->width(); + } else { + width = sgItem()->implicitWidth(); + } + + double height; + + if (QSGItemPrivate::get(sgItem())->heightValid) { + height = sgItem()->height(); + } else { + height = sgItem()->implicitHeight(); + } + + + return QSizeF(width, height); } QRectF SGItemNodeInstance::boundingRectWithStepChilds(QSGItem *parentItem) const diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qmlgraphicsitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qmlgraphicsitemnodeinstance.cpp index 0092e7beab3..acb4ad488e1 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qmlgraphicsitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qmlgraphicsitemnodeinstance.cpp @@ -104,7 +104,24 @@ bool QmlGraphicsItemNodeInstance::isQmlGraphicsItem() const QSizeF QmlGraphicsItemNodeInstance::size() const { - return QSizeF(qmlGraphicsItem()->width(), qmlGraphicsItem()->height()); + double width; + + if (QDeclarativeItemPrivate::get(qmlGraphicsItem())->widthValid) { + width = qmlGraphicsItem()->width(); + } else { + width = qmlGraphicsItem()->implicitWidth(); + } + + double height; + + if (QDeclarativeItemPrivate::get(qmlGraphicsItem())->heightValid) { + height = qmlGraphicsItem()->height(); + } else { + height = qmlGraphicsItem()->implicitHeight(); + } + + + return QSizeF(width, height); } void QmlGraphicsItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)