Exemple #1
0
void ModelRewriter::removeAnchor(const InternalNodeState::Pointer &state, const QString &propertyName)
{
    if (state.isNull() || !state->isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    m_modelToTextMerger.removeProperty(state, propertyName);

    if (!modificationGroupActive())
        m_modelToTextMerger.applyChanges(*m_textModifier);
}
Exemple #2
0
/**
  Removes a property from the given state in the QML source text.

  \param state The state from which to remove the property.
  \param name The name of the property to remove.
 */
void ModelRewriter::removeProperty(const InternalNodeState::Pointer& state, const QString& name)
{
    if (state.isNull() || !state->isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

//    qDebug() << "remove property" << name << "in node" << state->modelNode()->id() << "for state" << state->modelState()->name();

    m_modelToTextMerger.removeProperty(state, name);

    if (!modificationGroupActive())
        m_modelToTextMerger.applyChanges(*m_textModifier);
}
Exemple #3
0
void ModelRewriter::setAnchor(const InternalNodeState::Pointer &state, const QString &propertyName, const QVariant &value)
{
    if (state.isNull() || !state->isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    if (state->propertyLocation(propertyName).isValid())
        m_modelToTextMerger.changePropertyValue(state, propertyName, value);
    else
        m_modelToTextMerger.addProperty(state, propertyName, value);

    if (!modificationGroupActive())
        m_modelToTextMerger.applyChanges(*m_textModifier);
}
Exemple #4
0
/**
  Changes the value of a property in the given state in the QML source text.

  \param state The state for which the property is changed.
  \param name The name of the property to change.
  \param value The new value for the property.

  \note Changing a property value can only be done after the property has been added to that state.
  \see {@link addProperty}
 */
void ModelRewriter::changePropertyValue(const InternalNodeState::Pointer& state, const QString& name, const QVariant& value)
{
    if (state->modelNode()->isReadOnly())
        return; //the rewriter ignores read only nodes
    if (state.isNull() || !state->isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    if (!modificationGroupActive() && !state->location().isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    m_modelToTextMerger.changePropertyValue(state, name, value);

    if (!modificationGroupActive())
        m_modelToTextMerger.applyChanges(*m_textModifier);
}