OSDN Git Service

QmlDesigner: Add component complete feature
authorMarco Bubke <marco.bubke@nokia.com>
Thu, 9 Dec 2010 15:09:37 +0000 (16:09 +0100)
committerMarco Bubke <marco.bubke@nokia.com>
Thu, 9 Dec 2010 15:35:28 +0000 (16:35 +0100)
This notifies the views if the instance has be really instanced.

35 files changed:
src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
src/plugins/qmldesigner/components/formeditor/formeditorview.h
src/plugins/qmldesigner/components/integration/componentview.cpp
src/plugins/qmldesigner/components/integration/componentview.h
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h
src/plugins/qmldesigner/components/navigator/navigatorview.cpp
src/plugins/qmldesigner/components/navigator/navigatorview.h
src/plugins/qmldesigner/designercore/designercore.pri
src/plugins/qmldesigner/designercore/include/abstractview.h
src/plugins/qmldesigner/designercore/include/nodeinstanceclientinterface.h
src/plugins/qmldesigner/designercore/include/nodeinstanceserverinterface.h
src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
src/plugins/qmldesigner/designercore/include/qmlmodelview.h
src/plugins/qmldesigner/designercore/include/rewriterview.h
src/plugins/qmldesigner/designercore/instances/completecomponentcommand.cpp [new file with mode: 0644]
src/plugins/qmldesigner/designercore/instances/completecomponentcommand.h [new file with mode: 0644]
src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.cpp [new file with mode: 0644]
src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.h [new file with mode: 0644]
src/plugins/qmldesigner/designercore/instances/instances.pri
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h
src/plugins/qmldesigner/designercore/instances/nodeinstanceserver.cpp
src/plugins/qmldesigner/designercore/instances/nodeinstanceserver.h
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverinterface.cpp
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
src/plugins/qmldesigner/designercore/model/abstractview.cpp
src/plugins/qmldesigner/designercore/model/model.cpp
src/plugins/qmldesigner/designercore/model/model_p.h
src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
src/plugins/qmldesigner/designercore/model/rewriterview.cpp
src/plugins/qmldesigner/designercore/model/viewlogger.cpp
src/plugins/qmldesigner/designercore/model/viewlogger.h

index 8d97c81..5884215 100644 (file)
@@ -435,6 +435,11 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const QString &
     }
 }
 
+void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeList)
+{
+}
+
+
 void FormEditorView::customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data)
 {
     if (identifier == "__start rewriter transaction__") {
index 2fbf9fe..f98c3b0 100644 (file)
@@ -101,6 +101,8 @@ public:
     void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
     void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
 
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
+
     double margins() const;
     double spacing() const;
     void deActivateItemCreator();
index 8741d72..d24d6fb 100644 (file)
@@ -161,6 +161,7 @@ void ComponentView::bindingPropertiesChanged(const QList<BindingProperty>& /*pro
 void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {}
 void ComponentView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/) {}
 void ComponentView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/) {};
+void ComponentView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/) {}
 
 
 void ComponentView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/,
@@ -170,7 +171,6 @@ void ComponentView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*
 
 void ComponentView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {}
 
-void ComponentView::importsChanged() {}
 
 void ComponentView::auxiliaryDataChanged(const ModelNode &/*node*/, const QString &/*name*/, const QVariant &/*data*/) {}
 
index 40a0ffc..b2aeb59 100644 (file)
@@ -69,6 +69,7 @@ public:
     void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 
     void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
                                       const QList<ModelNode> &lastSelectedNodeList);
@@ -77,8 +78,6 @@ public:
 
     void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
 
-    void importsChanged();
-
     void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
 
     void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
index fea1e71..a1e967a 100644 (file)
@@ -65,6 +65,11 @@ void DesignDocumentControllerView::instancePropertyChange(const QList<QPair<Mode
 {
 }
 
+void DesignDocumentControllerView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/)
+{
+
+}
+
 static QStringList arrayToStringList(const QByteArray &byteArray)
 {
     QString str(QString::fromLatin1(byteArray));
index 9d61a58..8ad3891 100644 (file)
@@ -60,7 +60,7 @@ public:
     virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
     virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
-
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 
     ModelNode insertModel(const ModelNode &modelNode)
     { return m_modelMerger.insertModel(modelNode); }
index 7b57375..9e1ae2d 100644 (file)
@@ -198,6 +198,10 @@ void NavigatorView::instancePropertyChange(const QList<QPair<ModelNode, QString>
 {
 }
 
+void NavigatorView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/)
+{
+}
+
 void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex)
 {
     if (m_treeModel->isInTree(node))
index ea1ca45..30994c5 100644 (file)
@@ -82,6 +82,7 @@ public:
     void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 
 private slots:
 //    void handleChangedItem(QStandardItem * item);
index 10570f5..4124021 100644 (file)
@@ -119,7 +119,9 @@ SOURCES += $$PWD/model/abstractview.cpp \
     $$PWD/instances/addimportcommand.cpp \
     $$PWD/instances/childrenchangedcommand.cpp \
     $$PWD/instances/statepreviewimagechangedcommand.cpp \
-    $$PWD/instances/imagecontainer.cpp
+    $$PWD/instances/imagecontainer.cpp \
+    $$PWD/instances/completecomponentcommand.cpp \
+    $$PWD/instances/componentcompletedcommand.cpp
 HEADERS += $$PWD/include/corelib_global.h \
     $$PWD/include/abstractview.h \
     $$PWD/include/nodeinstanceview.h \
@@ -237,7 +239,9 @@ HEADERS += $$PWD/include/corelib_global.h \
     $$PWD/instances/addimportcommand.h \
     $$PWD/instances/childrenchangedcommand.h \
     $$PWD/instances/statepreviewimagechangedcommand.h \
-    $$PWD/instances/imagecontainer.h
+    $$PWD/instances/imagecontainer.h \
+    $$PWD/instances/completecomponentcommand.h \
+    $$PWD/instances/componentcompletedcommand.h
 contains(CONFIG, plugin) {
   # If core.pri has been included in the qmldesigner plugin
   SOURCES += $$PWD/model/basetexteditmodifier.cpp
index 2e27e01..70b8383 100644 (file)
@@ -107,6 +107,7 @@ public:
     void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
 
     void emitInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void emitInstancesCompleted(const QVector<ModelNode> &nodeList);
 
     virtual void modelAttached(Model *model);
     virtual void modelAboutToBeDetached(Model *model);
@@ -124,6 +125,8 @@ public:
     virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) = 0;
 
     virtual void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList) = 0;
+    virtual void instancesCompleted(const QVector<ModelNode> &completedNodeList) = 0;
+
 
     virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
                                       const QList<ModelNode> &lastSelectedNodeList) = 0;
index 4b263fb..6712822 100644 (file)
@@ -10,6 +10,7 @@ class PixmapChangedCommand;
 class InformationChangedCommand;
 class ChildrenChangedCommand;
 class StatePreviewImageChangedCommand;
+class ComponentCompletedCommand;
 
 class NodeInstanceClientInterface
 {
@@ -19,6 +20,7 @@ public:
     virtual void pixmapChanged(const PixmapChangedCommand &command) = 0;
     virtual void childrenChanged(const ChildrenChangedCommand &command) = 0;
     virtual void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) = 0;
+    virtual void componentCompleted(const ComponentCompletedCommand &command) = 0;
 
     virtual void flush() {};
     virtual qint64 bytesToWrite() const {return 0;}
index f64321e..dc6d57d 100644 (file)
@@ -21,6 +21,7 @@ class RemoveInstancesCommand;
 class RemovePropertiesCommand;
 class ChangeStateCommand;
 class AddImportCommand;
+class CompleteComponentCommand;
 
 class NodeInstanceServerInterface : public QObject
 {
@@ -40,6 +41,7 @@ public:
     virtual void changeIds(const ChangeIdsCommand &command) = 0;
     virtual void changeState(const ChangeStateCommand &command) = 0;
     virtual void addImport(const AddImportCommand &command) = 0;
+    virtual void completeComponent(const CompleteComponentCommand &command) = 0;
 
     virtual void setBlockUpdates(bool /*block*/) {}
 
index 0f37eb4..619958f 100644 (file)
@@ -63,6 +63,7 @@ class ChangeIdsCommand;
 class RemoveInstancesCommand;
 class RemovePropertiesCommand;
 class AddImportCommand;
+class CompleteComponentCommand;
 
 class CORESHARED_EXPORT NodeInstanceView : public AbstractView, public NodeInstanceClientInterface
 {
@@ -94,6 +95,7 @@ public:
     void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
     void importAdded(const Import &import);
     void importRemoved(const Import &import);
 
@@ -118,6 +120,7 @@ public:
     void informationChanged(const InformationChangedCommand &command);
     void childrenChanged(const ChildrenChangedCommand &command);
     void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command);
+    void componentCompleted(const ComponentCompletedCommand &command);
 
 private: // functions
     NodeInstance rootNodeInstance() const;
@@ -143,6 +146,8 @@ private: // functions
     CreateSceneCommand createCreateSceneCommand() const;
     ClearSceneCommand createClearSceneCommand() const;
     CreateInstancesCommand createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const;
+    CompleteComponentCommand createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const;
+    ComponentCompletedCommand createComponentCompletedCommand(const QList<NodeInstance> &instanceList) const;
     ReparentInstancesCommand createReparentInstancesCommand(const QList<NodeInstance> &instanceList) const;
     ReparentInstancesCommand createReparentInstancesCommand(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent) const;
     ChangeFileUrlCommand createChangeFileUrlCommand(const QUrl &fileUrl) const;
index f5e9510..930a689 100644 (file)
@@ -91,6 +91,7 @@ public:
     virtual void nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName);
 
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 
     void nodeCreated(const ModelNode &createdNode);
     void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
index f5e7719..ee1a320 100644 (file)
@@ -135,6 +135,7 @@ public:
     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
 
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 
     void importAdded(const Import &import);
     void importRemoved(const Import &import);
diff --git a/src/plugins/qmldesigner/designercore/instances/completecomponentcommand.cpp b/src/plugins/qmldesigner/designercore/instances/completecomponentcommand.cpp
new file mode 100644 (file)
index 0000000..91fbef0
--- /dev/null
@@ -0,0 +1,33 @@
+#include "completecomponentcommand.h"
+
+namespace QmlDesigner {
+
+CompleteComponentCommand::CompleteComponentCommand()
+{
+}
+
+CompleteComponentCommand::CompleteComponentCommand(const QVector<qint32> &container)
+    : m_instanceVector(container)
+{
+}
+
+QVector<qint32> CompleteComponentCommand::instances() const
+{
+    return m_instanceVector;
+}
+
+QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command)
+{
+    out << command.instances();
+
+    return out;
+}
+
+QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command)
+{
+    in >> command.m_instanceVector;
+
+    return in;
+}
+
+} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/instances/completecomponentcommand.h b/src/plugins/qmldesigner/designercore/instances/completecomponentcommand.h
new file mode 100644 (file)
index 0000000..2bc5e0f
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef COMPLETECOMPONENT_H
+#define COMPLETECOMPONENT_H
+
+#include <QMetaType>
+#include <QVector>
+
+namespace QmlDesigner {
+
+class CompleteComponentCommand
+{
+    friend QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command);
+
+public:
+    CompleteComponentCommand();
+    CompleteComponentCommand(const QVector<qint32> &container);
+
+    QVector<qint32> instances() const;
+
+private:
+    QVector<qint32> m_instanceVector;
+};
+
+QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command);
+QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command);
+
+} // namespace QmlDesigner
+
+Q_DECLARE_METATYPE(QmlDesigner::CompleteComponentCommand);
+
+#endif // COMPLETECOMPONENT_H
diff --git a/src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.cpp b/src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.cpp
new file mode 100644 (file)
index 0000000..e209574
--- /dev/null
@@ -0,0 +1,34 @@
+#include "componentcompletedcommand.h"
+
+namespace QmlDesigner {
+
+ComponentCompletedCommand::ComponentCompletedCommand()
+{
+}
+
+ComponentCompletedCommand::ComponentCompletedCommand(const QVector<qint32> &container)
+    : m_instanceVector(container)
+{
+}
+
+QVector<qint32> ComponentCompletedCommand::instances() const
+{
+    return m_instanceVector;
+}
+
+QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command)
+{
+    out << command.instances();
+
+    return out;
+}
+
+QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command)
+{
+    in >> command.m_instanceVector;
+
+    return in;
+}
+
+} // namespace QmlDesigner
+
diff --git a/src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.h b/src/plugins/qmldesigner/designercore/instances/componentcompletedcommand.h
new file mode 100644 (file)
index 0000000..c391777
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef COMPONENTCOMPLETEDCOMMAND_H
+#define COMPONENTCOMPLETEDCOMMAND_H
+#include <QMetaType>
+#include <QVector>
+
+namespace QmlDesigner {
+
+class ComponentCompletedCommand
+{
+    friend QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command);
+
+public:
+    ComponentCompletedCommand();
+    ComponentCompletedCommand(const QVector<qint32> &container);
+
+    QVector<qint32> instances() const;
+
+private:
+    QVector<qint32> m_instanceVector;
+};
+
+QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command);
+QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command);
+
+} // namespace QmlDesigner
+
+Q_DECLARE_METATYPE(QmlDesigner::ComponentCompletedCommand);
+
+#endif // COMPONENTCOMPLETEDCOMMAND_H
index 5d51301..060f8ed 100644 (file)
@@ -3,6 +3,8 @@ INCLUDEPATH += $$PWD/../include
 
 
 HEADERS += $$PWD/behaviornodeinstance.h
+HEADERS += $$PWD/componentcompletedcommand.h
+HEADERS += $$PWD//completecomponentcommand.h
 HEADERS += $$PWDstatepreviewimagechangedcommand.h
 HEADERS += $$PWD//imagecontainer.h
 HEADERS += $$PWD/childrenchangedcommand.h
@@ -45,6 +47,8 @@ HEADERS += $$PWD/../include/nodeinstanceserverinterface.h
 
 
 SOURCES +=  $$PWD/behaviornodeinstance.cpp
+SOURCES +=  $$PWD/componentcompletedcommand.cpp
+SOURCES +=  $$PWD/completecomponentcommand.cpp
 SOURCES +=  $$PWD/statepreviewimagechangedcommand.cpp
 SOURCES +=  $$PWD/imagecontainer.cpp
 SOURCES +=  $$PWD/childrenchangedcommand.cpp
index 41eee3c..0520c98 100644 (file)
@@ -23,6 +23,7 @@
 #include "changeidscommand.h"
 #include "changestatecommand.h"
 #include "addimportcommand.h"
+#include "completecomponentcommand.h"
 
 #include "informationchangedcommand.h"
 #include "pixmapchangedcommand.h"
@@ -30,6 +31,7 @@
 #include "childrenchangedcommand.h"
 #include "imagecontainer.h"
 #include "statepreviewimagechangedcommand.h"
+#include "componentcompletedcommand.h"
 
 namespace QmlDesigner {
 
@@ -83,6 +85,11 @@ void NodeInstanceClientProxy::statePreviewImagesChanged(const StatePreviewImageC
     writeCommand(QVariant::fromValue(command));
 }
 
+void NodeInstanceClientProxy::componentCompleted(const ComponentCompletedCommand &command)
+{
+    writeCommand(QVariant::fromValue(command));
+}
+
 void NodeInstanceClientProxy::flush()
 {
 }
@@ -142,6 +149,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
     static const int changeIdsCommandType = QMetaType::type("ChangeIdsCommand");
     static const int changeStateCommandType = QMetaType::type("ChangeStateCommand");
     static const int addImportCommandType = QMetaType::type("AddImportCommand");
+    static const int completeComponentCommandType = QMetaType::type("CompleteComponentCommand");
 
     if (command.userType() ==  createInstancesCommandType)
         nodeInstanceServer()->createInstances(command.value<CreateInstancesCommand>());
@@ -167,6 +175,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
         nodeInstanceServer()->changeState(command.value<ChangeStateCommand>());
     else if (command.userType() ==  addImportCommandType)
         nodeInstanceServer()->addImport(command.value<AddImportCommand>());
+    else if (command.userType() ==  completeComponentCommandType)
+        nodeInstanceServer()->completeComponent(command.value<CompleteComponentCommand>());
     else
         Q_ASSERT(false);
 }
index 5206fc5..3fc1e0a 100644 (file)
@@ -25,6 +25,8 @@ public:
     void pixmapChanged(const PixmapChangedCommand &command);
     void childrenChanged(const ChildrenChangedCommand &command);
     void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command);
+    void componentCompleted(const ComponentCompletedCommand &command);
+
     void flush();
     qint64 bytesToWrite() const;
 
index 32dcc85..fdba9ec 100644 (file)
@@ -36,6 +36,8 @@
 #include "changestatecommand.h"
 #include "addimportcommand.h"
 #include "childrenchangedcommand.h"
+#include "completecomponentcommand.h"
+#include "componentcompletedcommand.h"
 
 #include <iostream>
 #include <stdio.h>
@@ -76,8 +78,6 @@ void NodeInstanceServer::createInstances(const CreateInstancesCommand &command)
             }
 
         }
-
-        instance.doComponentComplete();
     }
 
     nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
@@ -221,6 +221,17 @@ void NodeInstanceServer::changeState(const ChangeStateCommand &command)
     startRenderTimer();
 }
 
+void NodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
+{
+    foreach(qint32 instanceId, command.instances()) {
+        if (hasInstanceForId(instanceId)) {
+            ServerNodeInstance instance = instanceForId(instanceId);
+            instance.doComponentComplete();
+            m_componentCompletedVector.append(instanceId);
+        }
+    }
+}
+
 void NodeInstanceServer::addImport(const AddImportCommand &command)
 {
     QString importStatement = QString("import ");
@@ -787,6 +798,10 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
             if (!parentChangedSet.isEmpty())
                 sendChildrenChangedCommand(parentChangedSet.toList());
 
+            if (!m_componentCompletedVector.isEmpty())
+                nodeInstanceClient()->componentCompleted(ComponentCompletedCommand(m_componentCompletedVector));
+            m_componentCompletedVector.clear();
+
             if (!dirtyInstanceSet.isEmpty())
                 nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(dirtyInstanceSet.toList()));
 
index 830df50..f4fe0aa 100644 (file)
@@ -49,6 +49,7 @@ public:
     void reparentInstances(const ReparentInstancesCommand &command);
     void changeState(const ChangeStateCommand &command);
     void addImport(const AddImportCommand &command);
+    void completeComponent(const CompleteComponentCommand &command);
 
     ServerNodeInstance instanceForId(qint32 id) const;
     bool hasInstanceForId(qint32 id) const;
@@ -127,6 +128,7 @@ private:
     int m_timer;
     bool m_slowRenderTimer;
     QVector<InstancePropertyPair> m_changedPropertyList;
+    QVector<qint32> m_componentCompletedVector;
     QStringList m_importList;
 };
 
index 80800b4..d4a567d 100644 (file)
@@ -16,6 +16,7 @@
 #include "reparentinstancescommand.h"
 #include "changeidscommand.h"
 #include "changestatecommand.h"
+#include "completecomponentcommand.h"
 
 #include "informationchangedcommand.h"
 #include "pixmapchangedcommand.h"
@@ -24,6 +25,7 @@
 #include "childrenchangedcommand.h"
 #include "imagecontainer.h"
 #include "statepreviewimagechangedcommand.h"
+#include "componentcompletedcommand.h"
 
 
 namespace QmlDesigner {
@@ -117,6 +119,12 @@ void NodeInstanceServerInterface::registerCommands()
 
     qRegisterMetaType<StatePreviewImageChangedCommand>("StatePreviewImageChangedCommand");
     qRegisterMetaTypeStreamOperators<StatePreviewImageChangedCommand>("StatePreviewImageChangedCommand");
+
+    qRegisterMetaType<CompleteComponentCommand>("CompleteComponentCommand");
+    qRegisterMetaTypeStreamOperators<CompleteComponentCommand>("CompleteComponentCommand");
+
+    qRegisterMetaType<ComponentCompletedCommand>("ComponentCompletedCommand");
+    qRegisterMetaTypeStreamOperators<ComponentCompletedCommand>("ComponentCompletedCommand");
 }
 
 }
index fa14071..69b0209 100644 (file)
@@ -22,6 +22,7 @@
 #include "changeidscommand.h"
 #include "changestatecommand.h"
 #include "addimportcommand.h"
+#include "completecomponentcommand.h"
 
 #include "informationchangedcommand.h"
 #include "pixmapchangedcommand.h"
@@ -29,6 +30,7 @@
 #include "childrenchangedcommand.h"
 #include "imagecontainer.h"
 #include "statepreviewimagechangedcommand.h"
+#include "componentcompletedcommand.h"
 
 #include "nodeinstanceview.h"
 #include "nodeinstanceclientproxy.h"
@@ -78,6 +80,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
     static const int pixmapChangedCommandType = QMetaType::type("PixmapChangedCommand");
     static const int childrenChangedCommandType = QMetaType::type("ChildrenChangedCommand");
     static const int statePreviewImageChangedCommandType = QMetaType::type("StatePreviewImageChangedCommand");
+    static const int componentCompletedCommandType = QMetaType::type("ComponentCompletedCommand");
 
     if (command.userType() ==  informationChangedCommandType)
         nodeInstanceClient()->informationChanged(command.value<InformationChangedCommand>());
@@ -89,6 +92,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
         nodeInstanceClient()->childrenChanged(command.value<ChildrenChangedCommand>());
     else if (command.userType() == statePreviewImageChangedCommandType)
         nodeInstanceClient()->statePreviewImagesChanged(command.value<StatePreviewImageChangedCommand>());
+    else if (command.userType() == componentCompletedCommandType)
+        nodeInstanceClient()->componentCompleted(command.value<ComponentCompletedCommand>());
     else
         Q_ASSERT(false);
 }
@@ -213,4 +218,9 @@ void NodeInstanceServerProxy::addImport(const AddImportCommand &command)
 {
     writeCommand(QVariant::fromValue(command));
 }
+
+void NodeInstanceServerProxy::completeComponent(const CompleteComponentCommand &command)
+{
+    writeCommand(QVariant::fromValue(command));
+}
 } // namespace QmlDesigner
index 40a6baf..f4d4b3a 100644 (file)
@@ -37,6 +37,7 @@ public:
     void changeIds(const ChangeIdsCommand &command);
     void changeState(const ChangeStateCommand &command);
     void addImport(const AddImportCommand &command);
+    void completeComponent(const CompleteComponentCommand &command);
 
     void setBlockUpdates(bool block);
 
index 20465dd..65a0e1f 100644 (file)
@@ -73,6 +73,8 @@
 #include "childrenchangedcommand.h"
 #include "imagecontainer.h"
 #include "statepreviewimagechangedcommand.h"
+#include "completecomponentcommand.h"
+#include "componentcompletedcommand.h"
 
 #include "nodeinstanceserverproxy.h"
 
@@ -144,6 +146,7 @@ void NodeInstanceView::modelAttached(Model *model)
         nodeInstanceServer()->addImport(createImportCommand(import));
 
     loadNodes(allModelNodes());
+
     setBlockUpdates(false);
 }
 
@@ -176,6 +179,7 @@ void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
     NodeInstance instance = loadNode(createdNode);
     nodeInstanceServer()->createInstances(createCreateInstancesCommand(QList<NodeInstance>() << instance));
     nodeInstanceServer()->changePropertyValues(createChangeValueCommand(createdNode.variantProperties()));
+    nodeInstanceServer()->completeComponent(createComponentCompleteCommand(QList<NodeInstance>() << instance));
 }
 
 /*! \brief Notifing the view that a node was created.
@@ -427,6 +431,10 @@ void NodeInstanceView::instancePropertyChange(const QList<QPair<ModelNode, QStri
 
 }
 
+void NodeInstanceView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/)
+{
+}
+
 void NodeInstanceView::importAdded(const Import &import)
 {
     nodeInstanceServer()->addImport(createImportCommand(import));
@@ -456,17 +464,12 @@ void NodeInstanceView::loadNodes(const QList<ModelNode> &nodeList)
         bindingPropertyList.append(node.bindingProperties());
     }
 
-//    QListIterator<ModelNode> listIterator(nodeList);
-//    listIterator.toBack();
-
-//    while (listIterator.hasPrevious())
-//        instanceForNode(listIterator.previous()).doComponentComplete();
-
     nodeInstanceServer()->createInstances(createCreateInstancesCommand(instanceList));
     nodeInstanceServer()->reparentInstances(createReparentInstancesCommand(instanceList));
     nodeInstanceServer()->changeIds(createChangeIdsCommand(instanceList));
     nodeInstanceServer()->changePropertyValues(createChangeValueCommand(variantPropertyList));
     nodeInstanceServer()->changePropertyBindings(createChangeBindingCommand(bindingPropertyList));
+    nodeInstanceServer()->completeComponent(createComponentCompleteCommand(instanceList));
 }
 
 void NodeInstanceView::removeAllInstanceNodeRelationships()
@@ -692,6 +695,28 @@ ClearSceneCommand NodeInstanceView::createClearSceneCommand() const
     return ClearSceneCommand();
 }
 
+CompleteComponentCommand NodeInstanceView::createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const
+{
+    QVector<qint32> containerList;
+    foreach(const NodeInstance &instance, instanceList) {
+        if (instance.instanceId() >= 0)
+            containerList.append(instance.instanceId());
+    }
+
+    return CompleteComponentCommand(containerList);
+}
+
+ComponentCompletedCommand NodeInstanceView::createComponentCompletedCommand(const QList<NodeInstance> &instanceList) const
+{
+    QVector<qint32> containerList;
+    foreach(const NodeInstance &instance, instanceList) {
+        if (instance.instanceId() >= 0)
+            containerList.append(instance.instanceId());
+    }
+
+    return ComponentCompletedCommand(containerList);
+}
+
 CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const
 {
     QVector<InstanceContainer> containerList;
@@ -910,6 +935,23 @@ void NodeInstanceView::statePreviewImagesChanged(const StatePreviewImageChangedC
 
 }
 
+void NodeInstanceView::componentCompleted(const ComponentCompletedCommand &command)
+{
+    if (!model())
+        return;
+
+    QVector<ModelNode> nodeVector;
+
+    foreach(const qint32 &instanceId, command.instances()) {
+        if (hasModelNodeForInternalId(instanceId)) {
+            nodeVector.append(modelNodeForInternalId(instanceId));
+        }
+    }
+
+    if (!nodeVector.isEmpty())
+        emitInstancesCompleted(nodeVector);
+}
+
 void NodeInstanceView::childrenChanged(const ChildrenChangedCommand &command)
 {
      if (!model())
index 7c2b613..fc4a577 100644 (file)
@@ -393,6 +393,12 @@ void AbstractView::emitInstancePropertyChange(const QList<QPair<ModelNode, QStri
         model()->m_d->notifyInstancePropertyChange(propertyList);
 }
 
+void AbstractView::emitInstancesCompleted(const QVector<ModelNode> &nodeVector)
+{
+    if (model() && nodeInstanceView() == this)
+        model()->m_d->notifyInstancesCompleted(nodeVector);
+}
+
 void AbstractView::changeRootNodeType(const QString &type, int majorVersion, int minorVersion)
 {
     Internal::WriteLocker locker(m_model.data());
index f1c0558..8e2daf9 100644 (file)
@@ -414,6 +414,35 @@ void ModelPrivate::notifyInstancePropertyChange(const QList<QPair<ModelNode, QSt
     }
 }
 
+void ModelPrivate::notifyInstancesCompleted(const QVector<ModelNode> &nodeVector)
+{
+    bool resetModel = false;
+    QString description;
+
+    QVector<Internal::InternalNode::Pointer> internalVector(toInternalNodeVector(nodeVector));
+
+    try {
+        if (rewriterView())
+            rewriterView()->instancesCompleted(toModelNodeVector(internalVector, rewriterView()));
+    } catch (RewritingException &e) {
+        description = e.description();
+        resetModel = true;
+    }
+
+    foreach (const QWeakPointer<AbstractView> &view, m_viewList) {
+        Q_ASSERT(view != 0);
+        view->instancesCompleted(toModelNodeVector(internalVector, view.data()));
+    }
+
+    if (nodeInstanceView()) {
+        nodeInstanceView()->instancesCompleted(toModelNodeVector(internalVector, nodeInstanceView()));
+    }
+
+    if (resetModel) {
+        resetModelByRewriter(description);
+    }
+}
+
 void ModelPrivate::notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data)
 {
     bool resetModel = false;
@@ -1026,6 +1055,15 @@ QList<ModelNode> ModelPrivate::toModelNodeList(const QList<InternalNode::Pointer
     return newNodeList;
 }
 
+QVector<ModelNode> ModelPrivate::toModelNodeVector(const QVector<InternalNode::Pointer> &nodeVector, AbstractView *view) const
+{
+    QVector<ModelNode> newNodeVector;
+    foreach (const Internal::InternalNode::Pointer &node, nodeVector)
+        newNodeVector.append(ModelNode(node, model(), view));
+
+    return newNodeVector;
+}
+
 QList<Internal::InternalNode::Pointer> ModelPrivate::toInternalNodeList(const QList<ModelNode> &nodeList) const
 {
     QList<Internal::InternalNode::Pointer> newNodeList;
@@ -1035,6 +1073,15 @@ QList<Internal::InternalNode::Pointer> ModelPrivate::toInternalNodeList(const QL
     return newNodeList;
 }
 
+QVector<Internal::InternalNode::Pointer> ModelPrivate::toInternalNodeVector(const QVector<ModelNode> &nodeVector) const
+{
+    QVector<Internal::InternalNode::Pointer> newNodeVector;
+    foreach (const ModelNode &node, nodeVector)
+        newNodeVector.append(node.internalNode());
+
+    return newNodeVector;
+}
+
 void ModelPrivate::changeSelectedNodes(const QList<InternalNode::Pointer> &newSelectedNodeList,
                                        const QList<InternalNode::Pointer> &oldSelectedNodeList)
 {
index 74531b9..d824164 100644 (file)
@@ -144,7 +144,7 @@ public:
 
     void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
     void notifyInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
-
+    void notifyInstancesCompleted(const QVector<ModelNode> &nodeList);
 
 
     void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
@@ -207,6 +207,8 @@ private: //functions
     void removeNodeFromModel(const InternalNodePointer &node);
     QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList) const;
     QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &nodeList, AbstractView *view) const;
+    QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &nodeVector, AbstractView *view) const;
+    QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &nodeVector) const;
 
 private:
     Model *m_q;
index 9cadcf3..40e450f 100644 (file)
@@ -362,6 +362,9 @@ void QmlModelView::instancePropertyChange(const QList<QPair<ModelNode, QString>
         nodeInstancePropertyChanged(propertyPair.first, propertyPair.second);
     }
 }
+void QmlModelView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/)
+{
+}
 
 void QmlModelView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName)
 {
@@ -431,7 +434,7 @@ void QmlModelView::otherPropertyChanged(const QmlObjectNode &/*qmlObjectNode*/,
 {
 }
 
-void  QmlModelView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState)
+void  QmlModelView::stateChanged(const QmlModelState &/*newQmlModelState*/, const QmlModelState &/*oldQmlModelState*/)
 {
 }
 
index 470c3f6..fd7e2a8 100644 (file)
@@ -385,6 +385,10 @@ void RewriterView::instancePropertyChange(const QList<QPair<ModelNode, QString>
 {
 }
 
+void RewriterView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/)
+{
+}
+
 
 void RewriterView::selectedNodesChanged(const QList<ModelNode> & /* selectedNodeList, */, const QList<ModelNode> & /*lastSelectedNodeList */)
 {
index 3977d77..5e50053 100644 (file)
@@ -212,6 +212,14 @@ void ViewLogger::instancePropertyChange(const QList<QPair<ModelNode, QString> >
         m_output << time() << indent("property: ") << propertyPair.first << propertyPair.second << endl;
 }
 
+void ViewLogger::instancesCompleted(const QVector<ModelNode> &completedNodeList)
+{
+     m_output << time() << indent("instancesCompleted:") << endl;
+
+     foreach(const ModelNode &node, completedNodeList)
+         m_output << time() << indent("node: ") << node << endl;
+
+}
 
 } // namespace Internal
 } // namespace QmlDesigner
index a20b7b2..75de80b 100644 (file)
@@ -73,7 +73,7 @@ public:
     void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
-
+    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
 protected:
     QString time() const;