From ed66ba4cce8acdcb7d3908493b23bc82a19e1dac Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 31 Aug 2022 10:26:55 +0200 Subject: [PATCH] QmlDesigner: Use new validation approach in states editor Many validation tests can now be skipped. Task-number: QDS-7454 Change-Id: I43ef981379cf495506b6cf8e8b3cedf50b061281 Reviewed-by: Thomas Hartmann --- .../components/stateseditor/stateseditormodel.cpp | 15 ++++----------- .../components/stateseditor/stateseditorview.cpp | 8 ++------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 270d51239dd..f2adcf4f363 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -100,20 +100,13 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const return index.internalId(); case HasWhenCondition: - return stateNode.isValid() && stateNode.hasProperty("when"); + return stateNode.hasProperty("when"); - case WhenConditionString: { - if (stateNode.isValid() && stateNode.hasBindingProperty("when")) - return stateNode.bindingProperty("when").expression(); - else - return QString(); - } + case WhenConditionString: + return stateNode.bindingProperty("when").expression(); case IsDefault: { - QmlModelState modelState(stateNode); - if (modelState.isValid()) - return modelState.isDefault(); - return false; + return QmlModelState(stateNode).isDefault(); } case ModelHasDefaultState: diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 054a1f4e005..f70789310cc 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -346,9 +346,7 @@ void StatesEditorView::resetWhenCondition(int internalNodeId) if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); try { - if (state.isValid() && state.modelNode().hasProperty("when")) - state.modelNode().removeProperty("when"); - + state.modelNode().removeProperty("when"); } catch (const RewritingException &e) { e.showException(); } @@ -409,9 +407,7 @@ void StatesEditorView::setAnnotation(int internalNodeId) QmlModelState state(modelNodeForInternalId(internalNodeId)); try { if (state.isValid()) { - ModelNode modelNode = state.modelNode(); - - if (modelNode.isValid()) { + if (ModelNode modelNode = state.modelNode()) { if (!m_editor) m_editor = new AnnotationEditor(this);