Exemplo n.º 1
0
QmlPropertyChanges QmlModelState::propertyChanges(const ModelNode &node)
{
    if (!isBaseState()) {
        addChangeSetIfNotExists(node);
        foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
            //### exception if not valid QmlModelStateOperation
            if (QmlPropertyChanges::isValidQmlPropertyChanges(childNode)
                    && QmlPropertyChanges(childNode).target().isValid()
                    && QmlPropertyChanges(childNode).target() == node)
                return QmlPropertyChanges(childNode); //### exception if not valid(childNode);
        }
    }
Exemplo n.º 2
0
QList<QmlPropertyChanges> QmlModelState::propertyChanges() const
{
    //### exception if not valid
    QList<QmlPropertyChanges> returnList;

    if (isBaseState())
        return returnList;

    if (!modelNode().hasProperty("changes"))
        return returnList;

    Q_ASSERT(modelNode().property("changes").isNodeListProperty());

    foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
        //### exception if not valid QmlModelStateOperation
        if (QmlPropertyChanges(childNode).isValid())
            returnList.append(QmlPropertyChanges(childNode));
    }
    return returnList;
}
Exemplo n.º 3
0
void QmlModelState::addChangeSetIfNotExists(const ModelNode &node)
{
    //### exception if not valid

    if (!isValid())
        throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    if (hasPropertyChanges(node)) {
        return; //changeSet already there
    }

    ModelNode newChangeSet;
    if (qmlModelView()->rootModelNode().majorQtQuickVersion() > 1) {
        newChangeSet = modelNode().view()->createModelNode("QtQuick.PropertyChanges", 2, 0);
    } else {
        newChangeSet = modelNode().view()->createModelNode("QtQuick.PropertyChanges", 1, 0);
    }

    modelNode().nodeListProperty("changes").reparentHere(newChangeSet);

    QmlPropertyChanges(newChangeSet).setTarget(node);
    Q_ASSERT(QmlPropertyChanges(newChangeSet).isValid());
}