QmlDesigner: Use more string views in the model

To decouple the string implementation from the internal string. It
should lead to much less allocations too after the rest of the code is
converted too.

Change-Id: Ifb49f57b9e5ac5af4963e1257c535ddef6044d93
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2024-07-18 21:52:33 +02:00
parent fc0cedf347
commit 3e05959468
113 changed files with 835 additions and 649 deletions

View File

@@ -5,13 +5,16 @@
#include <QByteArray> #include <QByteArray>
#include <QList> #include <QList>
#include <QVarLengthArray>
#include <vector> #include <vector>
namespace QmlDesigner { namespace QmlDesigner {
using PropertyName = QByteArray; using PropertyName = QByteArray;
using PropertyNameView = QByteArrayView;
using PropertyNameList = QList<PropertyName>; using PropertyNameList = QList<PropertyName>;
using PropertyNameViews = QVarLengthArray<PropertyNameView, 64>;
using PropertyNames = std::vector<PropertyName>; using PropertyNames = std::vector<PropertyName>;
using TypeName = QByteArray; using TypeName = QByteArray;

View File

@@ -733,7 +733,7 @@ public:
signalHandler.view() signalHandler.view()
->emitCustomNotification(EditConnectionNotification, ->emitCustomNotification(EditConnectionNotification,
{signalHandler.parentModelNode()}, {signalHandler.parentModelNode()},
{signalHandler.name()}); {signalHandler.name().toByteArray()});
//ActionEditor::invokeEditor(signalHandler, removeSignal); //ActionEditor::invokeEditor(signalHandler, removeSignal);
}); });

View File

@@ -211,7 +211,7 @@ QHash<int, QByteArray> BindingModel::roleNames() const
std::optional<int> BindingModel::rowForProperty(const AbstractProperty &property) const std::optional<int> BindingModel::rowForProperty(const AbstractProperty &property) const
{ {
PropertyName name = property.name(); PropertyNameView name = property.name();
int internalId = property.parentModelNode().internalId(); int internalId = property.parentModelNode().internalId();
for (int i = 0; i < rowCount(); ++i) { for (int i = 0; i < rowCount(); ++i) {

View File

@@ -42,7 +42,7 @@ void BindingModelItem::updateProperty(const BindingProperty &property)
{ {
setData(property.parentModelNode().internalId(), InternalIdRole); setData(property.parentModelNode().internalId(), InternalIdRole);
setData(idOrTypeName(property.parentModelNode()), TargetNameRole); setData(idOrTypeName(property.parentModelNode()), TargetNameRole);
setData(property.name(), TargetPropertyNameRole); setData(property.name().toByteArray(), TargetPropertyNameRole);
// TODO: Make this safe when the new codemodel allows it. // TODO: Make this safe when the new codemodel allows it.
if (auto expression = property.expression(); !expression.isEmpty()) { if (auto expression = property.expression(); !expression.isEmpty()) {

View File

@@ -175,7 +175,7 @@ void convertPropertyType(const T &property, const QVariant &value)
if (!node.isValid()) if (!node.isValid())
return; return;
PropertyName name = property.name(); PropertyNameView name = property.name();
TypeName type = property.dynamicTypeName(); TypeName type = property.dynamicTypeName();
node.removeProperty(name); node.removeProperty(name);

View File

@@ -259,7 +259,7 @@ void ConnectionModel::updateTargetNode(int rowNumber)
void ConnectionModel::updateCustomData(QStandardItem *item, const SignalHandlerProperty &signalHandlerProperty) void ConnectionModel::updateCustomData(QStandardItem *item, const SignalHandlerProperty &signalHandlerProperty)
{ {
item->setData(signalHandlerProperty.parentModelNode().internalId(), UserRoles::InternalIdRole); item->setData(signalHandlerProperty.parentModelNode().internalId(), UserRoles::InternalIdRole);
item->setData(signalHandlerProperty.name(), UserRoles::TargetPropertyNameRole); item->setData(signalHandlerProperty.name().toByteArray(), UserRoles::TargetPropertyNameRole);
item->setData(signalHandlerProperty.parentModelNode() item->setData(signalHandlerProperty.parentModelNode()
.bindingProperty("target") .bindingProperty("target")
.resolveToModelNode() .resolveToModelNode()

View File

@@ -55,7 +55,7 @@ void DynamicPropertiesItem::updateProperty(const AbstractProperty &property)
{ {
setData(property.parentModelNode().internalId(), InternalIdRole); setData(property.parentModelNode().internalId(), InternalIdRole);
setData(idOrTypeName(property.parentModelNode()), TargetNameRole); setData(idOrTypeName(property.parentModelNode()), TargetNameRole);
setData(property.name(), PropertyNameRole); setData(property.name().toByteArray(), PropertyNameRole);
setData(property.dynamicTypeName(), PropertyTypeRole); setData(property.dynamicTypeName(), PropertyTypeRole);
if (property.isVariantProperty()) { if (property.isVariantProperty()) {

View File

@@ -136,7 +136,7 @@ void DynamicPropertiesModel::setCurrentProperty(const AbstractProperty &property
setCurrentIndex(*index); setCurrentIndex(*index);
} }
void DynamicPropertiesModel::setCurrent(int internalId, const PropertyName &name) void DynamicPropertiesModel::setCurrent(int internalId, PropertyNameView name)
{ {
if (internalId < 0) if (internalId < 0)
return; return;
@@ -195,7 +195,7 @@ AbstractProperty DynamicPropertiesModel::propertyForRow(int row) const
return {}; return {};
} }
std::optional<int> DynamicPropertiesModel::findRow(int nodeId, const PropertyName &name) const std::optional<int> DynamicPropertiesModel::findRow(int nodeId, PropertyNameView name) const
{ {
for (int i = 0; i < rowCount(); ++i) { for (int i = 0; i < rowCount(); ++i) {
if (auto *item = itemForRow(i)) { if (auto *item = itemForRow(i)) {
@@ -243,7 +243,7 @@ void DynamicPropertiesModel::addModelNode(const ModelNode &node)
void DynamicPropertiesModel::addProperty(const AbstractProperty &property) void DynamicPropertiesModel::addProperty(const AbstractProperty &property)
{ {
const PropertyName name = property.name(); const PropertyNameView name = property.name();
for (int i = 0; i < rowCount(); ++i) { for (int i = 0; i < rowCount(); ++i) {
if (auto *item = itemForRow(i)) { if (auto *item = itemForRow(i)) {
if (item->propertyName() > name) { if (item->propertyName() > name) {
@@ -282,7 +282,7 @@ void DynamicPropertiesModel::commitPropertyType(int row, const TypeName &type)
} }
} }
void DynamicPropertiesModel::commitPropertyName(int row, const PropertyName &name) void DynamicPropertiesModel::commitPropertyName(int row, PropertyNameView name)
{ {
AbstractProperty property = propertyForRow(row); AbstractProperty property = propertyForRow(row);
if (!property.isValid()) if (!property.isValid())
@@ -346,7 +346,7 @@ void DynamicPropertiesModel::dispatchPropertyChanges(const AbstractProperty &abs
QmlPropertyChanges changes(abstractProperty.parentModelNode()); QmlPropertyChanges changes(abstractProperty.parentModelNode());
if (changes.target().isValid()) { if (changes.target().isValid()) {
const ModelNode target = changes.target(); const ModelNode target = changes.target();
const PropertyName propertyName = abstractProperty.name(); const PropertyNameView propertyName = abstractProperty.name();
const AbstractProperty targetProperty = target.variantProperty(propertyName); const AbstractProperty targetProperty = target.variantProperty(propertyName);
if (target.hasProperty(propertyName) && targetProperty.isDynamic()) if (target.hasProperty(propertyName) && targetProperty.isDynamic())
updateItem(targetProperty); updateItem(targetProperty);

View File

@@ -46,13 +46,13 @@ public:
void reset(const QList<ModelNode> &modelNodes = {}); void reset(const QList<ModelNode> &modelNodes = {});
void setCurrentIndex(int i); void setCurrentIndex(int i);
void setCurrentProperty(const AbstractProperty &property); void setCurrentProperty(const AbstractProperty &property);
void setCurrent(int internalId, const PropertyName &name); void setCurrent(int internalId, PropertyNameView name);
void updateItem(const AbstractProperty &property); void updateItem(const AbstractProperty &property);
void removeItem(const AbstractProperty &property); void removeItem(const AbstractProperty &property);
void commitPropertyType(int row, const TypeName &type); void commitPropertyType(int row, const TypeName &type);
void commitPropertyName(int row, const PropertyName &name); void commitPropertyName(int row, PropertyNameView name);
void commitPropertyValue(int row, const QVariant &value); void commitPropertyValue(int row, const QVariant &value);
void dispatchPropertyChanges(const AbstractProperty &abstractProperty); void dispatchPropertyChanges(const AbstractProperty &abstractProperty);
@@ -61,7 +61,7 @@ protected:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
private: private:
std::optional<int> findRow(int nodeId, const PropertyName &name) const; std::optional<int> findRow(int nodeId, PropertyNameView name) const;
DynamicPropertiesItem *itemForRow(int row) const; DynamicPropertiesItem *itemForRow(int row) const;
DynamicPropertiesItem *itemForProperty(const AbstractProperty &property) const; DynamicPropertiesItem *itemForProperty(const AbstractProperty &property) const;
ModelNode modelNodeForItem(DynamicPropertiesItem *item); ModelNode modelNodeForItem(DynamicPropertiesItem *item);

View File

@@ -519,47 +519,51 @@ const std::vector<PropertyName> PropertyTreeModel::sortedAndFilteredPropertyName
const std::vector<PropertyName> PropertyTreeModel::getDynamicProperties( const std::vector<PropertyName> PropertyTreeModel::getDynamicProperties(
const ModelNode &modelNode) const const ModelNode &modelNode) const
{ {
QList<PropertyName> list = Utils::transform(modelNode.dynamicProperties(), auto dynamicProperties = modelNode.dynamicProperties();
[](const AbstractProperty &property) { auto dynamicPropertyNames = Utils::transform<PropertyNameViews>(
return property.name(); dynamicProperties, [](const AbstractProperty &property) { return property.name(); });
});
QList<PropertyName> filtered auto filtered = Utils::filtered(dynamicPropertyNames, [this, modelNode](PropertyNameView propertyName) {
= Utils::filtered(list, [this, modelNode](const PropertyName &propertyName) { TypeName propertyType = modelNode.property(propertyName).dynamicTypeName();
PropertyName propertyType = modelNode.property(propertyName).dynamicTypeName(); switch (m_type) {
switch (m_type) { case AllTypes:
case AllTypes: return true;
return true; case NumberType:
case NumberType: return propertyType == "float" || propertyType == "double" || propertyType == "int";
return propertyType == "float" || propertyType == "double" case StringType:
|| propertyType == "int"; return propertyType == "string";
case StringType: case UrlType:
return propertyType == "string"; return propertyType == "url";
case UrlType: case ColorType:
return propertyType == "url"; return propertyType == "color";
case ColorType: case BoolType:
return propertyType == "color"; return propertyType == "bool";
case BoolType: default:
return propertyType == "bool"; break;
default: }
break; return true;
} });
return true;
});
return Utils::sorted(std::vector<PropertyName>(filtered.begin(), filtered.end())); auto sorted = Utils::sorted(filtered);
return Utils::transform<std::vector<PropertyName>>(sorted, [](PropertyNameView propertyName) {
return propertyName.toByteArray();
});
} }
const std::vector<PropertyName> PropertyTreeModel::getDynamicSignals(const ModelNode &modelNode) const const std::vector<PropertyName> PropertyTreeModel::getDynamicSignals(const ModelNode &modelNode) const
{ {
QList<PropertyName> list = Utils::transform(modelNode.dynamicProperties(), auto list = Utils::transform<std::vector<PropertyName>>(
[](const AbstractProperty &property) { modelNode.dynamicProperties(), [](const AbstractProperty &property) -> PropertyName {
if (property.isSignalDeclarationProperty()) if (property.isSignalDeclarationProperty())
return property.name(); return property.name().toByteArray();
return PropertyName(property.name() + "Changed"); return property.name().toByteArray() + "Changed";
}); });
return Utils::sorted(std::vector<PropertyName>(list.begin(), list.end()));
std::sort(list.begin(), list.end());
return list;
} }
const std::vector<PropertyName> PropertyTreeModel::sortedAndFilteredPropertyNames( const std::vector<PropertyName> PropertyTreeModel::sortedAndFilteredPropertyNames(

View File

@@ -234,7 +234,7 @@ bool BakeLightsDataModel::reset()
PropertyName dotName = mi.name() + '.'; PropertyName dotName = mi.name() + '.';
for (const AbstractProperty &prop : props) { for (const AbstractProperty &prop : props) {
if (prop.name().startsWith(dotName)) { if (prop.name().startsWith(dotName)) {
PropertyName subName = prop.name().mid(dotName.size()); PropertyNameView subName = prop.name().mid(dotName.size());
if (subName == "bakedLightmap") { if (subName == "bakedLightmap") {
ModelNode blm = prop.toBindingProperty().resolveToModelNode(); ModelNode blm = prop.toBindingProperty().resolveToModelNode();
if (blm.isValid()) { if (blm.isValid()) {
@@ -269,7 +269,7 @@ bool BakeLightsDataModel::reset()
PropertyName dotName = mi.name() + '.'; PropertyName dotName = mi.name() + '.';
for (const AbstractProperty &prop : props) { for (const AbstractProperty &prop : props) {
if (prop.name().startsWith(dotName)) { if (prop.name().startsWith(dotName)) {
PropertyName subName = prop.name().mid(dotName.size()); PropertyNameView subName = prop.name().mid(dotName.size());
if (subName == "bakeMode") { if (subName == "bakeMode") {
if (prop.isVariantProperty()) { if (prop.isVariantProperty()) {
QString bakeModeStr = prop.toVariantProperty().value() QString bakeModeStr = prop.toVariantProperty().value()

View File

@@ -200,7 +200,7 @@ qreal FormEditorItem::selectionWeigth(const QPointF &point, int iteration)
return weight; return weight;
} }
void FormEditorItem::synchronizeOtherProperty(const QByteArray &propertyName) void FormEditorItem::synchronizeOtherProperty(PropertyNameView propertyName)
{ {
if (propertyName == "opacity") if (propertyName == "opacity")
setOpacity(qmlItemNode().instanceValue("opacity").toDouble()); setOpacity(qmlItemNode().instanceValue("opacity").toDouble());
@@ -557,7 +557,7 @@ QmlItemNode FormEditorItem::qmlItemNode() const
return m_qmlItemNode; return m_qmlItemNode;
} }
void FormEditorFlowItem::synchronizeOtherProperty(const QByteArray &) void FormEditorFlowItem::synchronizeOtherProperty(PropertyNameView)
{ {
setContentVisible(true); setContentVisible(true);
} }
@@ -783,7 +783,7 @@ QTransform FormEditorFlowActionItem::instanceSceneContentItemTransform() const
return sceneTransform(); return sceneTransform();
} }
void FormEditorTransitionItem::synchronizeOtherProperty(const QByteArray &) void FormEditorTransitionItem::synchronizeOtherProperty(PropertyNameView)
{ {
setContentVisible(true); setContentVisible(true);
} }

View File

@@ -87,7 +87,7 @@ public:
QPointF center() const; QPointF center() const;
qreal selectionWeigth(const QPointF &point, int iteration); qreal selectionWeigth(const QPointF &point, int iteration);
virtual void synchronizeOtherProperty(const QByteArray &propertyName); virtual void synchronizeOtherProperty(PropertyNameView propertyName);
virtual void setDataModelPosition(const QPointF &position); virtual void setDataModelPosition(const QPointF &position);
virtual void setDataModelPositionInBaseState(const QPointF &position); virtual void setDataModelPositionInBaseState(const QPointF &position);
virtual QPointF instancePosition() const; virtual QPointF instancePosition() const;
@@ -141,7 +141,7 @@ class FormEditorFlowItem : public FormEditorItem
friend FormEditorScene; friend FormEditorScene;
public: public:
void synchronizeOtherProperty(const QByteArray &propertyName) override; void synchronizeOtherProperty(PropertyNameView propertyName) override;
void setDataModelPosition(const QPointF &position) override; void setDataModelPosition(const QPointF &position) override;
void setDataModelPositionInBaseState(const QPointF &position) override; void setDataModelPositionInBaseState(const QPointF &position) override;
void updateGeometry() override; void updateGeometry() override;
@@ -198,7 +198,7 @@ class FormEditorTransitionItem : public FormEditorItem
friend FormEditorScene; friend FormEditorScene;
public: public:
void synchronizeOtherProperty(const QByteArray &propertyName) override; void synchronizeOtherProperty(PropertyNameView propertyName) override;
void setDataModelPosition(const QPointF &position) override; void setDataModelPosition(const QPointF &position) override;
void setDataModelPositionInBaseState(const QPointF &position) override; void setDataModelPositionInBaseState(const QPointF &position) override;
void updateGeometry() override; void updateGeometry() override;

View File

@@ -142,7 +142,7 @@ void FormEditorScene::synchronizeParent(const QmlItemNode &qmlItemNode)
reparentItem(qmlItemNode, parentNode); reparentItem(qmlItemNode, parentNode);
} }
void FormEditorScene::synchronizeOtherProperty(FormEditorItem *item, const QByteArray &propertyName) void FormEditorScene::synchronizeOtherProperty(FormEditorItem *item, PropertyNameView propertyName)
{ {
Q_ASSERT(item); Q_ASSERT(item);

View File

@@ -59,7 +59,7 @@ public:
void synchronizeTransformation(FormEditorItem *item); void synchronizeTransformation(FormEditorItem *item);
void synchronizeParent(const QmlItemNode &qmlItemNode); void synchronizeParent(const QmlItemNode &qmlItemNode);
void synchronizeOtherProperty(FormEditorItem *item, const QByteArray &propertyName); void synchronizeOtherProperty(FormEditorItem *item, PropertyNameView propertyName);
FormEditorItem* calulateNewParent(FormEditorItem *widget); FormEditorItem* calulateNewParent(FormEditorItem *widget);
LayerItem* manipulatorLayerItem() const; LayerItem* manipulatorLayerItem() const;

View File

@@ -100,7 +100,7 @@ QList<PropertyName> getPropertyNames(const ModelNode &listElementNode)
names.reserve(properties.size()); names.reserve(properties.size());
for (const auto &property : properties) for (const auto &property : properties)
names.push_back(property.name()); names.push_back(property.name().toByteArray());
std::sort(names.begin(), names.end()); std::sort(names.begin(), names.end());

View File

@@ -401,8 +401,8 @@ void MaterialBrowserModel::copyMaterialProperties(int idx, const QString &sectio
// Dynamic properties must always be set in base state // Dynamic properties must always be set in base state
const QList<AbstractProperty> dynProps = m_copiedMaterial.dynamicProperties(); const QList<AbstractProperty> dynProps = m_copiedMaterial.dynamicProperties();
for (const auto &prop : dynProps) { for (const auto &prop : dynProps) {
dynamicProps.insert(prop.name(), prop.dynamicTypeName()); dynamicProps.insert(prop.name().toByteArray(), prop.dynamicTypeName());
validProps.insert(prop.name()); validProps.insert(prop.name().toByteArray());
} }
} }
@@ -417,7 +417,7 @@ void MaterialBrowserModel::copyMaterialProperties(int idx, const QString &sectio
if (changes.isValid()) { if (changes.isValid()) {
const QList<AbstractProperty> changedProps = changes.targetProperties(); const QList<AbstractProperty> changedProps = changes.targetProperties();
for (const auto &changedProp : changedProps) for (const auto &changedProp : changedProps)
validProps.insert(changedProp.name()); validProps.insert(changedProp.name().toByteArray());
} }
} }

View File

@@ -100,27 +100,34 @@ WidgetInfo MaterialBrowserView::widgetInfo()
executeInTransaction(__FUNCTION__, [&] { executeInTransaction(__FUNCTION__, [&] {
if (all) { // all material properties copied if (all) { // all material properties copied
// remove current properties // remove current properties
PropertyNameList propNames;
if (mat.isInBaseState()) { if (mat.isInBaseState()) {
const QList<AbstractProperty> baseProps = material.properties(); const QList<AbstractProperty> baseProps = material.properties();
PropertyNameViews propNames;
for (const auto &baseProp : baseProps) { for (const auto &baseProp : baseProps) {
if (!baseProp.isDynamic()) if (!baseProp.isDynamic())
propNames.append(baseProp.name()); propNames.append(baseProp.name());
} }
for (PropertyNameView propName : propNames) {
if (propName != "objectName" && propName != "data")
mat.removeProperty(propName);
}
} else { } else {
QmlPropertyChanges changes = mat.propertyChangeForCurrentState(); QmlPropertyChanges changes = mat.propertyChangeForCurrentState();
if (changes.isValid()) { if (changes.isValid()) {
PropertyNameViews propNames;
const QList<AbstractProperty> changedProps = changes.targetProperties(); const QList<AbstractProperty> changedProps = changes.targetProperties();
for (const auto &changedProp : changedProps) { for (const auto &changedProp : changedProps) {
if (!changedProp.isDynamic()) if (!changedProp.isDynamic())
propNames.append(changedProp.name()); propNames.append(changedProp.name());
} }
for (PropertyNameView propName : propNames) {
if (propName != "objectName" && propName != "data")
mat.removeProperty(propName);
}
} }
} }
for (const PropertyName &propName : std::as_const(propNames)) {
if (propName != "objectName" && propName != "data")
mat.removeProperty(propName);
}
} }
// apply pasted properties // apply pasted properties

View File

@@ -110,9 +110,9 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName)
continue; continue;
// Add dynamic property // Add dynamic property
propertiesAndSignals.append(property.name()); propertiesAndSignals.append(property.name().toByteArray());
// Add its change signal // Add its change signal
PropertyName name = property.name(); PropertyName name = property.name().toByteArray();
QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1(); QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1();
name[0] = firstChar.toLatin1(); name[0] = firstChar.toLatin1();
name.prepend("on"); name.prepend("on");
@@ -124,7 +124,7 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName)
QList<PropertyName> incompatibleProperties; QList<PropertyName> incompatibleProperties;
for (const auto &property : matProps) { for (const auto &property : matProps) {
if (!propertiesAndSignals.contains(property.name())) if (!propertiesAndSignals.contains(property.name()))
incompatibleProperties.append(property.name()); incompatibleProperties.append(property.name().toByteArray());
} }
// When switching between material types, copy base (diffuse) color and map properties of // When switching between material types, copy base (diffuse) color and map properties of
@@ -135,7 +135,7 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName)
int targetIndex = -1; int targetIndex = -1;
NodeMetaInfo oldMetaInfo = m_selectedMaterial.metaInfo(); NodeMetaInfo oldMetaInfo = m_selectedMaterial.metaInfo();
struct CopyData { struct CopyData {
CopyData() {}; CopyData() {}
CopyData(PropertyName n) : name(n) {} CopyData(PropertyName n) : name(n) {}
PropertyName name; PropertyName name;
QVariant value; QVariant value;

View File

@@ -61,17 +61,17 @@ MaterialEditorQmlBackend::~MaterialEditorQmlBackend()
{ {
} }
PropertyName MaterialEditorQmlBackend::auxNamePostFix(const PropertyName &propertyName) PropertyName MaterialEditorQmlBackend::auxNamePostFix(PropertyNameView propertyName)
{ {
return propertyName + "__AUX"; return propertyName + "__AUX";
} }
void MaterialEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void MaterialEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, PropertyNameView name,
const QVariant &value, const QVariant &value,
MaterialEditorView *materialEditor) MaterialEditorView *materialEditor)
{ {
PropertyName propertyName(name); PropertyName propertyName(name.toByteArray());
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto valueObject = qobject_cast<PropertyEditorValue *>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); auto valueObject = qobject_cast<PropertyEditorValue *>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName))));
if (!valueObject) { if (!valueObject) {
@@ -101,7 +101,9 @@ void MaterialEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qm
} }
} }
void MaterialEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyName &name, const QVariant &value) void MaterialEditorQmlBackend::setValue(const QmlObjectNode &,
PropertyNameView name,
const QVariant &value)
{ {
// Vector*D values need to be split into their subcomponents // Vector*D values need to be split into their subcomponents
if (value.typeId() == QVariant::Vector2D) { if (value.typeId() == QVariant::Vector2D) {
@@ -139,7 +141,7 @@ void MaterialEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyNam
propertyValue->setValue(QVariant(vecValue[i])); propertyValue->setValue(QVariant(vecValue[i]));
} }
} else { } else {
PropertyName propertyName = name; PropertyName propertyName = name.toByteArray();
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName))));
if (propertyValue) if (propertyValue)

View File

@@ -36,7 +36,7 @@ public:
void setup(const QmlObjectNode &selectedMaterialNode, const QString &stateName, const QUrl &qmlSpecificsFile, void setup(const QmlObjectNode &selectedMaterialNode, const QString &stateName, const QUrl &qmlSpecificsFile,
MaterialEditorView *materialEditor); MaterialEditorView *materialEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
QQmlContext *context() const; QQmlContext *context() const;
MaterialEditorContextObject *contextObject() const; MaterialEditorContextObject *contextObject() const;
@@ -59,9 +59,10 @@ public:
private: private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, const QVariant &value, PropertyNameView name,
const QVariant &value,
MaterialEditorView *materialEditor); MaterialEditorView *materialEditor);
PropertyName auxNamePostFix(const PropertyName &propertyName); PropertyName auxNamePostFix(PropertyNameView propertyName);
// to avoid a crash while destructing DesignerPropertyMap in the QQmlData // to avoid a crash while destructing DesignerPropertyMap in the QQmlData
// this needs be destructed after m_quickWidget->engine() is destructed // this needs be destructed after m_quickWidget->engine() is destructed

View File

@@ -640,7 +640,7 @@ void MaterialEditorView::setupQmlBackend()
#endif #endif
} }
void MaterialEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) void MaterialEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
executeInTransaction(__FUNCTION__, [&] { executeInTransaction(__FUNCTION__, [&] {
@@ -649,11 +649,11 @@ void MaterialEditorView::commitVariantValueToModel(const PropertyName &propertyN
m_locked = false; m_locked = false;
} }
void MaterialEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) void MaterialEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
PropertyName name = propertyName; PropertyNameView name = propertyName;
name.chop(5); name.chop(5);
try { try {
@@ -668,7 +668,7 @@ void MaterialEditorView::commitAuxValueToModel(const PropertyName &propertyName,
m_locked = false; m_locked = false;
} }
void MaterialEditorView::removePropertyFromModel(const PropertyName &propertyName) void MaterialEditorView::removePropertyFromModel(PropertyNameView propertyName)
{ {
m_locked = true; m_locked = true;
executeInTransaction(__FUNCTION__, [&] { executeInTransaction(__FUNCTION__, [&] {
@@ -1210,7 +1210,9 @@ void MaterialEditorView::dragEnded()
} }
// from model to material editor // from model to material editor
void MaterialEditorView::setValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value) void MaterialEditorView::setValue(const QmlObjectNode &qmlObjectNode,
PropertyNameView name,
const QVariant &value)
{ {
m_locked = true; m_locked = true;
m_qmlBackEnd->setValue(qmlObjectNode, name, value); m_qmlBackEnd->setValue(qmlObjectNode, name, value);

View File

@@ -97,7 +97,7 @@ public slots:
protected: protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
private: private:
@@ -111,9 +111,9 @@ private:
void setupQmlBackend(); void setupQmlBackend();
void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value);
void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value);
void removePropertyFromModel(const PropertyName &propertyName); void removePropertyFromModel(PropertyNameView propertyName);
void renameMaterial(ModelNode &material, const QString &newName); void renameMaterial(ModelNode &material, const QString &newName);
void duplicateMaterial(const ModelNode &material); void duplicateMaterial(const ModelNode &material);

View File

@@ -102,7 +102,7 @@ QVariant DynamicPropertiesProxyModel::data(const QModelIndex &index, int role) c
QTC_ASSERT(property.isValid(), return QVariant()); QTC_ASSERT(property.isValid(), return QVariant());
if (role == propertyNameRole) if (role == propertyNameRole)
return property.name(); return property.name().toByteArray();
if (propertyTypeRole) if (propertyTypeRole)
return property.dynamicTypeName(); return property.dynamicTypeName();
@@ -353,7 +353,7 @@ void DynamicPropertyRow::commitValue(const QVariant &value)
variantProperty.setDynamicTypeNameAndValue(variantProperty.dynamicTypeName(), value); variantProperty.setDynamicTypeNameAndValue(variantProperty.dynamicTypeName(), value);
} else { } else {
QTC_CHECK(objectNode.isValid()); QTC_CHECK(objectNode.isValid());
PropertyName name = variantProperty.name(); PropertyNameView name = variantProperty.name();
if (objectNode.isValid() && objectNode.modelValue(name) != value) if (objectNode.isValid() && objectNode.modelValue(name) != value)
objectNode.setVariantProperty(name, value); objectNode.setVariantProperty(name, value);
} }
@@ -400,7 +400,7 @@ void DynamicPropertyRow::commitExpression(const QString &expression)
} else { } else {
QmlObjectNode objectNode = bindingProperty.parentQmlObjectNode(); QmlObjectNode objectNode = bindingProperty.parentQmlObjectNode();
QTC_CHECK(objectNode.isValid()); QTC_CHECK(objectNode.isValid());
PropertyName name = bindingProperty.name(); PropertyNameView name = bindingProperty.name();
if (objectNode.isValid() && objectNode.expression(name) != theExpression) if (objectNode.isValid() && objectNode.expression(name) != theExpression)
objectNode.setBindingProperty(name, theExpression); objectNode.setBindingProperty(name, theExpression);
} }
@@ -444,7 +444,7 @@ void DynamicPropertyRow::resetValue()
try { try {
QmlObjectNode objectNode = property.parentQmlObjectNode(); QmlObjectNode objectNode = property.parentQmlObjectNode();
QTC_CHECK(objectNode.isValid()); QTC_CHECK(objectNode.isValid());
PropertyName name = property.name(); PropertyNameView name = property.name();
if (objectNode.isValid() && objectNode.propertyAffectedByCurrentState(name)) if (objectNode.isValid() && objectNode.propertyAffectedByCurrentState(name))
objectNode.removeProperty(name); objectNode.removeProperty(name);

View File

@@ -226,9 +226,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
continue; continue;
// Add dynamic property // Add dynamic property
propertiesAndSignals.append(property.name()); propertiesAndSignals.append(property.name().toByteArray());
// Add its change signal // Add its change signal
PropertyName name = property.name(); PropertyName name = property.name().toByteArray();
QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1(); QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1();
name[0] = firstChar.toLatin1(); name[0] = firstChar.toLatin1();
name.prepend("on"); name.prepend("on");
@@ -240,7 +240,7 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
QList<PropertyName> incompatibleProperties; QList<PropertyName> incompatibleProperties;
for (const auto &property : selectedNode.properties()) { for (const auto &property : selectedNode.properties()) {
if (!propertiesAndSignals.contains(property.name())) if (!propertiesAndSignals.contains(property.name()))
incompatibleProperties.append(property.name()); incompatibleProperties.append(property.name().toByteArray());
} }
Utils::sort(incompatibleProperties); Utils::sort(incompatibleProperties);

View File

@@ -22,11 +22,12 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagebox.h> #include <coreplugin/messagebox.h>
#include <qmljs/qmljssimplereader.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <qmljs/qmljssimplereader.h> #include <utils/smallstring.h>
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
@@ -105,11 +106,11 @@ PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyE
PropertyEditorQmlBackend::~PropertyEditorQmlBackend() = default; PropertyEditorQmlBackend::~PropertyEditorQmlBackend() = default;
void PropertyEditorQmlBackend::setupPropertyEditorValue(const PropertyName &name, void PropertyEditorQmlBackend::setupPropertyEditorValue(PropertyNameView name,
PropertyEditorView *propertyEditor, PropertyEditorView *propertyEditor,
const NodeMetaInfo &type) const NodeMetaInfo &type)
{ {
QmlDesigner::PropertyName propertyName(name); QmlDesigner::PropertyName propertyName(name.toByteArray());
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName))));
if (!valueObject) { if (!valueObject) {
@@ -142,9 +143,9 @@ QVariant properDefaultAuxiliaryProperties(const QmlObjectNode &qmlObjectNode,
} }
QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode,
const PropertyName &propertyName) PropertyNameView propertyName)
{ {
const QVariant value = qmlObjectNode.modelValue("Layout." + propertyName); const QVariant value = qmlObjectNode.modelValue("Layout."_sv + propertyName);
QVariant marginsValue = qmlObjectNode.modelValue("Layout.margins"); QVariant marginsValue = qmlObjectNode.modelValue("Layout.margins");
if (!marginsValue.isValid()) if (!marginsValue.isValid())
@@ -177,9 +178,9 @@ QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNod
} }
QVariant properDefaultInsightAttachedProperties(const QmlObjectNode &qmlObjectNode, QVariant properDefaultInsightAttachedProperties(const QmlObjectNode &qmlObjectNode,
const PropertyName &propertyName) PropertyNameView propertyName)
{ {
const QVariant value = qmlObjectNode.modelValue("InsightCategory." + propertyName); const QVariant value = qmlObjectNode.modelValue("InsightCategory."_sv + propertyName);
if (value.isValid()) if (value.isValid())
return value; return value;
@@ -197,8 +198,12 @@ void PropertyEditorQmlBackend::setupLayoutAttachedProperties(const QmlObjectNode
"minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan", "minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan",
"topMargin", "bottomMargin", "leftMargin", "rightMargin", "margins"}; "topMargin", "bottomMargin", "leftMargin", "rightMargin", "margins"};
for (const PropertyName &propertyName : propertyNames) { for (PropertyNameView propertyName : propertyNames) {
createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor); createPropertyEditorValue(qmlObjectNode,
"Layout."_sv + propertyName,
properDefaultLayoutAttachedProperties(qmlObjectNode,
propertyName),
propertyEditor);
} }
} }
} }
@@ -208,7 +213,7 @@ void PropertyEditorQmlBackend::setupInsightAttachedProperties(const QmlObjectNod
{ {
const PropertyName propertyName = "category"; const PropertyName propertyName = "category";
createPropertyEditorValue(qmlObjectNode, createPropertyEditorValue(qmlObjectNode,
"InsightCategory." + propertyName, "InsightCategory."_sv + propertyName,
properDefaultInsightAttachedProperties(qmlObjectNode, propertyName), properDefaultInsightAttachedProperties(qmlObjectNode, propertyName),
propertyEditor); propertyEditor);
} }
@@ -287,7 +292,7 @@ void PropertyEditorQmlBackend::setupAuxiliaryProperties(const QmlObjectNode &qml
} }
void PropertyEditorQmlBackend::handleInstancePropertyChangedInModelNodeProxy( void PropertyEditorQmlBackend::handleInstancePropertyChangedInModelNodeProxy(
const ModelNode &modelNode, const PropertyName &propertyName) const ModelNode &modelNode, PropertyNameView propertyName)
{ {
m_backendModelNode.handleInstancePropertyChanged(modelNode, propertyName); m_backendModelNode.handleInstancePropertyChanged(modelNode, propertyName);
} }
@@ -308,11 +313,11 @@ void PropertyEditorQmlBackend::handlePropertiesRemovedInModelNodeProxy(const Abs
} }
void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, PropertyNameView name,
const QVariant &value, const QVariant &value,
PropertyEditorView *propertyEditor) PropertyEditorView *propertyEditor)
{ {
PropertyName propertyName(name); PropertyName propertyName(name.toByteArray());
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName))));
if (!valueObject) { if (!valueObject) {
@@ -345,7 +350,9 @@ void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qm
} }
} }
void PropertyEditorQmlBackend::setValue(const QmlObjectNode & , const PropertyName &name, const QVariant &value) void PropertyEditorQmlBackend::setValue(const QmlObjectNode &,
PropertyNameView name,
const QVariant &value)
{ {
// Vector*D values need to be split into their subcomponents // Vector*D values need to be split into their subcomponents
if (value.typeId() == QVariant::Vector2D) { if (value.typeId() == QVariant::Vector2D) {
@@ -383,7 +390,7 @@ void PropertyEditorQmlBackend::setValue(const QmlObjectNode & , const PropertyNa
propertyValue->setValue(QVariant(vecValue[i])); propertyValue->setValue(QVariant(vecValue[i]));
} }
} else { } else {
PropertyName propertyName = name; PropertyName propertyName = name.toByteArray();
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName))));
if (propertyValue) if (propertyValue)
@@ -391,7 +398,7 @@ void PropertyEditorQmlBackend::setValue(const QmlObjectNode & , const PropertyNa
} }
} }
void PropertyEditorQmlBackend::setExpression(const PropertyName &propName, const QString &exp) void PropertyEditorQmlBackend::setExpression(PropertyNameView propName, const QString &exp)
{ {
PropertyEditorValue *propertyValue = propertyValueForName(QString::fromUtf8(propName)); PropertyEditorValue *propertyValue = propertyValueForName(QString::fromUtf8(propName));
if (propertyValue) if (propertyValue)
@@ -615,7 +622,9 @@ QString PropertyEditorQmlBackend::propertyEditorResourcesPath()
return Core::ICore::resourcePath("qmldesigner/propertyEditorQmlSources").toString(); return Core::ICore::resourcePath("qmldesigner/propertyEditorQmlSources").toString();
} }
inline bool dotPropertyHeuristic(const QmlObjectNode &node, const NodeMetaInfo &type, const PropertyName &name) inline bool dotPropertyHeuristic(const QmlObjectNode &node,
const NodeMetaInfo &type,
PropertyNameView name)
{ {
if (!name.contains(".")) if (!name.contains("."))
return true; return true;
@@ -623,7 +632,7 @@ inline bool dotPropertyHeuristic(const QmlObjectNode &node, const NodeMetaInfo &
if (name.count('.') > 1) if (name.count('.') > 1)
return false; return false;
QList<QByteArray> list = name.split('.'); QList<QByteArray> list = name.toByteArray().split('.');
const PropertyName parentProperty = list.first(); const PropertyName parentProperty = list.first();
const PropertyName itemProperty = list.last(); const PropertyName itemProperty = list.last();
@@ -738,7 +747,7 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &metaTyp
Utils::sort(basicProperties, propertyMetaInfoCompare); Utils::sort(basicProperties, propertyMetaInfoCompare);
auto findAndFillTemplate = [&nodes, &node, &needsTypeArgTypes](const PropertyName &label, auto findAndFillTemplate = [&nodes, &node, &needsTypeArgTypes](PropertyNameView label,
const PropertyMetaInfo &property) { const PropertyMetaInfo &property) {
const auto &propertyName = property.name(); const auto &propertyName = property.name();
PropertyName underscoreProperty = propertyName; PropertyName underscoreProperty = propertyName;
@@ -962,9 +971,10 @@ void PropertyEditorQmlBackend::emitSelectionChanged()
m_backendModelNode.emitSelectionChanged(); m_backendModelNode.emitSelectionChanged();
} }
void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, const PropertyName &name) void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode,
PropertyNameView name)
{ {
PropertyName propertyName = name; PropertyName propertyName = name.toByteArray();
propertyName.replace("Layout.", ""); propertyName.replace("Layout.", "");
setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName)); setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName));
@@ -978,9 +988,9 @@ void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObje
} }
void PropertyEditorQmlBackend::setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode, void PropertyEditorQmlBackend::setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode,
const PropertyName &name) PropertyNameView name)
{ {
PropertyName propertyName = name; PropertyName propertyName = name.toByteArray();
propertyName.replace("InsightCategory.", ""); propertyName.replace("InsightCategory.", "");
setValue(qmlObjectNode, name, properDefaultInsightAttachedProperties(qmlObjectNode, propertyName)); setValue(qmlObjectNode, name, properDefaultInsightAttachedProperties(qmlObjectNode, propertyName));
} }

View File

@@ -38,8 +38,8 @@ public:
void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor); void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor); void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
void setExpression(const PropertyName &propName, const QString &exp); void setExpression(PropertyNameView propName, const QString &exp);
QQmlContext *context(); QQmlContext *context();
PropertyEditorContextObject* contextObject(); PropertyEditorContextObject* contextObject();
@@ -66,9 +66,9 @@ public:
void emitSelectionChanged(); void emitSelectionChanged();
void setValueforLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, void setValueforLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode,
const PropertyName &name); PropertyNameView name);
void setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode, void setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode,
const PropertyName &name); PropertyNameView name);
void setValueforAuxiliaryProperties(const QmlObjectNode &qmlObjectNode, AuxiliaryDataKeyView key); void setValueforAuxiliaryProperties(const QmlObjectNode &qmlObjectNode, AuxiliaryDataKeyView key);
void setupLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, void setupLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode,
@@ -79,7 +79,7 @@ public:
PropertyEditorView *propertyEditor); PropertyEditorView *propertyEditor);
void handleInstancePropertyChangedInModelNodeProxy(const ModelNode &modelNode, void handleInstancePropertyChangedInModelNodeProxy(const ModelNode &modelNode,
const PropertyName &propertyName); PropertyNameView propertyName);
void handleVariantPropertyChangedInModelNodeProxy(const VariantProperty &property); void handleVariantPropertyChangedInModelNodeProxy(const VariantProperty &property);
void handleBindingPropertyChangedInModelNodeProxy(const BindingProperty &property); void handleBindingPropertyChangedInModelNodeProxy(const BindingProperty &property);
@@ -89,9 +89,10 @@ public:
private: private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, const QVariant &value, PropertyNameView name,
const QVariant &value,
PropertyEditorView *propertyEditor); PropertyEditorView *propertyEditor);
void setupPropertyEditorValue(const PropertyName &name, void setupPropertyEditorValue(PropertyNameView name,
PropertyEditorView *propertyEditor, PropertyEditorView *propertyEditor,
const NodeMetaInfo &type); const NodeMetaInfo &type);

View File

@@ -71,7 +71,7 @@ static bool cleverColorCompare(const QVariant &value1, const QVariant &value2)
// "red" is the same color as "#ff0000" // "red" is the same color as "#ff0000"
// To simplify editing we convert all explicit color names in the hash format // To simplify editing we convert all explicit color names in the hash format
static void fixAmbigousColorNames(const ModelNode &modelNode, const PropertyName &name, QVariant *value) static void fixAmbigousColorNames(const ModelNode &modelNode, PropertyNameView name, QVariant *value)
{ {
if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isColor()) { if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isColor()) {
if (value->typeId() == QVariant::Color) { if (value->typeId() == QVariant::Color) {
@@ -86,7 +86,7 @@ static void fixAmbigousColorNames(const ModelNode &modelNode, const PropertyName
} }
} }
static void fixUrl(const ModelNode &modelNode, const PropertyName &name, QVariant *value) static void fixUrl(const ModelNode &modelNode, PropertyNameView name, QVariant *value)
{ {
if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isUrl()) { if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isUrl()) {
if (!value->isValid()) if (!value->isValid())
@@ -192,7 +192,7 @@ bool PropertyEditorValue::isInModel() const
return modelNode().hasProperty(name()); return modelNode().hasProperty(name());
} }
PropertyName PropertyEditorValue::name() const PropertyNameView PropertyEditorValue::name() const
{ {
return m_name; return m_name;
} }
@@ -202,7 +202,7 @@ QString PropertyEditorValue::nameAsQString() const
return QString::fromUtf8(m_name); return QString::fromUtf8(m_name);
} }
void PropertyEditorValue::setName(const PropertyName &name) void PropertyEditorValue::setName(PropertyNameView name)
{ {
m_name = name; m_name = name;
} }
@@ -273,7 +273,7 @@ bool PropertyEditorValue::isAvailable() const
const auto mcuAllowedItemProperties = mcuManager.allowedItemProperties(); const auto mcuAllowedItemProperties = mcuManager.allowedItemProperties();
const auto mcuBannedComplexProperties = mcuManager.bannedComplexProperties(); const auto mcuBannedComplexProperties = mcuManager.bannedComplexProperties();
const QList<QByteArray> list = name().split('.'); const QList<QByteArray> list = name().toByteArray().split('.');
const QByteArray pureName = list.constFirst(); const QByteArray pureName = list.constFirst();
const QString pureNameStr = QString::fromUtf8(pureName); const QString pureNameStr = QString::fromUtf8(pureName);
@@ -623,7 +623,7 @@ ModelNode PropertyEditorNodeWrapper::parentModelNode() const
return m_editorValue->modelNode(); return m_editorValue->modelNode();
} }
PropertyName PropertyEditorNodeWrapper::propertyName() const PropertyNameView PropertyEditorNodeWrapper::propertyName() const
{ {
return m_editorValue->name(); return m_editorValue->name();
} }
@@ -761,10 +761,10 @@ static QObject *variantToQObject(const QVariant &value)
} }
void PropertyEditorSubSelectionWrapper::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void PropertyEditorSubSelectionWrapper::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, PropertyNameView name,
const QVariant &value) const QVariant &value)
{ {
PropertyName propertyName(name); Utils::SmallString propertyName = name.toByteArray();
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName)))); auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName))));
if (!valueObject) { if (!valueObject) {
@@ -901,14 +901,13 @@ void PropertyEditorSubSelectionWrapper::changeValue(const QString &name)
} }
} }
void PropertyEditorSubSelectionWrapper::setValueFromModel(const PropertyName &name, void PropertyEditorSubSelectionWrapper::setValueFromModel(PropertyNameView name, const QVariant &value)
const QVariant &value)
{ {
m_locked = true; m_locked = true;
QmlObjectNode qmlObjectNode(m_modelNode); QmlObjectNode qmlObjectNode(m_modelNode);
PropertyName propertyName = name; Utils::SmallString propertyName = name;
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto propertyValue = qobject_cast<PropertyEditorValue *>( auto propertyValue = qobject_cast<PropertyEditorValue *>(
variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName)))); variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName))));
@@ -917,7 +916,7 @@ void PropertyEditorSubSelectionWrapper::setValueFromModel(const PropertyName &na
m_locked = false; m_locked = false;
} }
void PropertyEditorSubSelectionWrapper::resetValue(const PropertyName &name) void PropertyEditorSubSelectionWrapper::resetValue(PropertyNameView name)
{ {
auto propertyValue = qobject_cast<PropertyEditorValue *>( auto propertyValue = qobject_cast<PropertyEditorValue *>(
variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(name)))); variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(name))));
@@ -964,7 +963,7 @@ void PropertyEditorSubSelectionWrapper::changeExpression(const QString &property
}); /* end of transaction */ }); /* end of transaction */
} }
void PropertyEditorSubSelectionWrapper::removePropertyFromModel(const PropertyName &propertyName) void PropertyEditorSubSelectionWrapper::removePropertyFromModel(PropertyNameView propertyName)
{ {
QTC_ASSERT(m_modelNode.isValid(), return ); QTC_ASSERT(m_modelNode.isValid(), return );
@@ -982,7 +981,7 @@ void PropertyEditorSubSelectionWrapper::removePropertyFromModel(const PropertyNa
m_locked = false; m_locked = false;
} }
void PropertyEditorSubSelectionWrapper::commitVariantValueToModel(const PropertyName &propertyName, void PropertyEditorSubSelectionWrapper::commitVariantValueToModel(PropertyNameView propertyName,
const QVariant &value) const QVariant &value)
{ {
QTC_ASSERT(m_modelNode.isValid(), return ); QTC_ASSERT(m_modelNode.isValid(), return );

View File

@@ -30,15 +30,17 @@ public:
Q_INVOKABLE void deleteModelNode(); Q_INVOKABLE void deleteModelNode();
void setValueFromModel(const PropertyName &name, const QVariant &value); void setValueFromModel(PropertyNameView name, const QVariant &value);
void resetValue(const PropertyName &name); void resetValue(PropertyNameView name);
bool isRelevantModelNode(const ModelNode &modelNode) const; bool isRelevantModelNode(const ModelNode &modelNode) const;
private: private:
void changeValue(const QString &name); void changeValue(const QString &name);
void changeExpression(const QString &propertyName); void changeExpression(const QString &propertyName);
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value); void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
PropertyNameView name,
const QVariant &value);
void exportPropertyAsAlias(const QString &name); void exportPropertyAsAlias(const QString &name);
void removeAliasExport(const QString &name); void removeAliasExport(const QString &name);
bool locked() const; bool locked() const;
@@ -46,8 +48,8 @@ private:
ModelNode m_modelNode; ModelNode m_modelNode;
QQmlPropertyMap m_valuesPropertyMap; QQmlPropertyMap m_valuesPropertyMap;
bool m_locked = false; bool m_locked = false;
void removePropertyFromModel(const PropertyName &propertyName); void removePropertyFromModel(PropertyNameView propertyName);
void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value);
AbstractView *view() const; AbstractView *view() const;
}; };
@@ -67,7 +69,7 @@ public:
QString type() const; QString type() const;
QQmlPropertyMap *properties(); QQmlPropertyMap *properties();
ModelNode parentModelNode() const; ModelNode parentModelNode() const;
PropertyName propertyName() const; PropertyNameView propertyName() const;
public slots: public slots:
void add(const QString &type = QString()); void add(const QString &type = QString());
@@ -142,9 +144,9 @@ public:
bool isAvailable() const; bool isAvailable() const;
PropertyName name() const; PropertyNameView name() const;
QString nameAsQString() const; QString nameAsQString() const;
void setName(const PropertyName &name); void setName(PropertyNameView name);
ModelNode modelNode() const; ModelNode modelNode() const;
void setModelNode(const ModelNode &modelNode); void setModelNode(const ModelNode &modelNode);
@@ -205,7 +207,7 @@ private:
ModelNode m_modelNode; ModelNode m_modelNode;
QVariant m_value; QVariant m_value;
QString m_expression; QString m_expression;
PropertyName m_name; Utils::SmallString m_name;
bool m_isInSubState = false; bool m_isInSubState = false;
bool m_isInModel = false; bool m_isInModel = false;
bool m_isBound = false; bool m_isBound = false;

View File

@@ -47,12 +47,12 @@ enum {
namespace QmlDesigner { namespace QmlDesigner {
static bool propertyIsAttachedLayoutProperty(const PropertyName &propertyName) static bool propertyIsAttachedLayoutProperty(PropertyNameView propertyName)
{ {
return propertyName.contains("Layout."); return propertyName.contains("Layout.");
} }
static bool propertyIsAttachedInsightProperty(const PropertyName &propertyName) static bool propertyIsAttachedInsightProperty(PropertyNameView propertyName)
{ {
return propertyName.contains("InsightCategory."); return propertyName.contains("InsightCategory.");
} }
@@ -317,7 +317,7 @@ void PropertyEditorView::refreshMetaInfos(const TypeIds &deletedTypeIds)
} }
void PropertyEditorView::setExpressionOnObjectNode(const QmlObjectNode &constObjectNode, void PropertyEditorView::setExpressionOnObjectNode(const QmlObjectNode &constObjectNode,
const PropertyName &name, PropertyNameView name,
const QString &newExpression) const QString &newExpression)
{ {
auto qmlObjectNode = constObjectNode; auto qmlObjectNode = constObjectNode;
@@ -662,7 +662,7 @@ void PropertyEditorView::setupQmlBackend()
#endif // QDS_USE_PROJECTSTORAGE #endif // QDS_USE_PROJECTSTORAGE
} }
void PropertyEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) void PropertyEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
try { try {
@@ -680,11 +680,11 @@ void PropertyEditorView::commitVariantValueToModel(const PropertyName &propertyN
m_locked = false; m_locked = false;
} }
void PropertyEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) void PropertyEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
PropertyName name = propertyName; PropertyNameView name = propertyName;
name.chop(5); name.chop(5);
try { try {
@@ -704,7 +704,7 @@ void PropertyEditorView::commitAuxValueToModel(const PropertyName &propertyName,
m_locked = false; m_locked = false;
} }
void PropertyEditorView::removePropertyFromModel(const PropertyName &propertyName) void PropertyEditorView::removePropertyFromModel(PropertyNameView propertyName)
{ {
m_locked = true; m_locked = true;
try { try {
@@ -794,45 +794,51 @@ void PropertyEditorView::propertiesRemoved(const QList<AbstractProperty> &proper
if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) { if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) {
m_locked = true; m_locked = true;
PropertyName propertyName = property.name(); const PropertyName propertyName = property.name().toByteArray();
propertyName.replace('.', '_'); PropertyName convertedpropertyName = propertyName;
convertedpropertyName.replace('.', '_');
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName( PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(
QString::fromUtf8(propertyName)); QString::fromUtf8(convertedpropertyName));
if (value) { if (value) {
value->resetValue(); value->resetValue();
m_qmlBackEndForCurrentType m_qmlBackEndForCurrentType
->setValue(m_selectedNode, ->setValue(m_selectedNode,
property.name(), propertyName,
QmlObjectNode(m_selectedNode).instanceValue(property.name())); QmlObjectNode(m_selectedNode).instanceValue(propertyName));
} }
m_locked = false; m_locked = false;
if (propertyIsAttachedLayoutProperty(property.name())) { if (propertyIsAttachedLayoutProperty(propertyName)) {
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, property.name()); m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode,
propertyName);
if (property.name() == "Layout.margins") {
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.topMargin");
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.bottomMargin");
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.leftMargin");
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.rightMargin");
if (propertyName == "Layout.margins") {
m_qmlBackEndForCurrentType
->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.topMargin");
m_qmlBackEndForCurrentType
->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.bottomMargin");
m_qmlBackEndForCurrentType
->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.leftMargin");
m_qmlBackEndForCurrentType
->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.rightMargin");
} }
} }
if (propertyIsAttachedInsightProperty(property.name())) { if (propertyIsAttachedInsightProperty(propertyName)) {
m_qmlBackEndForCurrentType->setValueforInsightAttachedProperties(m_selectedNode, m_qmlBackEndForCurrentType->setValueforInsightAttachedProperties(m_selectedNode,
property.name()); propertyName);
} }
if ("width" == property.name() || "height" == property.name()) { if ("width" == propertyName || "height" == propertyName) {
const QmlItemNode qmlItemNode = m_selectedNode; const QmlItemNode qmlItemNode = m_selectedNode;
if (qmlItemNode.isInLayout()) if (qmlItemNode.isInLayout())
resetPuppet(); resetPuppet();
} }
if (property.name().contains("anchor")) if (propertyName.contains("anchor"))
m_qmlBackEndForCurrentType->backendAnchorBinding().invalidate(m_selectedNode); m_qmlBackEndForCurrentType->backendAnchorBinding().invalidate(m_selectedNode);
} }
} }
@@ -1066,7 +1072,7 @@ void PropertyEditorView::dragEnded()
} }
void PropertyEditorView::setValue(const QmlObjectNode &qmlObjectNode, void PropertyEditorView::setValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, PropertyNameView name,
const QVariant &value) const QVariant &value)
{ {
m_locked = true; m_locked = true;

View File

@@ -85,7 +85,7 @@ public:
void refreshMetaInfos(const TypeIds &deletedTypeIds) override; void refreshMetaInfos(const TypeIds &deletedTypeIds) override;
static void setExpressionOnObjectNode(const QmlObjectNode &objectNode, static void setExpressionOnObjectNode(const QmlObjectNode &objectNode,
const PropertyName &name, PropertyNameView name,
const QString &expression); const QString &expression);
static void generateAliasForProperty(const ModelNode &modelNode, static void generateAliasForProperty(const ModelNode &modelNode,
@@ -97,7 +97,7 @@ public:
protected: protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
void setupPane(const TypeName &typeName); void setupPane(const TypeName &typeName);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
private: //functions private: //functions
@@ -111,9 +111,9 @@ private: //functions
void delayedResetView(); void delayedResetView();
void setupQmlBackend(); void setupQmlBackend();
void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value);
void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value);
void removePropertyFromModel(const PropertyName &propertyName); void removePropertyFromModel(PropertyNameView propertyName);
bool noValidSelection() const; bool noValidSelection() const;

View File

@@ -11,7 +11,7 @@ PropertyNameValidator::PropertyNameValidator(QObject *parent)
: QValidator(parent) : QValidator(parent)
{} {}
QValidator::State PropertyNameValidator::validate(QString &input, int &pos) const QValidator::State PropertyNameValidator::validate(QString &input, int &) const
{ {
if (input.isEmpty()) if (input.isEmpty())
return QValidator::Intermediate; return QValidator::Intermediate;

View File

@@ -250,7 +250,7 @@ void QmlModelNodeProxy::changeType(int internalId, const QString &typeName)
} }
void QmlModelNodeProxy::handleInstancePropertyChanged(const ModelNode &modelNode, void QmlModelNodeProxy::handleInstancePropertyChanged(const ModelNode &modelNode,
const PropertyName &propertyName) PropertyNameView propertyName)
{ {
const QmlObjectNode qmlObjectNode(modelNode); const QmlObjectNode qmlObjectNode(modelNode);

View File

@@ -61,7 +61,7 @@ public:
Q_INVOKABLE void changeType(int internalId, const QString &typeName); Q_INVOKABLE void changeType(int internalId, const QString &typeName);
void handleInstancePropertyChanged(const ModelNode &modelNode, const PropertyName &propertyName); void handleInstancePropertyChanged(const ModelNode &modelNode, PropertyNameView propertyName);
void handleBindingPropertyChanged(const BindingProperty &property); void handleBindingPropertyChanged(const BindingProperty &property);
void handleVariantPropertyChanged(const VariantProperty &property); void handleVariantPropertyChanged(const VariantProperty &property);

View File

@@ -42,7 +42,7 @@ QVariant PropertyModel::data(const QModelIndex &index, int role) const
switch (role) { switch (role) {
case Name: { case Name: {
return m_properties.at(index.row()).name(); return m_properties.at(index.row()).name().toByteArray();
} }
case Value: { case Value: {

View File

@@ -67,17 +67,17 @@ TextureEditorQmlBackend::~TextureEditorQmlBackend()
{ {
} }
PropertyName TextureEditorQmlBackend::auxNamePostFix(const PropertyName &propertyName) PropertyName TextureEditorQmlBackend::auxNamePostFix(PropertyNameView propertyName)
{ {
return propertyName + "__AUX"; return propertyName + "__AUX";
} }
void TextureEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void TextureEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, PropertyNameView name,
const QVariant &value, const QVariant &value,
TextureEditorView *textureEditor) TextureEditorView *textureEditor)
{ {
PropertyName propertyName(name); PropertyName propertyName(name.toByteArray());
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto valueObject = qobject_cast<PropertyEditorValue *>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); auto valueObject = qobject_cast<PropertyEditorValue *>(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName))));
if (!valueObject) { if (!valueObject) {
@@ -107,7 +107,9 @@ void TextureEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qml
} }
} }
void TextureEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyName &name, const QVariant &value) void TextureEditorQmlBackend::setValue(const QmlObjectNode &,
PropertyNameView name,
const QVariant &value)
{ {
// Vector*D values need to be split into their subcomponents // Vector*D values need to be split into their subcomponents
if (value.typeId() == QVariant::Vector2D) { if (value.typeId() == QVariant::Vector2D) {
@@ -145,7 +147,7 @@ void TextureEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyName
propertyValue->setValue(QVariant(vecValue[i])); propertyValue->setValue(QVariant(vecValue[i]));
} }
} else { } else {
PropertyName propertyName = name; PropertyName propertyName = name.toByteArray();
propertyName.replace('.', '_'); propertyName.replace('.', '_');
auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); auto propertyValue = qobject_cast<PropertyEditorValue *>(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName))));
if (propertyValue) if (propertyValue)

View File

@@ -37,7 +37,7 @@ public:
void setup(const QmlObjectNode &selectedTextureNode, const QString &stateName, const QUrl &qmlSpecificsFile, void setup(const QmlObjectNode &selectedTextureNode, const QString &stateName, const QUrl &qmlSpecificsFile,
TextureEditorView *textureEditor); TextureEditorView *textureEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
QQmlContext *context() const; QQmlContext *context() const;
TextureEditorContextObject *contextObject() const; TextureEditorContextObject *contextObject() const;
@@ -58,9 +58,10 @@ public:
private: private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, const QVariant &value, PropertyNameView name,
const QVariant &value,
TextureEditorView *textureEditor); TextureEditorView *textureEditor);
PropertyName auxNamePostFix(const PropertyName &propertyName); PropertyName auxNamePostFix(PropertyNameView propertyName);
// to avoid a crash while destructing DesignerPropertyMap in the QQmlData // to avoid a crash while destructing DesignerPropertyMap in the QQmlData
// this needs be destructed after m_quickWidget->engine() is destructed // this needs be destructed after m_quickWidget->engine() is destructed

View File

@@ -475,7 +475,7 @@ void TextureEditorView::setupQmlBackend()
#endif #endif
} }
void TextureEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) void TextureEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
executeInTransaction("TextureEditorView:commitVariantValueToModel", [&] { executeInTransaction("TextureEditorView:commitVariantValueToModel", [&] {
@@ -484,11 +484,11 @@ void TextureEditorView::commitVariantValueToModel(const PropertyName &propertyNa
m_locked = false; m_locked = false;
} }
void TextureEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) void TextureEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value)
{ {
m_locked = true; m_locked = true;
PropertyName name = propertyName; PropertyNameView name = propertyName;
name.chop(5); name.chop(5);
try { try {
@@ -503,7 +503,7 @@ void TextureEditorView::commitAuxValueToModel(const PropertyName &propertyName,
m_locked = false; m_locked = false;
} }
void TextureEditorView::removePropertyFromModel(const PropertyName &propertyName) void TextureEditorView::removePropertyFromModel(PropertyNameView propertyName)
{ {
m_locked = true; m_locked = true;
executeInTransaction("MaterialEditorView:removePropertyFromModel", [&] { executeInTransaction("MaterialEditorView:removePropertyFromModel", [&] {
@@ -565,18 +565,21 @@ void TextureEditorView::propertiesRemoved(const QList<AbstractProperty> &propert
if (node.isRootNode()) if (node.isRootNode())
m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported()); m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported());
auto propertyName = property.name().toByteArray();
if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) {
// TODO: workaround for bug QDS-8539. To be removed once it is fixed. // TODO: workaround for bug QDS-8539. To be removed once it is fixed.
if (node.metaInfo().property(property.name()).propertyType().isUrl()) { if (node.metaInfo().property(property.name()).propertyType().isUrl()) {
resetPuppet(); resetPuppet();
} else { } else {
setValue(m_selectedTexture, property.name(), setValue(m_selectedTexture,
QmlObjectNode(m_selectedTexture).instanceValue(property.name())); propertyName,
QmlObjectNode(m_selectedTexture).instanceValue(propertyName));
} }
} }
if (property.name() == "materials" && (node == m_selectedModel if (propertyName == "materials"
|| QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { && (node == m_selectedModel
|| QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) {
m_qmlBackEnd->contextObject()->setHasSingleModelSelection(false); m_qmlBackEnd->contextObject()->setHasSingleModelSelection(false);
} }
@@ -594,10 +597,16 @@ void TextureEditorView::variantPropertiesChanged(const QList<VariantProperty> &p
if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) {
if (property.isDynamic()) if (property.isDynamic())
m_dynamicPropertiesModel->updateItem(property); m_dynamicPropertiesModel->updateItem(property);
if (m_selectedTexture.property(property.name()).isBindingProperty()) auto propertyName = property.name().toByteArray();
setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).instanceValue(property.name())); if (m_selectedTexture.property(propertyName).isBindingProperty()) {
else setValue(m_selectedTexture,
setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).modelValue(property.name())); propertyName,
QmlObjectNode(m_selectedTexture).instanceValue(propertyName));
} else {
setValue(m_selectedTexture,
propertyName,
QmlObjectNode(m_selectedTexture).modelValue(propertyName));
}
} }
dynamicPropertiesModel()->dispatchPropertyChanges(property); dynamicPropertiesModel()->dispatchPropertyChanges(property);
@@ -615,17 +624,25 @@ void TextureEditorView::bindingPropertiesChanged(const QList<BindingProperty> &p
if (property.isAliasExport()) if (property.isAliasExport())
m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported()); m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported());
auto propertyName = property.name().toByteArray();
if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) {
if (property.isDynamic()) if (property.isDynamic())
m_dynamicPropertiesModel->updateItem(property); m_dynamicPropertiesModel->updateItem(property);
if (QmlObjectNode(m_selectedTexture).modelNode().property(property.name()).isBindingProperty()) if (QmlObjectNode(m_selectedTexture).modelNode().property(propertyName).isBindingProperty()) {
setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).instanceValue(property.name())); setValue(m_selectedTexture,
else propertyName,
setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).modelValue(property.name())); QmlObjectNode(m_selectedTexture).instanceValue(propertyName));
} else {
setValue(m_selectedTexture,
propertyName,
QmlObjectNode(m_selectedTexture).modelValue(propertyName));
}
} }
if (property.name() == "materials" && (node == m_selectedModel if (propertyName == "materials"
|| QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { && (node == m_selectedModel
|| QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) {
bool hasMaterials = QmlObjectNode(m_selectedModel).hasBindingProperty("materials"); bool hasMaterials = QmlObjectNode(m_selectedModel).hasBindingProperty("materials");
m_qmlBackEnd->contextObject()->setHasSingleModelSelection(hasMaterials); m_qmlBackEnd->contextObject()->setHasSingleModelSelection(hasMaterials);
} }
@@ -878,7 +895,9 @@ void TextureEditorView::dragEnded()
} }
// from model to texture editor // from model to texture editor
void TextureEditorView::setValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value) void TextureEditorView::setValue(const QmlObjectNode &qmlObjectNode,
PropertyNameView name,
const QVariant &value)
{ {
m_locked = true; m_locked = true;
m_qmlBackEnd->setValue(qmlObjectNode, name, value); m_qmlBackEnd->setValue(qmlObjectNode, name, value);

View File

@@ -83,7 +83,7 @@ public slots:
protected: protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value);
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
private: private:
@@ -96,9 +96,9 @@ private:
void setupQmlBackend(); void setupQmlBackend();
void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value);
void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value);
void removePropertyFromModel(const PropertyName &propertyName); void removePropertyFromModel(PropertyNameView propertyName);
void duplicateTexture(const ModelNode &texture); void duplicateTexture(const ModelNode &texture);
bool noValidSelection() const; bool noValidSelection() const;

View File

@@ -268,7 +268,7 @@ PropertyMetaInfo metainfo(const AbstractProperty &property)
return metainfo(property.parentModelNode(), property.name()); return metainfo(property.parentModelNode(), property.name());
} }
PropertyMetaInfo metainfo(const ModelNode &node, const PropertyName &propertyName) PropertyMetaInfo metainfo(const ModelNode &node, PropertyNameView propertyName)
{ {
return node.metaInfo().property(propertyName); return node.metaInfo().property(propertyName);
} }

View File

@@ -31,8 +31,7 @@ QMLDESIGNERCORE_EXPORT bool addImportWithCheck(const QString &importName,
QMLDESIGNERCORE_EXPORT bool addImportWithCheck(const QString &importName, Model *model); QMLDESIGNERCORE_EXPORT bool addImportWithCheck(const QString &importName, Model *model);
QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const AbstractProperty &property); QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const AbstractProperty &property);
QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const ModelNode &node, QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const ModelNode &node, PropertyNameView propertyName);
const PropertyName &propertyName);
QMLDESIGNERCORE_EXPORT QString componentFilePath(const PathCacheType &pathCache, QMLDESIGNERCORE_EXPORT QString componentFilePath(const PathCacheType &pathCache,
const NodeMetaInfo &metaInfo); const NodeMetaInfo &metaInfo);

View File

@@ -89,7 +89,7 @@ void StylesheetMerger::syncNodeProperties(ModelNode &outputNode, const ModelNode
continue; continue;
ModelNode newNode = createReplacementNode(oldNode, oldNode); ModelNode newNode = createReplacementNode(oldNode, oldNode);
// cache the property name as removing it will invalidate it // cache the property name as removing it will invalidate it
PropertyName propertyName = nodeProperty.name(); PropertyNameView propertyName = nodeProperty.name();
// remove property first to prevent invalid reparenting situation // remove property first to prevent invalid reparenting situation
outputNode.removeProperty(propertyName); outputNode.removeProperty(propertyName);
outputNode.nodeProperty(propertyName).reparentHere(newNode); outputNode.nodeProperty(propertyName).reparentHere(newNode);
@@ -169,7 +169,8 @@ ModelNode StylesheetMerger::createReplacementNode(const ModelNode& styleNode, Mo
continue; continue;
if (isTextAlignmentProperty(variantProperty) && !m_options.preserveTextAlignment && !styleNode.hasProperty(variantProperty.name())) if (isTextAlignmentProperty(variantProperty) && !m_options.preserveTextAlignment && !styleNode.hasProperty(variantProperty.name()))
continue; continue;
propertyList.append(QPair<PropertyName, QVariant>(variantProperty.name(), variantProperty.value())); propertyList.append(QPair<PropertyName, QVariant>(variantProperty.name().toByteArray(),
variantProperty.value()));
} }
#ifdef QDS_USE_PROJECTSTORAGE #ifdef QDS_USE_PROJECTSTORAGE
@@ -278,7 +279,7 @@ void StylesheetMerger::replaceNode(ModelNode &replacedNode, ModelNode &newNode)
for (const NodeProperty &prop : parentModelNode.nodeProperties()) { for (const NodeProperty &prop : parentModelNode.nodeProperties()) {
if (prop.modelNode().id() == replacedNode.id()) { if (prop.modelNode().id() == replacedNode.id()) {
isNodeProperty = true; isNodeProperty = true;
reparentName = prop.name(); reparentName = prop.name().toByteArray();
} }
} }
ReparentInfo info; ReparentInfo info;

View File

@@ -10,18 +10,18 @@ namespace Internal {
AddPropertyVisitor::AddPropertyVisitor(TextModifier &modifier, AddPropertyVisitor::AddPropertyVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const PropertyName &name, PropertyNameView name,
const QString &value, const QString &value,
QmlRefactoring::PropertyType propertyType, QmlRefactoring::PropertyType propertyType,
const PropertyNameList &propertyOrder, const PropertyNameList &propertyOrder,
const TypeName &dynamicTypeName) : const TypeName &dynamicTypeName)
QMLRewriter(modifier), : QMLRewriter(modifier)
m_parentLocation(parentLocation), , m_parentLocation(parentLocation)
m_name(name), , m_name(name)
m_value(value), , m_value(value)
m_propertyType(propertyType), , m_propertyType(propertyType)
m_propertyOrder(propertyOrder), , m_propertyOrder(propertyOrder)
m_dynamicTypeName(dynamicTypeName) , m_dynamicTypeName(dynamicTypeName)
{ {
} }

View File

@@ -15,7 +15,7 @@ public:
public: public:
AddPropertyVisitor(TextModifier &modifier, AddPropertyVisitor(TextModifier &modifier,
quint32 parentLocation, quint32 parentLocation,
const PropertyName &name, PropertyNameView name,
const QString &value, const QString &value,
QmlRefactoring::PropertyType propertyType, QmlRefactoring::PropertyType propertyType,
const PropertyNameList &propertyOrder, const PropertyNameList &propertyOrder,
@@ -30,7 +30,7 @@ private:
private: private:
quint32 m_parentLocation; quint32 m_parentLocation;
PropertyName m_name; PropertyNameView m_name;
QString m_value; QString m_value;
QmlRefactoring::PropertyType m_propertyType; QmlRefactoring::PropertyType m_propertyType;
PropertyNameList m_propertyOrder; PropertyNameList m_propertyOrder;

View File

@@ -18,16 +18,16 @@ class Inserter: public QMLRewriter
public: public:
Inserter(TextModifier &modifier, Inserter(TextModifier &modifier,
quint32 targetParentObjectLocation, quint32 targetParentObjectLocation,
const PropertyName &targetPropertyName, PropertyNameView targetPropertyName,
bool targetIsArrayBinding, bool targetIsArrayBinding,
TextModifier::MoveInfo moveInfo, TextModifier::MoveInfo moveInfo,
const PropertyNameList &propertyOrder): const PropertyNameList &propertyOrder)
QMLRewriter(modifier), : QMLRewriter(modifier)
targetParentObjectLocation(targetParentObjectLocation), , targetParentObjectLocation(targetParentObjectLocation)
targetPropertyName(targetPropertyName), , targetPropertyName(targetPropertyName)
targetIsArrayBinding(targetIsArrayBinding), , targetIsArrayBinding(targetIsArrayBinding)
moveInfo(moveInfo), , moveInfo(moveInfo)
propertyOrder(propertyOrder) , propertyOrder(propertyOrder)
{} {}
protected: protected:
@@ -124,7 +124,7 @@ private:
private: private:
quint32 targetParentObjectLocation; quint32 targetParentObjectLocation;
PropertyName targetPropertyName; PropertyNameView targetPropertyName;
bool targetIsArrayBinding; bool targetIsArrayBinding;
TextModifier::MoveInfo moveInfo; TextModifier::MoveInfo moveInfo;
PropertyNameList propertyOrder; PropertyNameList propertyOrder;
@@ -132,16 +132,16 @@ private:
MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier, MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier,
quint32 objectLocation, quint32 objectLocation,
const PropertyName &targetPropertyName, PropertyNameView targetPropertyName,
bool targetIsArrayBinding, bool targetIsArrayBinding,
quint32 targetParentObjectLocation, quint32 targetParentObjectLocation,
const PropertyNameList &propertyOrder): const PropertyNameList &propertyOrder)
QMLRewriter(modifier), : QMLRewriter(modifier)
objectLocation(objectLocation), , objectLocation(objectLocation)
targetPropertyName(targetPropertyName), , targetPropertyName(targetPropertyName)
targetIsArrayBinding(targetIsArrayBinding), , targetIsArrayBinding(targetIsArrayBinding)
targetParentObjectLocation(targetParentObjectLocation), , targetParentObjectLocation(targetParentObjectLocation)
propertyOrder(propertyOrder) , propertyOrder(propertyOrder)
{ {
} }

View File

@@ -13,7 +13,7 @@ class MoveObjectVisitor: public QMLRewriter
public: public:
MoveObjectVisitor(QmlDesigner::TextModifier &modifier, MoveObjectVisitor(QmlDesigner::TextModifier &modifier,
quint32 objectLocation, quint32 objectLocation,
const QmlDesigner::PropertyName &targetPropertyName, PropertyNameView targetPropertyName,
bool targetIsArrayBinding, bool targetIsArrayBinding,
quint32 targetParentObjectLocation, quint32 targetParentObjectLocation,
const PropertyNameList &propertyOrder); const PropertyNameList &propertyOrder);
@@ -31,7 +31,7 @@ private:
private: private:
QList<QmlJS::AST::Node *> parents; QList<QmlJS::AST::Node *> parents;
quint32 objectLocation; quint32 objectLocation;
PropertyName targetPropertyName; PropertyNameView targetPropertyName;
bool targetIsArrayBinding; bool targetIsArrayBinding;
quint32 targetParentObjectLocation; quint32 targetParentObjectLocation;
PropertyNameList propertyOrder; PropertyNameList propertyOrder;

View File

@@ -63,7 +63,9 @@ bool QmlRefactoring::removeImport(const Import &import)
return visitor.remove(qmlDocument->qmlProgram(), import); return visitor.remove(qmlDocument->qmlProgram(), import);
} }
bool QmlRefactoring::addToArrayMemberList(int parentLocation, const PropertyName &propertyName, const QString &content) bool QmlRefactoring::addToArrayMemberList(int parentLocation,
PropertyNameView propertyName,
const QString &content)
{ {
if (parentLocation < 0) if (parentLocation < 0)
return false; return false;
@@ -83,7 +85,7 @@ bool QmlRefactoring::addToObjectMemberList(int parentLocation, const QString &co
} }
bool QmlRefactoring::addProperty(int parentLocation, bool QmlRefactoring::addProperty(int parentLocation,
const PropertyName &name, PropertyNameView name,
const QString &value, const QString &value,
PropertyType propertyType, PropertyType propertyType,
const TypeName &dynamicTypeName) const TypeName &dynamicTypeName)
@@ -95,7 +97,10 @@ bool QmlRefactoring::addProperty(int parentLocation,
return visit(qmlDocument->qmlProgram()); return visit(qmlDocument->qmlProgram());
} }
bool QmlRefactoring::changeProperty(int parentLocation, const PropertyName &name, const QString &value, PropertyType propertyType) bool QmlRefactoring::changeProperty(int parentLocation,
PropertyNameView name,
const QString &value,
PropertyType propertyType)
{ {
if (parentLocation < 0) if (parentLocation < 0)
return false; return false;
@@ -117,7 +122,10 @@ bool QmlRefactoring::changeObjectType(int nodeLocation, const QString &newType)
return visit(qmlDocument->qmlProgram()); return visit(qmlDocument->qmlProgram());
} }
bool QmlRefactoring::moveObject(int objectLocation, const PropertyName &targetPropertyName, bool targetIsArrayBinding, int targetParentObjectLocation) bool QmlRefactoring::moveObject(int objectLocation,
PropertyNameView targetPropertyName,
bool targetIsArrayBinding,
int targetParentObjectLocation)
{ {
if (objectLocation < 0 || targetParentObjectLocation < 0) if (objectLocation < 0 || targetParentObjectLocation < 0)
return false; return false;
@@ -150,7 +158,7 @@ bool QmlRefactoring::removeObject(int nodeLocation)
return visit(qmlDocument->qmlProgram()); return visit(qmlDocument->qmlProgram());
} }
bool QmlRefactoring::removeProperty(int parentLocation, const PropertyName &name) bool QmlRefactoring::removeProperty(int parentLocation, PropertyNameView name)
{ {
if (parentLocation < 0 || name.isEmpty()) if (parentLocation < 0 || name.isEmpty())
return false; return false;

View File

@@ -30,21 +30,27 @@ public:
bool addImport(const Import &import); bool addImport(const Import &import);
bool removeImport(const Import &import); bool removeImport(const Import &import);
bool addToArrayMemberList(int parentLocation, const PropertyName &propertyName, const QString &content); bool addToArrayMemberList(int parentLocation, PropertyNameView propertyName, const QString &content);
bool addToObjectMemberList(int parentLocation, const QString &content); bool addToObjectMemberList(int parentLocation, const QString &content);
bool addProperty(int parentLocation, bool addProperty(int parentLocation,
const PropertyName &name, PropertyNameView name,
const QString &value, const QString &value,
PropertyType propertyType, PropertyType propertyType,
const TypeName &dynamicTypeName = TypeName()); const TypeName &dynamicTypeName = TypeName());
bool changeProperty(int parentLocation, const PropertyName &name, const QString &value, PropertyType propertyType); bool changeProperty(int parentLocation,
PropertyNameView name,
const QString &value,
PropertyType propertyType);
bool changeObjectType(int nodeLocation, const QString &newType); bool changeObjectType(int nodeLocation, const QString &newType);
bool moveObject(int objectLocation, const PropertyName &targetPropertyName, bool targetIsArray, int targetParentObjectLocation); bool moveObject(int objectLocation,
PropertyNameView targetPropertyName,
bool targetIsArray,
int targetParentObjectLocation);
bool moveObjectBeforeObject(int movingObjectLocation, int beforeObjectLocation, bool inDefaultProperty); bool moveObjectBeforeObject(int movingObjectLocation, int beforeObjectLocation, bool inDefaultProperty);
bool removeObject(int nodeLocation); bool removeObject(int nodeLocation);
bool removeProperty(int parentLocation, const PropertyName &name); bool removeProperty(int parentLocation, PropertyNameView name);
private: private:
QmlJS::Document::Ptr qmlDocument; QmlJS::Document::Ptr qmlDocument;

View File

@@ -231,9 +231,10 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AS
} }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this // FIXME: duplicate code in the QmlJS::Rewriter class, remove this
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
const QmlDesigner::PropertyName &propertyName, QmlJS::AST::UiObjectMemberList *members,
const QmlDesigner::PropertyNameList &propertyOrder) PropertyNameView propertyName,
const QmlDesigner::PropertyNameList &propertyOrder)
{ {
if (!members) if (!members)
return nullptr; // empty members return nullptr; // empty members

View File

@@ -52,7 +52,10 @@ protected:
void includeLeadingEmptyLine(int &start) const; void includeLeadingEmptyLine(int &start) const;
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder); static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder);
static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const QmlDesigner::PropertyName &propertyName, const PropertyNameList &propertyOrder); static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(
QmlJS::AST::UiObjectMemberList *members,
PropertyNameView propertyName,
const PropertyNameList &propertyOrder);
protected: protected:
bool didRewriting() const bool didRewriting() const

View File

@@ -3,9 +3,12 @@
#pragma once #pragma once
#include "qmldesignercorelib_global.h"
#include <utils/smallstring.h>
#include <QPointer> #include <QPointer>
#include <QSharedPointer> #include <QSharedPointer>
#include "qmldesignercorelib_global.h"
#include <memory> #include <memory>
@@ -53,12 +56,12 @@ public:
AbstractProperty &operator=(AbstractProperty &&) noexcept = default; AbstractProperty &operator=(AbstractProperty &&) noexcept = default;
~AbstractProperty(); ~AbstractProperty();
AbstractProperty(const AbstractProperty &property, AbstractView *view); AbstractProperty(const AbstractProperty &property, AbstractView *view);
AbstractProperty(const PropertyName &propertyName, AbstractProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode, const Internal::InternalNodePointer &internalNode,
Model *model, Model *model,
AbstractView *view); AbstractView *view);
const PropertyName &name() const; PropertyNameView name() const & { return m_propertyName; }
bool isValid() const; bool isValid() const;
explicit operator bool() const { return isValid(); } explicit operator bool() const { return isValid(); }
@@ -139,7 +142,7 @@ protected:
Internal::ModelPrivate *privateModel() const; Internal::ModelPrivate *privateModel() const;
private: private:
PropertyName m_propertyName; Utils::SmallString m_propertyName;
Internal::InternalNodePointer m_internalNode; Internal::InternalNodePointer m_internalNode;
QPointer<Model> m_model; QPointer<Model> m_model;
QPointer<AbstractView> m_view; QPointer<AbstractView> m_view;

View File

@@ -39,10 +39,12 @@ public:
static QVariant convertToLiteral(const TypeName &typeName, const QString &expression); static QVariant convertToLiteral(const TypeName &typeName, const QString &expression);
BindingProperty(const PropertyName &propertyName, BindingProperty(Utils::SmallStringView propertyName,
const Internal::InternalNodePointer &internalNode, const Internal::InternalNodePointer &internalNode,
Model *model, Model *model,
AbstractView *view); AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{}
private: private:
ModelNode resolveBinding(const QString &binding, ModelNode currentNode) const; ModelNode resolveBinding(const QString &binding, ModelNode currentNode) const;

View File

@@ -110,14 +110,14 @@ public:
//### //###
AbstractProperty property(const PropertyName &name) const; AbstractProperty property(PropertyNameView name) const;
VariantProperty variantProperty(const PropertyName &name) const; VariantProperty variantProperty(PropertyNameView name) const;
BindingProperty bindingProperty(const PropertyName &name) const; BindingProperty bindingProperty(PropertyNameView name) const;
SignalHandlerProperty signalHandlerProperty(const PropertyName &name) const; SignalHandlerProperty signalHandlerProperty(PropertyNameView name) const;
SignalDeclarationProperty signalDeclarationProperty(const PropertyName &name) const; SignalDeclarationProperty signalDeclarationProperty(PropertyNameView name) const;
NodeListProperty nodeListProperty(const PropertyName &name) const; NodeListProperty nodeListProperty(PropertyNameView name) const;
NodeProperty nodeProperty(const PropertyName &name) const; NodeProperty nodeProperty(PropertyNameView name) const;
NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; NodeAbstractProperty nodeAbstractProperty(PropertyNameView name) const;
NodeAbstractProperty defaultNodeAbstractProperty() const; NodeAbstractProperty defaultNodeAbstractProperty() const;
NodeListProperty defaultNodeListProperty() const; NodeListProperty defaultNodeListProperty() const;
NodeProperty defaultNodeProperty() const; NodeProperty defaultNodeProperty() const;

View File

@@ -35,10 +35,12 @@ public:
friend auto qHash(const NodeAbstractProperty &property) { qHash(AbstractProperty(property)); } friend auto qHash(const NodeAbstractProperty &property) { qHash(AbstractProperty(property)); }
NodeAbstractProperty(const PropertyName &propertyName, NodeAbstractProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode, const Internal::InternalNodePointer &internalNode,
Model *model, Model *model,
AbstractView *view); AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{}
protected: protected:
NodeAbstractProperty(const Internal::InternalNodeAbstractPropertyPointer &property, Model *model, AbstractView *view); NodeAbstractProperty(const Internal::InternalNodeAbstractPropertyPointer &property, Model *model, AbstractView *view);

View File

@@ -51,12 +51,12 @@ public:
QPixmap renderPixmap() const; QPixmap renderPixmap() const;
QPixmap blurredRenderPixmap() const; QPixmap blurredRenderPixmap() const;
QVariant property(const PropertyName &name) const; QVariant property(PropertyNameView name) const;
bool hasProperty(const PropertyName &name) const; bool hasProperty(PropertyNameView name) const;
bool hasBindingForProperty(const PropertyName &name) const; bool hasBindingForProperty(PropertyNameView name) const;
QPair<PropertyName, qint32> anchor(const PropertyName &name) const; QPair<PropertyName, qint32> anchor(PropertyNameView name) const;
bool hasAnchor(const PropertyName &name) const; bool hasAnchor(PropertyNameView name) const;
TypeName instanceType(const PropertyName &name) const; TypeName instanceType(PropertyNameView name) const;
qint32 parentId() const; qint32 parentId() const;
qint32 instanceId() const; qint32 instanceId() const;
@@ -72,7 +72,7 @@ public:
QStringList allStateNames() const; QStringList allStateNames() const;
protected: protected:
void setProperty(const PropertyName &name, const QVariant &value); void setProperty(PropertyNameView name, const QVariant &value);
InformationName setInformation(InformationName name, InformationName setInformation(InformationName name,
const QVariant &information, const QVariant &information,
const QVariant &secondInformation, const QVariant &secondInformation,
@@ -94,10 +94,13 @@ protected:
InformationName setInformationIsAnchoredByChildren(bool isAnchoredByChildren); InformationName setInformationIsAnchoredByChildren(bool isAnchoredByChildren);
InformationName setInformationIsAnchoredBySibling(bool isAnchoredBySibling); InformationName setInformationIsAnchoredBySibling(bool isAnchoredBySibling);
InformationName setInformationHasContent(bool hasContent); InformationName setInformationHasContent(bool hasContent);
InformationName setInformationHasAnchor(const PropertyName &sourceAnchorLine, bool hasAnchor); InformationName setInformationHasAnchor(PropertyNameView sourceAnchorLine, bool hasAnchor);
InformationName setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId); InformationName setInformationAnchor(PropertyNameView sourceAnchorLine,
InformationName setInformationInstanceTypeForProperty(const PropertyName &property, const TypeName &type); const PropertyName &targetAnchorLine,
InformationName setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty); qint32 targetInstanceId);
InformationName setInformationInstanceTypeForProperty(PropertyNameView property,
const TypeName &type);
InformationName setInformationHasBindingForProperty(PropertyNameView, bool hasProperty);
InformationName setAllStates(const QStringList &states); InformationName setAllStates(const QStringList &states);
void setParentId(qint32 instanceId); void setParentId(qint32 instanceId);

View File

@@ -240,7 +240,8 @@ private: // functions
void handleQsbProcessExit(Utils::Process *qsbProcess, const QString &shader); void handleQsbProcessExit(Utils::Process *qsbProcess, const QString &shader);
void updateQsbPathToFilterMap(); void updateQsbPathToFilterMap();
void updateRotationBlocks(); void updateRotationBlocks();
void maybeResetOnPropertyChange(const PropertyName &name, const ModelNode &node, void maybeResetOnPropertyChange(PropertyNameView name,
const ModelNode &node,
PropertyChangeFlags flags); PropertyChangeFlags flags);
private: private:

View File

@@ -166,10 +166,13 @@ public:
using reference = ModelNode; using reference = ModelNode;
NodeListProperty(); NodeListProperty();
NodeListProperty(const PropertyName &propertyName,
NodeListProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode, const Internal::InternalNodePointer &internalNode,
Model *model, Model *model,
AbstractView *view); AbstractView *view)
: NodeAbstractProperty(propertyName, internalNode, model, view)
{}
QList<ModelNode> toModelNodeList() const; QList<ModelNode> toModelNodeList() const;
QList<QmlObjectNode> toQmlObjectNodeList() const; QList<QmlObjectNode> toQmlObjectNodeList() const;
void slide(int, int) const; void slide(int, int) const;

View File

@@ -94,7 +94,7 @@ public:
bool hasProperty(::Utils::SmallStringView propertyName) const; bool hasProperty(::Utils::SmallStringView propertyName) const;
PropertyMetaInfos properties() const; PropertyMetaInfos properties() const;
PropertyMetaInfos localProperties() const; PropertyMetaInfos localProperties() const;
PropertyMetaInfo property(const PropertyName &propertyName) const; PropertyMetaInfo property(PropertyNameView propertyName) const;
PropertyNameList signalNames() const; PropertyNameList signalNames() const;
PropertyNameList slotNames() const; PropertyNameList slotNames() const;
PropertyName defaultPropertyName() const; PropertyName defaultPropertyName() const;

View File

@@ -24,10 +24,13 @@ public:
void setDynamicTypeNameAndsetModelNode(const TypeName &typeName, const ModelNode &modelNode); void setDynamicTypeNameAndsetModelNode(const TypeName &typeName, const ModelNode &modelNode);
NodeProperty(); NodeProperty();
NodeProperty(const PropertyName &propertyName,
NodeProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode, const Internal::InternalNodePointer &internalNode,
Model *model, Model *model,
AbstractView *view); AbstractView *view)
: NodeAbstractProperty(propertyName, internalNode, model, view)
{}
}; };
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -9,6 +9,8 @@
#include <projectstorage/projectstoragetypes.h> #include <projectstorage/projectstoragetypes.h>
#include <projectstorageids.h> #include <projectstorageids.h>
#include <utils/smallstring.h>
#include <QString> #include <QString>
#include <memory> #include <memory>
@@ -25,7 +27,8 @@ class QMLDESIGNERCORE_EXPORT PropertyMetaInfo
public: public:
PropertyMetaInfo(); PropertyMetaInfo();
PropertyMetaInfo(std::shared_ptr<NodeMetaInfoPrivate> nodeMetaInfoPrivateData, PropertyMetaInfo(std::shared_ptr<NodeMetaInfoPrivate> nodeMetaInfoPrivateData,
const PropertyName &propertyName); PropertyNameView propertyName);
PropertyMetaInfo([[maybe_unused]] PropertyDeclarationId id, PropertyMetaInfo([[maybe_unused]] PropertyDeclarationId id,
[[maybe_unused]] NotNullPointer<const ProjectStorageType> projectStorage) [[maybe_unused]] NotNullPointer<const ProjectStorageType> projectStorage)
#ifdef QDS_USE_PROJECTSTORAGE #ifdef QDS_USE_PROJECTSTORAGE

View File

@@ -30,8 +30,8 @@ public:
static bool isValidQml3DNode(const ModelNode &modelNode); static bool isValidQml3DNode(const ModelNode &modelNode);
static bool isValidVisualRoot(const ModelNode &modelNode); static bool isValidVisualRoot(const ModelNode &modelNode);
bool handleEulerRotation(const PropertyName &name); bool handleEulerRotation(PropertyNameView name);
bool isBlocked(const PropertyName &propName) const; bool isBlocked(PropertyNameView propName) const;
friend auto qHash(const Qml3DNode &node) { return qHash(node.modelNode()); } friend auto qHash(const Qml3DNode &node) { return qHash(node.modelNode()); }

View File

@@ -34,7 +34,7 @@ public:
bool isValid() const; bool isValid() const;
explicit operator bool() const { return isValid(); } explicit operator bool() const { return isValid(); }
static bool isValidQmlPropertyChanges(const ModelNode &modelNode); static bool isValidQmlPropertyChanges(const ModelNode &modelNode);
void removeProperty(const PropertyName &name); void removeProperty(PropertyNameView name);
}; };
} //QmlDesigner } //QmlDesigner

View File

@@ -214,7 +214,7 @@ public:
static const PropertyNameList &mouseSignals() { return s_mouseSignals; } static const PropertyNameList &mouseSignals() { return s_mouseSignals; }
protected: protected:
QList<ModelNode> transitionsForProperty(const PropertyName &propertyName, const ModelNode &modelNode); QList<ModelNode> transitionsForProperty(PropertyNameView propertyName, const ModelNode &modelNode);
private: private:
static PropertyNameList s_mouseSignals; static PropertyNameList s_mouseSignals;

View File

@@ -51,26 +51,26 @@ public:
QmlModelState currentState() const; QmlModelState currentState() const;
QmlTimeline currentTimeline() const; QmlTimeline currentTimeline() const;
void setVariantProperty(const PropertyName &name, const QVariant &value); void setVariantProperty(PropertyNameView name, const QVariant &value);
void setBindingProperty(const PropertyName &name, const QString &expression); void setBindingProperty(PropertyNameView name, const QString &expression);
NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; NodeAbstractProperty nodeAbstractProperty(PropertyNameView name) const;
NodeAbstractProperty defaultNodeAbstractProperty() const; NodeAbstractProperty defaultNodeAbstractProperty() const;
NodeProperty nodeProperty(const PropertyName &name) const; NodeProperty nodeProperty(PropertyNameView name) const;
NodeListProperty nodeListProperty(const PropertyName &name) const; NodeListProperty nodeListProperty(PropertyNameView name) const;
bool instanceHasValue(const PropertyName &name) const; bool instanceHasValue(PropertyNameView name) const;
QVariant instanceValue(const PropertyName &name) const; QVariant instanceValue(PropertyNameView name) const;
TypeName instanceType(const PropertyName &name) const; TypeName instanceType(PropertyNameView name) const;
bool hasProperty(const PropertyName &name) const; bool hasProperty(PropertyNameView name) const;
bool hasBindingProperty(const PropertyName &name) const; bool hasBindingProperty(PropertyNameView name) const;
bool instanceHasBinding(const PropertyName &name) const; bool instanceHasBinding(PropertyNameView name) const;
bool propertyAffectedByCurrentState(const PropertyName &name) const; bool propertyAffectedByCurrentState(PropertyNameView name) const;
QVariant modelValue(const PropertyName &name) const; QVariant modelValue(PropertyNameView name) const;
bool isTranslatableText(const PropertyName &name) const; bool isTranslatableText(PropertyNameView name) const;
QString stripedTranslatableText(const PropertyName &name) const; QString stripedTranslatableText(PropertyNameView name) const;
BindingProperty bindingProperty(const PropertyName &name) const; BindingProperty bindingProperty(PropertyNameView name) const;
QString expression(const PropertyName &name) const; QString expression(PropertyNameView name) const;
bool isInBaseState() const; bool isInBaseState() const;
bool timelineIsActive() const; bool timelineIsActive() const;
QmlPropertyChanges propertyChangeForCurrentState() const; QmlPropertyChanges propertyChangeForCurrentState() const;
@@ -87,7 +87,7 @@ public:
QList<QmlModelState> allAffectingStates() const; QList<QmlModelState> allAffectingStates() const;
QList<QmlModelStateOperation> allAffectingStatesOperations() const; QList<QmlModelStateOperation> allAffectingStatesOperations() const;
void removeProperty(const PropertyName &name); void removeProperty(PropertyNameView name);
void setParent(const QmlObjectNode &newParent); void setParent(const QmlObjectNode &newParent);
@@ -99,7 +99,7 @@ public:
bool hasDefaultPropertyName() const; bool hasDefaultPropertyName() const;
PropertyName defaultPropertyName() const; PropertyName defaultPropertyName() const;
static QVariant instanceValue(const ModelNode &modelNode, const PropertyName &name); static QVariant instanceValue(const ModelNode &modelNode, PropertyNameView name);
static QString generateTranslatableText(const QString &text, static QString generateTranslatableText(const QString &text,
const DesignerSettings &designerSettings); const DesignerSettings &designerSettings);

View File

@@ -25,8 +25,8 @@ public:
static bool isValidQmlTimeline(const ModelNode &modelNode); static bool isValidQmlTimeline(const ModelNode &modelNode);
void destroy(); void destroy();
QmlTimelineKeyframeGroup keyframeGroup(const ModelNode &modelNode, const PropertyName &propertyName); QmlTimelineKeyframeGroup keyframeGroup(const ModelNode &modelNode, PropertyNameView propertyName);
bool hasTimeline(const ModelNode &modelNode, const PropertyName &propertyName); bool hasTimeline(const ModelNode &modelNode, PropertyNameView propertyName);
qreal startKeyframe() const; qreal startKeyframe() const;
qreal endKeyframe() const; qreal endKeyframe() const;
@@ -45,8 +45,7 @@ public:
QList<QmlTimelineKeyframeGroup> keyframeGroupsForTarget(const ModelNode &target) const; QList<QmlTimelineKeyframeGroup> keyframeGroupsForTarget(const ModelNode &target) const;
void destroyKeyframesForTarget(const ModelNode &target); void destroyKeyframesForTarget(const ModelNode &target);
void removeKeyframesForTargetAndProperty(const ModelNode &target, void removeKeyframesForTargetAndProperty(const ModelNode &target, PropertyNameView propertyName);
const PropertyName &propertyName);
static bool hasActiveTimeline(AbstractView *view); static bool hasActiveTimeline(AbstractView *view);
@@ -54,13 +53,13 @@ public:
void toogleRecording(bool b) const; void toogleRecording(bool b) const;
void resetGroupRecording() const; void resetGroupRecording() const;
bool hasKeyframeGroup(const ModelNode &node, const PropertyName &propertyName) const; bool hasKeyframeGroup(const ModelNode &node, PropertyNameView propertyName) const;
bool hasKeyframeGroupForTarget(const ModelNode &node) const; bool hasKeyframeGroupForTarget(const ModelNode &node) const;
void insertKeyframe(const ModelNode &target, const PropertyName &propertyName); void insertKeyframe(const ModelNode &target, PropertyNameView propertyName);
private: private:
void addKeyframeGroupIfNotExists(const ModelNode &node, const PropertyName &propertyName); void addKeyframeGroupIfNotExists(const ModelNode &node, PropertyNameView propertyName);
QList<QmlTimelineKeyframeGroup> allKeyframeGroups() const; QList<QmlTimelineKeyframeGroup> allKeyframeGroups() const;
}; };

View File

@@ -28,7 +28,7 @@ public:
void setTarget(const ModelNode &target); void setTarget(const ModelNode &target);
PropertyName propertyName() const; PropertyName propertyName() const;
void setPropertyName(const PropertyName &propertyName); void setPropertyName(PropertyNameView propertyName);
void setValue(const QVariant &value, qreal frame); void setValue(const QVariant &value, qreal frame);
QVariant value(qreal frame) const; QVariant value(qreal frame) const;

View File

@@ -100,7 +100,7 @@ public:
bool isFlowWildcard() const; bool isFlowWildcard() const;
private: private:
void setDoubleProperty(const PropertyName &name, double value); void setDoubleProperty(PropertyNameView name, double value);
}; };
class QMLDESIGNERCORE_EXPORT QmlModelStateGroup class QMLDESIGNERCORE_EXPORT QmlModelStateGroup

View File

@@ -21,10 +21,15 @@ public:
SignalHandlerProperty(); SignalHandlerProperty();
SignalHandlerProperty(const SignalHandlerProperty &property, AbstractView *view); SignalHandlerProperty(const SignalHandlerProperty &property, AbstractView *view);
static PropertyName prefixAdded(const PropertyName &propertyName); static PropertyName prefixAdded(PropertyNameView propertyName);
static PropertyName prefixRemoved(const PropertyName &propertyName); static PropertyName prefixRemoved(PropertyNameView propertyName);
SignalHandlerProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view); SignalHandlerProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode,
Model *model,
AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{}
}; };
class QMLDESIGNERCORE_EXPORT SignalDeclarationProperty final : public AbstractProperty class QMLDESIGNERCORE_EXPORT SignalDeclarationProperty final : public AbstractProperty
@@ -39,7 +44,13 @@ public:
SignalDeclarationProperty(); SignalDeclarationProperty();
SignalDeclarationProperty(const SignalDeclarationProperty &property, AbstractView *view); SignalDeclarationProperty(const SignalDeclarationProperty &property, AbstractView *view);
SignalDeclarationProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view);
SignalDeclarationProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode,
Model *model,
AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{}
}; };
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -37,7 +37,13 @@ public:
VariantProperty(); VariantProperty();
VariantProperty(const VariantProperty &property, AbstractView *view); VariantProperty(const VariantProperty &property, AbstractView *view);
VariantProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view);
VariantProperty(PropertyNameView propertyName,
const Internal::InternalNodePointer &internalNode,
Model *model,
AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{}
}; };
QMLDESIGNERCORE_EXPORT QTextStream& operator<<(QTextStream &stream, const VariantProperty &property); QMLDESIGNERCORE_EXPORT QTextStream& operator<<(QTextStream &stream, const VariantProperty &property);

View File

@@ -43,18 +43,17 @@ public:
bool isInLayoutable{false}; bool isInLayoutable{false};
bool directUpdates{false}; bool directUpdates{false};
std::map<Utils::SmallString, QVariant, std::less<>> propertyValues;
QHash<PropertyName, QVariant> propertyValues; std::map<Utils::SmallString, bool, std::less<>> hasBindingForProperty;
QHash<PropertyName, bool> hasBindingForProperty; std::map<Utils::SmallString, bool, std::less<>> hasAnchors;
QHash<PropertyName, bool> hasAnchors; std::map<Utils::SmallString, TypeName, std::less<>> instanceTypes;
QHash<PropertyName, TypeName> instanceTypes;
QPixmap renderPixmap; QPixmap renderPixmap;
QPixmap blurredRenderPixmap; QPixmap blurredRenderPixmap;
QString errorMessage; QString errorMessage;
QHash<PropertyName, QPair<PropertyName, qint32> > anchors; std::map<Utils::SmallString, std::pair<PropertyName, qint32>, std::less<>> anchors;
QStringList allStates; QStringList allStates;
}; };
@@ -285,17 +284,32 @@ int NodeInstance::penWidth() const
return 1; return 1;
} }
QVariant NodeInstance::property(const PropertyName &name) const namespace {
template<typename... Arguments>
auto value(const std::map<Arguments...> &dict,
PropertyNameView key,
typename std::map<Arguments...>::mapped_type defaultValue = {})
{
if (auto found = dict.find(key); found != dict.end())
return found->second;
return defaultValue;
}
} // namespace
QVariant NodeInstance::property(PropertyNameView name) const
{ {
if (isValid()) { if (isValid()) {
if (d->propertyValues.contains(name)) { if (auto found = d->propertyValues.find(name); found != d->propertyValues.end()) {
return d->propertyValues.value(name); return found->second;
} else { } else {
// Query may be for a subproperty, e.g. scale.x // Query may be for a subproperty, e.g. scale.x
const int index = name.indexOf('.'); const auto index = name.indexOf('.');
if (index != -1) { if (index != -1) {
PropertyName parentPropName = name.left(index); PropertyNameView parentPropName = name.left(index);
QVariant varValue = d->propertyValues.value(parentPropName); QVariant varValue = value(d->propertyValues, parentPropName);
if (varValue.typeId() == QVariant::Vector2D) { if (varValue.typeId() == QVariant::Vector2D) {
auto value = varValue.value<QVector2D>(); auto value = varValue.value<QVector2D>();
char subProp = name.right(1)[0]; char subProp = name.right(1)[0];
@@ -361,7 +375,7 @@ QVariant NodeInstance::property(const PropertyName &name) const
return QVariant(); return QVariant();
} }
bool NodeInstance::hasProperty(const PropertyName &name) const bool NodeInstance::hasProperty(PropertyNameView name) const
{ {
if (isValid()) if (isValid())
return d->propertyValues.contains(name); return d->propertyValues.contains(name);
@@ -369,18 +383,18 @@ bool NodeInstance::hasProperty(const PropertyName &name) const
return false; return false;
} }
bool NodeInstance::hasBindingForProperty(const PropertyName &name) const bool NodeInstance::hasBindingForProperty(PropertyNameView name) const
{ {
if (isValid()) if (isValid())
return d->hasBindingForProperty.value(name, false); return value(d->hasBindingForProperty, name, false);
return false; return false;
} }
TypeName NodeInstance::instanceType(const PropertyName &name) const TypeName NodeInstance::instanceType(PropertyNameView name) const
{ {
if (isValid()) if (isValid())
return d->instanceTypes.value(name); return value(d->instanceTypes, name);
return TypeName(); return TypeName();
} }
@@ -393,28 +407,28 @@ qint32 NodeInstance::parentId() const
return false; return false;
} }
bool NodeInstance::hasAnchor(const PropertyName &name) const bool NodeInstance::hasAnchor(PropertyNameView name) const
{ {
if (isValid()) if (isValid())
return d->hasAnchors.value(name, false); return value(d->hasAnchors, name, false);
return false; return false;
} }
QPair<PropertyName, qint32> NodeInstance::anchor(const PropertyName &name) const QPair<PropertyName, qint32> NodeInstance::anchor(PropertyNameView name) const
{ {
if (isValid()) if (isValid())
return d->anchors.value(name, QPair<PropertyName, qint32>(PropertyName(), qint32(-1))); return value(d->anchors, name, QPair<PropertyName, qint32>(PropertyName(), qint32(-1)));
return QPair<PropertyName, qint32>(PropertyName(), -1); return QPair<PropertyName, qint32>(PropertyName(), -1);
} }
void NodeInstance::setProperty(const PropertyName &name, const QVariant &value) void NodeInstance::setProperty(PropertyNameView name, const QVariant &value)
{ {
const int index = name.indexOf('.'); const auto index = name.indexOf('.');
if (index != -1) { if (index != -1) {
PropertyName parentPropName = name.left(index); PropertyNameView parentPropName = name.left(index);
QVariant oldValue = d->propertyValues.value(parentPropName); QVariant oldValue = QmlDesigner::value(d->propertyValues, parentPropName);
QVariant newValueVar; QVariant newValueVar;
bool update = false; bool update = false;
if (oldValue.typeId() == QVariant::Vector2D) { if (oldValue.typeId() == QVariant::Vector2D) {
@@ -464,12 +478,12 @@ void NodeInstance::setProperty(const PropertyName &name, const QVariant &value)
newValueVar = newValue; newValueVar = newValue;
} }
if (update) { if (update) {
d->propertyValues.insert(parentPropName, newValueVar); d->propertyValues.emplace(parentPropName, newValueVar);
return; return;
} }
} }
d->propertyValues.insert(name, value); d->propertyValues.emplace(name, value);
} }
QPixmap NodeInstance::renderPixmap() const QPixmap NodeInstance::renderPixmap() const
@@ -671,41 +685,50 @@ InformationName NodeInstance::setInformationHasContent(bool hasContent)
return NoInformationChange; return NoInformationChange;
} }
InformationName NodeInstance::setInformationHasAnchor(const PropertyName &sourceAnchorLine, bool hasAnchor) InformationName NodeInstance::setInformationHasAnchor(PropertyNameView sourceAnchorLine, bool hasAnchor)
{ {
if (d->hasAnchors.value(sourceAnchorLine) != hasAnchor) { if (auto found = d->hasAnchors.find(sourceAnchorLine);
d->hasAnchors.insert(sourceAnchorLine, hasAnchor); found == d->hasAnchors.end() || found->second != hasAnchor) {
d->hasAnchors.emplace_hint(found, sourceAnchorLine, hasAnchor);
return HasAnchor; return HasAnchor;
} }
return NoInformationChange; return NoInformationChange;
} }
InformationName NodeInstance::setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId) InformationName NodeInstance::setInformationAnchor(PropertyNameView sourceAnchorLine,
const PropertyName &targetAnchorLine,
qint32 targetInstanceId)
{ {
QPair<PropertyName, qint32> anchorPair = QPair<PropertyName, qint32>(targetAnchorLine, targetInstanceId); std::pair<PropertyName, qint32> anchorPair = std::pair<PropertyName, qint32>(targetAnchorLine,
if (d->anchors.value(sourceAnchorLine) != anchorPair) { targetInstanceId);
d->anchors.insert(sourceAnchorLine, anchorPair); if (auto found = d->anchors.find(sourceAnchorLine);
found == d->anchors.end() || found->second != anchorPair) {
d->anchors.emplace_hint(found, sourceAnchorLine, anchorPair);
return Anchor; return Anchor;
} }
return NoInformationChange; return NoInformationChange;
} }
InformationName NodeInstance::setInformationInstanceTypeForProperty(const PropertyName &property, const TypeName &type) InformationName NodeInstance::setInformationInstanceTypeForProperty(PropertyNameView property,
const TypeName &type)
{ {
if (d->instanceTypes.value(property) != type) { if (auto found = d->instanceTypes.find(property);
d->instanceTypes.insert(property, type); found == d->instanceTypes.end() || found->second != type) {
d->instanceTypes.emplace_hint(found, property, type);
return InstanceTypeForProperty; return InstanceTypeForProperty;
} }
return NoInformationChange; return NoInformationChange;
} }
InformationName NodeInstance::setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty) InformationName NodeInstance::setInformationHasBindingForProperty(PropertyNameView property,
bool hasProperty)
{ {
if (d->hasBindingForProperty.value(property) != hasProperty) { if (auto found = d->hasBindingForProperty.find(property);
d->hasBindingForProperty.insert(property, hasProperty); found == d->hasBindingForProperty.end() || found->second != hasProperty) {
d->hasBindingForProperty.emplace_hint(found, property, hasProperty);
return HasBindingForProperty; return HasBindingForProperty;
} }

View File

@@ -470,7 +470,7 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList<AbstractProperty>&
m_nodeInstanceServer->removeProperties(createRemovePropertiesCommand(nonNodePropertyList)); m_nodeInstanceServer->removeProperties(createRemovePropertiesCommand(nonNodePropertyList));
for (const AbstractProperty &property : propertyList) { for (const AbstractProperty &property : propertyList) {
const PropertyName &name = property.name(); const PropertyNameView name = property.name();
if (name == "anchors.fill") { if (name == "anchors.fill") {
resetHorizontalAnchors(property.parentModelNode()); resetHorizontalAnchors(property.parentModelNode());
resetVerticalAnchors(property.parentModelNode()); resetVerticalAnchors(property.parentModelNode());
@@ -602,7 +602,7 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty &listProperty)
{ {
QTC_ASSERT(m_nodeInstanceServer, return); QTC_ASSERT(m_nodeInstanceServer, return);
QVector<ReparentContainer> containerList; QVector<ReparentContainer> containerList;
PropertyName propertyName = listProperty.name(); PropertyNameView propertyName = listProperty.name();
qint32 containerInstanceId = -1; qint32 containerInstanceId = -1;
ModelNode containerNode = listProperty.parentModelNode(); ModelNode containerNode = listProperty.parentModelNode();
if (hasInstanceForModelNode(containerNode)) if (hasInstanceForModelNode(containerNode))
@@ -613,7 +613,11 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty &listProperty)
qint32 instanceId = -1; qint32 instanceId = -1;
if (hasInstanceForModelNode(node)) { if (hasInstanceForModelNode(node)) {
instanceId = instanceForModelNode(node).instanceId(); instanceId = instanceForModelNode(node).instanceId();
ReparentContainer container(instanceId, containerInstanceId, propertyName, containerInstanceId, propertyName); ReparentContainer container(instanceId,
containerInstanceId,
propertyName.toByteArray(),
containerInstanceId,
propertyName.toByteArray());
containerList.append(container); containerList.append(container);
} }
} }
@@ -1135,7 +1139,11 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
for (const NodeInstance &instance : std::as_const(instanceList)) { for (const NodeInstance &instance : std::as_const(instanceList)) {
if (instance.modelNode().hasParentProperty()) { if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty(); NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name()); ReparentContainer container(instance.instanceId(),
-1,
PropertyName(),
instanceForModelNode(parentProperty.parentModelNode()).instanceId(),
parentProperty.name().toByteArray());
reparentContainerList.append(container); reparentContainerList.append(container);
} }
} }
@@ -1167,7 +1175,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
const QString expression = fullyQualifyPropertyIfApplies(property); const QString expression = fullyQualifyPropertyIfApplies(property);
PropertyBindingContainer container(instance.instanceId(), PropertyBindingContainer container(instance.instanceId(),
property.name(), property.name().toByteArray(),
expression, expression,
property.dynamicTypeName()); property.dynamicTypeName());
bindingContainerList.append(container); bindingContainerList.append(container);
@@ -1312,7 +1320,11 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
for (const NodeInstance &instance : instanceList) { for (const NodeInstance &instance : instanceList) {
if (instance.modelNode().hasParentProperty()) { if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty(); NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name()); ReparentContainer container(instance.instanceId(),
-1,
PropertyName(),
instanceForModelNode(parentProperty.parentModelNode()).instanceId(),
parentProperty.name().toByteArray());
containerList.append(container); containerList.append(container);
} }
} }
@@ -1334,8 +1346,11 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
if (oldPropertyParent.isValid() && hasInstanceForModelNode(oldPropertyParent.parentModelNode())) if (oldPropertyParent.isValid() && hasInstanceForModelNode(oldPropertyParent.parentModelNode()))
oldParentInstanceId = instanceForModelNode(oldPropertyParent.parentModelNode()).instanceId(); oldParentInstanceId = instanceForModelNode(oldPropertyParent.parentModelNode()).instanceId();
ReparentContainer container(instanceForModelNode(node).instanceId(),
ReparentContainer container(instanceForModelNode(node).instanceId(), oldParentInstanceId, oldPropertyParent.name(), newParentInstanceId, newPropertyParent.name()); oldParentInstanceId,
oldPropertyParent.name().toByteArray(),
newParentInstanceId,
newPropertyParent.name().toByteArray());
containerList.append(container); containerList.append(container);
@@ -1380,7 +1395,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList<B
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
const QString expression = fullyQualifyPropertyIfApplies(property); const QString expression = fullyQualifyPropertyIfApplies(property);
PropertyBindingContainer container(instance.instanceId(), PropertyBindingContainer container(instance.instanceId(),
property.name(), property.name().toByteArray(),
expression, expression,
property.dynamicTypeName()); property.dynamicTypeName());
containerList.append(container); containerList.append(container);
@@ -1455,7 +1470,9 @@ RemovePropertiesCommand NodeInstanceView::createRemovePropertiesCommand(const QL
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForModelNode(node)) { if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyAbstractContainer container(instance.instanceId(), property.name(), property.dynamicTypeName()); PropertyAbstractContainer container(instance.instanceId(),
property.name().toByteArray(),
property.dynamicTypeName());
containerList.append(container); containerList.append(container);
} }
@@ -2307,7 +2324,8 @@ void NodeInstanceView::updateRotationBlocks()
} }
} }
void NodeInstanceView::maybeResetOnPropertyChange(const PropertyName &name, const ModelNode &node, void NodeInstanceView::maybeResetOnPropertyChange(PropertyNameView name,
const ModelNode &node,
PropertyChangeFlags flags) PropertyChangeFlags flags)
{ {
bool reset = false; bool reset = false;

View File

@@ -1950,7 +1950,7 @@ PropertyMetaInfos NodeMetaInfo::localProperties() const
} }
} }
PropertyMetaInfo NodeMetaInfo::property(const PropertyName &propertyName) const PropertyMetaInfo NodeMetaInfo::property(PropertyNameView propertyName) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -4287,10 +4287,10 @@ PropertyMetaInfo &PropertyMetaInfo::operator=(PropertyMetaInfo &&) = default;
PropertyMetaInfo::PropertyMetaInfo( PropertyMetaInfo::PropertyMetaInfo(
[[maybe_unused]] std::shared_ptr<NodeMetaInfoPrivate> nodeMetaInfoPrivateData, [[maybe_unused]] std::shared_ptr<NodeMetaInfoPrivate> nodeMetaInfoPrivateData,
[[maybe_unused]] const PropertyName &propertyName) [[maybe_unused]] PropertyNameView propertyName)
#ifndef QDS_USE_PROJECTSTORAGE #ifndef QDS_USE_PROJECTSTORAGE
: m_nodeMetaInfoPrivateData{nodeMetaInfoPrivateData} : m_nodeMetaInfoPrivateData{nodeMetaInfoPrivateData}
, m_propertyName{propertyName} , m_propertyName{propertyName.toByteArray()}
#endif #endif
{} {}

View File

@@ -15,6 +15,8 @@
#include <QTextStream> #include <QTextStream>
#include <qmlobjectnode.h> #include <qmlobjectnode.h>
#include <QByteArrayView>
namespace QmlDesigner { namespace QmlDesigner {
/*! /*!
@@ -23,20 +25,25 @@ namespace QmlDesigner {
\brief The AbstractProperty class is a value holder for a property. \brief The AbstractProperty class is a value holder for a property.
*/ */
AbstractProperty::AbstractProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view) AbstractProperty::AbstractProperty(PropertyNameView propertyName,
: m_propertyName(propertyName), const Internal::InternalNodePointer &internalNode,
m_internalNode(internalNode), Model *model,
m_model(model), AbstractView *view)
m_view(view) : m_propertyName(propertyName)
, m_internalNode(internalNode)
, m_model(model)
, m_view(view)
{ {
Q_ASSERT_X(!m_propertyName.contains(' '), Q_FUNC_INFO, "a property name cannot contain a space"); Q_ASSERT_X(!m_propertyName.contains(' '), Q_FUNC_INFO, "a property name cannot contain a space");
} }
AbstractProperty::AbstractProperty(const Internal::InternalPropertyPointer &property, Model* model, AbstractView *view) AbstractProperty::AbstractProperty(const Internal::InternalPropertyPointer &property,
: m_propertyName(property->name()), Model *model,
m_internalNode(property->propertyOwner()), AbstractView *view)
m_model(model), : m_propertyName(property->name())
m_view(view) , m_internalNode(property->propertyOwner())
, m_model(model)
, m_view(view)
{ {
} }
@@ -66,17 +73,7 @@ AbstractView *AbstractProperty::view() const
return m_view.data(); return m_view.data();
} }
/*! /*!
Holds a value for a property. Returns the value of the property.
The QVariant is null if the property does not exist.
*/
const PropertyName &AbstractProperty::name() const
{
return m_propertyName;
}
/*!
Checks if the property is valid. Checks if the property is valid.
A property is valid if the belonging model node A property is valid if the belonging model node
@@ -319,12 +316,13 @@ TypeName AbstractProperty::dynamicTypeName() const
QDebug operator<<(QDebug debug, const AbstractProperty &property) QDebug operator<<(QDebug debug, const AbstractProperty &property)
{ {
return debug.nospace() << "AbstractProperty(" return debug.nospace() << "AbstractProperty("
<< (property.isValid() ? property.name() : PropertyName("invalid")) << ')'; << (property.isValid() ? property.name() : PropertyNameView("invalid"))
<< ')';
} }
QTextStream &operator<<(QTextStream &stream, const AbstractProperty &property) QTextStream &operator<<(QTextStream &stream, const AbstractProperty &property)
{ {
stream << "AbstractProperty(" << property.name() << ')'; stream << "AbstractProperty(" << property.name().toByteArray() << ')';
return stream; return stream;
} }

View File

@@ -25,15 +25,7 @@ BindingProperty::BindingProperty() = default;
BindingProperty::BindingProperty(const BindingProperty &property, AbstractView *view) BindingProperty::BindingProperty(const BindingProperty &property, AbstractView *view)
: AbstractProperty(property.name(), property.internalNodeSharedPointer(), property.model(), view) : AbstractProperty(property.name(), property.internalNodeSharedPointer(), property.model(), view)
{ {}
}
BindingProperty::BindingProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{
}
void BindingProperty::setExpression(const QString &expression) void BindingProperty::setExpression(const QString &expression)
{ {
@@ -361,7 +353,7 @@ void BindingProperty::setDynamicTypeNameAndExpression(const TypeName &typeName,
QDebug operator<<(QDebug debug, const BindingProperty &property) QDebug operator<<(QDebug debug, const BindingProperty &property)
{ {
if (!property.isValid()) if (!property.isValid())
return debug.nospace() << "BindingProperty(" << PropertyName("invalid") << ')'; return debug.nospace() << "BindingProperty(" << "invalid" << ')';
else else
return debug.nospace() << "BindingProperty(" << property.name() << " " << property.expression() << ')'; return debug.nospace() << "BindingProperty(" << property.name() << " " << property.expression() << ')';
} }
@@ -369,9 +361,10 @@ QDebug operator<<(QDebug debug, const BindingProperty &property)
QTextStream& operator<<(QTextStream &stream, const BindingProperty &property) QTextStream& operator<<(QTextStream &stream, const BindingProperty &property)
{ {
if (!property.isValid()) if (!property.isValid())
stream << "BindingProperty(" << PropertyName("invalid") << ')'; stream << "BindingProperty(" << "invalid" << ')';
else else
stream << "BindingProperty(" << property.name() << " " << property.expression() << ')'; stream << "BindingProperty(" << property.name().toByteArray() << " "
<< property.expression() << ')';
return stream; return stream;
} }

View File

@@ -6,7 +6,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalBindingProperty::InternalBindingProperty(const PropertyName &name, InternalBindingProperty::InternalBindingProperty(PropertyNameView name,
const InternalNodePointer &propertyOwner) const InternalNodePointer &propertyOwner)
: InternalProperty(name, propertyOwner, PropertyType::Binding) : InternalProperty(name, propertyOwner, PropertyType::Binding)
{ {

View File

@@ -14,7 +14,7 @@ public:
using Pointer = std::shared_ptr<InternalBindingProperty>; using Pointer = std::shared_ptr<InternalBindingProperty>;
static constexpr PropertyType type = PropertyType::Binding; static constexpr PropertyType type = PropertyType::Binding;
InternalBindingProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); InternalBindingProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
bool isValid() const override; bool isValid() const override;

View File

@@ -129,8 +129,17 @@ AuxiliaryDatasForType InternalNode::auxiliaryData(AuxiliaryDataType type) const
PropertyNameList InternalNode::propertyNameList() const PropertyNameList InternalNode::propertyNameList() const
{ {
return Utils::transform<PropertyNameList>(m_nameProperties, return Utils::transform<PropertyNameList>(m_nameProperties, [](const auto &entry) {
[](const auto &entry) { return entry.first; }); return entry.first.toQByteArray();
});
}
PropertyNameViews InternalNode::propertyNameViews() const
{
return Utils::transform<PropertyNameViews>(m_nameProperties,
[](const auto &entry) -> PropertyNameView {
return entry.first;
});
} }
QList<InternalNode::Pointer> InternalNode::allSubNodes() const QList<InternalNode::Pointer> InternalNode::allSubNodes() const

View File

@@ -144,7 +144,7 @@ public:
auto nodeProperty(PropertyNameView name) const { return property<InternalNodeProperty>(name); } auto nodeProperty(PropertyNameView name) const { return property<InternalNodeProperty>(name); }
template<typename Type> template<typename Type>
Type *addProperty(const PropertyName &name) Type *addProperty(PropertyNameView name)
{ {
auto newProperty = std::make_shared<Type>(name, shared_from_this()); auto newProperty = std::make_shared<Type>(name, shared_from_this());
auto pointer = newProperty.get(); auto pointer = newProperty.get();
@@ -153,32 +153,32 @@ public:
return pointer; return pointer;
} }
auto addBindingProperty(const PropertyName &name) auto addBindingProperty(PropertyNameView name)
{ {
return addProperty<InternalBindingProperty>(name); return addProperty<InternalBindingProperty>(name);
} }
auto addSignalHandlerProperty(const PropertyName &name) auto addSignalHandlerProperty(PropertyNameView name)
{ {
return addProperty<InternalSignalHandlerProperty>(name); return addProperty<InternalSignalHandlerProperty>(name);
} }
auto addSignalDeclarationProperty(const PropertyName &name) auto addSignalDeclarationProperty(PropertyNameView name)
{ {
return addProperty<InternalSignalDeclarationProperty>(name); return addProperty<InternalSignalDeclarationProperty>(name);
} }
auto addNodeListProperty(const PropertyName &name) auto addNodeListProperty(PropertyNameView name)
{ {
return addProperty<InternalNodeListProperty>(name); return addProperty<InternalNodeListProperty>(name);
} }
auto addVariantProperty(const PropertyName &name) auto addVariantProperty(PropertyNameView name)
{ {
return addProperty<InternalVariantProperty>(name); return addProperty<InternalVariantProperty>(name);
} }
auto addNodeProperty(const PropertyName &name, const TypeName &dynamicTypeName) auto addNodeProperty(PropertyNameView name, const TypeName &dynamicTypeName)
{ {
auto property = addProperty<InternalNodeProperty>(name); auto property = addProperty<InternalNodeProperty>(name);
property->setDynamicTypeName(dynamicTypeName); property->setDynamicTypeName(dynamicTypeName);
@@ -187,6 +187,9 @@ public:
} }
PropertyNameList propertyNameList() const; PropertyNameList propertyNameList() const;
PropertyNameViews propertyNameViews() const;
bool hasProperties() const { return m_nameProperties.size(); }
QList<InternalNode::Pointer> allSubNodes() const; QList<InternalNode::Pointer> allSubNodes() const;
QList<InternalNode::Pointer> allDirectSubNodes() const; QList<InternalNode::Pointer> allDirectSubNodes() const;
@@ -215,7 +218,7 @@ public:
m_nameProperties.erase(found); // C++ 23 -> m_nameProperties.erase(name) m_nameProperties.erase(found); // C++ 23 -> m_nameProperties.erase(name)
} }
using PropertyDict = std::map<PropertyName, InternalPropertyPointer, std::less<>>; using PropertyDict = std::map<Utils::SmallString, InternalPropertyPointer, std::less<>>;
PropertyDict::const_iterator begin() const { return m_nameProperties.begin(); } PropertyDict::const_iterator begin() const { return m_nameProperties.begin(); }

View File

@@ -7,7 +7,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalNodeAbstractProperty::InternalNodeAbstractProperty(const PropertyName &name, InternalNodeAbstractProperty::InternalNodeAbstractProperty(PropertyNameView name,
const InternalNode::Pointer &propertyOwner, const InternalNode::Pointer &propertyOwner,
PropertyType propertyType) PropertyType propertyType)
: InternalProperty(name, propertyOwner, propertyType) : InternalProperty(name, propertyOwner, propertyType)

View File

@@ -24,7 +24,7 @@ public:
bool isValid() const override; bool isValid() const override;
protected: protected:
InternalNodeAbstractProperty(const PropertyName &name, InternalNodeAbstractProperty(PropertyNameView name,
const InternalNodePointer &propertyOwner, const InternalNodePointer &propertyOwner,
PropertyType propertyType); PropertyType propertyType);
virtual void remove(const InternalNodePointer &node) = 0; virtual void remove(const InternalNodePointer &node) = 0;

View File

@@ -8,7 +8,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalNodeListProperty::InternalNodeListProperty(const PropertyName &name, InternalNodeListProperty::InternalNodeListProperty(PropertyNameView name,
const InternalNodePointer &propertyOwner) const InternalNodePointer &propertyOwner)
: InternalNodeAbstractProperty(name, propertyOwner, PropertyType::NodeList) : InternalNodeAbstractProperty(name, propertyOwner, PropertyType::NodeList)
{ {

View File

@@ -17,7 +17,7 @@ public:
using Pointer = std::shared_ptr<InternalNodeListProperty>; using Pointer = std::shared_ptr<InternalNodeListProperty>;
static constexpr PropertyType type = PropertyType::NodeList; static constexpr PropertyType type = PropertyType::NodeList;
InternalNodeListProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); InternalNodeListProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
bool isValid() const override; bool isValid() const override;

View File

@@ -7,7 +7,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalNodeProperty::InternalNodeProperty(const PropertyName &name, InternalNodeProperty::InternalNodeProperty(PropertyNameView name,
const InternalNode::Pointer &propertyOwner) const InternalNode::Pointer &propertyOwner)
: InternalNodeAbstractProperty(name, propertyOwner, PropertyType::Node) : InternalNodeAbstractProperty(name, propertyOwner, PropertyType::Node)
{ {

View File

@@ -14,7 +14,7 @@ public:
using Pointer = std::shared_ptr<InternalNodeProperty>; using Pointer = std::shared_ptr<InternalNodeProperty>;
static constexpr PropertyType type = PropertyType::Node; static constexpr PropertyType type = PropertyType::Node;
InternalNodeProperty(const PropertyName &name, const InternalNodePointer &node); InternalNodeProperty(PropertyNameView name, const InternalNodePointer &node);
bool isValid() const override; bool isValid() const override;
bool isEmpty() const override; bool isEmpty() const override;

View File

@@ -41,7 +41,7 @@ namespace Internal {
InternalProperty::~InternalProperty() = default; InternalProperty::~InternalProperty() = default;
InternalProperty::InternalProperty(const PropertyName &name, InternalProperty::InternalProperty(PropertyNameView name,
const InternalNode::Pointer &propertyOwner, const InternalNode::Pointer &propertyOwner,
PropertyType propertyType) PropertyType propertyType)
: m_name(name) : m_name(name)
@@ -57,7 +57,7 @@ bool InternalProperty::isValid() const
return !m_propertyOwner.expired() && !m_name.isEmpty(); return !m_propertyOwner.expired() && !m_name.isEmpty();
} }
PropertyName InternalProperty::name() const PropertyNameView InternalProperty::name() const
{ {
return m_name; return m_name;
} }

View File

@@ -103,7 +103,7 @@ public:
virtual bool isValid() const; virtual bool isValid() const;
PropertyName name() const; PropertyNameView name() const;
bool isBindingProperty() const { return m_propertyType == PropertyType::Binding; } bool isBindingProperty() const { return m_propertyType == PropertyType::Binding; }
bool isVariantProperty() const { return m_propertyType == PropertyType::Variant; } bool isVariantProperty() const { return m_propertyType == PropertyType::Variant; }
@@ -182,14 +182,14 @@ public:
PropertyType type() const { return m_propertyType; } PropertyType type() const { return m_propertyType; }
protected: // functions protected: // functions
InternalProperty(const PropertyName &name, InternalProperty(PropertyNameView name,
const InternalNodePointer &propertyOwner, const InternalNodePointer &propertyOwner,
PropertyType propertyType); PropertyType propertyType);
void setDynamicTypeName(const TypeName &name); void setDynamicTypeName(const TypeName &name);
private: private:
PropertyName m_name; Utils::SmallString m_name;
TypeName m_dynamicType; TypeName m_dynamicType;
std::weak_ptr<InternalNode> m_propertyOwner; std::weak_ptr<InternalNode> m_propertyOwner;
PropertyType m_propertyType = PropertyType::None; PropertyType m_propertyType = PropertyType::None;

View File

@@ -6,7 +6,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalSignalHandlerProperty::InternalSignalHandlerProperty(const PropertyName &name, InternalSignalHandlerProperty::InternalSignalHandlerProperty(PropertyNameView name,
const InternalNodePointer &propertyOwner) const InternalNodePointer &propertyOwner)
: InternalProperty(name, propertyOwner, PropertyType::SignalHandler) : InternalProperty(name, propertyOwner, PropertyType::SignalHandler)
{ {
@@ -46,7 +46,7 @@ void InternalSignalDeclarationProperty::setSignature(const QString &signature)
} }
InternalSignalDeclarationProperty::InternalSignalDeclarationProperty( InternalSignalDeclarationProperty::InternalSignalDeclarationProperty(
const PropertyName &name, const InternalNodePointer &propertyOwner) PropertyNameView name, const InternalNodePointer &propertyOwner)
: InternalProperty(name, propertyOwner, PropertyType::SignalDeclaration) : InternalProperty(name, propertyOwner, PropertyType::SignalDeclaration)
{ {
setDynamicTypeName("signal"); setDynamicTypeName("signal");

View File

@@ -14,7 +14,7 @@ public:
using Pointer = std::shared_ptr<InternalSignalHandlerProperty>; using Pointer = std::shared_ptr<InternalSignalHandlerProperty>;
static constexpr PropertyType type = PropertyType::SignalHandler; static constexpr PropertyType type = PropertyType::SignalHandler;
InternalSignalHandlerProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); InternalSignalHandlerProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
bool isValid() const override; bool isValid() const override;
@@ -31,8 +31,7 @@ public:
using Pointer = std::shared_ptr<InternalSignalDeclarationProperty>; using Pointer = std::shared_ptr<InternalSignalDeclarationProperty>;
static constexpr PropertyType type = PropertyType::SignalDeclaration; static constexpr PropertyType type = PropertyType::SignalDeclaration;
InternalSignalDeclarationProperty(const PropertyName &name, InternalSignalDeclarationProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
const InternalNodePointer &propertyOwner);
bool isValid() const override; bool isValid() const override;

View File

@@ -6,8 +6,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
InternalVariantProperty::InternalVariantProperty(const PropertyName &name, InternalVariantProperty::InternalVariantProperty(PropertyNameView name, const InternalNodePointer &node)
const InternalNodePointer &node)
: InternalProperty(name, node, PropertyType::Variant) : InternalProperty(name, node, PropertyType::Variant)
{ {
} }

View File

@@ -14,7 +14,7 @@ public:
using Pointer = std::shared_ptr<InternalVariantProperty>; using Pointer = std::shared_ptr<InternalVariantProperty>;
static constexpr PropertyType type = PropertyType::Variant; static constexpr PropertyType type = PropertyType::Variant;
InternalVariantProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); InternalVariantProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
bool isValid() const override; bool isValid() const override;

View File

@@ -347,9 +347,9 @@ InternalNodePointer ModelPrivate::createNode(TypeNameView typeName,
notifyNodeCreated(newNode); notifyNodeCreated(newNode);
if (!newNode->propertyNameList().isEmpty()) if (newNode->hasProperties())
notifyVariantPropertiesChanged(newNode, notifyVariantPropertiesChanged(newNode,
newNode->propertyNameList(), newNode->propertyNameViews(),
AbstractView::PropertiesAdded); AbstractView::PropertiesAdded);
return newNode; return newNode;
@@ -473,7 +473,7 @@ void ModelPrivate::removeNode(const InternalNodePointer &node)
removeNodeFromModel(node); removeNodeFromModel(node);
InternalNodePointer parentNode; InternalNodePointer parentNode;
PropertyName parentPropertyName; PropertyNameView parentPropertyName;
if (oldParentProperty) { if (oldParentProperty) {
parentNode = oldParentProperty->propertyOwner(); parentNode = oldParentProperty->propertyOwner();
parentPropertyName = oldParentProperty->name(); parentPropertyName = oldParentProperty->name();
@@ -923,7 +923,7 @@ void ModelPrivate::notifyNodeAboutToBeRemoved(const InternalNodePointer &interna
void ModelPrivate::notifyNodeRemoved(const InternalNodePointer &removedNode, void ModelPrivate::notifyNodeRemoved(const InternalNodePointer &removedNode,
const InternalNodePointer &parentNode, const InternalNodePointer &parentNode,
const PropertyName &parentPropertyName, PropertyNameView parentPropertyName,
AbstractView::PropertyChangeFlags propertyChange) AbstractView::PropertyChangeFlags propertyChange)
{ {
notifyNormalViewsLast([&](AbstractView *view) { notifyNormalViewsLast([&](AbstractView *view) {
@@ -1026,12 +1026,12 @@ void ModelPrivate::notifyScriptFunctionsChanged(const InternalNodePointer &node,
} }
void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &node, void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &node,
const PropertyNameList &propertyNameList, const PropertyNameViews &propertyNameViews,
AbstractView::PropertyChangeFlags propertyChange) AbstractView::PropertyChangeFlags propertyChange)
{ {
notifyNodeInstanceViewLast([&](AbstractView *view) { notifyNodeInstanceViewLast([&](AbstractView *view) {
QList<VariantProperty> propertyList; QList<VariantProperty> propertyList;
for (const PropertyName &propertyName : propertyNameList) { for (PropertyNameView propertyName : propertyNameViews) {
VariantProperty property(propertyName, node, m_model, view); VariantProperty property(propertyName, node, m_model, view);
propertyList.append(property); propertyList.append(property);
} }
@@ -1042,9 +1042,9 @@ void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &nod
void ModelPrivate::notifyNodeAboutToBeReparent(const InternalNodePointer &node, void ModelPrivate::notifyNodeAboutToBeReparent(const InternalNodePointer &node,
const InternalNodePointer &newParent, const InternalNodePointer &newParent,
const PropertyName &newPropertyName, PropertyNameView newPropertyName,
const InternalNodePointer &oldParent, const InternalNodePointer &oldParent,
const PropertyName &oldPropertyName, PropertyNameView oldPropertyName,
AbstractView::PropertyChangeFlags propertyChange) AbstractView::PropertyChangeFlags propertyChange)
{ {
notifyNodeInstanceViewLast([&](AbstractView *view) { notifyNodeInstanceViewLast([&](AbstractView *view) {
@@ -1069,7 +1069,7 @@ void ModelPrivate::notifyNodeAboutToBeReparent(const InternalNodePointer &node,
void ModelPrivate::notifyNodeReparent(const InternalNodePointer &node, void ModelPrivate::notifyNodeReparent(const InternalNodePointer &node,
const InternalNodeAbstractProperty *newPropertyParent, const InternalNodeAbstractProperty *newPropertyParent,
const InternalNodePointer &oldParent, const InternalNodePointer &oldParent,
const PropertyName &oldPropertyName, PropertyNameView oldPropertyName,
AbstractView::PropertyChangeFlags propertyChange) AbstractView::PropertyChangeFlags propertyChange)
{ {
notifyNodeInstanceViewLast([&](AbstractView *view) { notifyNodeInstanceViewLast([&](AbstractView *view) {
@@ -1348,7 +1348,7 @@ void ModelPrivate::removeProperties(const QList<InternalProperty *> &properties)
} }
void ModelPrivate::setBindingProperty(const InternalNodePointer &node, void ModelPrivate::setBindingProperty(const InternalNodePointer &node,
const PropertyName &name, PropertyNameView name,
const QString &expression) const QString &expression)
{ {
AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges; AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges;
@@ -1381,7 +1381,9 @@ void ModelPrivate::setBindingProperties(const ModelResourceSet::SetExpressions &
notifyBindingPropertiesChanged(bindingProperties, propertyChange); notifyBindingPropertiesChanged(bindingProperties, propertyChange);
} }
void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &node, const PropertyName &name, const QString &source) void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &node,
PropertyNameView name,
const QString &source)
{ {
AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges; AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges;
InternalSignalHandlerProperty *signalHandlerProperty = nullptr; InternalSignalHandlerProperty *signalHandlerProperty = nullptr;
@@ -1396,7 +1398,9 @@ void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &node, con
notifySignalHandlerPropertiesChanged({signalHandlerProperty}, propertyChange); notifySignalHandlerPropertiesChanged({signalHandlerProperty}, propertyChange);
} }
void ModelPrivate::setSignalDeclarationProperty(const InternalNodePointer &node, const PropertyName &name, const QString &signature) void ModelPrivate::setSignalDeclarationProperty(const InternalNodePointer &node,
PropertyNameView name,
const QString &signature)
{ {
AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges; AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges;
InternalSignalDeclarationProperty *signalDeclarationProperty = nullptr; InternalSignalDeclarationProperty *signalDeclarationProperty = nullptr;
@@ -1411,7 +1415,9 @@ void ModelPrivate::setSignalDeclarationProperty(const InternalNodePointer &node,
notifySignalDeclarationPropertiesChanged({signalDeclarationProperty}, propertyChange); notifySignalDeclarationPropertiesChanged({signalDeclarationProperty}, propertyChange);
} }
void ModelPrivate::setVariantProperty(const InternalNodePointer &node, const PropertyName &name, const QVariant &value) void ModelPrivate::setVariantProperty(const InternalNodePointer &node,
PropertyNameView name,
const QVariant &value)
{ {
AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges; AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges;
InternalVariantProperty *variantProperty = nullptr; InternalVariantProperty *variantProperty = nullptr;
@@ -1424,11 +1430,11 @@ void ModelPrivate::setVariantProperty(const InternalNodePointer &node, const Pro
variantProperty->setValue(value); variantProperty->setValue(value);
variantProperty->resetDynamicTypeName(); variantProperty->resetDynamicTypeName();
notifyVariantPropertiesChanged(node, PropertyNameList({name}), propertyChange); notifyVariantPropertiesChanged(node, PropertyNameViews({name}), propertyChange);
} }
void ModelPrivate::setDynamicVariantProperty(const InternalNodePointer &node, void ModelPrivate::setDynamicVariantProperty(const InternalNodePointer &node,
const PropertyName &name, PropertyNameView name,
const TypeName &dynamicPropertyType, const TypeName &dynamicPropertyType,
const QVariant &value) const QVariant &value)
{ {
@@ -1442,11 +1448,11 @@ void ModelPrivate::setDynamicVariantProperty(const InternalNodePointer &node,
} }
variantProperty->setDynamicValue(dynamicPropertyType, value); variantProperty->setDynamicValue(dynamicPropertyType, value);
notifyVariantPropertiesChanged(node, PropertyNameList({name}), propertyChange); notifyVariantPropertiesChanged(node, PropertyNameViews({name}), propertyChange);
} }
void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &node, void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &node,
const PropertyName &name, PropertyNameView name,
const TypeName &dynamicPropertyType, const TypeName &dynamicPropertyType,
const QString &expression) const QString &expression)
{ {
@@ -1465,7 +1471,7 @@ void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &node,
} }
void ModelPrivate::reparentNode(const InternalNodePointer &parentNode, void ModelPrivate::reparentNode(const InternalNodePointer &parentNode,
const PropertyName &name, PropertyNameView name,
const InternalNodePointer &childNode, const InternalNodePointer &childNode,
bool list, bool list,
const TypeName &dynamicTypeName) const TypeName &dynamicTypeName)
@@ -1474,7 +1480,7 @@ void ModelPrivate::reparentNode(const InternalNodePointer &parentNode,
InternalNodeAbstractPropertyPointer oldParentProperty(childNode->parentProperty()); InternalNodeAbstractPropertyPointer oldParentProperty(childNode->parentProperty());
InternalNodePointer oldParentNode; InternalNodePointer oldParentNode;
PropertyName oldParentPropertyName; Utils::SmallString oldParentPropertyName;
if (oldParentProperty && oldParentProperty->isValid()) { if (oldParentProperty && oldParentProperty->isValid()) {
oldParentNode = childNode->parentProperty()->propertyOwner(); oldParentNode = childNode->parentProperty()->propertyOwner();
oldParentPropertyName = childNode->parentProperty()->name(); oldParentPropertyName = childNode->parentProperty()->name();
@@ -1519,7 +1525,7 @@ void ModelPrivate::clearParent(const InternalNodePointer &node)
{ {
InternalNodeAbstractPropertyPointer oldParentProperty(node->parentProperty()); InternalNodeAbstractPropertyPointer oldParentProperty(node->parentProperty());
InternalNodePointer oldParentNode; InternalNodePointer oldParentNode;
PropertyName oldParentPropertyName; Utils::SmallString oldParentPropertyName;
if (oldParentProperty->isValid()) { if (oldParentProperty->isValid()) {
oldParentNode = node->parentProperty()->propertyOwner(); oldParentNode = node->parentProperty()->propertyOwner();
oldParentPropertyName = node->parentProperty()->name(); oldParentPropertyName = node->parentProperty()->name();
@@ -1563,7 +1569,10 @@ void ModelPrivate::setNodeSource(const InternalNodePointer &node, const QString
notifyNodeSourceChanged(node, nodeSource); notifyNodeSourceChanged(node, nodeSource);
} }
void ModelPrivate::changeNodeOrder(const InternalNodePointer &parentNode, const PropertyName &listPropertyName, int from, int to) void ModelPrivate::changeNodeOrder(const InternalNodePointer &parentNode,
PropertyNameView listPropertyName,
int from,
int to)
{ {
auto nodeList = parentNode->nodeListProperty(listPropertyName); auto nodeList = parentNode->nodeListProperty(listPropertyName);
Q_ASSERT(nodeList); Q_ASSERT(nodeList);

View File

@@ -50,7 +50,7 @@ class InternalVariantProperty;
class InternalNodeAbstractProperty; class InternalNodeAbstractProperty;
class InternalNodeListProperty; class InternalNodeListProperty;
using PropertyPair = QPair<InternalNodePointer, PropertyName>; using PropertyPair = std::pair<InternalNodePointer, Utils::SmallString>;
class ModelPrivate; class ModelPrivate;
@@ -162,19 +162,19 @@ public:
void notifyNodeCreated(const InternalNodePointer &newNode); void notifyNodeCreated(const InternalNodePointer &newNode);
void notifyNodeAboutToBeReparent(const InternalNodePointer &node, void notifyNodeAboutToBeReparent(const InternalNodePointer &node,
const InternalNodePointer &newParent, const InternalNodePointer &newParent,
const PropertyName &newPropertyName, PropertyNameView newPropertyName,
const InternalNodePointer &oldParent, const InternalNodePointer &oldParent,
const PropertyName &oldPropertyName, PropertyNameView oldPropertyName,
AbstractView::PropertyChangeFlags propertyChange); AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeReparent(const InternalNodePointer &node, void notifyNodeReparent(const InternalNodePointer &node,
const InternalNodeAbstractProperty *newPropertyParent, const InternalNodeAbstractProperty *newPropertyParent,
const InternalNodePointer &oldParent, const InternalNodePointer &oldParent,
const PropertyName &oldPropertyName, PropertyNameView oldPropertyName,
AbstractView::PropertyChangeFlags propertyChange); AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeAboutToBeRemoved(const InternalNodePointer &node); void notifyNodeAboutToBeRemoved(const InternalNodePointer &node);
void notifyNodeRemoved(const InternalNodePointer &removedNode, void notifyNodeRemoved(const InternalNodePointer &removedNode,
const InternalNodePointer &parentNode, const InternalNodePointer &parentNode,
const PropertyName &parentPropertyName, PropertyNameView parentPropertyName,
AbstractView::PropertyChangeFlags propertyChange); AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeIdChanged(const InternalNodePointer &node, const QString &newId, const QString &oldId); void notifyNodeIdChanged(const InternalNodePointer &node, const QString &newId, const QString &oldId);
void notifyNodeTypeChanged(const InternalNodePointer &node, const TypeName &type, int majorVersion, int minorVersion); void notifyNodeTypeChanged(const InternalNodePointer &node, const TypeName &type, int majorVersion, int minorVersion);
@@ -192,7 +192,9 @@ public:
void notifySignalDeclarationPropertiesChanged( void notifySignalDeclarationPropertiesChanged(
const QVector<QmlDesigner::Internal::InternalSignalDeclarationProperty *> &propertyList, const QVector<QmlDesigner::Internal::InternalSignalDeclarationProperty *> &propertyList,
AbstractView::PropertyChangeFlags propertyChange); AbstractView::PropertyChangeFlags propertyChange);
void notifyVariantPropertiesChanged(const InternalNodePointer &node, const PropertyNameList &propertyNameList, AbstractView::PropertyChangeFlags propertyChange); void notifyVariantPropertiesChanged(const InternalNodePointer &node,
const PropertyNameViews &propertyNameList,
AbstractView::PropertyChangeFlags propertyChange);
void notifyScriptFunctionsChanged(const InternalNodePointer &node, const QStringList &scriptFunctionList); void notifyScriptFunctionsChanged(const InternalNodePointer &node, const QStringList &scriptFunctionList);
void notifyNodeOrderChanged(const QmlDesigner::Internal::InternalNodeListProperty *internalListProperty, void notifyNodeOrderChanged(const QmlDesigner::Internal::InternalNodeListProperty *internalListProperty,
@@ -260,24 +262,42 @@ public:
void notifyUsedImportsChanged(const Imports &usedImportsChanged); void notifyUsedImportsChanged(const Imports &usedImportsChanged);
//node state property manipulation //node state property manipulation
void addProperty(const InternalNodePointer &node, const PropertyName &name); void addProperty(const InternalNodePointer &node, PropertyNameView name);
void setPropertyValue(const InternalNodePointer &node,const PropertyName &name, const QVariant &value); void setPropertyValue(const InternalNodePointer &node, PropertyNameView name, const QVariant &value);
void removePropertyAndRelatedResources(InternalProperty *property); void removePropertyAndRelatedResources(InternalProperty *property);
void removeProperty(InternalProperty *property); void removeProperty(InternalProperty *property);
void removeProperties(const QList<InternalProperty *> &properties); void removeProperties(const QList<InternalProperty *> &properties);
void setBindingProperty(const InternalNodePointer &node, void setBindingProperty(const InternalNodePointer &node,
const PropertyName &name, PropertyNameView name,
const QString &expression); const QString &expression);
void setBindingProperties(const ModelResourceSet::SetExpressions &setExpressions); void setBindingProperties(const ModelResourceSet::SetExpressions &setExpressions);
void setSignalHandlerProperty(const InternalNodePointer &node, const PropertyName &name, const QString &source); void setSignalHandlerProperty(const InternalNodePointer &node,
void setSignalDeclarationProperty(const InternalNodePointer &node, const PropertyName &name, const QString &signature); PropertyNameView name,
void setVariantProperty(const InternalNodePointer &node, const PropertyName &name, const QVariant &value); const QString &source);
void setDynamicVariantProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &propertyType, const QVariant &value); void setSignalDeclarationProperty(const InternalNodePointer &node,
void setDynamicBindingProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression); PropertyNameView name,
void reparentNode(const InternalNodePointer &parentNode, const PropertyName &name, const InternalNodePointer &childNode, const QString &signature);
bool list = true, const TypeName &dynamicTypeName = TypeName()); void setVariantProperty(const InternalNodePointer &node,
void changeNodeOrder(const InternalNodePointer &parentNode, const PropertyName &listPropertyName, int from, int to); PropertyNameView name,
const QVariant &value);
void setDynamicVariantProperty(const InternalNodePointer &node,
PropertyNameView name,
const TypeName &propertyType,
const QVariant &value);
void setDynamicBindingProperty(const InternalNodePointer &node,
PropertyNameView name,
const TypeName &dynamicPropertyType,
const QString &expression);
void reparentNode(const InternalNodePointer &parentNode,
PropertyNameView name,
const InternalNodePointer &childNode,
bool list = true,
const TypeName &dynamicTypeName = TypeName());
void changeNodeOrder(const InternalNodePointer &parentNode,
PropertyNameView listPropertyName,
int from,
int to);
static bool propertyNameIsValid(PropertyNameView propertyName); static bool propertyNameIsValid(PropertyNameView propertyName);
void clearParent(const InternalNodePointer &node); void clearParent(const InternalNodePointer &node);
void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion); void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion);

View File

@@ -338,7 +338,7 @@ bool ModelNode::hasParentProperty() const
\return BindingProperty named name \return BindingProperty named name
*/ */
BindingProperty ModelNode::bindingProperty(const PropertyName &name) const BindingProperty ModelNode::bindingProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -346,7 +346,7 @@ BindingProperty ModelNode::bindingProperty(const PropertyName &name) const
return BindingProperty(name, m_internalNode, model(), view()); return BindingProperty(name, m_internalNode, model(), view());
} }
SignalHandlerProperty ModelNode::signalHandlerProperty(const PropertyName &name) const SignalHandlerProperty ModelNode::signalHandlerProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -354,7 +354,7 @@ SignalHandlerProperty ModelNode::signalHandlerProperty(const PropertyName &name)
return SignalHandlerProperty(name, m_internalNode, model(), view()); return SignalHandlerProperty(name, m_internalNode, model(), view());
} }
SignalDeclarationProperty ModelNode::signalDeclarationProperty(const PropertyName &name) const SignalDeclarationProperty ModelNode::signalDeclarationProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -372,7 +372,7 @@ SignalDeclarationProperty ModelNode::signalDeclarationProperty(const PropertyNam
\return NodeProperty named name \return NodeProperty named name
*/ */
NodeProperty ModelNode::nodeProperty(const PropertyName &name) const NodeProperty ModelNode::nodeProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -390,7 +390,7 @@ NodeProperty ModelNode::nodeProperty(const PropertyName &name) const
\return NodeListProperty named name \return NodeListProperty named name
*/ */
NodeListProperty ModelNode::nodeListProperty(const PropertyName &name) const NodeListProperty ModelNode::nodeListProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -398,7 +398,7 @@ NodeListProperty ModelNode::nodeListProperty(const PropertyName &name) const
return NodeListProperty(name, m_internalNode, model(), view()); return NodeListProperty(name, m_internalNode, model(), view());
} }
NodeAbstractProperty ModelNode::nodeAbstractProperty(const PropertyName &name) const NodeAbstractProperty ModelNode::nodeAbstractProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -431,7 +431,7 @@ NodeProperty ModelNode::defaultNodeProperty() const
\return VariantProperty named name \return VariantProperty named name
*/ */
VariantProperty ModelNode::variantProperty(const PropertyName &name) const VariantProperty ModelNode::variantProperty(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};
@@ -439,7 +439,7 @@ VariantProperty ModelNode::variantProperty(const PropertyName &name) const
return VariantProperty(name, m_internalNode, model(), view()); return VariantProperty(name, m_internalNode, model(), view());
} }
AbstractProperty ModelNode::property(const PropertyName &name) const AbstractProperty ModelNode::property(PropertyNameView name) const
{ {
if (!isValid()) if (!isValid())
return {}; return {};

View File

@@ -13,6 +13,8 @@
#include <nodemetainfo.h> #include <nodemetainfo.h>
#include <utils/smallstringio.h>
namespace QmlDesigner { namespace QmlDesigner {
NodeAbstractProperty::NodeAbstractProperty() = default; NodeAbstractProperty::NodeAbstractProperty() = default;
@@ -22,11 +24,6 @@ NodeAbstractProperty::NodeAbstractProperty(const NodeAbstractProperty &property,
{ {
} }
NodeAbstractProperty::NodeAbstractProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model *model, AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{
}
NodeAbstractProperty::NodeAbstractProperty(const Internal::InternalNodeAbstractProperty::Pointer &property, Model *model, AbstractView *view) NodeAbstractProperty::NodeAbstractProperty(const Internal::InternalNodeAbstractProperty::Pointer &property, Model *model, AbstractView *view)
: AbstractProperty(property, model, view) : AbstractProperty(property, model, view)
{} {}
@@ -218,12 +215,14 @@ bool operator !=(const NodeAbstractProperty &property1, const NodeAbstractProper
QDebug operator<<(QDebug debug, const NodeAbstractProperty &property) QDebug operator<<(QDebug debug, const NodeAbstractProperty &property)
{ {
return debug.nospace() << "NodeAbstractProperty(" << (property.isValid() ? property.name() : PropertyName("invalid")) << ')'; return debug.nospace() << "NodeAbstractProperty("
<< (property.isValid() ? property.name() : PropertyNameView("invalid"))
<< ')';
} }
QTextStream& operator<<(QTextStream &stream, const NodeAbstractProperty &property) QTextStream& operator<<(QTextStream &stream, const NodeAbstractProperty &property)
{ {
stream << "NodeAbstractProperty(" << property.name() << ')'; stream << "NodeAbstractProperty(" << property.name().toByteArray() << ')';
return stream; return stream;
} }

View File

@@ -23,14 +23,6 @@ Internal::NodeListPropertyIterator::value_type Internal::NodeListPropertyIterato
NodeListProperty::NodeListProperty() = default; NodeListProperty::NodeListProperty() = default;
NodeListProperty::NodeListProperty(const PropertyName &propertyName,
const Internal::InternalNodePointer &internalNode,
Model *model,
AbstractView *view)
: NodeAbstractProperty(propertyName, internalNode, model, view)
{
}
NodeListProperty::NodeListProperty(const Internal::InternalNodeListProperty::Pointer &internalNodeListProperty, Model* model, AbstractView *view) NodeListProperty::NodeListProperty(const Internal::InternalNodeListProperty::Pointer &internalNodeListProperty, Model* model, AbstractView *view)
: NodeAbstractProperty(internalNodeListProperty, model, view) : NodeAbstractProperty(internalNodeListProperty, model, view)
{ {

View File

@@ -10,12 +10,6 @@ namespace QmlDesigner {
NodeProperty::NodeProperty() = default; NodeProperty::NodeProperty() = default;
NodeProperty::NodeProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view)
: NodeAbstractProperty(propertyName, internalNode, model, view)
{
}
void NodeProperty::setModelNode(const ModelNode &modelNode) void NodeProperty::setModelNode(const ModelNode &modelNode)
{ {
if (!isValid()) if (!isValid())

View File

@@ -15,11 +15,6 @@ SignalHandlerProperty::SignalHandlerProperty(const SignalHandlerProperty &proper
{ {
} }
SignalHandlerProperty::SignalHandlerProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{
}
void SignalHandlerProperty::setSource(const QString &source) void SignalHandlerProperty::setSource(const QString &source)
{ {
Internal::WriteLocker locker(model()); Internal::WriteLocker locker(model());
@@ -56,11 +51,11 @@ QString SignalHandlerProperty::source() const
return QString(); return QString();
} }
PropertyName SignalHandlerProperty::prefixAdded(const PropertyName &propertyName) PropertyName SignalHandlerProperty::prefixAdded(PropertyNameView propertyName)
{ {
QString nameAsString = QString::fromUtf8(propertyName); QString nameAsString = QString::fromUtf8(propertyName);
if (nameAsString.startsWith("on")) if (propertyName.startsWith("on"))
return propertyName; return propertyName.toByteArray();
QChar firstChar = nameAsString.at(0).toUpper(); QChar firstChar = nameAsString.at(0).toUpper();
nameAsString[0] = firstChar; nameAsString[0] = firstChar;
@@ -69,11 +64,11 @@ PropertyName SignalHandlerProperty::prefixAdded(const PropertyName &propertyName
return nameAsString.toLatin1(); return nameAsString.toLatin1();
} }
PropertyName SignalHandlerProperty::prefixRemoved(const PropertyName &propertyName) PropertyName SignalHandlerProperty::prefixRemoved(PropertyNameView propertyName)
{ {
QString nameAsString = QString::fromUtf8(propertyName); QString nameAsString = QString::fromUtf8(propertyName);
if (!nameAsString.startsWith("on")) if (!nameAsString.startsWith("on"))
return propertyName; return propertyName.toByteArray();
nameAsString.remove(0, 2); nameAsString.remove(0, 2);
QChar firstChar = nameAsString.at(0).toLower(); QChar firstChar = nameAsString.at(0).toLower();
@@ -89,15 +84,6 @@ SignalDeclarationProperty::SignalDeclarationProperty(const SignalDeclarationProp
: AbstractProperty(property.name(), property.internalNodeSharedPointer(), property.model(), view) : AbstractProperty(property.name(), property.internalNodeSharedPointer(), property.model(), view)
{} {}
SignalDeclarationProperty::SignalDeclarationProperty(
const PropertyName &propertyName,
const Internal::InternalNodePointer &internalNode,
Model *model,
AbstractView *view)
: AbstractProperty(propertyName, internalNode, model, view)
{
}
void SignalDeclarationProperty::setSignature(const QString &signature) void SignalDeclarationProperty::setSignature(const QString &signature)
{ {
Internal::WriteLocker locker(model()); Internal::WriteLocker locker(model());

View File

@@ -7,7 +7,7 @@
#include "model.h" #include "model.h"
#include "model_p.h" #include "model_p.h"
#include <utils/smallstringio.h>
namespace QmlDesigner { namespace QmlDesigner {
@@ -19,11 +19,6 @@ VariantProperty::VariantProperty(const VariantProperty &property, AbstractView *
} }
VariantProperty::VariantProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view) :
AbstractProperty(propertyName, internalNode, model, view)
{
}
void VariantProperty::setValue(const QVariant &value) void VariantProperty::setValue(const QVariant &value)
{ {
if (!isValid()) if (!isValid())
@@ -114,7 +109,9 @@ QDebug operator<<(QDebug debug, const VariantProperty &property)
QTextStream& operator<<(QTextStream &stream, const VariantProperty &property) QTextStream& operator<<(QTextStream &stream, const VariantProperty &property)
{ {
stream << "VariantProperty(" << property.name() << ',' << ' ' << property.value().toString() << ' ' << property.value().typeName() << property.parentModelNode() << ')'; stream << "VariantProperty(" << property.name().toByteArray() << ',' << ' '
<< property.value().toString() << ' ' << property.value().typeName()
<< property.parentModelNode() << ')';
return stream; return stream;
} }

View File

@@ -39,7 +39,7 @@ bool Qml3DNode::isValidVisualRoot(const ModelNode &modelNode)
&& (modelNode.metaInfo().isQtQuick3DNode() || modelNode.metaInfo().isQtQuick3DMaterial()); && (modelNode.metaInfo().isQtQuick3DNode() || modelNode.metaInfo().isQtQuick3DMaterial());
} }
bool Qml3DNode::handleEulerRotation(const PropertyName &name) bool Qml3DNode::handleEulerRotation(PropertyNameView name)
{ {
if (isBlocked(name)) if (isBlocked(name))
return false; return false;
@@ -50,7 +50,7 @@ bool Qml3DNode::handleEulerRotation(const PropertyName &name)
return true; return true;
} }
bool Qml3DNode::isBlocked(const PropertyName &propName) const bool Qml3DNode::isBlocked(PropertyNameView propName) const
{ {
if (modelNode().isValid() && propName.startsWith("eulerRotation")) if (modelNode().isValid() && propName.startsWith("eulerRotation"))
return modelNode().auxiliaryDataWithDefault(rotBlockProperty).toBool(); return modelNode().auxiliaryDataWithDefault(rotBlockProperty).toBool();

View File

@@ -12,20 +12,30 @@ namespace QmlDesigner {
static PropertyName lineTypeToString(AnchorLineType lineType) static PropertyName lineTypeToString(AnchorLineType lineType)
{ {
switch (lineType) { switch (lineType) {
case AnchorLineLeft: return PropertyName("left"); case AnchorLineLeft:
case AnchorLineTop: return PropertyName("top"); return QByteArrayLiteral("left");
case AnchorLineRight: return PropertyName("right"); case AnchorLineTop:
case AnchorLineBottom: return PropertyName("bottom"); return QByteArrayLiteral("top");
case AnchorLineHorizontalCenter: return PropertyName("horizontalCenter"); case AnchorLineRight:
case AnchorLineVerticalCenter: return PropertyName("verticalCenter"); return QByteArrayLiteral("right");
case AnchorLineBaseline: return PropertyName("baseline"); case AnchorLineBottom:
case AnchorLineFill: return PropertyName("fill"); return QByteArrayLiteral("bottom");
case AnchorLineCenter: return PropertyName("centerIn"); case AnchorLineHorizontalCenter:
default: return PropertyName(); return QByteArrayLiteral("horizontalCenter");
case AnchorLineVerticalCenter:
return QByteArrayLiteral("verticalCenter");
case AnchorLineBaseline:
return QByteArrayLiteral("baseline");
case AnchorLineFill:
return QByteArrayLiteral("fill");
case AnchorLineCenter:
return QByteArrayLiteral("centerIn");
default:
return {};
} }
} }
static AnchorLineType propertyNameToLineType(const PropertyName & name) static AnchorLineType propertyNameToLineType(PropertyNameView name)
{ {
if (name == "left") if (name == "left")
return AnchorLineLeft; return AnchorLineLeft;
@@ -49,30 +59,52 @@ static AnchorLineType propertyNameToLineType(const PropertyName & name)
return AnchorLineInvalid; return AnchorLineInvalid;
} }
static PropertyName marginPropertyName(AnchorLineType lineType) static PropertyNameView marginPropertyName(AnchorLineType lineType)
{ {
switch (lineType) { switch (lineType) {
case AnchorLineLeft: return PropertyName("anchors.leftMargin"); case AnchorLineLeft:
case AnchorLineTop: return PropertyName("anchors.topMargin"); return {"anchors.leftMargin"};
case AnchorLineRight: return PropertyName("anchors.rightMargin"); case AnchorLineTop:
case AnchorLineBottom: return PropertyName("anchors.bottomMargin"); return {"anchors.topMargin"};
case AnchorLineHorizontalCenter: return PropertyName("anchors.horizontalCenterOffset"); case AnchorLineRight:
case AnchorLineVerticalCenter: return PropertyName("anchors.verticalCenterOffset"); return {"anchors.rightMargin"};
default: return PropertyName(); case AnchorLineBottom:
return {"anchors.bottomMargin"};
case AnchorLineHorizontalCenter:
return {"anchors.horizontalCenterOffset"};
case AnchorLineVerticalCenter:
return {"anchors.verticalCenterOffset"};
default:
return {};
} }
} }
static PropertyName anchorPropertyName(AnchorLineType lineType) static PropertyNameView anchorPropertyName(AnchorLineType lineType)
{ {
const PropertyName typeString = lineTypeToString(lineType); switch (lineType) {
case AnchorLineLeft:
if (typeString.isEmpty()) return {"anchors.left"};
return PropertyName(); case AnchorLineTop:
else return {"anchors.top"};
return PropertyName("anchors.") + typeString; case AnchorLineRight:
return {"anchors.right"};
case AnchorLineBottom:
return {"anchors.bottom"};
case AnchorLineHorizontalCenter:
return {"anchors.horizontalCenter"};
case AnchorLineVerticalCenter:
return {"anchors.verticalCenter"};
case AnchorLineBaseline:
return {"anchors.baseline"};
case AnchorLineFill:
return {"anchors.fill"};
case AnchorLineCenter:
return {"anchors.centerIn"};
default:
return {};
}
} }
QmlAnchors::QmlAnchors(const QmlItemNode &fxItemNode) : m_qmlItemNode(fxItemNode) QmlAnchors::QmlAnchors(const QmlItemNode &fxItemNode) : m_qmlItemNode(fxItemNode)
{ {
} }
@@ -95,7 +127,7 @@ bool QmlAnchors::modelHasAnchors() const
bool QmlAnchors::modelHasAnchor(AnchorLineType sourceAnchorLineType) const bool QmlAnchors::modelHasAnchor(AnchorLineType sourceAnchorLineType) const
{ {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLineType); const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLineType);
if (sourceAnchorLineType & AnchorLineFill) if (sourceAnchorLineType & AnchorLineFill)
return qmlItemNode().modelNode().hasBindingProperty(propertyName) || qmlItemNode().modelNode().hasBindingProperty("anchors.fill"); return qmlItemNode().modelNode().hasBindingProperty(propertyName) || qmlItemNode().modelNode().hasBindingProperty("anchors.fill");
@@ -117,7 +149,7 @@ AnchorLine QmlAnchors::modelAnchor(AnchorLineType sourceAnchorLineType) const
targetAnchorLinePair.first = lineTypeToString(sourceAnchorLineType); targetAnchorLinePair.first = lineTypeToString(sourceAnchorLineType);
} else { } else {
AbstractProperty binding = qmlItemNode().modelNode().bindingProperty(anchorPropertyName(sourceAnchorLineType)).resolveToProperty(); AbstractProperty binding = qmlItemNode().modelNode().bindingProperty(anchorPropertyName(sourceAnchorLineType)).resolveToProperty();
targetAnchorLinePair.first = binding.name(); targetAnchorLinePair.first = binding.name().toByteArray();
targetAnchorLinePair.second = binding.parentModelNode(); targetAnchorLinePair.second = binding.parentModelNode();
} }
@@ -146,7 +178,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
removeAnchor(sourceAnchorLine); removeAnchor(sourceAnchorLine);
} }
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine);
ModelNode targetModelNode = targetQmlItemNode.modelNode(); ModelNode targetModelNode = targetQmlItemNode.modelNode();
QString targetExpression = targetModelNode.validId(); QString targetExpression = targetModelNode.validId();
if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode()) if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode())
@@ -296,7 +328,7 @@ void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
{ {
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){ qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){
if (qmlItemNode().isInBaseState()) { if (qmlItemNode().isInBaseState()) {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine);
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) { if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
qmlItemNode().modelNode().removeProperty("anchors.fill"); qmlItemNode().modelNode().removeProperty("anchors.fill");
qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression(QLatin1String("parent.top")); qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression(QLatin1String("parent.top"));
@@ -344,7 +376,7 @@ bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const
if (!qmlItemNode().isValid()) if (!qmlItemNode().isValid())
return false; return false;
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine);
if (sourceAnchorLine & AnchorLineFill) if (sourceAnchorLine & AnchorLineFill)
return qmlItemNode().nodeInstance().hasAnchor(propertyName) || qmlItemNode().nodeInstance().hasAnchor("anchors.fill"); return qmlItemNode().nodeInstance().hasAnchor(propertyName) || qmlItemNode().nodeInstance().hasAnchor("anchors.fill");
@@ -418,7 +450,7 @@ double QmlAnchors::instanceAnchorLine(AnchorLineType anchorLine) const
void QmlAnchors::setMargin(AnchorLineType sourceAnchorLineType, double margin) const void QmlAnchors::setMargin(AnchorLineType sourceAnchorLineType, double margin) const
{ {
PropertyName propertyName = marginPropertyName(sourceAnchorLineType); PropertyNameView propertyName = marginPropertyName(sourceAnchorLineType);
qmlItemNode().setVariantProperty(propertyName, qRound(margin)); qmlItemNode().setVariantProperty(propertyName, qRound(margin));
} }
@@ -506,7 +538,7 @@ double QmlAnchors::instanceMargin(AnchorLineType sourceAnchorLineType) const
void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType) void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType)
{ {
if (qmlItemNode().isInBaseState()) { if (qmlItemNode().isInBaseState()) {
PropertyName propertyName = marginPropertyName(sourceAnchorLineType); PropertyNameView propertyName = marginPropertyName(sourceAnchorLineType);
qmlItemNode().modelNode().removeProperty(propertyName); qmlItemNode().modelNode().removeProperty(propertyName);
} }
} }

Some files were not shown because too many files have changed in this diff Show More