forked from qt-creator/qt-creator
QmlDesigner: Handle dynamic properties when adding a material
... to Content Library. Also remove one unused method. Fixes: QDS-12898 Change-Id: I8bc1d98bd5bc9d65e8c73d425025d7e15008b4a4 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -82,11 +82,6 @@ QVariant ContentLibraryUserModel::data(const QModelIndex &index, int role) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentLibraryUserModel::isValidIndex(int idx) const
|
|
||||||
{
|
|
||||||
return idx > -1 && idx < rowCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryUserModel::updateNoMatchMaterials()
|
void ContentLibraryUserModel::updateNoMatchMaterials()
|
||||||
{
|
{
|
||||||
m_noMatchMaterials = Utils::allOf(m_userMaterials, [&](ContentLibraryMaterial *item) {
|
m_noMatchMaterials = Utils::allOf(m_userMaterials, [&](ContentLibraryMaterial *item) {
|
||||||
|
@@ -95,7 +95,6 @@ private:
|
|||||||
void loadMaterialBundle();
|
void loadMaterialBundle();
|
||||||
void load3DBundle();
|
void load3DBundle();
|
||||||
void loadTextureBundle();
|
void loadTextureBundle();
|
||||||
bool isValidIndex(int idx) const;
|
|
||||||
void removeMaterialFromContentLib(ContentLibraryMaterial *mat);
|
void removeMaterialFromContentLib(ContentLibraryMaterial *mat);
|
||||||
void remove3DFromContentLib(ContentLibraryItem *item);
|
void remove3DFromContentLib(ContentLibraryItem *item);
|
||||||
QPair<QString, QString> getUniqueLibItemNames(const QString &defaultName,
|
QPair<QString, QString> getUniqueLibItemNames(const QString &defaultName,
|
||||||
|
@@ -597,7 +597,10 @@ QPair<QString, QSet<QString>> ContentLibraryView::modelNodeToQmlString(const Mod
|
|||||||
if (p.isVariantProperty()) {
|
if (p.isVariantProperty()) {
|
||||||
QVariant pValue = p.toVariantProperty().value();
|
QVariant pValue = p.toVariantProperty().value();
|
||||||
QString val;
|
QString val;
|
||||||
if (strcmp(pValue.typeName(), "QString") == 0 || strcmp(pValue.typeName(), "QColor") == 0) {
|
|
||||||
|
if (!pValue.typeName()) {
|
||||||
|
// dynamic property with no value assigned
|
||||||
|
} else if (strcmp(pValue.typeName(), "QString") == 0 || strcmp(pValue.typeName(), "QColor") == 0) {
|
||||||
val = QLatin1String("\"%1\"").arg(pValue.toString());
|
val = QLatin1String("\"%1\"").arg(pValue.toString());
|
||||||
} else if (strcmp(pValue.typeName(), "QUrl") == 0) {
|
} else if (strcmp(pValue.typeName(), "QUrl") == 0) {
|
||||||
QString pValueStr = pValue.toString();
|
QString pValueStr = pValue.toString();
|
||||||
@@ -609,12 +612,20 @@ QPair<QString, QSet<QString>> ContentLibraryView::modelNodeToQmlString(const Mod
|
|||||||
} else {
|
} else {
|
||||||
val = pValue.toString();
|
val = pValue.toString();
|
||||||
}
|
}
|
||||||
|
if (p.isDynamic()) {
|
||||||
|
QString valWithColon = val.isEmpty() ? QString() : (": " + val);
|
||||||
|
qml += indent + "property " + p.dynamicTypeName() + " " + p.name() + valWithColon + "\n";
|
||||||
|
} else {
|
||||||
qml += indent + p.name() + ": " + val + "\n";
|
qml += indent + p.name() + ": " + val + "\n";
|
||||||
|
}
|
||||||
} else if (p.isBindingProperty()) {
|
} else if (p.isBindingProperty()) {
|
||||||
qml += indent + p.name() + ": " + p.toBindingProperty().expression() + "\n";
|
|
||||||
|
|
||||||
ModelNode depNode = modelNodeForId(p.toBindingProperty().expression());
|
ModelNode depNode = modelNodeForId(p.toBindingProperty().expression());
|
||||||
|
QTC_ASSERT(depNode.isValid(), continue);
|
||||||
|
|
||||||
|
if (p.isDynamic())
|
||||||
|
qml += indent + "property " + p.dynamicTypeName() + " " + p.name() + ": " + depNode.id() + "\n";
|
||||||
|
else
|
||||||
|
qml += indent + p.name() + ": " + depNode.id() + "\n";
|
||||||
|
|
||||||
if (depNode && !depListIds.contains(depNode.id())) {
|
if (depNode && !depListIds.contains(depNode.id())) {
|
||||||
depListIds.append(depNode.id());
|
depListIds.append(depNode.id());
|
||||||
|
Reference in New Issue
Block a user