From b8494fa6b2aa5fb2bc51ad815b77038ab65fd32c Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Thu, 14 Jul 2011 18:13:57 +0200 Subject: [PATCH] QmlDesigner: fix for states stateChanged() was never called. cleanup: I removed stateChanged() and use actualStateChanged() Change-Id: I11a73b21dca5083147223f6e4f23da4c7305263c Reviewed-on: http://codereview.qt.nokia.com/1677 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Marco Bubke <marco.bubke@nokia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com> --- .../components/formeditor/formeditorview.cpp | 6 ++++-- .../components/formeditor/formeditorview.h | 3 ++- .../components/propertyeditor/propertyeditor.cpp | 6 ++++-- .../components/propertyeditor/propertyeditor.h | 2 +- .../components/stateseditor/stateseditorview.cpp | 6 ++++-- .../components/stateseditor/stateseditorview.h | 2 +- .../qmldesigner/designercore/include/qmlmodelview.h | 1 - .../qmldesigner/designercore/model/qmlmodelview.cpp | 13 +------------ 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 3a5d5ea63f..08e63291d5 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -651,9 +651,11 @@ bool FormEditorView::isMoveToolAvailable() const return true; } -void FormEditorView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) +void FormEditorView::actualStateChanged(const ModelNode &node) { - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); + + QmlModelState newQmlModelState(node); m_formEditorWidget->anchorToolAction()->setEnabled(newQmlModelState.isBaseState()); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.h b/src/plugins/qmldesigner/components/formeditor/formeditorview.h index 7b6bebdc64..f08ad2c2f6 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.h @@ -118,6 +118,8 @@ public: double spacing() const; void deActivateItemCreator(); + void actualStateChanged(const ModelNode &node); + public slots: void activateItemCreator(const QString &name); @@ -125,7 +127,6 @@ signals: void ItemCreatorDeActivated(); protected: - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void reset(); protected slots: diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index d494e90878..7e7fad921c 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -933,9 +933,11 @@ QWidget *PropertyEditor::widget() return m_stackedWidget; } -void PropertyEditor::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) + +void PropertyEditor::actualStateChanged(const ModelNode &node) { - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); + QmlModelState newQmlModelState(node); Q_ASSERT(newQmlModelState.isValid()); if (debug) qDebug() << Q_FUNC_INFO << newQmlModelState.name(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h index d626b21246..02a97954d2 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h @@ -111,12 +111,12 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void resetView(); + void actualStateChanged(const ModelNode &node); protected: void timerEvent(QTimerEvent *event); void otherPropertyChanged(const QmlObjectNode &, const QString &propertyName); void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void setupPane(const QString &typeName); void setValue(const QmlObjectNode &fxObjectNode, const QString &name, const QVariant &value); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index e4cde53158..277eb33189 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -308,14 +308,16 @@ void StatesEditorView::nodeInstancePropertyChanged(const ModelNode &node, const QmlModelView::nodeInstancePropertyChanged(node, propertyName); } -void StatesEditorView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) +void StatesEditorView::actualStateChanged(const ModelNode &node) { + QmlModelState newQmlModelState(node); + if (newQmlModelState.isBaseState()) { m_statesEditorWidget->setCurrentStateInternalId(0); } else { m_statesEditorWidget->setCurrentStateInternalId(newQmlModelState.modelNode().internalId()); } - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); } void StatesEditorView::transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 3bfc7bb75c..89cd210752 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -67,7 +67,7 @@ public: // QmlModelView - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); + void actualStateChanged(const ModelNode &node); void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); void parentChanged(const QmlObjectNode &qmlObjectNode); void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); diff --git a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h index d77bfbb6cb..ab36aa7211 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h +++ b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h @@ -131,7 +131,6 @@ protected: virtual void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName) ; virtual void parentChanged(const QmlObjectNode &qmlObjectNode); virtual void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); - virtual void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void activateState(const QmlModelState &state); diff --git a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp index 97f1047615..01b5215905 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp @@ -440,16 +440,8 @@ void QmlModelView::rewriterEndTransaction() } -void QmlModelView::actualStateChanged(const ModelNode &node) +void QmlModelView::actualStateChanged(const ModelNode & /*node*/) { - QmlModelState newState(node); - QmlModelState oldState = currentState(); - - if (!newState.isValid()) - newState = baseState(); - - if (newState != oldState) - stateChanged(newState, oldState); } @@ -480,8 +472,5 @@ void QmlModelView::otherPropertyChanged(const QmlObjectNode &/*qmlObjectNode*/, { } -void QmlModelView::stateChanged(const QmlModelState &/*newQmlModelState*/, const QmlModelState &/*oldQmlModelState*/) -{ -} } //QmlDesigner -- GitLab