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 {};
|
||||
}
|
||||
|
||||
bool ContentLibraryUserModel::isValidIndex(int idx) const
|
||||
{
|
||||
return idx > -1 && idx < rowCount();
|
||||
}
|
||||
|
||||
void ContentLibraryUserModel::updateNoMatchMaterials()
|
||||
{
|
||||
m_noMatchMaterials = Utils::allOf(m_userMaterials, [&](ContentLibraryMaterial *item) {
|
||||
|
@@ -95,7 +95,6 @@ private:
|
||||
void loadMaterialBundle();
|
||||
void load3DBundle();
|
||||
void loadTextureBundle();
|
||||
bool isValidIndex(int idx) const;
|
||||
void removeMaterialFromContentLib(ContentLibraryMaterial *mat);
|
||||
void remove3DFromContentLib(ContentLibraryItem *item);
|
||||
QPair<QString, QString> getUniqueLibItemNames(const QString &defaultName,
|
||||
|
@@ -597,7 +597,10 @@ QPair<QString, QSet<QString>> ContentLibraryView::modelNodeToQmlString(const Mod
|
||||
if (p.isVariantProperty()) {
|
||||
QVariant pValue = p.toVariantProperty().value();
|
||||
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());
|
||||
} else if (strcmp(pValue.typeName(), "QUrl") == 0) {
|
||||
QString pValueStr = pValue.toString();
|
||||
@@ -609,12 +612,20 @@ QPair<QString, QSet<QString>> ContentLibraryView::modelNodeToQmlString(const Mod
|
||||
} else {
|
||||
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";
|
||||
}
|
||||
} else if (p.isBindingProperty()) {
|
||||
qml += indent + p.name() + ": " + p.toBindingProperty().expression() + "\n";
|
||||
|
||||
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())) {
|
||||
depListIds.append(depNode.id());
|
||||
|
Reference in New Issue
Block a user