summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-23 14:27:03 +0100
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-23 14:27:36 +0100
commit37433e2be091714022adad71a4c207e40f4c98d8 (patch)
tree17250e8a22d0f2b5e233d92a23be2ad426a85cb8 /src/plugins
parentf97c7e1409b544b0f91ae2f4f18d37ef04bc7c96 (diff)
downloadqt-creator-37433e2be091714022adad71a4c207e40f4c98d8.tar.gz
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
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp21
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp4
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp4
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.h2
4 files changed, 16 insertions, 15 deletions
diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
index 9b0c16d5e6..eaed395efa 100644
--- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
+++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
@@ -161,19 +161,9 @@ void DesignDocumentController::detachNodeInstanceView()
void DesignDocumentController::attachNodeInstanceView()
{
- QmlModelState state;
if (m_d->nodeInstanceView)
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
@@ -209,7 +199,18 @@ void DesignDocumentController::blockModelSync(bool block)
m_d->textModifier->deactivateChangeSignals();
} else {
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();
+
+ if (state.isValid() && m_d->statesEditorView)
+ m_d->statesEditorView->setCurrentState(state);
}
}
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
index 2af517f172..8b13aacbe6 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
@@ -707,8 +707,8 @@ void PropertyEditor::resetView()
ctxt->setContextProperty("finishedNotify", QVariant(false));
if (specificQmlData.isEmpty())
type->m_contextObject->setSpecificQmlData(specificQmlData);
-
- type->setup(fxObjectNode, currentState().name(), qmlSpecificsFile, this);
+ QString currentStateName = currentState().isValid() ? currentState().name() : QLatin1String("invalid state");
+ type->setup(fxObjectNode, currentStateName, qmlSpecificsFile, this);
type->m_contextObject->setGlobalBaseUrl(qmlFile);
type->m_contextObject->setSpecificQmlData(specificQmlData);
}
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
index a3694f10d4..161013a385 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
@@ -241,11 +241,11 @@ void StatesEditorView::modelAboutToBeDetached(Model *model)
resetModel();
}
-void StatesEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &propertyList)
+void StatesEditorView::propertiesRemoved(const QList<AbstractProperty>& propertyList)
{
foreach (const AbstractProperty &property, propertyList) {
if (property.name() == "states" && property.parentModelNode().isRootNode())
- m_statesEditorModel->reset();
+ resetModel();
}
}
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h
index e09fe0d3a1..58b31ea083 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h
@@ -57,7 +57,7 @@ public:
// AbstractView
void modelAttached(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 nodeAboutToBeRemoved(const ModelNode &removedNode);