summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Gruendl <henning.gruendl@qt.io>2019-12-11 14:45:40 +0100
committerHenning Gründl <henning.gruendl@qt.io>2019-12-11 15:07:47 +0000
commit88bbd748dd7837fcdb386f0d30094d461e8d9395 (patch)
treeaa50b3449d75525a2fa40c1817f70520bb8be736
parent3094d5b3ae9074c22f20f068d59687f45a29af48 (diff)
downloadqt-creator-88bbd748dd7837fcdb386f0d30094d461e8d9395.tar.gz
QmlDesigner: Fix material manager
Task-number: QDS-1332 Change-Id: I70828c3ce584ab72115f92dda4a27341e00085e2 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml13
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp7
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h1
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp4
4 files changed, 18 insertions, 7 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml
index 050f8f45ed..5b0a61d5c0 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/EditableListView.qml
@@ -55,8 +55,6 @@ Rectangle {
border.color: StudioTheme.Values.themeControlOutline
border.width: StudioTheme.Values.border
- property int numVisibleItems: myRepeater.count
-
Layout.preferredWidth: StudioTheme.Values.height * 10
Layout.preferredHeight: myColumn.height
@@ -158,6 +156,13 @@ Rectangle {
}
}
+ Item {
+ id: dummyItem
+ visible: myRepeater.count === 0
+ width: StudioTheme.Values.height
+ height: StudioTheme.Values.height
+ }
+
Row {
id: row
spacing: -StudioTheme.Values.border
@@ -175,7 +180,7 @@ Rectangle {
StudioControls.AbstractButton {
buttonIcon: "+"
iconFont: StudioTheme.Constants.font
- enabled: !myRepeater.dirty
+ enabled: !myRepeater.dirty && !(editableListView.backendValue.isInModel && !editableListView.backendValue.isIdList)
onClicked: {
var idx = myRepeater.localModel.push("") - 1
myRepeater.model = myRepeater.localModel // trigger on change handler
@@ -187,7 +192,7 @@ Rectangle {
StudioControls.AbstractButton {
buttonIcon: "-"
iconFont: StudioTheme.Constants.font
- enabled: myRepeater.model.length
+ enabled: myRepeater.model.length && !(editableListView.backendValue.isInModel && !editableListView.backendValue.isIdList)
onClicked: {
var lastItem = myColumn.currentIndex === myRepeater.localModel.length - 1
if (myColumn.currentItem.initialModelData === "") {
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());