Commit 599b72a2 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Use is valid functons instead of create a invalid node



Change-Id: I5f7cdcede593cdce2c577315ccead95e8841870e
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 07147a32
......@@ -53,7 +53,7 @@ static inline bool checkIfNodeIsAView(const ModelNode &node)
static inline void getProperties(const ModelNode node, QHash<PropertyName, QVariant> &propertyHash)
{
if (QmlObjectNode(node).isValid()) {
if (QmlObjectNode::isValidQmlObjectNode(node)) {
foreach (const PropertyName &propertyName, node.propertyNames()) {
if (node.property(propertyName).isVariantProperty() ||
(node.property(propertyName).isBindingProperty() &&
......@@ -61,15 +61,17 @@ static inline void getProperties(const ModelNode node, QHash<PropertyName, QVari
propertyHash.insert(propertyName, QmlObjectNode(node).instanceValue(propertyName));
}
}
}
QmlItemNode itemNode(node);
if (itemNode.isValid()) {
propertyHash.insert("width", itemNode.instanceValue("width"));
propertyHash.insert("height", itemNode.instanceValue("height"));
propertyHash.remove("x");
propertyHash.remove("y");
propertyHash.remove("rotation");
propertyHash.remove("opacity");
if (QmlItemNode::isValidQmlItemNode(node)) {
QmlItemNode itemNode(node);
propertyHash.insert("width", itemNode.instanceValue("width"));
propertyHash.insert("height", itemNode.instanceValue("height"));
propertyHash.remove("x");
propertyHash.remove("y");
propertyHash.remove("rotation");
propertyHash.remove("opacity");
}
}
}
......
......@@ -104,8 +104,8 @@ void FormEditorView::modelAttached(Model *model)
Q_ASSERT(m_scene->formLayerItem());
if (rootQmlObjectNode().toQmlItemNode().isValid())
setupFormEditorItemTree(rootQmlObjectNode().toQmlItemNode());
if (QmlItemNode::isValidQmlItemNode(rootModelNode()))
setupFormEditorItemTree(rootModelNode());
m_formEditorWidget->updateActions();
}
......@@ -159,7 +159,7 @@ void FormEditorView::nodeCreated(const ModelNode &createdNode)
QmlModelView::nodeCreated(createdNode);
ModelNode node(createdNode);
//If the node has source for components/custom parsers we ignore it.
if (QmlItemNode(node).isValid() && node.nodeSourceType() == ModelNode::NodeWithoutSource) //only setup QmlItems
if (QmlItemNode::isValidQmlItemNode(node) && node.nodeSourceType() == ModelNode::NodeWithoutSource) //only setup QmlItems
setupFormEditorItemTree(QmlItemNode(node));
}
......@@ -648,8 +648,8 @@ void FormEditorView::delayedReset()
m_resizeTool->clear();
m_dragTool->clear();
m_scene->clearFormEditorItems();
if (rootQmlObjectNode().toQmlItemNode().isValid())
setupFormEditorItemTree(rootQmlObjectNode().toQmlItemNode());
if (QmlItemNode::isValidQmlItemNode(rootModelNode()))
setupFormEditorItemTree(rootModelNode());
}
......
......@@ -347,12 +347,12 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent)
QVector<ModelNode> nodeReparentVector;
NodeAbstractProperty parentProperty;
QmlItemNode parent(newParent->qmlItemNode());
if (parent.isValid()) {
if (parent.hasDefaultProperty())
parentProperty = parent.nodeAbstractProperty(parent.defaultProperty());
QmlItemNode parentItemNode(newParent->qmlItemNode());
if (parentItemNode.isValid()) {
if (parentItemNode.hasDefaultProperty())
parentProperty = parentItemNode.nodeAbstractProperty(parentItemNode.defaultProperty());
else
parentProperty = parent.nodeAbstractProperty("data");
parentProperty = parentItemNode.nodeAbstractProperty("data");
foreach (FormEditorItem* item, m_itemList) {
if (!item || !item->qmlItemNode().isValid())
......
......@@ -139,8 +139,9 @@ void ComponentView::searchForComponentAndAddToList(const ModelNode &node)
m_standardItemModel->appendRow(item);
} else {
QString description;
ModelNode parentNode = node.parentProperty().parentModelNode();
if (parentNode.isValid()) {
if (node.hasParentProperty()) {
ModelNode parentNode = node.parentProperty().parentModelNode();
if (parentNode.id().isEmpty())
description = parentNode.simplifiedTypeName() + QLatin1Char(' ');
else
......
......@@ -379,7 +379,7 @@ void DesignDocument::deleteSelected()
RewriterTransaction transaction(rewriterView());
QList<ModelNode> toDelete = qmlModelView()->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode(node).isValid())
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
QmlObjectNode(node).destroy();
}
......@@ -562,7 +562,7 @@ void DesignDocument::paste()
if (!targetNode.isValid())
targetNode = view.rootModelNode();
if (targetNode.parentProperty().isValid() &&
if (targetNode.hasParentProperty() &&
(pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
(pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
(pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
......@@ -572,7 +572,7 @@ void DesignDocument::paste()
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
scatterItem(pastedNode, targetNode);
if (targetNode.nodeListProperty(defaultProperty).isValid())
if (targetNode.hasNodeListProperty(defaultProperty))
targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
transaction.commit();
......
......@@ -47,8 +47,8 @@
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
{
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
if (parentNode.isValid()) {
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x") = localPos.toPoint().x();
modelNode.variantProperty("y") = localPos.toPoint().y();
......
......@@ -42,8 +42,8 @@
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
{
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
if (parentNode.isValid()) {
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x") = localPos.toPoint().x();
modelNode.variantProperty("y") = localPos.toPoint().y();
......@@ -303,7 +303,7 @@ void NavigatorView::leftButtonClicked()
foreach (const ModelNode &node, selectedModelNodes()) {
if (!node.isRootNode() && !node.parentProperty().parentModelNode().isRootNode()) {
if (QmlItemNode(node).isValid()) {
if (QmlItemNode::isValidQmlItemNode(node)) {
QPointF scenePos = QmlItemNode(node).instanceScenePosition();
node.parentProperty().parentModelNode().parentProperty().reparentHere(node);
if (!scenePos.isNull())
......@@ -330,7 +330,7 @@ void NavigatorView::rightButtonClicked()
if (index >= 0) { //for the first node the semantics are not clear enough. Wrapping would be irritating.
ModelNode newParent = node.parentProperty().toNodeListProperty().at(index);
if (QmlItemNode(node).isValid()) {
if (QmlItemNode::isValidQmlItemNode(node)) {
QPointF scenePos = QmlItemNode(node).instanceScenePosition();
newParent.nodeAbstractProperty(newParent.metaInfo().defaultPropertyName()).reparentHere(node);
if (!scenePos.isNull())
......
......@@ -184,7 +184,7 @@ void setupPropertyEditorValue(const PropertyName &name, QDeclarativePropertyMap
}
void createPropertyEditorValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor)
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor)
{
PropertyName propertyName(name);
propertyName.replace('.', '_');
......@@ -196,55 +196,55 @@ void createPropertyEditorValue(const QmlObjectNode &fxObjectNode, const Property
propertyMap->insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
}
valueObject->setName(name);
valueObject->setModelNode(fxObjectNode);
valueObject->setModelNode(qmlObjectNode);
if (fxObjectNode.propertyAffectedByCurrentState(name) && !(fxObjectNode.modelNode().property(name).isBindingProperty()))
valueObject->setValue(fxObjectNode.modelValue(name));
if (qmlObjectNode.propertyAffectedByCurrentState(name) && !(qmlObjectNode.modelNode().property(name).isBindingProperty()))
valueObject->setValue(qmlObjectNode.modelValue(name));
else
valueObject->setValue(value);
if (propertyName != "id" &&
fxObjectNode.currentState().isBaseState() &&
fxObjectNode.modelNode().property(propertyName).isBindingProperty()) {
valueObject->setExpression(fxObjectNode.modelNode().bindingProperty(propertyName).expression());
qmlObjectNode.currentState().isBaseState() &&
qmlObjectNode.modelNode().property(propertyName).isBindingProperty()) {
valueObject->setExpression(qmlObjectNode.modelNode().bindingProperty(propertyName).expression());
} else {
valueObject->setExpression(fxObjectNode.instanceValue(name).toString());
valueObject->setExpression(qmlObjectNode.instanceValue(name).toString());
}
}
void PropertyEditor::NodeType::setValue(const QmlObjectNode & fxObjectNode, const PropertyName &name, const QVariant &value)
void PropertyEditor::NodeType::setValue(const QmlObjectNode & qmlObjectNode, const PropertyName &name, const QVariant &value)
{
PropertyName propertyName = name;
propertyName.replace('.', '_');
PropertyEditorValue *propertyValue = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value(propertyName)));
if (propertyValue) {
propertyValue->setValue(value);
if (!fxObjectNode.hasBindingProperty(name))
if (!qmlObjectNode.hasBindingProperty(name))
propertyValue->setExpression(value.toString());
else
propertyValue->setExpression(fxObjectNode.expression(name));
propertyValue->setExpression(qmlObjectNode.expression(name));
}
}
void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor)
void PropertyEditor::NodeType::setup(const QmlObjectNode &qmlObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor)
{
if (!fxObjectNode.isValid())
if (!qmlObjectNode.isValid())
return;
QDeclarativeContext *ctxt = m_view->rootContext();
if (fxObjectNode.isValid()) {
foreach (const PropertyName &propertyName, fxObjectNode.modelNode().metaInfo().propertyNames())
createPropertyEditorValue(fxObjectNode, propertyName, fxObjectNode.instanceValue(propertyName), &m_backendValuesPropertyMap, propertyEditor);
if (qmlObjectNode.isValid()) {
foreach (const PropertyName &propertyName, qmlObjectNode.modelNode().metaInfo().propertyNames())
createPropertyEditorValue(qmlObjectNode, propertyName, qmlObjectNode.instanceValue(propertyName), &m_backendValuesPropertyMap, propertyEditor);
// className
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("className")));
if (!valueObject)
valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
valueObject->setName("className");
valueObject->setModelNode(fxObjectNode.modelNode());
valueObject->setValue(fxObjectNode.modelNode().simplifiedTypeName());
valueObject->setModelNode(qmlObjectNode.modelNode());
valueObject->setValue(qmlObjectNode.modelNode().simplifiedTypeName());
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_backendValuesPropertyMap.insert("className", QVariant::fromValue(valueObject));
......@@ -253,12 +253,12 @@ void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QS
if (!valueObject)
valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
valueObject->setName("id");
valueObject->setValue(fxObjectNode.id());
valueObject->setValue(qmlObjectNode.id());
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject));
// anchors
m_backendAnchorBinding.setup(QmlItemNode(fxObjectNode.modelNode()));
m_backendAnchorBinding.setup(QmlItemNode(qmlObjectNode.modelNode()));
ctxt->setContextProperty("anchorBackend", &m_backendAnchorBinding);
......@@ -267,16 +267,16 @@ void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QS
m_contextObject->setSpecificsUrl(qmlSpecificsFile);
m_contextObject->setStateName(stateName);
if (!fxObjectNode.isValid())
if (!qmlObjectNode.isValid())
return;
ctxt->setContextProperty("propertyCount", QVariant(fxObjectNode.modelNode().properties().count()));
ctxt->setContextProperty("propertyCount", QVariant(qmlObjectNode.modelNode().properties().count()));
m_contextObject->setIsBaseState(fxObjectNode.isInBaseState());
m_contextObject->setIsBaseState(qmlObjectNode.isInBaseState());
m_contextObject->setSelectionChanged(false);
m_contextObject->setSelectionChanged(false);
NodeMetaInfo metaInfo = fxObjectNode.modelNode().metaInfo();
NodeMetaInfo metaInfo = qmlObjectNode.modelNode().metaInfo();
if (metaInfo.isValid()) {
m_contextObject->setMajorVersion(metaInfo.majorVersion());
......@@ -473,12 +473,12 @@ void PropertyEditor::changeValue(const QString &name)
if (value ==0)
return;
QmlObjectNode fxObjectNode(m_selectedNode);
QmlObjectNode qmlObjectNode(m_selectedNode);
QVariant castedValue;
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
castedValue = fxObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value());
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
castedValue = qmlObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value());
} else {
qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)";
return ;
......@@ -489,9 +489,9 @@ void PropertyEditor::changeValue(const QString &name)
return ;
}
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(propertyName))
if (fxObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl"
|| fxObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName))
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl"
|| qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths
QString filePath = castedValue.toUrl().toString();
if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) {
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
......@@ -508,11 +508,11 @@ void PropertyEditor::changeValue(const QString &name)
try {
if (!value->value().isValid()) { //reset
fxObjectNode.removeProperty(propertyName);
qmlObjectNode.removeProperty(propertyName);
} else {
if (castedValue.isValid() && !castedValue.isNull()) {
m_locked = true;
fxObjectNode.setVariantProperty(propertyName, castedValue);
qmlObjectNode.setVariantProperty(propertyName, castedValue);
m_locked = false;
}
}
......@@ -538,38 +538,38 @@ void PropertyEditor::changeExpression(const QString &propertyName)
PropertyName underscoreName(name);
underscoreName.replace('.', '_');
QmlObjectNode fxObjectNode(m_selectedNode);
QmlObjectNode qmlObjectNode(m_selectedNode);
PropertyEditorValue *value = qobject_cast<PropertyEditorValue*>(variantToQObject(m_currentType->m_backendValuesPropertyMap.value(underscoreName)));
if (fxObjectNode.modelNode().metaInfo().isValid() && fxObjectNode.modelNode().metaInfo().hasProperty(name)) {
if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(name)) {
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (QColor(value->expression().remove('"')).isValid()) {
fxObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
transaction.commit(); //committing in the try block
return;
}
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
if (value->expression().compare("false", Qt::CaseInsensitive) == 0 || value->expression().compare("true", Qt::CaseInsensitive) == 0) {
if (value->expression().compare("true", Qt::CaseInsensitive) == 0)
fxObjectNode.setVariantProperty(name, true);
qmlObjectNode.setVariantProperty(name, true);
else
fxObjectNode.setVariantProperty(name, false);
qmlObjectNode.setVariantProperty(name, false);
transaction.commit(); //committing in the try block
return;
}
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
bool ok;
int intValue = value->expression().toInt(&ok);
if (ok) {
fxObjectNode.setVariantProperty(name, intValue);
qmlObjectNode.setVariantProperty(name, intValue);
transaction.commit(); //committing in the try block
return;
}
} else if (fxObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
bool ok;
qreal realValue = value->expression().toFloat(&ok);
if (ok) {
fxObjectNode.setVariantProperty(name, realValue);
qmlObjectNode.setVariantProperty(name, realValue);
transaction.commit(); //committing in the try block
return;
}
......@@ -584,8 +584,8 @@ void PropertyEditor::changeExpression(const QString &propertyName)
if (value->expression().isEmpty())
return;
if (fxObjectNode.expression(name) != value->expression() || !fxObjectNode.propertyAffectedByCurrentState(name))
fxObjectNode.setBindingProperty(name, value->expression());
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
qmlObjectNode.setBindingProperty(name, value->expression());
transaction.commit(); //committing in the try block
}
......@@ -744,13 +744,13 @@ void PropertyEditor::resetView()
m_stackedWidget->addWidget(type->m_view);
m_typeHash.insert(qmlFile.toString(), type);
QmlObjectNode fxObjectNode;
QmlObjectNode qmlObjectNode;
if (m_selectedNode.isValid()) {
fxObjectNode = QmlObjectNode(m_selectedNode);
Q_ASSERT(fxObjectNode.isValid());
qmlObjectNode = QmlObjectNode(m_selectedNode);
Q_ASSERT(qmlObjectNode.isValid());
}
QDeclarativeContext *ctxt = type->m_view->rootContext();
type->setup(fxObjectNode, currentState().name(), qmlSpecificsFile, this);
type->setup(qmlObjectNode, currentState().name(), qmlSpecificsFile, this);
ctxt->setContextProperty("finishedNotify", QVariant(false));
if (specificQmlData.isEmpty())
type->m_contextObject->setSpecificQmlData(specificQmlData);
......@@ -1008,10 +1008,10 @@ void PropertyEditor::instancePropertyChange(const QList<QPair<ModelNode, Propert
}
void PropertyEditor::setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value)
void PropertyEditor::setValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value)
{
m_locked = true;
m_currentType->setValue(fxObjectNode, name, value);
m_currentType->setValue(qmlObjectNode, name, value);
m_locked = false;
}
......
......@@ -356,14 +356,14 @@ void PropertyEditorNodeWrapper::changeValue(const QString &propertyName)
if (name.isNull())
return;
if (m_modelNode.isValid()) {
QmlDesigner::QmlObjectNode fxObjectNode(m_modelNode);
QmlDesigner::QmlObjectNode qmlObjectNode(m_modelNode);
PropertyEditorValue *valueObject = qvariant_cast<PropertyEditorValue *>(m_valuesPropertyMap.value(name));
if (valueObject->value().isValid())
fxObjectNode.setVariantProperty(name, valueObject->value());
qmlObjectNode.setVariantProperty(name, valueObject->value());
else
fxObjectNode.removeProperty(name);
qmlObjectNode.removeProperty(name);
}
}
......@@ -372,17 +372,17 @@ void PropertyEditorNodeWrapper::setup()
Q_ASSERT(m_editorValue);
Q_ASSERT(m_editorValue->modelNode().isValid());
if ((m_editorValue->modelNode().isValid() && m_modelNode.isValid())) {
QmlDesigner::QmlObjectNode fxObjectNode(m_modelNode);
QmlDesigner::QmlObjectNode qmlObjectNode(m_modelNode);
foreach ( const QString &propertyName, m_valuesPropertyMap.keys())
m_valuesPropertyMap.clear(propertyName);
foreach (QObject *object, m_valuesPropertyMap.children())
delete object;
foreach (const QmlDesigner::PropertyName &propertyName, m_modelNode.metaInfo().propertyNames()) {
if (fxObjectNode.isValid()) {
if (qmlObjectNode.isValid()) {
PropertyEditorValue *valueObject = new PropertyEditorValue(&m_valuesPropertyMap);
valueObject->setName(propertyName);
valueObject->setValue(fxObjectNode.instanceValue(propertyName));
valueObject->setValue(qmlObjectNode.instanceValue(propertyName));
connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_valuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_valuesPropertyMap.insert(propertyName, QVariant::fromValue(valueObject));
}
......
......@@ -92,7 +92,7 @@ public:
bool horizontalCentered();
bool verticalCentered();
QVariant itemNode() const { return QVariant::fromValue(m_fxItemNode.modelNode()); }
QVariant itemNode() const { return QVariant::fromValue(m_qmlItemNode.modelNode()); }
QVariant topTarget() const { return QVariant::fromValue(m_topTarget.modelNode()); }
QVariant bottomTarget() const { return QVariant::fromValue(m_bottomTarget.modelNode()); }
......@@ -151,7 +151,7 @@ private:
ModelNode modelNode() const;
QmlItemNode m_fxItemNode;
QmlItemNode m_qmlItemNode;
QRectF parentBoundingBox();
......
......@@ -64,9 +64,11 @@ public:
QString name() const;
void setName(const QString &name);
bool isValid() const;
static bool isValidQmlModelState(const ModelNode &modelNode);
void destroy();
bool isBaseState() const;
static bool isBaseState(const ModelNode &modelNode);
QmlModelState duplicate(const QString &name) const;
QmlModelStateGroup stateGroup() const;
......
......@@ -72,7 +72,7 @@ QStringList QmlModelStateGroup::names() const
if (modelNode().property("states").isNodeListProperty()) {
foreach (const ModelNode &node, modelNode().nodeListProperty("states").toModelNodeList()) {
if (QmlModelState(node).isValid())
if (QmlModelState::isValidQmlModelState(node))
returnList.append(QmlModelState(node).name());
}
}
......@@ -110,7 +110,7 @@ QList<QmlItemNode> QmlItemNode::children() const
}
foreach (const ModelNode &modelNode, modelNodeList) {
if (QmlItemNode(modelNode).isValid()) //if ModelNode is FxItem
if (QmlItemNode::isValidQmlItemNode(modelNode)) //if ModelNode is FxItem
returnList.append(modelNode);
}
}
......@@ -134,7 +134,7 @@ QList<QmlObjectNode> QmlItemNode::resources() const
}
foreach (const ModelNode &node, modelNodeList) {
if (!QmlObjectNode(node).isValid()) //if ModelNode is no FxItem
if (!QmlObjectNode::isValidQmlObjectNode(node)) //if ModelNode is no FxItem
returnList.append(node);
}
}
......@@ -150,7 +150,7 @@ QList<QmlObjectNode> QmlItemNode::defaultPropertyChildren() const
modelNodeList.append(modelNode().nodeListProperty(defaultProperty()).toModelNodeList());
foreach (const ModelNode &node, modelNodeList) {
if (!QmlObjectNode(node).isValid()) //if ModelNode is no FxItem
if (!QmlObjectNode::isValidQmlObjectNode(node)) //if ModelNode is no FxItem
returnList.append(node);
}
}
......@@ -272,11 +272,10 @@ QTransform QmlItemNode::instanceSceneContentItemTransform() const
QPointF QmlItemNode::instanceScenePosition() const
{
QmlItemNode parentNode = instanceParent().toQmlItemNode();
if (!parentNode.isValid())
parentNode = modelNode().parentProperty().parentQmlObjectNode().toQmlItemNode();
if (parentNode.isValid())
return parentNode.instanceSceneTransform().map(nodeInstance().position());
if (hasInstanceParentItem())
return instanceParentItem().instanceSceneTransform().map(nodeInstance().position());
else if (modelNode().hasParentProperty() && QmlItemNode::isValidQmlItemNode(modelNode().parentProperty().parentModelNode()))
return QmlItemNode(modelNode().parentProperty().parentModelNode()).instanceSceneTransform().map(nodeInstance().position());
return QPointF();
}
......@@ -331,8 +330,8 @@ QList<QmlModelState> QmlModelStateGroup::allStates() const
if (modelNode().property("states").isNodeListProperty()) {
foreach (const ModelNode &node, modelNode().nodeListProperty("states").toModelNodeList()) {
if (QmlModelState(node).isValid())
returnList.append(QmlModelState(node));
if (QmlModelState::isValidQmlModelState(node))
returnList.append(node);
}
}
return returnList;
......
......@@ -58,10 +58,7 @@ QmlModelView::QmlModelView(QObject *parent)
void QmlModelView::setCurrentState(const QmlModelState &state)