diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2011-06-28 16:24:53 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2011-06-28 16:26:26 +0200 |
commit | ddb602536cd6813df57d5ea09483e195e5b12433 (patch) | |
tree | 49039bb55a49e44d207b62f9f5a60113e72fdb50 /share/qtcreator/qml/qmlpuppet/qml2puppet | |
parent | 014ef6e2db4d631668fe21820995de888a7660a9 (diff) | |
download | qt-creator-ddb602536cd6813df57d5ea09483e195e5b12433.tar.gz |
QmlDesigner: Fix painted bounding rectangle for step childs
We used only the bounding rectangle of the item under our control. But child
items which are created in a component can be out side of the bounding
rectangle. To fix compute a combined bounding rectangle of the item and all
stepchildren. Stepchildren described the child not create directly by us.
Change-Id: I7f25f112aa5eb2f80cfccec5d358221ab5e35d9b
Reviewed-on: http://codereview.qt.nokia.com/839
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp | 120 | ||||
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h | 1 |
2 files changed, 16 insertions, 105 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp index 8735ddf7d5..3b3e7e3e54 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp @@ -244,9 +244,6 @@ SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object) instance->setHasContent(anyItemHasContent(sgItem)); sgItem->setFlag(QSGItem::ItemHasContents, true); - if (sgItem->inherits("QSGText")) - instance->setResizable(false); - static_cast<QDeclarativeParserStatus*>(sgItem)->classBegin(); instance->populateResetValueHash(); @@ -274,96 +271,33 @@ bool SGItemNodeInstance::isSGItem() const QSizeF SGItemNodeInstance::size() const { - if (isValid()) { - double implicitWidth = sgItem()->implicitWidth(); - if (!m_hasWidth - && implicitWidth // WORKAROUND - && sgItem()->width() <= 0 - && implicitWidth != sgItem()->width() - && !hasBindingForProperty("width")) { - sgItem()->blockSignals(true); - sgItem()->setWidth(implicitWidth); - sgItem()->blockSignals(false); - } - - double implicitHeight = sgItem()->implicitHeight(); - if (!m_hasHeight - && implicitWidth // WORKAROUND - && sgItem()->height() <= 0 - && implicitHeight != sgItem()->height() - && !hasBindingForProperty("height")) { - sgItem()->blockSignals(true); - sgItem()->setHeight(implicitHeight); - sgItem()->blockSignals(false); - } - - } - - if (isRootNodeInstance()) { - if (!m_hasWidth) { - sgItem()->blockSignals(true); - if (sgItem()->width() < 10.) - sgItem()->setWidth(100.); - sgItem()->blockSignals(false); - } - - if (!m_hasHeight) { - sgItem()->blockSignals(true); - if (sgItem()->height() < 10.) - sgItem()->setHeight(100.); - sgItem()->blockSignals(false); - } - } - return QSizeF(sgItem()->width(), sgItem()->height()); } -QRectF SGItemNodeInstance::boundingRect() const +QRectF SGItemNodeInstance::boundingRectWithStepChilds(QSGItem *parentItem) const { - if (isValid()) { - double implicitWidth = sgItem()->implicitWidth(); - if (!m_hasWidth - && implicitWidth // WORKAROUND - && sgItem()->width() <= 0 - && implicitWidth != sgItem()->width() - && !hasBindingForProperty("width")) { - sgItem()->blockSignals(true); - sgItem()->setWidth(implicitWidth); - sgItem()->blockSignals(false); - } + QRectF boundingRect = parentItem->boundingRect(); - double implicitHeight = sgItem()->implicitHeight(); - if (!m_hasHeight - && implicitWidth // WORKAROUND - && sgItem()->height() <= 0 - && implicitHeight != sgItem()->height() - && !hasBindingForProperty("height")) { - sgItem()->blockSignals(true); - sgItem()->setHeight(implicitHeight); - sgItem()->blockSignals(false); + foreach (QSGItem *childItem, parentItem->childItems()) { + if (nodeInstanceServer()->hasInstanceForObject(childItem)) { + QRectF transformedRect = childItem->mapRectToItem(parentItem, childItemBoundingRect(childItem)); + boundingRect = boundingRect.united(transformedRect); } - } - if (isRootNodeInstance()) { - if (!m_hasWidth) { - sgItem()->blockSignals(true); - if (sgItem()->width() < 10.) - sgItem()->setWidth(100.); - sgItem()->blockSignals(false); - } + return boundingRect; +} - if (!m_hasHeight) { - sgItem()->blockSignals(true); - if (sgItem()->height() < 10.) - sgItem()->setHeight(100.); - sgItem()->blockSignals(false); +QRectF SGItemNodeInstance::boundingRect() const +{ + if (sgItem()) { + if (sgItem()->clip()) { + return sgItem()->boundingRect(); + } else { + return boundingRectWithStepChilds(); } } - if (sgItem()) - return sgItem()->boundingRect(); - return QRectF(); } @@ -409,30 +343,6 @@ void SGItemNodeInstance::setPropertyBinding(const QString &name, const QString & QVariant SGItemNodeInstance::property(const QString &name) const { - if (name == "width" && !hasBindingForProperty("width")) { - double implicitWidth = sgItem()->implicitWidth(); - if (!m_hasWidth - && implicitWidth // WORKAROUND - && sgItem()->width() <= 0 - && implicitWidth != sgItem()->width()) { - sgItem()->blockSignals(true); - sgItem()->setWidth(implicitWidth); - sgItem()->blockSignals(false); - } - } - - if (name == "height" && !hasBindingForProperty("height")) { - double implicitHeight = sgItem()->implicitHeight(); - if (!m_hasHeight - && implicitHeight // WORKAROUND - && sgItem()->width() <= 0 - && implicitHeight != sgItem()->height()) { - sgItem()->blockSignals(true); - sgItem()->setHeight(implicitHeight); - sgItem()->blockSignals(false); - } - } - return ObjectNodeInstance::property(name); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h index de17a6216e..eabd778009 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h @@ -149,6 +149,7 @@ protected: void resetHorizontal(); void resetVertical(); void refresh(); + QRectF boundingRectWithStepChilds(QSGItem *parentItem) const; private: //variables bool m_hasHeight; |