diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index bcfcb63cb7b..43ccfda84f9 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -1168,6 +1168,8 @@ void ConnectionModelStatementDelegate::handleRhsAssignmentChanged() assignmentStatement.rhs.nodeId = m_rhsAssignmentDelegate.id(); assignmentStatement.rhs.propertyName = m_rhsAssignmentDelegate.name(); + setupPropertyType(); + emit statementChanged(); } @@ -1305,6 +1307,7 @@ void ConnectionModelStatementDelegate::setupAssignment() const auto assignment = std::get(m_statement); m_lhsDelegate.setup(assignment.lhs.nodeId, assignment.lhs.propertyName); m_rhsAssignmentDelegate.setup(assignment.rhs.nodeId, assignment.rhs.propertyName); + setupPropertyType(); } void ConnectionModelStatementDelegate::setupSetProperty() @@ -1420,6 +1423,26 @@ void ConnectionModelStatementDelegate::setupPrintMessage() m_stringArgument.setText(ConnectionEditorStatements::toString(consoleLog.argument)); } +void ConnectionModelStatementDelegate::setupPropertyType() +{ + PropertyTreeModel::PropertyTypes type = PropertyTreeModel::AllTypes; + + const NodeMetaInfo metaInfo = m_rhsAssignmentDelegate.propertyMetaInfo(); + + if (metaInfo.isBool()) + type = PropertyTreeModel::BoolType; + else if (metaInfo.isNumber()) + type = PropertyTreeModel::NumberType; + else if (metaInfo.isColor()) + type = PropertyTreeModel::ColorType; + else if (metaInfo.isString()) + type = PropertyTreeModel::StringType; + else if (metaInfo.isUrl()) + type = PropertyTreeModel::UrlType; + + m_lhsDelegate.setPropertyType(type); +} + QString ConnectionModelStatementDelegate::baseStateName() const { return tr("Base State"); diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h index 499e0abea8d..156227b4014 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h @@ -216,6 +216,7 @@ private: void setupChangeState(); void setupStates(); void setupPrintMessage(); + void setupPropertyType(); QString baseStateName() const; ActionType m_actionType; diff --git a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp index 14a4a9ca814..dcbbe5c1a60 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp @@ -833,6 +833,7 @@ PropertyTreeModelDelegate::PropertyTreeModelDelegate(ConnectionView *parent) : m void PropertyTreeModelDelegate::setPropertyType(PropertyTreeModel::PropertyTypes type) { m_model.setPropertyType(type); + setupNameComboBox(m_idCombboBox.currentText(), m_nameCombboBox.currentText(), 0); } void PropertyTreeModelDelegate::setup(const QString &id, const QString &name, bool *nameExists) @@ -846,7 +847,13 @@ void PropertyTreeModelDelegate::setup(const QString &id, const QString &name, bo m_idCombboBox.setModel(idLists); m_idCombboBox.setCurrentText(id); + setupNameComboBox(id, name, nameExists); +} +void PropertyTreeModelDelegate::setupNameComboBox(const QString &id, + const QString &name, + bool *nameExists) +{ const auto modelNode = m_model.getModelNodeForId(id); //m_nameCombboBox std::vector nameVector = Utils::transform(m_model.getProperties(modelNode), @@ -889,6 +896,14 @@ void PropertyTreeModelDelegate::handleNameChanged() // commit data } +NodeMetaInfo PropertyTreeModelDelegate::propertyMetaInfo() const +{ + const auto modelNode = m_model.getModelNodeForId(m_idCombboBox.currentText()); + if (modelNode.isValid()) + return modelNode.metaInfo().property(m_nameCombboBox.currentText().toUtf8()).propertyType(); + return {}; +} + void PropertyTreeModelDelegate::handleIdChanged() { const auto id = m_idCombboBox.currentText(); diff --git a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.h b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.h index 48a1c768b2d..ec96328c02c 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.h @@ -164,8 +164,10 @@ public: explicit PropertyTreeModelDelegate(ConnectionView *parent = nullptr); void setPropertyType(PropertyTreeModel::PropertyTypes type); void setup(const QString &id, const QString &name, bool *nameExists = nullptr); + void setupNameComboBox(const QString &id, const QString &name, bool *nameExists); QString id() const; QString name() const; + NodeMetaInfo propertyMetaInfo() const; signals: void commitData();