summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2020-04-21 08:18:19 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2020-04-21 10:57:58 +0000
commit75e6d4402c98923d29d1c1795187aa7d149fd7d0 (patch)
treeb862919abfc725adedc25fb1eba4f8cb795b57ee
parentb39edea49500831ff62f3f28c17bcca89a05dd17 (diff)
downloadqt-creator-75e6d4402c98923d29d1c1795187aa7d149fd7d0.tar.gz
QmlDesigner: Expose all states to property editor
Change-Id: I9b89a9f8a8ed23c18ef5421a4380e90a484ae097 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp9
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h6
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp5
3 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp
index 0bf0503888..8be49060e6 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp
@@ -347,6 +347,15 @@ void PropertyEditorContextObject::setStateName(const QString &newStateName)
emit stateNameChanged();
}
+void PropertyEditorContextObject::setAllStateNames(const QStringList &allStates)
+{
+ if (allStates == m_allStateNames)
+ return;
+
+ m_allStateNames = allStates;
+ emit allStateNamesChanged();
+}
+
void PropertyEditorContextObject::setIsBaseState(bool newIsBaseState)
{
if (newIsBaseState == m_isBaseState)
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h
index 4b74f7331b..9e3309ee35 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h
@@ -46,6 +46,7 @@ class PropertyEditorContextObject : public QObject
Q_PROPERTY(QString specificQmlData READ specificQmlData WRITE setSpecificQmlData NOTIFY specificQmlDataChanged)
Q_PROPERTY(QString stateName READ stateName WRITE setStateName NOTIFY stateNameChanged)
+ Q_PROPERTY(QStringList allStateNames READ allStateNames WRITE setAllStateNames NOTIFY allStateNamesChanged)
Q_PROPERTY(bool isBaseState READ isBaseState WRITE setIsBaseState NOTIFY isBaseStateChanged)
Q_PROPERTY(bool selectionChanged READ selectionChanged WRITE setSelectionChanged NOTIFY selectionChangedChanged)
@@ -70,6 +71,7 @@ public:
QUrl specificsUrl() const {return m_specificsUrl; }
QString specificQmlData() const {return m_specificQmlData; }
QString stateName() const {return m_stateName; }
+ QStringList allStateNames() const { return m_allStateNames; }
bool isBaseState() const { return m_isBaseState; }
bool selectionChanged() const { return m_selectionChanged; }
@@ -114,6 +116,7 @@ signals:
void specificsUrlChanged();
void specificQmlDataChanged();
void stateNameChanged();
+ void allStateNamesChanged();
void isBaseStateChanged();
void selectionChangedChanged();
void backendValuesChanged();
@@ -134,6 +137,8 @@ public slots:
void setStateName(const QString &newStateName);
+ void setAllStateNames(const QStringList &allStates);
+
void setIsBaseState(bool newIsBaseState);
void setSelectionChanged(bool newSelectionChanged);
@@ -151,6 +156,7 @@ private:
QString m_specificQmlData;
QString m_stateName;
+ QStringList m_allStateNames;
bool m_isBaseState;
bool m_selectionChanged;
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
index 56202a2596..d9a685c703 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
@@ -394,8 +394,13 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q
contextObject()->setStateName(stateName);
if (!qmlObjectNode.isValid())
return;
+
context()->setContextProperty(QLatin1String("propertyCount"), QVariant(qmlObjectNode.modelNode().properties().count()));
+ QStringList stateNames = qmlObjectNode.allStateNames();
+ stateNames.prepend("base state");
+ contextObject()->setAllStateNames(stateNames);
+
contextObject()->setIsBaseState(qmlObjectNode.isInBaseState());
contextObject()->setHasAliasExport(qmlObjectNode.isAliasExported());