diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2019-12-11 14:45:40 +0100 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2019-12-11 15:07:47 +0000 |
commit | 88bbd748dd7837fcdb386f0d30094d461e8d9395 (patch) | |
tree | aa50b3449d75525a2fa40c1817f70520bb8be736 /src | |
parent | 3094d5b3ae9074c22f20f068d59687f45a29af48 (diff) | |
download | qt-creator-88bbd748dd7837fcdb386f0d30094d461e8d9395.tar.gz |
QmlDesigner: Fix material manager
Task-number: QDS-1332
Change-Id: I70828c3ce584ab72115f92dda4a27341e00085e2
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'src')
3 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 8c4bc83297..b1efd1af0e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -375,7 +375,9 @@ QStringList PropertyEditorValue::getExpressionAsList() const bool PropertyEditorValue::idListAdd(const QString &value) { - QTC_ASSERT(isIdList(), return false); + const QmlDesigner::QmlObjectNode objectNode(modelNode()); + if (!isIdList() && (objectNode.isValid() && objectNode.hasProperty(name()))) + return false; static const QRegExp rx("^[a-z_]\\w*|^[A-Z]\\w*\\.{1}([a-z_]\\w*\\.?)+"); if (!rx.exactMatch(value)) @@ -393,7 +395,6 @@ bool PropertyEditorValue::idListRemove(int idx) QTC_ASSERT(isIdList(), return false); auto stringList = generateStringList(expression()); - if (idx < 0 || idx >= stringList.size()) return false; @@ -438,6 +439,8 @@ QString PropertyEditorValue::generateString(const QStringList &stringList) const { if (stringList.size() > 1) return "[" + stringList.join(",") + "]"; + else if (stringList.isEmpty()) + return QString(); else return stringList.first(); } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h index 481fbb3458..a69bca8a73 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h @@ -83,6 +83,7 @@ class PropertyEditorValue : public QObject Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged FINAL) Q_PROPERTY(bool isTranslated READ isTranslated NOTIFY expressionChanged FINAL) + Q_PROPERTY(bool isIdList READ isIdList NOTIFY expressionChanged FINAL) Q_PROPERTY(QStringList expressionAsList READ getExpressionAsList NOTIFY expressionChanged FINAL) Q_PROPERTY(QString name READ nameAsQString FINAL) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index 1d0c165bda..d97d090f19 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -280,8 +280,10 @@ void PropertyEditorView::changeExpression(const QString &propertyName) } } - if (value->expression().isEmpty()) + if (value->expression().isEmpty()) { + value->resetValue(); return; + } if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name)) qmlObjectNode.setBindingProperty(name, value->expression()); |