static void handleTabComponent(const ModelNode &modelNode)
{
    if (modelNode.hasNodeProperty("component")
            && modelNode.nodeProperty("component").modelNode().nodeSourceType() == ModelNode::NodeWithComponentSource) {
        designDocument()->changeToSubComponent(modelNode.nodeProperty("component").modelNode());
    }
}
static void handleDelegate(const ModelNode &modelNode)
{
    if (modelNode.metaInfo().isView()
            && modelNode.hasNodeProperty("delegate")
            && modelNode.nodeProperty("delegate").modelNode().nodeSourceType() == ModelNode::NodeWithComponentSource)
        designDocument()->changeToSubComponent(modelNode.nodeProperty("delegate").modelNode());
}
static void syncNodeProperties(ModelNode &outputNode, const ModelNode &inputNode, const QHash<QString, QString> &idRenamingHash, AbstractView *view)
{
    foreach (const NodeProperty &nodeProperty, inputNode.nodeProperties()) {
        ModelNode newNode = createNodeFromNode(nodeProperty.modelNode(), idRenamingHash, view);
        outputNode.nodeProperty(nodeProperty.name()).reparentHere(newNode);
    }
}
void GradientLineQmlAdaptor::setupGradient()
{
    if (!active())
        return;

    ModelNode modelNode = m_itemNode.modelNode();
    QLinearGradient newGradient;
    QVector<QGradientStop> stops;

    if (!modelNode.isValid())
        return;

    if (modelNode.hasBindingProperty(gradientName()))
        return;

    if (modelNode.hasProperty(gradientName())) { //gradient exists

        ModelNode gradientNode = modelNode.nodeProperty(gradientName()).modelNode();
        QList<ModelNode> stopList = gradientNode.nodeListProperty("stops").toModelNodeList();

        foreach (const ModelNode &stopNode, stopList) {
            QmlObjectNode stopObjectNode = stopNode;
            if (stopObjectNode.isValid()) {
                qreal position = stopObjectNode.modelValue("position").toReal();
                QColor color = stopObjectNode.modelValue("color").value<QColor>();
                stops.append( QPair<qreal, QColor>(position, color));
            }
        }
static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode)
{
    QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally();

    QHash<PropertyName, QVariant> propertyHash;

    getProperties(modelNode, propertyHash);

    ModelNode componentModelNode;

    if (modelNode.hasNodeProperty("sourceComponent")) {
        componentModelNode = modelNode.nodeProperty("sourceComponent").modelNode();
    } else if (modelNode.hasNodeListProperty("component")) {

     /*
     * The component property should be a NodeProperty, but currently is a NodeListProperty, because
     * the default property is always implcitly a NodeListProperty. This is something that has to be fixed.
     */

        componentModelNode = modelNode.nodeListProperty("component").toModelNodeList().first();
    }

    Core::EditorManager::openEditor(componentModelNode.metaInfo().componentFileName(), Core::Id(), Core::EditorManager::DoNotMakeVisible);

    ModelNode rootModelNode = currentDesignDocument()->rewriterView()->rootModelNode();
    applyProperties(rootModelNode, propertyHash);
}
Exemple #6
0
static ModelNode resolveBinding(const QString &binding, ModelNode currentNode, AbstractView* view)
{
    int i = 0;
    QString element = binding.split(QLatin1Char('.')).at(0);
    while (!element.isEmpty())
    {
        if (element == "parent") {
            if (currentNode.hasParentProperty())
                currentNode = currentNode.parentProperty().toNodeAbstractProperty().parentModelNode();
            else
                return ModelNode(); //binding not valid
        } else if (currentNode.hasProperty(element)) {
            if (currentNode.property(element).isNodeProperty()) {
                currentNode = currentNode.nodeProperty(element).modelNode();
            } else {
                currentNode = view->modelNodeForId(element); //id
                if (!currentNode.isValid())
                    return ModelNode(); //binding not valid
            }
        } else {
            currentNode = view->modelNodeForId(element); //id
        }
        i++;
        if (i < binding.split(QLatin1Char('.')).count())
            element = binding.split(QLatin1Char('.')).at(i);
        else
            element.clear();
    }
    return currentNode;

}
static bool hasDelegateWithFileComponent(const ModelNode &node)
{
    if (node.isValid()
            && node.metaInfo().isValid()
            && node.metaInfo().isView()
            && node.hasNodeProperty("delegate")
            && node.nodeProperty("delegate").modelNode().metaInfo().isFileComponent())
        return true;

    return false;
}
Exemple #8
0
static bool isInEditedPath(const NodeAbstractProperty &propertyParent, const ModelNode &editingPathViewModelNode)
{
    if (editingPathViewModelNode.isValid()) {
        if (editingPathViewModelNode.hasNodeProperty("path")) {
            ModelNode pathModelNode = editingPathViewModelNode.nodeProperty("path").modelNode();
            if (pathModelNode.metaInfo().isSubclassOf("QtQuick.Path")) {
                if (propertyParent.name() == "pathElements" && propertyParent.parentModelNode() == pathModelNode)
                    return true;
            }
        }
    }

    return false;
}
Exemple #9
0
void BehaviorDialog::accept()
{
    QDialog::accept();
    if (m_modelNode.hasProperty(m_propertyName))
        m_modelNode.removeProperty(m_propertyName);
    if (m_ui->comboBox->currentIndex() == 0) {
        RewriterTransaction transaction(m_modelNode.view()->beginRewriterTransaction());
        ModelNode Behavior = m_modelNode.view()->createModelNode("Qt/Behavior", 4, 7);
        m_modelNode.nodeProperty(m_propertyName).reparentHere(Behavior);
        ModelNode animation = m_modelNode.view()->createModelNode("Qt/NumberAnimation", 4, 7);
        animation.variantProperty("duration") = m_ui->duration->value();
        animation.variantProperty("easing") = m_ui->curve->currentText();
        Behavior.nodeProperty("animation").reparentHere(animation);
    } else {
        RewriterTransaction transaction(m_modelNode.view()->beginRewriterTransaction());
        ModelNode springFollow = m_modelNode.view()->createModelNode("Qt/SpringFollow", 4, 7);
        m_modelNode.nodeProperty(m_propertyName).reparentHere(springFollow);
        springFollow.variantProperty("velocity") = m_ui->velocity->value();
        springFollow.variantProperty("spring") = m_ui->spring->value();
        springFollow.variantProperty("damping") = m_ui->damping->value();
        springFollow.bindingProperty("source") = m_ui->source->text();
    }
}
static ModelNode addNodeChild(const ModelNode &parentNode, const QString &typeName, int major, int minor, const QString &parentProperty)
{
    ModelNode newNode = parentNode.view()->createModelNode(typeName, major, minor);
    parentNode.nodeProperty(parentProperty).reparentHere(newNode);
    return newNode;
}
static void openFileComponentForDelegate(const ModelNode &modelNode)
{
    openFileComponent(modelNode.nodeProperty("delegate").modelNode());
}