bla.txt 30.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
index ee55ff4..30a3948 100644
--- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
@@ -37,10 +37,12 @@
 #include <metainfo.h>
 
 #include "resizehandleitem.h"
+#include <rewritingexception.h>
 
 #include <QApplication>
 #include <QGraphicsSceneMouseEvent>
 #include <QtDebug>
+#include <QMessageBox>
 
 namespace QmlDesigner {
 
@@ -143,7 +145,7 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
     m_dragNode = view()->createQmlItemNode(itemLibraryEntry, pos, parentNode);
 
     Q_ASSERT(m_dragNode.modelNode().isValid());
-    Q_ASSERT(m_dragNode.isValid());
+    //Q_ASSERT(m_dragNode.isValid());
 
     QList<QmlItemNode> nodeList;
     nodeList.append(m_dragNode);
@@ -205,7 +207,11 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
         event->accept();
         end(event->scenePos());
         //Q_ASSERT(m_token.isValid());
-        m_rewriterTransaction.commit();
+        try {
+            m_rewriterTransaction.commit();
+        } catch (RewritingException &e) {
+            QMessageBox::warning(0, "Error", e.description());
+        }
         m_dragNode = ModelNode();
         view()->changeToSelectionTool();
     }
@@ -230,7 +236,11 @@ void DragTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
         if (m_dragNode.isValid())
             m_dragNode.destroy();
         end(event->scenePos());
-        m_rewriterTransaction.commit();
+        try {
+            m_rewriterTransaction.commit();
+        } catch (RewritingException &e) {
+            QMessageBox::warning(0, "Error", e.description());
+        }
         QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::show();
         QList<QmlItemNode> nodeList;
         view()->setSelectedQmlItemNodes(nodeList);
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
index 3488be9..f8a18ea 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
@@ -116,8 +116,9 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
 {
     m_scene->addFormEditorItem(qmlItemNode);
 
-    foreach (const QmlItemNode &nextNode, qmlItemNode.children()) //TODO instance children
-        setupFormEditorItemTree(nextNode);
+    foreach (const QmlObjectNode &nextNode, qmlItemNode.allDirectSubNodes()) //TODO instance children
+        if (QmlItemNode(nextNode).isValid())
+            setupFormEditorItemTree(nextNode.toQmlItemNode());
 }
 
 void FormEditorView::nodeCreated(const ModelNode &createdNode)
diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
index f68dfa0..71f8124 100644
--- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
+++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
@@ -47,6 +47,7 @@
 #include <componentaction.h>
 #include <qmlobjectnode.h>
 #include <rewriterview.h>
+#include <rewritingexception.h>
 #include <nodelistproperty.h>
 #include <toolbox.h>
 
@@ -462,6 +463,8 @@ void DesignDocumentController::copySelected()
     QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
     model->setMetaInfo(m_d->model->metaInfo());
     model->setFileUrl(m_d->model->fileUrl());
+    foreach (const Import &import, m_d->model->imports())
+        model->addImport(import);
 
     Q_ASSERT(model);
 
@@ -557,6 +560,8 @@ void DesignDocumentController::paste()
     QScopedPointer<Model> model(Model::create("empty"));
     model->setMetaInfo(m_d->model->metaInfo());
     model->setFileUrl(m_d->model->fileUrl());
+    foreach (const Import &import, m_d->model->imports())
+        model->addImport(import);
     Q_ASSERT(model);
 
     if (!m_d->model)
@@ -601,48 +606,56 @@ void DesignDocumentController::paste()
 
         QList<ModelNode> pastedNodeList;
 
-        RewriterTransaction transaction(m_d->formEditorView.data());
+        try {
+            RewriterTransaction transaction(m_d->formEditorView.data());
 
-        int offset = double(qrand()) / RAND_MAX * 20 - 10;
+            int offset = double(qrand()) / RAND_MAX * 20 - 10;
 
-        foreach (const ModelNode &node, selectedNodes) {
-            QString defaultProperty(targetNode.metaInfo().defaultProperty());
-            ModelNode pastedNode(view.insertModel(node));
-            pastedNodeList.append(pastedNode);
-            scatterItem(pastedNode, targetNode, offset);
-            targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-        }
+            foreach (const ModelNode &node, selectedNodes) {
+                QString defaultProperty(targetNode.metaInfo().defaultProperty());
+                ModelNode pastedNode(view.insertModel(node));
+                pastedNodeList.append(pastedNode);
+                scatterItem(pastedNode, targetNode, offset);
+                targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
+            }
 
-        view.setSelectedModelNodes(pastedNodeList);
+            view.setSelectedModelNodes(pastedNodeList);
+        } catch (RewritingException &e) { 
+            qWarning() << e.description(); //silent error
+        }
     } else {
-        RewriterTransaction transaction(m_d->formEditorView.data());
+        try {
+            RewriterTransaction transaction(m_d->formEditorView.data());
 
-        model->detachView(&view);
-        m_d->model->attachView(&view);
-        ModelNode pastedNode(view.insertModel(rootNode));
-        ModelNode targetNode;
+            model->detachView(&view);
+            m_d->model->attachView(&view);
+            ModelNode pastedNode(view.insertModel(rootNode));
+            ModelNode targetNode;
 
-        if (!view.selectedModelNodes().isEmpty())
-            targetNode = view.selectedModelNodes().first();
+            if (!view.selectedModelNodes().isEmpty())
+                targetNode = view.selectedModelNodes().first();
 
-        if (!targetNode.isValid())
-            targetNode = view.rootModelNode();
+            if (!targetNode.isValid())
+                targetNode = view.rootModelNode();
 
-        if (targetNode.parentProperty().isValid() &&
-            (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
-            (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
-            (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
+            if (targetNode.parentProperty().isValid() &&
+                (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
+                (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
+                (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
 
-            targetNode = targetNode.parentProperty().parentModelNode();
+                targetNode = targetNode.parentProperty().parentModelNode();
 
-        QString defaultProperty(targetNode.metaInfo().defaultProperty());
+            QString defaultProperty(targetNode.metaInfo().defaultProperty());
 
-        scatterItem(pastedNode, targetNode);
-        if (targetNode.nodeListProperty(defaultProperty).isValid()) {
-            targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-        }
+            scatterItem(pastedNode, targetNode);
+            if (targetNode.nodeListProperty(defaultProperty).isValid()) {
+                targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
+            }
 
-        view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
+            view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
+        } catch (RewritingException &e) { 
+            qWarning() << e.description(); //silent error
+        }
     }
 }
 
diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
index dc5244f..5d5890d 100644
--- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
+++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
@@ -130,7 +130,12 @@ void DesignDocumentControllerView::fromText(QString text)
     inputModel->setMetaInfo(model()->metaInfo());
     inputModel->setFileUrl(model()->fileUrl());
     QPlainTextEdit textEdit;
-    QString imports("import Qt 4.7;\n");
+    QString imports;//("import Qt 4.7;\n");
+    qDebug() << imports;
+    qDebug() << model()->metaInfo().hasNodeMetaInfo("Button");
+    foreach (Import import, model()->imports())
+        imports += import.toString() + ";\n";
+    qDebug() << imports;
     textEdit.setPlainText(imports + text);
     NotIndentingTextEditModifier modifier(&textEdit);
 
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index ec66ff7..df08b21 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -37,6 +37,7 @@
 #include <qgraphicswidget.h>
 #include <abstractview.h>
 #include <invalididexception.h>
+#include <rewritingexception.h>
 
 #include <QMimeData>
 #include <QMessageBox>
@@ -470,49 +471,55 @@ void NavigatorTreeModel::removeSubTree(const ModelNode &node)
 
 void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
 {
-    QString propertyQmlType = qmlTypeInQtContainer(parentProperty.metaInfo().type());
-
-    RewriterTransaction transaction = m_view->beginRewriterTransaction();
-    foreach (const ModelNode &node, modelNodes) {
-        if (!node.isValid())
-            continue;
-
-        if (node != parentProperty.parentModelNode() &&
-            !node.isAncestorOf(parentProperty.parentModelNode()) &&
-            node.metaInfo().isSubclassOf(propertyQmlType, -1, -1)) {
-
-            if (node.parentProperty() != parentProperty) {
+    try {
+        QString propertyQmlType = qmlTypeInQtContainer(parentProperty.metaInfo().type());
+
+        RewriterTransaction transaction = m_view->beginRewriterTransaction();
+        foreach (const ModelNode &node, modelNodes) {
+            if (!node.isValid())
+                continue;
+
+            if (node != parentProperty.parentModelNode() &&
+                !node.isAncestorOf(parentProperty.parentModelNode()) &&
+                (node.metaInfo().isSubclassOf(propertyQmlType, -1, -1) || propertyQmlType == "alias")) {
+                    //### todo: allowing alias is just a heuristic
+                    //once the MetaInfo is part of instances we can do this right
+
+                    if (node.parentProperty() != parentProperty) {
+
+                        if (parentProperty.isNodeProperty()) {
+                            ModelNode propertyNode = parentProperty.toNodeProperty().modelNode();
+                            // Destruction of ancestors is not allowed
+                            if (propertyNode.isAncestorOf(node)) {
+                                continue;
+                            }
+                            if (propertyNode.isValid()) {
+                                QApplication::setOverrideCursor(Qt::ArrowCursor);
+                                if (QMessageBox::warning(0, tr("Warning"), tr("Reparenting the component %1 here will cause the component %2 to be deleted. Do you want to proceed?").arg(node.id(), propertyNode.id()), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) {
+                                    QApplication::restoreOverrideCursor();
+                                    continue;
+                                }
+                                QApplication::restoreOverrideCursor();
+                                propertyNode.destroy();
+                            }
+                        }
 
-                if (parentProperty.isNodeProperty()) {
-                    ModelNode propertyNode = parentProperty.toNodeProperty().modelNode();
-                    // Destruction of ancestors is not allowed
-                    if (propertyNode.isAncestorOf(node)) {
-                        continue;
+                        parentProperty.reparentHere(node);
                     }
-                    if (propertyNode.isValid()) {
-                        QApplication::setOverrideCursor(Qt::ArrowCursor);
-                        if (QMessageBox::warning(0, tr("Warning"), tr("Reparenting the component %1 here will cause the component %2 to be deleted. Do you want to proceed?").arg(node.id(), propertyNode.id()), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) {
-                            QApplication::restoreOverrideCursor();
-                            continue;
+
+                    if (parentProperty.isNodeListProperty()) {
+                        int index = parentProperty.toNodeListProperty().toModelNodeList().indexOf(node);
+                        if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index
+                            --targetIndex;
+                        }
+                        if (index != targetIndex) {
+                            parentProperty.toNodeListProperty().slide(index, targetIndex);
                         }
-                        QApplication::restoreOverrideCursor();
-                        propertyNode.destroy();
                     }
-                }
-
-                parentProperty.reparentHere(node);
-            }
-
-            if (parentProperty.isNodeListProperty()) {
-                int index = parentProperty.toNodeListProperty().toModelNodeList().indexOf(node);
-                if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index
-                    --targetIndex;
-                }
-                if (index != targetIndex) {
-                    parentProperty.toNodeListProperty().slide(index, targetIndex);
-                }
             }
         }
+    }  catch (RewritingException &e) { //better safe than sorry! There always might be cases where we fail
+        QMessageBox::warning(0, "Error", e.description());
     }
 }
 
diff --git a/src/plugins/qmldesigner/designercore/include/metainfo.h b/src/plugins/qmldesigner/designercore/include/metainfo.h
index 2d4af4d..b09d569 100644
--- a/src/plugins/qmldesigner/designercore/include/metainfo.h
+++ b/src/plugins/qmldesigner/designercore/include/metainfo.h
@@ -84,6 +84,7 @@ public:
 
     QString fromQtTypes(const QString &type) const;
 
+    void inheritFrom(MetaInfo &other);
 
 public:
     static MetaInfo global();
diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h
index c2fce99..12aa17e 100644
--- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h
+++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h
@@ -59,6 +59,7 @@ namespace Internal {
     class ObjectNodeInstance;
     class QmlGraphicsItemNodeInstance;
     class QmlPropertyChangesNodeInstance;
+    class GraphicsObjectNodeInstance;
     class QmlStateNodeInstance;
 }
 
@@ -72,6 +73,7 @@ class CORESHARED_EXPORT NodeInstance
     friend CORESHARED_EXPORT bool operator==(const NodeInstance &first, const NodeInstance &second);
     friend CORESHARED_EXPORT class NodeMetaInfo;
     friend class QmlDesigner::Internal::QmlGraphicsItemNodeInstance;
+    friend class QmlDesigner::Internal::GraphicsObjectNodeInstance;
     friend class QmlDesigner::Internal::ObjectNodeInstance;
     friend class QmlDesigner::Internal::QmlPropertyChangesNodeInstance;
     friend class QmlDesigner::Internal::QmlStateNodeInstance;
diff --git a/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
index 926d446..d658415 100644
--- a/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
@@ -70,8 +70,10 @@ QSizeF GraphicsObjectNodeInstance::size() const
 
 QTransform GraphicsObjectNodeInstance::transform() const
 {
-    if (graphicsObject()->parentItem())
-        return graphicsObject()->itemTransform(graphicsObject()->parentItem());
+    NodeInstance nodeInstanceParent = nodeInstanceView()->instanceForNode(modelNode()).parent();
+    QGraphicsObject *graphicsObjectParent = qobject_cast<QGraphicsObject*>(nodeInstanceParent.internalObject());
+    if (graphicsObjectParent)
+        return graphicsObject()->itemTransform(graphicsObjectParent);
     else
         return sceneTransform();
 }
@@ -163,6 +165,11 @@ void initOption(QGraphicsItem *item, QStyleOptionGraphicsItem *option, const QTr
 
 void GraphicsObjectNodeInstance::paintRecursively(QGraphicsItem *graphicsItem, QPainter *painter) const
 {
+    if (QGraphicsObject *graphicsObject = graphicsItem->toGraphicsObject()) {
+        if (nodeInstanceView()->hasInstanceForObject(graphicsObject))
+            return; //we already keep track of this object elsewhere
+    }
+
     if (graphicsItem->isVisible()) {
         painter->save();
         painter->setTransform(graphicsItem->itemTransform(graphicsItem->parentItem()), true);
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
index d331d9c..28acccf 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
@@ -261,7 +261,21 @@ void NodeInstance::reparent(const NodeInstance &oldParentInstance, const QString
 */
 NodeInstance NodeInstance::parent() const
 {
-    return m_nodeInstance->nodeInstanceView()->instanceForObject(m_nodeInstance->parent());
+    QObject *parent = m_nodeInstance->parent();
+    //Maybe the object has been reparented inside a component and we
+    //do not keep track of the parent?
+    //In this case we iterate until we find a parent we keep track of,
+    //parent() gets 0
+    while (!m_nodeInstance->nodeInstanceView()->hasInstanceForObject(parent)) {
+        if (!parent) //this should not happen! warning?
+            return m_nodeInstance->nodeInstanceView()->instanceForObject(parent);
+           if (QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject*>(parent))
+               parent = graphicsObject->parentItem()->toGraphicsObject();
+           else
+               parent = parent->parent();
+    }
+    m_nodeInstance->nodeInstanceView()->instanceForObject(m_nodeInstance->parent());
+    return m_nodeInstance->nodeInstanceView()->instanceForObject(parent);
 }
 
 bool NodeInstance::hasParent() const
diff --git a/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
index 121b6e0..707592b 100644
--- a/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
@@ -121,13 +121,15 @@ QSizeF QmlGraphicsItemNodeInstance::size() const
     if (modelNode().isRootNode()) {
         if (!m_hasWidth) {
             qmlGraphicsItem()->blockSignals(true);
-            qmlGraphicsItem()->setWidth(100.);
+            if (qmlGraphicsItem()->width() < 10.)
+                qmlGraphicsItem()->setWidth(100.);
             qmlGraphicsItem()->blockSignals(false);
         }
 
         if (!m_hasHeight) {
             qmlGraphicsItem()->blockSignals(true);
-            qmlGraphicsItem()->setHeight(100.);
+            if (qmlGraphicsItem()->height() < 10.)
+                qmlGraphicsItem()->setHeight(100.);
             qmlGraphicsItem()->blockSignals(false);
         }
     }
@@ -163,13 +165,15 @@ QRectF QmlGraphicsItemNodeInstance::boundingRect() const
     if (modelNode().isRootNode()) {
         if (!m_hasWidth) {
             qmlGraphicsItem()->blockSignals(true);
-            qmlGraphicsItem()->setWidth(100.);
+            if (qmlGraphicsItem()->width() < 10.)
+                qmlGraphicsItem()->setWidth(100.);
             qmlGraphicsItem()->blockSignals(false);
         }
 
         if (!m_hasHeight) {
             qmlGraphicsItem()->blockSignals(true);
-            qmlGraphicsItem()->setHeight(100.);
+            if (qmlGraphicsItem()->height() < 10.)
+                qmlGraphicsItem()->setHeight(100.);
             qmlGraphicsItem()->blockSignals(false);
         }
     }
diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
index f350af0..5d89ba9 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
@@ -526,6 +526,13 @@ QString MetaInfo::fromQtTypes(const QString &type) const
     return type;
 }
 
+void MetaInfo::inheritFrom(MetaInfo &other)
+{
+    if (other.m_p.isNull())
+        return;
+    m_p = other.m_p;
+}
+
 /*!
   \brief Returns whether an enumerator is registered in the meta type system.
   */
diff --git a/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
index 9e84ae0..f7c3b1e 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
@@ -270,7 +270,8 @@ bool PropertyMetaInfo::isListProperty() const
         throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
     }
 
-    return type().contains("QDeclarativeList");
+    return type().contains("QDeclarativeList") ||
+        type().contains("alias"); //### this is a nasty hack - we have to get instances in to resolve this properly
 }
 
 /*!
diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
index 03bbde7..635f954 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
@@ -114,7 +114,7 @@ SubComponentManagerPrivate::SubComponentManagerPrivate(MetaInfo metaInfo, SubCom
         m_metaInfo(metaInfo)
 {
     connect(&m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(parseDirectory(QString)));
-    connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(parseFile(QString)));
+    connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(parseFile(QString, QString)));
 }
 
 void SubComponentManagerPrivate::addImport(int pos, const QDeclarativeDomImport &import)
diff --git a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
index 7e9290c..0184d64 100644
--- a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
@@ -38,6 +38,7 @@
 #include "bindingproperty.h"
 #include "variantproperty.h"
 #include "rewritertransaction.h"
+#include <rewritingexception.h>
 
 #include <QSet>
 #include <QStringList>
@@ -61,6 +62,8 @@ static QString fixExpression(const QString &expression, const QHash<QString, QSt
 static void syncVariantProperties(ModelNode &outputNode, const ModelNode &inputNode)
 {
     foreach (const VariantProperty &variantProperty, inputNode.variantProperties()) {
+        qDebug() << variantProperty.name();
+        qDebug() << variantProperty.value();
         outputNode.variantProperty(variantProperty.name()) = variantProperty.value();
     }
 }
@@ -168,26 +171,30 @@ ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
 
 void ModelMerger::replaceModel(const ModelNode &modelNode)
 {
-     RewriterTransaction transaction(view()->beginRewriterTransaction());
+    try {
+        RewriterTransaction transaction(view()->beginRewriterTransaction());
 
-    foreach (const Import &import, modelNode.model()->imports())
-        view()->model()->addImport(import);
-    view()->model()->setFileUrl(modelNode.model()->fileUrl());
+        foreach (const Import &import, modelNode.model()->imports())
+            view()->model()->addImport(import);
+        view()->model()->setFileUrl(modelNode.model()->fileUrl());
 
-    ModelNode rootNode(view()->rootModelNode());
+        ModelNode rootNode(view()->rootModelNode());
 
-    foreach (const QString &propertyName, rootNode.propertyNames())
-        rootNode.removeProperty(propertyName);
+        foreach (const QString &propertyName, rootNode.propertyNames())
+            rootNode.removeProperty(propertyName);
 
-    QHash<QString, QString> idRenamingHash;
-    setupIdRenamingHash(modelNode, idRenamingHash, view());
+        QHash<QString, QString> idRenamingHash;
+        setupIdRenamingHash(modelNode, idRenamingHash, view());
 
-    syncVariantProperties(rootNode, modelNode);
-    syncBindingProperties(rootNode, modelNode, idRenamingHash);
-    syncId(rootNode, modelNode, idRenamingHash);
-    syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
-    syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
-    m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
+        syncVariantProperties(rootNode, modelNode);
+        syncBindingProperties(rootNode, modelNode, idRenamingHash);
+        syncId(rootNode, modelNode, idRenamingHash);
+        syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
+        syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
+        m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
+    } catch (RewritingException &e) { 
+        qWarning() << e.description(); //silent error
+    }
 }
 
 } //namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
index 002550c..da19e7b 100644
--- a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
@@ -1,7 +1,4 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
+/**
 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 **
 ** Contact: Nokia Corporation (qt-info@nokia.com)
diff --git a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
index 1df6106..6704469 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
@@ -326,7 +326,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
     if (targetAnchorLine == AnchorLine::Invalid )
         return AnchorLine();
 
-    Q_ASSERT(targetAnchorLinePair.second.isValid());
+    //Q_ASSERT(targetAnchorLinePair.second.isValid()); //### todo proper fix
     return AnchorLine(QmlItemNode(qmlItemNode().nodeForInstance(targetAnchorLinePair.second)), targetAnchorLine);
 }
 
diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
index 13d6e94..2d60b2a 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
@@ -155,7 +155,6 @@ QList<QmlObjectNode> QmlItemNode::allDirectSubNodes() const
         QList<ModelNode> modelNodeList = modelNode().allDirectSubModelNodes();
 
         foreach (const ModelNode &node, modelNodeList) {
-            if (!QmlItemNode(node).isValid()) //if ModelNode is no FxItem
                 returnList.append(node);
         }
     }
diff --git a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
index d0885e7..784e0dd 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
@@ -200,7 +200,7 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
             parentNode.nodeAbstractProperty(parentNode.defaultProperty()).reparentHere(newNode);
         }
 
-        Q_ASSERT(newNode.isValid());
+        //Q_ASSERT(newNode.isValid());
 
         QString id;
         int i = 1;
@@ -224,10 +224,10 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
             newNode.setVariantProperty("opacity", 1);
         }
 
-        Q_ASSERT(newNode.isValid());
+        //Q_ASSERT(newNode.isValid());
     }
 
-    Q_ASSERT(newNode.isValid());
+    //Q_ASSERT(newNode.isValid());
 
     return newNode;
 }
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 59b1522..4f9946e 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -216,7 +216,7 @@ public:
             typeName = qmlValue->packageName() + QLatin1String("/") + qmlValue->className();
             majorVersion = qmlValue->version().major();
             minorVersion = qmlValue->version().minor();
-        } else if (value) {
+        } else {
             for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
                 if (!iter->next && iter->name)
                     typeName = iter->name->asString();
@@ -711,6 +711,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
             const QString astType = property->memberType->asString();
             AbstractProperty modelProperty = modelNode.property(astName);
             if (!property->expression || isLiteralValue(property->expression)) {
+                qDebug() << astName;
+                qDebug() << astType;
                 const QVariant variantValue = convertDynamicPropertyValueToVariant(astValue, astType);
                 syncVariantProperty(modelProperty, variantValue, astType, differenceHandler);
             } else {
diff --git a/src/plugins/qmldesigner/qmldesigner.pro b/src/plugins/qmldesigner/qmldesigner.pro
index 28abb28..baede56 100644
--- a/src/plugins/qmldesigner/qmldesigner.pro
+++ b/src/plugins/qmldesigner/qmldesigner.pro
@@ -1,3 +1,3 @@
 TEMPLATE  = subdirs
 
-SUBDIRS   = qmldesignerplugin.pro fxplugin
+SUBDIRS   = qmldesignerplugin.pro fxplugin mxplugin