Commit 9343583f authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Move createQmlState to QmlModelState

Change-Id: I8e88bd6f3a97e09f2325a28be975352ccd48a909
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 1fd9707d
......@@ -56,8 +56,6 @@ public:
QmlModelState baseState() const;
QmlModelStateGroup rootStateGroup() const;
ModelNode createQmlState(const PropertyListType &propertyList = PropertyListType());
QmlItemNode rootQmlItemNode() const;
protected:
......
......@@ -72,6 +72,8 @@ public:
QmlModelState duplicate(const QString &name) const;
QmlModelStateGroup stateGroup() const;
static ModelNode createQmlState(AbstractView *view, const PropertyListType &propertyList);
protected:
void addChangeSetIfNotExists(const ModelNode &node);
static QmlModelState createBaseState(const QmlModelView *view);
......
......@@ -506,7 +506,7 @@ QmlModelState QmlModelStateGroup::addState(const QString &name)
PropertyListType propertyList;
propertyList.append(qMakePair(PropertyName("name"), QVariant(name)));
ModelNode newState = QmlObjectNode(modelNode()).qmlModelView()->createQmlState(propertyList);
ModelNode newState = QmlModelState::createQmlState(modelNode().view(), propertyList);
modelNode().nodeListProperty("states").reparentHere(newState);
return newState;
......
......@@ -47,7 +47,7 @@
#include "modelmerger.h"
#include "nodemetainfo.h"
#include <utils/qtcassert.h>
namespace QmlDesigner {
......@@ -95,16 +95,4 @@ bool QmlModelView::hasInstanceForModelNode(const ModelNode &modelNode)
return nodeInstanceView() && nodeInstanceView()->hasInstanceForNode(modelNode);
}
ModelNode QmlModelView::createQmlState(const QmlDesigner::PropertyListType &propertyList)
{
QTC_CHECK(majorQtQuickVersion() < 3);
if (majorQtQuickVersion() > 1)
return createModelNode("QtQuick.State", 2, 0, propertyList);
else
return createModelNode("QtQuick.State", 1, 0, propertyList);
}
} //QmlDesigner
......@@ -35,6 +35,7 @@
#include <invalidmodelnodeexception.h>
#include "bindingproperty.h"
#include <utils/qtcassert.h>
namespace QmlDesigner {
......@@ -294,8 +295,7 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
// QmlModelState newState(stateGroup().addState(name));
PropertyListType propertyList;
propertyList.append(qMakePair(PropertyName("name"), QVariant(name)));
QmlModelState newState ( qmlModelView()->createQmlState(propertyList) );
QmlModelState newState(createQmlState(qmlModelView(), propertyList));
foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
ModelNode newModelNode(qmlModelView()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
foreach (const BindingProperty &bindingProperty, childNode.bindingProperties())
......@@ -316,6 +316,16 @@ QmlModelStateGroup QmlModelState::stateGroup() const
return parentNode.states();
}
ModelNode QmlModelState::createQmlState(AbstractView *view, const PropertyListType &propertyList)
{
QTC_CHECK(view->majorQtQuickVersion() < 3);
if (view->majorQtQuickVersion() > 1)
return view->createModelNode("QtQuick.State", 2, 0, propertyList);
else
return view->createModelNode("QtQuick.State", 1, 0, propertyList);
}
QmlModelState QmlModelState::createBaseState(const QmlModelView *view)
{
QmlModelState fxState(view->rootModelNode());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment