예제 #1
0
void ModelMerger::replaceModel(const ModelNode &modelNode)
{
        view()->model()->changeImports(modelNode.model()->imports(), QList<Import>());
        view()->model()->setFileUrl(modelNode.model()->fileUrl());

    try {
        RewriterTransaction transaction(view()->beginRewriterTransaction());

        ModelNode rootNode(view()->rootModelNode());

        foreach (const QString &propertyName, rootNode.propertyNames())
            rootNode.removeProperty(propertyName);

        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());
    } catch (RewritingException &e) { 
        qWarning() << e.description(); //silent error
    }
}
예제 #2
0
static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QString, QString> &idRenamingHash, AbstractView *view)
{
    QList<QPair<QString, QVariant> > propertyList;
    foreach (const VariantProperty &variantProperty, modelNode.variantProperties()) {
        propertyList.append(QPair<QString, QVariant>(variantProperty.name(), variantProperty.value()));
    }
    ModelNode newNode(view->createModelNode(modelNode.type(),modelNode.majorVersion(),modelNode.minorVersion(), propertyList));
    syncBindingProperties(newNode, modelNode, idRenamingHash);
    syncId(newNode, modelNode, idRenamingHash);
    syncNodeProperties(newNode, modelNode, idRenamingHash, view);
    syncNodeListProperties(newNode, modelNode, idRenamingHash, view);

    return newNode;
}
예제 #3
0
void ModelMerger::replaceModel(const ModelNode &modelNode)
{
     RewriterTransaction transaction(view()->beginRewriterTransaction());

    foreach (const Import &import, modelNode.model()->imports())
        view()->model()->addImport(import);
    view()->model()->setFileUrl(modelNode.model()->fileUrl());

    ModelNode rootNode(view()->rootModelNode());

    foreach (const QString &propertyName, rootNode.propertyNames())
        rootNode.removeProperty(propertyName);

    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());
}