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 <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2022-08-31 10:26:55 +02:00
parent 432ed0a72d
commit ed66ba4cce
2 changed files with 6 additions and 17 deletions

View File

@@ -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:

View File

@@ -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);