From b90cb496fced277eb0cdd83b67906aa4d18205e6 Mon Sep 17 00:00:00 2001
From: Marco Bubke <marco.bubke@nokia.com>
Date: Wed, 13 Jan 2010 14:22:56 +0100
Subject: [PATCH] Set the width or height of the root item to 100 if there is
 no width or height

Task-number: BAUHAUS-291
---
 .../core/instances/nodeinstanceview.cpp       |  2 +-
 .../instances/qmlgraphicsitemnodeinstance.cpp | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
index 67c2a3a62d4..ef024af87cf 100644
--- a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
+++ b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
@@ -597,7 +597,7 @@ QRectF NodeInstanceView::boundingRect() const
 QRectF NodeInstanceView::sceneRect() const
 {
     if (m_graphicsView)
-       return m_graphicsView->sceneRect();
+       return rootNodeInstance().boundingRect();
 
     return QRectF();
 }
diff --git a/src/plugins/qmldesigner/core/instances/qmlgraphicsitemnodeinstance.cpp b/src/plugins/qmldesigner/core/instances/qmlgraphicsitemnodeinstance.cpp
index 7593da3862a..be28b1dd618 100644
--- a/src/plugins/qmldesigner/core/instances/qmlgraphicsitemnodeinstance.cpp
+++ b/src/plugins/qmldesigner/core/instances/qmlgraphicsitemnodeinstance.cpp
@@ -107,6 +107,14 @@ QSizeF QmlGraphicsItemNodeInstance::size() const
 
     }
 
+    if (modelNode().isRootNode()) {
+        if (!m_hasWidth)
+            qmlGraphicsItem()->setWidth(100.);
+
+        if (!m_hasHeight)
+            qmlGraphicsItem()->setHeight(100.);
+    }
+
     return QSizeF(qmlGraphicsItem()->width(), qmlGraphicsItem()->height());
 }
 
@@ -127,6 +135,14 @@ QRectF QmlGraphicsItemNodeInstance::boundingRect() const
 
     }
 
+    if (modelNode().isRootNode()) {
+        if (!m_hasWidth)
+            qmlGraphicsItem()->setWidth(100.);
+
+        if (!m_hasHeight)
+            qmlGraphicsItem()->setHeight(100.);
+    }
+
     return qmlGraphicsItem()->boundingRect();
 }
 
@@ -237,6 +253,13 @@ int QmlGraphicsItemNodeInstance::penWidth() const
 
 void QmlGraphicsItemNodeInstance::resetProperty(const QString &name)
 {
+    if (name == "height")
+        m_hasHeight = false;
+
+    if (name == "width")
+        m_hasWidth = false;
+
+
     GraphicsObjectNodeInstance::resetProperty(name);
     if (name == "anchors.fill") {
         qmlGraphicsItem()->anchors()->resetFill();
-- 
GitLab