Commit 37433e2b authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: fixes state editing in text

In the stateseditor we have to use propertiesRemoved instead of
propertiesAboutToBeRemoved when reseting the model. Otherwise
the change we want to react to has not happened, yet.
Some sanity checking in the property editor.

In the DesignDocumentController we slightly change the order.
The textMoifider is activated (again) before we set back the old
state.
Note: We do check for isValid() since the rewriter might delete the state.


Reviewed-by: Kai Koehne
Task-number: QTCREATORBUG-4199
parent f97c7e14
...@@ -161,19 +161,9 @@ void DesignDocumentController::detachNodeInstanceView() ...@@ -161,19 +161,9 @@ void DesignDocumentController::detachNodeInstanceView()
void DesignDocumentController::attachNodeInstanceView() void DesignDocumentController::attachNodeInstanceView()
{ {
QmlModelState state;
if (m_d->nodeInstanceView) if (m_d->nodeInstanceView)
model()->attachView(m_d->nodeInstanceView.data()); model()->attachView(m_d->nodeInstanceView.data());
//We go back to base state (and back again) to avoid side effects from text editing.
if (m_d->statesEditorView) {
state = m_d->statesEditorView->currentState();
m_d->statesEditorView->setCurrentState(m_d->statesEditorView->baseState());
}
if (state.isValid() && m_d->statesEditorView)
m_d->statesEditorView->setCurrentState(state);
} }
QWidget *DesignDocumentController::centralWidget() const QWidget *DesignDocumentController::centralWidget() const
...@@ -209,7 +199,18 @@ void DesignDocumentController::blockModelSync(bool block) ...@@ -209,7 +199,18 @@ void DesignDocumentController::blockModelSync(bool block)
m_d->textModifier->deactivateChangeSignals(); m_d->textModifier->deactivateChangeSignals();
} else { } else {
attachNodeInstanceView(); attachNodeInstanceView();
QmlModelState state;
//We go back to base state (and back again) to avoid side effects from text editing.
if (m_d->statesEditorView) {
state = m_d->statesEditorView->currentState();
m_d->statesEditorView->setCurrentState(m_d->statesEditorView->baseState());
}
m_d->textModifier->reactivateChangeSignals(); m_d->textModifier->reactivateChangeSignals();
if (state.isValid() && m_d->statesEditorView)
m_d->statesEditorView->setCurrentState(state);
} }
} }
} }
......
...@@ -707,8 +707,8 @@ void PropertyEditor::resetView() ...@@ -707,8 +707,8 @@ void PropertyEditor::resetView()
ctxt->setContextProperty("finishedNotify", QVariant(false)); ctxt->setContextProperty("finishedNotify", QVariant(false));
if (specificQmlData.isEmpty()) if (specificQmlData.isEmpty())
type->m_contextObject->setSpecificQmlData(specificQmlData); type->m_contextObject->setSpecificQmlData(specificQmlData);
QString currentStateName = currentState().isValid() ? currentState().name() : QLatin1String("invalid state");
type->setup(fxObjectNode, currentState().name(), qmlSpecificsFile, this); type->setup(fxObjectNode, currentStateName, qmlSpecificsFile, this);
type->m_contextObject->setGlobalBaseUrl(qmlFile); type->m_contextObject->setGlobalBaseUrl(qmlFile);
type->m_contextObject->setSpecificQmlData(specificQmlData); type->m_contextObject->setSpecificQmlData(specificQmlData);
} }
......
...@@ -241,11 +241,11 @@ void StatesEditorView::modelAboutToBeDetached(Model *model) ...@@ -241,11 +241,11 @@ void StatesEditorView::modelAboutToBeDetached(Model *model)
resetModel(); resetModel();
} }
void StatesEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &propertyList) void StatesEditorView::propertiesRemoved(const QList<AbstractProperty>& propertyList)
{ {
foreach (const AbstractProperty &property, propertyList) { foreach (const AbstractProperty &property, propertyList) {
if (property.name() == "states" && property.parentModelNode().isRootNode()) if (property.name() == "states" && property.parentModelNode().isRootNode())
m_statesEditorModel->reset(); resetModel();
} }
} }
......
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
// AbstractView // AbstractView
void modelAttached(Model *model); void modelAttached(Model *model);
void modelAboutToBeDetached(Model *model); void modelAboutToBeDetached(Model *model);
void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList); void propertiesRemoved(const QList<AbstractProperty>& propertyList);
void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
void nodeAboutToBeRemoved(const ModelNode &removedNode); void nodeAboutToBeRemoved(const ModelNode &removedNode);
......
Supports Markdown
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