From 3e05959468c0c763bb2cf9e6188b323d412bcedc Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 18 Jul 2024 21:52:33 +0200 Subject: [PATCH] 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 --- .../interfaces/nodeinstanceglobal.h | 3 + .../componentcore/designeractionmanager.cpp | 2 +- .../connectioneditor/bindingmodel.cpp | 2 +- .../connectioneditor/bindingmodelitem.cpp | 2 +- .../connectioneditorutils.cpp | 2 +- .../connectioneditor/connectionmodel.cpp | 2 +- .../dynamicpropertiesitem.cpp | 2 +- .../dynamicpropertiesmodel.cpp | 10 +- .../connectioneditor/dynamicpropertiesmodel.h | 6 +- .../connectioneditor/propertytreemodel.cpp | 72 ++++++------ .../components/edit3d/bakelightsdatamodel.cpp | 4 +- .../components/formeditor/formeditoritem.cpp | 6 +- .../components/formeditor/formeditoritem.h | 6 +- .../components/formeditor/formeditorscene.cpp | 2 +- .../components/formeditor/formeditorscene.h | 2 +- .../listmodeleditor/listmodeleditormodel.cpp | 2 +- .../materialbrowser/materialbrowsermodel.cpp | 6 +- .../materialbrowser/materialbrowserview.cpp | 17 ++- .../materialeditorcontextobject.cpp | 8 +- .../materialeditorqmlbackend.cpp | 12 +- .../materialeditor/materialeditorqmlbackend.h | 7 +- .../materialeditor/materialeditorview.cpp | 12 +- .../materialeditor/materialeditorview.h | 8 +- .../dynamicpropertiesproxymodel.cpp | 8 +- .../propertyeditorcontextobject.cpp | 6 +- .../propertyeditorqmlbackend.cpp | 56 ++++++---- .../propertyeditor/propertyeditorqmlbackend.h | 15 +-- .../propertyeditor/propertyeditorvalue.cpp | 27 +++-- .../propertyeditor/propertyeditorvalue.h | 20 ++-- .../propertyeditor/propertyeditorview.cpp | 56 +++++----- .../propertyeditor/propertyeditorview.h | 10 +- .../propertyeditor/propertynamevalidator.cpp | 2 +- .../propertyeditor/qmlmodelnodeproxy.cpp | 2 +- .../propertyeditor/qmlmodelnodeproxy.h | 2 +- .../components/stateseditor/propertymodel.cpp | 2 +- .../textureeditor/textureeditorqmlbackend.cpp | 16 +-- .../textureeditor/textureeditorqmlbackend.h | 7 +- .../textureeditor/textureeditorview.cpp | 57 ++++++---- .../textureeditor/textureeditorview.h | 8 +- .../designercoreutils/modelutils.cpp | 2 +- .../designercoreutils/modelutils.h | 3 +- .../designercoreutils/stylesheetmerger.cpp | 7 +- .../filemanager/addpropertyvisitor.cpp | 18 +-- .../filemanager/addpropertyvisitor.h | 4 +- .../filemanager/moveobjectvisitor.cpp | 34 +++--- .../filemanager/moveobjectvisitor.h | 4 +- .../filemanager/qmlrefactoring.cpp | 18 ++- .../designercore/filemanager/qmlrefactoring.h | 16 ++- .../designercore/filemanager/qmlrewriter.cpp | 7 +- .../designercore/filemanager/qmlrewriter.h | 5 +- .../designercore/include/abstractproperty.h | 11 +- .../designercore/include/bindingproperty.h | 6 +- .../designercore/include/modelnode.h | 16 +-- .../include/nodeabstractproperty.h | 6 +- .../designercore/include/nodeinstance.h | 25 +++-- .../designercore/include/nodeinstanceview.h | 3 +- .../designercore/include/nodelistproperty.h | 7 +- .../designercore/include/nodemetainfo.h | 2 +- .../designercore/include/nodeproperty.h | 7 +- .../designercore/include/propertymetainfo.h | 5 +- .../designercore/include/qml3dnode.h | 4 +- .../designercore/include/qmlchangeset.h | 2 +- .../designercore/include/qmlitemnode.h | 2 +- .../designercore/include/qmlobjectnode.h | 38 +++---- .../designercore/include/qmltimeline.h | 13 +-- .../include/qmltimelinekeyframegroup.h | 2 +- .../designercore/include/qmlvisualnode.h | 2 +- .../include/signalhandlerproperty.h | 19 +++- .../designercore/include/variantproperty.h | 8 +- .../designercore/instances/nodeinstance.cpp | 103 +++++++++++------- .../instances/nodeinstanceview.cpp | 40 +++++-- .../designercore/metainfo/nodemetainfo.cpp | 6 +- .../designercore/model/abstractproperty.cpp | 44 ++++---- .../designercore/model/bindingproperty.cpp | 17 +-- .../model/internalbindingproperty.cpp | 2 +- .../model/internalbindingproperty.h | 2 +- .../designercore/model/internalnode.cpp | 13 ++- .../designercore/model/internalnode_p.h | 19 ++-- .../model/internalnodeabstractproperty.cpp | 2 +- .../model/internalnodeabstractproperty.h | 2 +- .../model/internalnodelistproperty.cpp | 2 +- .../model/internalnodelistproperty.h | 2 +- .../model/internalnodeproperty.cpp | 2 +- .../designercore/model/internalnodeproperty.h | 2 +- .../designercore/model/internalproperty.cpp | 4 +- .../designercore/model/internalproperty.h | 6 +- .../model/internalsignalhandlerproperty.cpp | 4 +- .../model/internalsignalhandlerproperty.h | 5 +- .../model/internalvariantproperty.cpp | 3 +- .../model/internalvariantproperty.h | 2 +- .../qmldesigner/designercore/model/model.cpp | 51 +++++---- .../qmldesigner/designercore/model/model_p.h | 54 ++++++--- .../designercore/model/modelnode.cpp | 16 +-- .../model/nodeabstractproperty.cpp | 13 +-- .../designercore/model/nodelistproperty.cpp | 8 -- .../designercore/model/nodeproperty.cpp | 6 - .../model/signalhandlerproperty.cpp | 24 +--- .../designercore/model/variantproperty.cpp | 11 +- .../designercore/qmltools/qml3dnode.cpp | 4 +- .../designercore/qmltools/qmlanchors.cpp | 100 +++++++++++------ .../designercore/qmltools/qmlchangeset.cpp | 2 +- .../designercore/qmltools/qmlitemnode.cpp | 2 +- .../designercore/qmltools/qmlobjectnode.cpp | 39 ++++--- .../qmltools/qmltextgenerator.cpp | 2 +- .../designercore/qmltools/qmltimeline.cpp | 14 +-- .../qmltools/qmltimelinekeyframegroup.cpp | 2 +- .../designercore/qmltools/qmlvisualnode.cpp | 4 +- .../designercore/rewriter/rewriteaction.cpp | 4 +- src/plugins/qmldesigner/documentmanager.cpp | 39 ++++--- .../qmlmultilanguageaspect.cpp | 10 -- .../tests/printers/gtest-creator-printing.cpp | 2 + .../unit/tests/printers/gtest-qt-printing.cpp | 9 +- tests/unit/tests/printers/gtest-qt-printing.h | 1 + 113 files changed, 835 insertions(+), 649 deletions(-) diff --git a/src/libs/qmlpuppetcommunication/interfaces/nodeinstanceglobal.h b/src/libs/qmlpuppetcommunication/interfaces/nodeinstanceglobal.h index ed0104ae54d..d5647a0740b 100644 --- a/src/libs/qmlpuppetcommunication/interfaces/nodeinstanceglobal.h +++ b/src/libs/qmlpuppetcommunication/interfaces/nodeinstanceglobal.h @@ -5,13 +5,16 @@ #include #include +#include #include namespace QmlDesigner { using PropertyName = QByteArray; +using PropertyNameView = QByteArrayView; using PropertyNameList = QList; +using PropertyNameViews = QVarLengthArray; using PropertyNames = std::vector; using TypeName = QByteArray; diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 9c2be3538aa..ff46eef5a1b 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -733,7 +733,7 @@ public: signalHandler.view() ->emitCustomNotification(EditConnectionNotification, {signalHandler.parentModelNode()}, - {signalHandler.name()}); + {signalHandler.name().toByteArray()}); //ActionEditor::invokeEditor(signalHandler, removeSignal); }); diff --git a/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp index b0666a0d275..4ef8a4ed378 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp @@ -211,7 +211,7 @@ QHash BindingModel::roleNames() const std::optional BindingModel::rowForProperty(const AbstractProperty &property) const { - PropertyName name = property.name(); + PropertyNameView name = property.name(); int internalId = property.parentModelNode().internalId(); for (int i = 0; i < rowCount(); ++i) { diff --git a/src/plugins/qmldesigner/components/connectioneditor/bindingmodelitem.cpp b/src/plugins/qmldesigner/components/connectioneditor/bindingmodelitem.cpp index 9e9fd92f528..e5e1372dd65 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/bindingmodelitem.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/bindingmodelitem.cpp @@ -42,7 +42,7 @@ void BindingModelItem::updateProperty(const BindingProperty &property) { setData(property.parentModelNode().internalId(), InternalIdRole); setData(idOrTypeName(property.parentModelNode()), TargetNameRole); - setData(property.name(), TargetPropertyNameRole); + setData(property.name().toByteArray(), TargetPropertyNameRole); // TODO: Make this safe when the new codemodel allows it. if (auto expression = property.expression(); !expression.isEmpty()) { diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectioneditorutils.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectioneditorutils.cpp index be0bd5fde14..b96e000f8cd 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectioneditorutils.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectioneditorutils.cpp @@ -175,7 +175,7 @@ void convertPropertyType(const T &property, const QVariant &value) if (!node.isValid()) return; - PropertyName name = property.name(); + PropertyNameView name = property.name(); TypeName type = property.dynamicTypeName(); node.removeProperty(name); diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index 8b5b6e6c991..50782eda7bc 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -259,7 +259,7 @@ void ConnectionModel::updateTargetNode(int rowNumber) void ConnectionModel::updateCustomData(QStandardItem *item, const SignalHandlerProperty &signalHandlerProperty) { item->setData(signalHandlerProperty.parentModelNode().internalId(), UserRoles::InternalIdRole); - item->setData(signalHandlerProperty.name(), UserRoles::TargetPropertyNameRole); + item->setData(signalHandlerProperty.name().toByteArray(), UserRoles::TargetPropertyNameRole); item->setData(signalHandlerProperty.parentModelNode() .bindingProperty("target") .resolveToModelNode() diff --git a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesitem.cpp b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesitem.cpp index ae23fab076d..53e668be65e 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesitem.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesitem.cpp @@ -55,7 +55,7 @@ void DynamicPropertiesItem::updateProperty(const AbstractProperty &property) { setData(property.parentModelNode().internalId(), InternalIdRole); setData(idOrTypeName(property.parentModelNode()), TargetNameRole); - setData(property.name(), PropertyNameRole); + setData(property.name().toByteArray(), PropertyNameRole); setData(property.dynamicTypeName(), PropertyTypeRole); if (property.isVariantProperty()) { diff --git a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp index 8b1c90257e2..687752b8c98 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp @@ -136,7 +136,7 @@ void DynamicPropertiesModel::setCurrentProperty(const AbstractProperty &property setCurrentIndex(*index); } -void DynamicPropertiesModel::setCurrent(int internalId, const PropertyName &name) +void DynamicPropertiesModel::setCurrent(int internalId, PropertyNameView name) { if (internalId < 0) return; @@ -195,7 +195,7 @@ AbstractProperty DynamicPropertiesModel::propertyForRow(int row) const return {}; } -std::optional DynamicPropertiesModel::findRow(int nodeId, const PropertyName &name) const +std::optional DynamicPropertiesModel::findRow(int nodeId, PropertyNameView name) const { for (int i = 0; i < rowCount(); ++i) { if (auto *item = itemForRow(i)) { @@ -243,7 +243,7 @@ void DynamicPropertiesModel::addModelNode(const ModelNode &node) void DynamicPropertiesModel::addProperty(const AbstractProperty &property) { - const PropertyName name = property.name(); + const PropertyNameView name = property.name(); for (int i = 0; i < rowCount(); ++i) { if (auto *item = itemForRow(i)) { 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); if (!property.isValid()) @@ -346,7 +346,7 @@ void DynamicPropertiesModel::dispatchPropertyChanges(const AbstractProperty &abs QmlPropertyChanges changes(abstractProperty.parentModelNode()); if (changes.target().isValid()) { const ModelNode target = changes.target(); - const PropertyName propertyName = abstractProperty.name(); + const PropertyNameView propertyName = abstractProperty.name(); const AbstractProperty targetProperty = target.variantProperty(propertyName); if (target.hasProperty(propertyName) && targetProperty.isDynamic()) updateItem(targetProperty); diff --git a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h index 071c72bef81..c1afecb0cd6 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h @@ -46,13 +46,13 @@ public: void reset(const QList &modelNodes = {}); void setCurrentIndex(int i); void setCurrentProperty(const AbstractProperty &property); - void setCurrent(int internalId, const PropertyName &name); + void setCurrent(int internalId, PropertyNameView name); void updateItem(const AbstractProperty &property); void removeItem(const AbstractProperty &property); 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 dispatchPropertyChanges(const AbstractProperty &abstractProperty); @@ -61,7 +61,7 @@ protected: QHash roleNames() const override; private: - std::optional findRow(int nodeId, const PropertyName &name) const; + std::optional findRow(int nodeId, PropertyNameView name) const; DynamicPropertiesItem *itemForRow(int row) const; DynamicPropertiesItem *itemForProperty(const AbstractProperty &property) const; ModelNode modelNodeForItem(DynamicPropertiesItem *item); diff --git a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp index db97345d41b..d9d4e04eac7 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/propertytreemodel.cpp @@ -519,47 +519,51 @@ const std::vector PropertyTreeModel::sortedAndFilteredPropertyName const std::vector PropertyTreeModel::getDynamicProperties( const ModelNode &modelNode) const { - QList list = Utils::transform(modelNode.dynamicProperties(), - [](const AbstractProperty &property) { - return property.name(); - }); + auto dynamicProperties = modelNode.dynamicProperties(); + auto dynamicPropertyNames = Utils::transform( + dynamicProperties, [](const AbstractProperty &property) { return property.name(); }); - QList filtered - = Utils::filtered(list, [this, modelNode](const PropertyName &propertyName) { - PropertyName propertyType = modelNode.property(propertyName).dynamicTypeName(); - switch (m_type) { - case AllTypes: - return true; - case NumberType: - return propertyType == "float" || propertyType == "double" - || propertyType == "int"; - case StringType: - return propertyType == "string"; - case UrlType: - return propertyType == "url"; - case ColorType: - return propertyType == "color"; - case BoolType: - return propertyType == "bool"; - default: - break; - } - return true; - }); + auto filtered = Utils::filtered(dynamicPropertyNames, [this, modelNode](PropertyNameView propertyName) { + TypeName propertyType = modelNode.property(propertyName).dynamicTypeName(); + switch (m_type) { + case AllTypes: + return true; + case NumberType: + return propertyType == "float" || propertyType == "double" || propertyType == "int"; + case StringType: + return propertyType == "string"; + case UrlType: + return propertyType == "url"; + case ColorType: + return propertyType == "color"; + case BoolType: + return propertyType == "bool"; + default: + break; + } + return true; + }); - return Utils::sorted(std::vector(filtered.begin(), filtered.end())); + auto sorted = Utils::sorted(filtered); + + return Utils::transform>(sorted, [](PropertyNameView propertyName) { + return propertyName.toByteArray(); + }); } const std::vector PropertyTreeModel::getDynamicSignals(const ModelNode &modelNode) const { - QList list = Utils::transform(modelNode.dynamicProperties(), - [](const AbstractProperty &property) { - if (property.isSignalDeclarationProperty()) - return property.name(); + auto list = Utils::transform>( + modelNode.dynamicProperties(), [](const AbstractProperty &property) -> PropertyName { + if (property.isSignalDeclarationProperty()) + return property.name().toByteArray(); - return PropertyName(property.name() + "Changed"); - }); - return Utils::sorted(std::vector(list.begin(), list.end())); + return property.name().toByteArray() + "Changed"; + }); + + std::sort(list.begin(), list.end()); + + return list; } const std::vector PropertyTreeModel::sortedAndFilteredPropertyNames( diff --git a/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp b/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp index 78a578c788b..bce2777f0d9 100644 --- a/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp +++ b/src/plugins/qmldesigner/components/edit3d/bakelightsdatamodel.cpp @@ -234,7 +234,7 @@ bool BakeLightsDataModel::reset() PropertyName dotName = mi.name() + '.'; for (const AbstractProperty &prop : props) { if (prop.name().startsWith(dotName)) { - PropertyName subName = prop.name().mid(dotName.size()); + PropertyNameView subName = prop.name().mid(dotName.size()); if (subName == "bakedLightmap") { ModelNode blm = prop.toBindingProperty().resolveToModelNode(); if (blm.isValid()) { @@ -269,7 +269,7 @@ bool BakeLightsDataModel::reset() PropertyName dotName = mi.name() + '.'; for (const AbstractProperty &prop : props) { if (prop.name().startsWith(dotName)) { - PropertyName subName = prop.name().mid(dotName.size()); + PropertyNameView subName = prop.name().mid(dotName.size()); if (subName == "bakeMode") { if (prop.isVariantProperty()) { QString bakeModeStr = prop.toVariantProperty().value() diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index b3df6b8fe72..e8f8846466b 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -200,7 +200,7 @@ qreal FormEditorItem::selectionWeigth(const QPointF &point, int iteration) return weight; } -void FormEditorItem::synchronizeOtherProperty(const QByteArray &propertyName) +void FormEditorItem::synchronizeOtherProperty(PropertyNameView propertyName) { if (propertyName == "opacity") setOpacity(qmlItemNode().instanceValue("opacity").toDouble()); @@ -557,7 +557,7 @@ QmlItemNode FormEditorItem::qmlItemNode() const return m_qmlItemNode; } -void FormEditorFlowItem::synchronizeOtherProperty(const QByteArray &) +void FormEditorFlowItem::synchronizeOtherProperty(PropertyNameView) { setContentVisible(true); } @@ -783,7 +783,7 @@ QTransform FormEditorFlowActionItem::instanceSceneContentItemTransform() const return sceneTransform(); } -void FormEditorTransitionItem::synchronizeOtherProperty(const QByteArray &) +void FormEditorTransitionItem::synchronizeOtherProperty(PropertyNameView) { setContentVisible(true); } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h index 3629d500e29..64569592394 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h @@ -87,7 +87,7 @@ public: QPointF center() const; 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 setDataModelPositionInBaseState(const QPointF &position); virtual QPointF instancePosition() const; @@ -141,7 +141,7 @@ class FormEditorFlowItem : public FormEditorItem friend FormEditorScene; public: - void synchronizeOtherProperty(const QByteArray &propertyName) override; + void synchronizeOtherProperty(PropertyNameView propertyName) override; void setDataModelPosition(const QPointF &position) override; void setDataModelPositionInBaseState(const QPointF &position) override; void updateGeometry() override; @@ -198,7 +198,7 @@ class FormEditorTransitionItem : public FormEditorItem friend FormEditorScene; public: - void synchronizeOtherProperty(const QByteArray &propertyName) override; + void synchronizeOtherProperty(PropertyNameView propertyName) override; void setDataModelPosition(const QPointF &position) override; void setDataModelPositionInBaseState(const QPointF &position) override; void updateGeometry() override; diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp index cd89b74853d..24522f41453 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp @@ -142,7 +142,7 @@ void FormEditorScene::synchronizeParent(const QmlItemNode &qmlItemNode) reparentItem(qmlItemNode, parentNode); } -void FormEditorScene::synchronizeOtherProperty(FormEditorItem *item, const QByteArray &propertyName) +void FormEditorScene::synchronizeOtherProperty(FormEditorItem *item, PropertyNameView propertyName) { Q_ASSERT(item); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h index 133991d5b79..29330402b82 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h @@ -59,7 +59,7 @@ public: void synchronizeTransformation(FormEditorItem *item); void synchronizeParent(const QmlItemNode &qmlItemNode); - void synchronizeOtherProperty(FormEditorItem *item, const QByteArray &propertyName); + void synchronizeOtherProperty(FormEditorItem *item, PropertyNameView propertyName); FormEditorItem* calulateNewParent(FormEditorItem *widget); LayerItem* manipulatorLayerItem() const; diff --git a/src/plugins/qmldesigner/components/listmodeleditor/listmodeleditormodel.cpp b/src/plugins/qmldesigner/components/listmodeleditor/listmodeleditormodel.cpp index f97b6f74acc..0eb654bf0d0 100644 --- a/src/plugins/qmldesigner/components/listmodeleditor/listmodeleditormodel.cpp +++ b/src/plugins/qmldesigner/components/listmodeleditor/listmodeleditormodel.cpp @@ -100,7 +100,7 @@ QList getPropertyNames(const ModelNode &listElementNode) names.reserve(properties.size()); for (const auto &property : properties) - names.push_back(property.name()); + names.push_back(property.name().toByteArray()); std::sort(names.begin(), names.end()); diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp index b74f3107412..f01424e96e8 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp @@ -401,8 +401,8 @@ void MaterialBrowserModel::copyMaterialProperties(int idx, const QString §io // Dynamic properties must always be set in base state const QList dynProps = m_copiedMaterial.dynamicProperties(); for (const auto &prop : dynProps) { - dynamicProps.insert(prop.name(), prop.dynamicTypeName()); - validProps.insert(prop.name()); + dynamicProps.insert(prop.name().toByteArray(), prop.dynamicTypeName()); + validProps.insert(prop.name().toByteArray()); } } @@ -417,7 +417,7 @@ void MaterialBrowserModel::copyMaterialProperties(int idx, const QString §io if (changes.isValid()) { const QList changedProps = changes.targetProperties(); for (const auto &changedProp : changedProps) - validProps.insert(changedProp.name()); + validProps.insert(changedProp.name().toByteArray()); } } diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp index c4503781b03..8c794560369 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp @@ -100,27 +100,34 @@ WidgetInfo MaterialBrowserView::widgetInfo() executeInTransaction(__FUNCTION__, [&] { if (all) { // all material properties copied // remove current properties - PropertyNameList propNames; if (mat.isInBaseState()) { const QList baseProps = material.properties(); + PropertyNameViews propNames; for (const auto &baseProp : baseProps) { if (!baseProp.isDynamic()) propNames.append(baseProp.name()); } + + for (PropertyNameView propName : propNames) { + if (propName != "objectName" && propName != "data") + mat.removeProperty(propName); + } } else { QmlPropertyChanges changes = mat.propertyChangeForCurrentState(); if (changes.isValid()) { + PropertyNameViews propNames; const QList changedProps = changes.targetProperties(); for (const auto &changedProp : changedProps) { if (!changedProp.isDynamic()) 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 diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp index f583498db78..fa3469254f5 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp @@ -110,9 +110,9 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName) continue; // Add dynamic property - propertiesAndSignals.append(property.name()); + propertiesAndSignals.append(property.name().toByteArray()); // Add its change signal - PropertyName name = property.name(); + PropertyName name = property.name().toByteArray(); QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1(); name[0] = firstChar.toLatin1(); name.prepend("on"); @@ -124,7 +124,7 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName) QList incompatibleProperties; for (const auto &property : matProps) { 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 @@ -135,7 +135,7 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName) int targetIndex = -1; NodeMetaInfo oldMetaInfo = m_selectedMaterial.metaInfo(); struct CopyData { - CopyData() {}; + CopyData() {} CopyData(PropertyName n) : name(n) {} PropertyName name; QVariant value; diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp index 2ba6b6b5376..d2338ce280f 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp @@ -61,17 +61,17 @@ MaterialEditorQmlBackend::~MaterialEditorQmlBackend() { } -PropertyName MaterialEditorQmlBackend::auxNamePostFix(const PropertyName &propertyName) +PropertyName MaterialEditorQmlBackend::auxNamePostFix(PropertyNameView propertyName) { return propertyName + "__AUX"; } void MaterialEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, + PropertyNameView name, const QVariant &value, MaterialEditorView *materialEditor) { - PropertyName propertyName(name); + PropertyName propertyName(name.toByteArray()); propertyName.replace('.', '_'); auto valueObject = qobject_cast(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); 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 if (value.typeId() == QVariant::Vector2D) { @@ -139,7 +141,7 @@ void MaterialEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyNam propertyValue->setValue(QVariant(vecValue[i])); } } else { - PropertyName propertyName = name; + PropertyName propertyName = name.toByteArray(); propertyName.replace('.', '_'); auto propertyValue = qobject_cast(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); if (propertyValue) diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h index 925b1bd92ca..c8dc64b045f 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h @@ -36,7 +36,7 @@ public: void setup(const QmlObjectNode &selectedMaterialNode, const QString &stateName, const QUrl &qmlSpecificsFile, 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; MaterialEditorContextObject *contextObject() const; @@ -59,9 +59,10 @@ public: private: void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, const QVariant &value, + PropertyNameView name, + const QVariant &value, MaterialEditorView *materialEditor); - PropertyName auxNamePostFix(const PropertyName &propertyName); + PropertyName auxNamePostFix(PropertyNameView propertyName); // to avoid a crash while destructing DesignerPropertyMap in the QQmlData // this needs be destructed after m_quickWidget->engine() is destructed diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp index 95caa90aa16..ee2d9123ce8 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp @@ -640,7 +640,7 @@ void MaterialEditorView::setupQmlBackend() #endif } -void MaterialEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) +void MaterialEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; executeInTransaction(__FUNCTION__, [&] { @@ -649,11 +649,11 @@ void MaterialEditorView::commitVariantValueToModel(const PropertyName &propertyN m_locked = false; } -void MaterialEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) +void MaterialEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; - PropertyName name = propertyName; + PropertyNameView name = propertyName; name.chop(5); try { @@ -668,7 +668,7 @@ void MaterialEditorView::commitAuxValueToModel(const PropertyName &propertyName, m_locked = false; } -void MaterialEditorView::removePropertyFromModel(const PropertyName &propertyName) +void MaterialEditorView::removePropertyFromModel(PropertyNameView propertyName) { m_locked = true; executeInTransaction(__FUNCTION__, [&] { @@ -1210,7 +1210,9 @@ void MaterialEditorView::dragEnded() } // 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_qmlBackEnd->setValue(qmlObjectNode, name, value); diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.h b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.h index 53ab58c6881..8c9247ee784 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.h +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.h @@ -97,7 +97,7 @@ public slots: protected: 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; private: @@ -111,9 +111,9 @@ private: void setupQmlBackend(); - void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); - void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); - void removePropertyFromModel(const PropertyName &propertyName); + void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value); + void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value); + void removePropertyFromModel(PropertyNameView propertyName); void renameMaterial(ModelNode &material, const QString &newName); void duplicateMaterial(const ModelNode &material); diff --git a/src/plugins/qmldesigner/components/propertyeditor/dynamicpropertiesproxymodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/dynamicpropertiesproxymodel.cpp index 48983666199..b1b693b4329 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/dynamicpropertiesproxymodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/dynamicpropertiesproxymodel.cpp @@ -102,7 +102,7 @@ QVariant DynamicPropertiesProxyModel::data(const QModelIndex &index, int role) c QTC_ASSERT(property.isValid(), return QVariant()); if (role == propertyNameRole) - return property.name(); + return property.name().toByteArray(); if (propertyTypeRole) return property.dynamicTypeName(); @@ -353,7 +353,7 @@ void DynamicPropertyRow::commitValue(const QVariant &value) variantProperty.setDynamicTypeNameAndValue(variantProperty.dynamicTypeName(), value); } else { QTC_CHECK(objectNode.isValid()); - PropertyName name = variantProperty.name(); + PropertyNameView name = variantProperty.name(); if (objectNode.isValid() && objectNode.modelValue(name) != value) objectNode.setVariantProperty(name, value); } @@ -400,7 +400,7 @@ void DynamicPropertyRow::commitExpression(const QString &expression) } else { QmlObjectNode objectNode = bindingProperty.parentQmlObjectNode(); QTC_CHECK(objectNode.isValid()); - PropertyName name = bindingProperty.name(); + PropertyNameView name = bindingProperty.name(); if (objectNode.isValid() && objectNode.expression(name) != theExpression) objectNode.setBindingProperty(name, theExpression); } @@ -444,7 +444,7 @@ void DynamicPropertyRow::resetValue() try { QmlObjectNode objectNode = property.parentQmlObjectNode(); QTC_CHECK(objectNode.isValid()); - PropertyName name = property.name(); + PropertyNameView name = property.name(); if (objectNode.isValid() && objectNode.propertyAffectedByCurrentState(name)) objectNode.removeProperty(name); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 4df1109173f..b1bde8fb0f3 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -226,9 +226,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName) continue; // Add dynamic property - propertiesAndSignals.append(property.name()); + propertiesAndSignals.append(property.name().toByteArray()); // Add its change signal - PropertyName name = property.name(); + PropertyName name = property.name().toByteArray(); QChar firstChar = QChar(property.name().at(0)).toUpper().toLatin1(); name[0] = firstChar.toLatin1(); name.prepend("on"); @@ -240,7 +240,7 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName) QList incompatibleProperties; for (const auto &property : selectedNode.properties()) { if (!propertiesAndSignals.contains(property.name())) - incompatibleProperties.append(property.name()); + incompatibleProperties.append(property.name().toByteArray()); } Utils::sort(incompatibleProperties); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 36af894db15..3798deb3cb1 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -22,11 +22,12 @@ #include #include +#include #include #include #include #include -#include +#include #include #include @@ -105,11 +106,11 @@ PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyE PropertyEditorQmlBackend::~PropertyEditorQmlBackend() = default; -void PropertyEditorQmlBackend::setupPropertyEditorValue(const PropertyName &name, +void PropertyEditorQmlBackend::setupPropertyEditorValue(PropertyNameView name, PropertyEditorView *propertyEditor, const NodeMetaInfo &type) { - QmlDesigner::PropertyName propertyName(name); + QmlDesigner::PropertyName propertyName(name.toByteArray()); propertyName.replace('.', '_'); auto valueObject = qobject_cast(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); if (!valueObject) { @@ -142,9 +143,9 @@ QVariant properDefaultAuxiliaryProperties(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"); if (!marginsValue.isValid()) @@ -177,9 +178,9 @@ QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNod } 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()) return value; @@ -197,8 +198,12 @@ void PropertyEditorQmlBackend::setupLayoutAttachedProperties(const QmlObjectNode "minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan", "topMargin", "bottomMargin", "leftMargin", "rightMargin", "margins"}; - for (const PropertyName &propertyName : propertyNames) { - createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor); + for (PropertyNameView propertyName : propertyNames) { + createPropertyEditorValue(qmlObjectNode, + "Layout."_sv + propertyName, + properDefaultLayoutAttachedProperties(qmlObjectNode, + propertyName), + propertyEditor); } } } @@ -208,7 +213,7 @@ void PropertyEditorQmlBackend::setupInsightAttachedProperties(const QmlObjectNod { const PropertyName propertyName = "category"; createPropertyEditorValue(qmlObjectNode, - "InsightCategory." + propertyName, + "InsightCategory."_sv + propertyName, properDefaultInsightAttachedProperties(qmlObjectNode, propertyName), propertyEditor); } @@ -287,7 +292,7 @@ void PropertyEditorQmlBackend::setupAuxiliaryProperties(const QmlObjectNode &qml } void PropertyEditorQmlBackend::handleInstancePropertyChangedInModelNodeProxy( - const ModelNode &modelNode, const PropertyName &propertyName) + const ModelNode &modelNode, PropertyNameView propertyName) { m_backendModelNode.handleInstancePropertyChanged(modelNode, propertyName); } @@ -308,11 +313,11 @@ void PropertyEditorQmlBackend::handlePropertiesRemovedInModelNodeProxy(const Abs } void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, + PropertyNameView name, const QVariant &value, PropertyEditorView *propertyEditor) { - PropertyName propertyName(name); + PropertyName propertyName(name.toByteArray()); propertyName.replace('.', '_'); auto valueObject = qobject_cast(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); 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 if (value.typeId() == QVariant::Vector2D) { @@ -383,7 +390,7 @@ void PropertyEditorQmlBackend::setValue(const QmlObjectNode & , const PropertyNa propertyValue->setValue(QVariant(vecValue[i])); } } else { - PropertyName propertyName = name; + PropertyName propertyName = name.toByteArray(); propertyName.replace('.', '_'); auto propertyValue = qobject_cast(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); 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)); if (propertyValue) @@ -615,7 +622,9 @@ QString PropertyEditorQmlBackend::propertyEditorResourcesPath() 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(".")) return true; @@ -623,7 +632,7 @@ inline bool dotPropertyHeuristic(const QmlObjectNode &node, const NodeMetaInfo & if (name.count('.') > 1) return false; - QList list = name.split('.'); + QList list = name.toByteArray().split('.'); const PropertyName parentProperty = list.first(); const PropertyName itemProperty = list.last(); @@ -738,7 +747,7 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &metaTyp Utils::sort(basicProperties, propertyMetaInfoCompare); - auto findAndFillTemplate = [&nodes, &node, &needsTypeArgTypes](const PropertyName &label, + auto findAndFillTemplate = [&nodes, &node, &needsTypeArgTypes](PropertyNameView label, const PropertyMetaInfo &property) { const auto &propertyName = property.name(); PropertyName underscoreProperty = propertyName; @@ -962,9 +971,10 @@ void PropertyEditorQmlBackend::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.", ""); setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName)); @@ -978,9 +988,9 @@ void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObje } void PropertyEditorQmlBackend::setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode, - const PropertyName &name) + PropertyNameView name) { - PropertyName propertyName = name; + PropertyName propertyName = name.toByteArray(); propertyName.replace("InsightCategory.", ""); setValue(qmlObjectNode, name, properDefaultInsightAttachedProperties(qmlObjectNode, propertyName)); } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h index 1c9b808ac3d..c9afbe91bd5 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h @@ -38,8 +38,8 @@ public: void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, 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 setExpression(const PropertyName &propName, const QString &exp); + void setValue(const QmlObjectNode &fxObjectNode, PropertyNameView name, const QVariant &value); + void setExpression(PropertyNameView propName, const QString &exp); QQmlContext *context(); PropertyEditorContextObject* contextObject(); @@ -66,9 +66,9 @@ public: void emitSelectionChanged(); void setValueforLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, - const PropertyName &name); + PropertyNameView name); void setValueforInsightAttachedProperties(const QmlObjectNode &qmlObjectNode, - const PropertyName &name); + PropertyNameView name); void setValueforAuxiliaryProperties(const QmlObjectNode &qmlObjectNode, AuxiliaryDataKeyView key); void setupLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, @@ -79,7 +79,7 @@ public: PropertyEditorView *propertyEditor); void handleInstancePropertyChangedInModelNodeProxy(const ModelNode &modelNode, - const PropertyName &propertyName); + PropertyNameView propertyName); void handleVariantPropertyChangedInModelNodeProxy(const VariantProperty &property); void handleBindingPropertyChangedInModelNodeProxy(const BindingProperty &property); @@ -89,9 +89,10 @@ public: private: void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, const QVariant &value, + PropertyNameView name, + const QVariant &value, PropertyEditorView *propertyEditor); - void setupPropertyEditorValue(const PropertyName &name, + void setupPropertyEditorValue(PropertyNameView name, PropertyEditorView *propertyEditor, const NodeMetaInfo &type); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index d79804d200e..a85287f6735 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -71,7 +71,7 @@ static bool cleverColorCompare(const QVariant &value1, const QVariant &value2) // "red" is the same color as "#ff0000" // 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 (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 (!value->isValid()) @@ -192,7 +192,7 @@ bool PropertyEditorValue::isInModel() const return modelNode().hasProperty(name()); } -PropertyName PropertyEditorValue::name() const +PropertyNameView PropertyEditorValue::name() const { return m_name; } @@ -202,7 +202,7 @@ QString PropertyEditorValue::nameAsQString() const return QString::fromUtf8(m_name); } -void PropertyEditorValue::setName(const PropertyName &name) +void PropertyEditorValue::setName(PropertyNameView name) { m_name = name; } @@ -273,7 +273,7 @@ bool PropertyEditorValue::isAvailable() const const auto mcuAllowedItemProperties = mcuManager.allowedItemProperties(); const auto mcuBannedComplexProperties = mcuManager.bannedComplexProperties(); - const QList list = name().split('.'); + const QList list = name().toByteArray().split('.'); const QByteArray pureName = list.constFirst(); const QString pureNameStr = QString::fromUtf8(pureName); @@ -623,7 +623,7 @@ ModelNode PropertyEditorNodeWrapper::parentModelNode() const return m_editorValue->modelNode(); } -PropertyName PropertyEditorNodeWrapper::propertyName() const +PropertyNameView PropertyEditorNodeWrapper::propertyName() const { return m_editorValue->name(); } @@ -761,10 +761,10 @@ static QObject *variantToQObject(const QVariant &value) } void PropertyEditorSubSelectionWrapper::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, + PropertyNameView name, const QVariant &value) { - PropertyName propertyName(name); + Utils::SmallString propertyName = name.toByteArray(); propertyName.replace('.', '_'); auto valueObject = qobject_cast(variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName)))); if (!valueObject) { @@ -901,14 +901,13 @@ void PropertyEditorSubSelectionWrapper::changeValue(const QString &name) } } -void PropertyEditorSubSelectionWrapper::setValueFromModel(const PropertyName &name, - const QVariant &value) +void PropertyEditorSubSelectionWrapper::setValueFromModel(PropertyNameView name, const QVariant &value) { m_locked = true; QmlObjectNode qmlObjectNode(m_modelNode); - PropertyName propertyName = name; + Utils::SmallString propertyName = name; propertyName.replace('.', '_'); auto propertyValue = qobject_cast( variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(propertyName)))); @@ -917,7 +916,7 @@ void PropertyEditorSubSelectionWrapper::setValueFromModel(const PropertyName &na m_locked = false; } -void PropertyEditorSubSelectionWrapper::resetValue(const PropertyName &name) +void PropertyEditorSubSelectionWrapper::resetValue(PropertyNameView name) { auto propertyValue = qobject_cast( variantToQObject(m_valuesPropertyMap.value(QString::fromUtf8(name)))); @@ -964,7 +963,7 @@ void PropertyEditorSubSelectionWrapper::changeExpression(const QString &property }); /* end of transaction */ } -void PropertyEditorSubSelectionWrapper::removePropertyFromModel(const PropertyName &propertyName) +void PropertyEditorSubSelectionWrapper::removePropertyFromModel(PropertyNameView propertyName) { QTC_ASSERT(m_modelNode.isValid(), return ); @@ -982,7 +981,7 @@ void PropertyEditorSubSelectionWrapper::removePropertyFromModel(const PropertyNa m_locked = false; } -void PropertyEditorSubSelectionWrapper::commitVariantValueToModel(const PropertyName &propertyName, +void PropertyEditorSubSelectionWrapper::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value) { QTC_ASSERT(m_modelNode.isValid(), return ); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h index c4b09f6b5af..5f734d59733 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h @@ -30,15 +30,17 @@ public: Q_INVOKABLE void deleteModelNode(); - void setValueFromModel(const PropertyName &name, const QVariant &value); - void resetValue(const PropertyName &name); + void setValueFromModel(PropertyNameView name, const QVariant &value); + void resetValue(PropertyNameView name); bool isRelevantModelNode(const ModelNode &modelNode) const; private: void changeValue(const QString &name); 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 removeAliasExport(const QString &name); bool locked() const; @@ -46,8 +48,8 @@ private: ModelNode m_modelNode; QQmlPropertyMap m_valuesPropertyMap; bool m_locked = false; - void removePropertyFromModel(const PropertyName &propertyName); - void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); + void removePropertyFromModel(PropertyNameView propertyName); + void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value); AbstractView *view() const; }; @@ -67,7 +69,7 @@ public: QString type() const; QQmlPropertyMap *properties(); ModelNode parentModelNode() const; - PropertyName propertyName() const; + PropertyNameView propertyName() const; public slots: void add(const QString &type = QString()); @@ -142,9 +144,9 @@ public: bool isAvailable() const; - PropertyName name() const; + PropertyNameView name() const; QString nameAsQString() const; - void setName(const PropertyName &name); + void setName(PropertyNameView name); ModelNode modelNode() const; void setModelNode(const ModelNode &modelNode); @@ -205,7 +207,7 @@ private: ModelNode m_modelNode; QVariant m_value; QString m_expression; - PropertyName m_name; + Utils::SmallString m_name; bool m_isInSubState = false; bool m_isInModel = false; bool m_isBound = false; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index 0d9ad50137a..9a0108dc676 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -47,12 +47,12 @@ enum { namespace QmlDesigner { -static bool propertyIsAttachedLayoutProperty(const PropertyName &propertyName) +static bool propertyIsAttachedLayoutProperty(PropertyNameView propertyName) { return propertyName.contains("Layout."); } -static bool propertyIsAttachedInsightProperty(const PropertyName &propertyName) +static bool propertyIsAttachedInsightProperty(PropertyNameView propertyName) { return propertyName.contains("InsightCategory."); } @@ -317,7 +317,7 @@ void PropertyEditorView::refreshMetaInfos(const TypeIds &deletedTypeIds) } void PropertyEditorView::setExpressionOnObjectNode(const QmlObjectNode &constObjectNode, - const PropertyName &name, + PropertyNameView name, const QString &newExpression) { auto qmlObjectNode = constObjectNode; @@ -662,7 +662,7 @@ void PropertyEditorView::setupQmlBackend() #endif // QDS_USE_PROJECTSTORAGE } -void PropertyEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) +void PropertyEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; try { @@ -680,11 +680,11 @@ void PropertyEditorView::commitVariantValueToModel(const PropertyName &propertyN m_locked = false; } -void PropertyEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) +void PropertyEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; - PropertyName name = propertyName; + PropertyNameView name = propertyName; name.chop(5); try { @@ -704,7 +704,7 @@ void PropertyEditorView::commitAuxValueToModel(const PropertyName &propertyName, m_locked = false; } -void PropertyEditorView::removePropertyFromModel(const PropertyName &propertyName) +void PropertyEditorView::removePropertyFromModel(PropertyNameView propertyName) { m_locked = true; try { @@ -794,45 +794,51 @@ void PropertyEditorView::propertiesRemoved(const QList &proper if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) { m_locked = true; - PropertyName propertyName = property.name(); - propertyName.replace('.', '_'); + const PropertyName propertyName = property.name().toByteArray(); + PropertyName convertedpropertyName = propertyName; + + convertedpropertyName.replace('.', '_'); PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName( - QString::fromUtf8(propertyName)); + QString::fromUtf8(convertedpropertyName)); if (value) { value->resetValue(); m_qmlBackEndForCurrentType ->setValue(m_selectedNode, - property.name(), - QmlObjectNode(m_selectedNode).instanceValue(property.name())); + propertyName, + QmlObjectNode(m_selectedNode).instanceValue(propertyName)); } m_locked = false; - if (propertyIsAttachedLayoutProperty(property.name())) { - m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, property.name()); - - 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 (propertyIsAttachedLayoutProperty(propertyName)) { + m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, + propertyName); + 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, - property.name()); + propertyName); } - if ("width" == property.name() || "height" == property.name()) { + if ("width" == propertyName || "height" == propertyName) { const QmlItemNode qmlItemNode = m_selectedNode; if (qmlItemNode.isInLayout()) resetPuppet(); } - if (property.name().contains("anchor")) + if (propertyName.contains("anchor")) m_qmlBackEndForCurrentType->backendAnchorBinding().invalidate(m_selectedNode); } } @@ -1066,7 +1072,7 @@ void PropertyEditorView::dragEnded() } void PropertyEditorView::setValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, + PropertyNameView name, const QVariant &value) { m_locked = true; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h index ef2b71f558e..128914cfb6e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h @@ -85,7 +85,7 @@ public: void refreshMetaInfos(const TypeIds &deletedTypeIds) override; static void setExpressionOnObjectNode(const QmlObjectNode &objectNode, - const PropertyName &name, + PropertyNameView name, const QString &expression); static void generateAliasForProperty(const ModelNode &modelNode, @@ -97,7 +97,7 @@ public: protected: void timerEvent(QTimerEvent *event) override; 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; private: //functions @@ -111,9 +111,9 @@ private: //functions void delayedResetView(); void setupQmlBackend(); - void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); - void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); - void removePropertyFromModel(const PropertyName &propertyName); + void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value); + void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value); + void removePropertyFromModel(PropertyNameView propertyName); bool noValidSelection() const; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertynamevalidator.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertynamevalidator.cpp index 32cb39fa97e..2af3d1bf9aa 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertynamevalidator.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertynamevalidator.cpp @@ -11,7 +11,7 @@ PropertyNameValidator::PropertyNameValidator(QObject *parent) : QValidator(parent) {} -QValidator::State PropertyNameValidator::validate(QString &input, int &pos) const +QValidator::State PropertyNameValidator::validate(QString &input, int &) const { if (input.isEmpty()) return QValidator::Intermediate; diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp index 9a889ffb00c..2799773c01e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp @@ -250,7 +250,7 @@ void QmlModelNodeProxy::changeType(int internalId, const QString &typeName) } void QmlModelNodeProxy::handleInstancePropertyChanged(const ModelNode &modelNode, - const PropertyName &propertyName) + PropertyNameView propertyName) { const QmlObjectNode qmlObjectNode(modelNode); diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h index 9b5c0203345..0d613694715 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h @@ -61,7 +61,7 @@ public: 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 handleVariantPropertyChanged(const VariantProperty &property); diff --git a/src/plugins/qmldesigner/components/stateseditor/propertymodel.cpp b/src/plugins/qmldesigner/components/stateseditor/propertymodel.cpp index db07dd22080..54212be829e 100644 --- a/src/plugins/qmldesigner/components/stateseditor/propertymodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/propertymodel.cpp @@ -42,7 +42,7 @@ QVariant PropertyModel::data(const QModelIndex &index, int role) const switch (role) { case Name: { - return m_properties.at(index.row()).name(); + return m_properties.at(index.row()).name().toByteArray(); } case Value: { diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp index b13d06aa15a..57eb7237d47 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp @@ -67,17 +67,17 @@ TextureEditorQmlBackend::~TextureEditorQmlBackend() { } -PropertyName TextureEditorQmlBackend::auxNamePostFix(const PropertyName &propertyName) +PropertyName TextureEditorQmlBackend::auxNamePostFix(PropertyNameView propertyName) { return propertyName + "__AUX"; } void TextureEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, - const QVariant &value, - TextureEditorView *textureEditor) + PropertyNameView name, + const QVariant &value, + TextureEditorView *textureEditor) { - PropertyName propertyName(name); + PropertyName propertyName(name.toByteArray()); propertyName.replace('.', '_'); auto valueObject = qobject_cast(variantToQObject(backendValuesPropertyMap().value(QString::fromUtf8(propertyName)))); 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 if (value.typeId() == QVariant::Vector2D) { @@ -145,7 +147,7 @@ void TextureEditorQmlBackend::setValue(const QmlObjectNode &, const PropertyName propertyValue->setValue(QVariant(vecValue[i])); } } else { - PropertyName propertyName = name; + PropertyName propertyName = name.toByteArray(); propertyName.replace('.', '_'); auto propertyValue = qobject_cast(variantToQObject(m_backendValuesPropertyMap.value(QString::fromUtf8(propertyName)))); if (propertyValue) diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h index f69c46a5698..954017c7987 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h @@ -37,7 +37,7 @@ public: void setup(const QmlObjectNode &selectedTextureNode, const QString &stateName, const QUrl &qmlSpecificsFile, 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; TextureEditorContextObject *contextObject() const; @@ -58,9 +58,10 @@ public: private: void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, - const PropertyName &name, const QVariant &value, + PropertyNameView name, + const QVariant &value, TextureEditorView *textureEditor); - PropertyName auxNamePostFix(const PropertyName &propertyName); + PropertyName auxNamePostFix(PropertyNameView propertyName); // to avoid a crash while destructing DesignerPropertyMap in the QQmlData // this needs be destructed after m_quickWidget->engine() is destructed diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp index 1c3f01daf7a..8af22aa734b 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp @@ -475,7 +475,7 @@ void TextureEditorView::setupQmlBackend() #endif } -void TextureEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) +void TextureEditorView::commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; executeInTransaction("TextureEditorView:commitVariantValueToModel", [&] { @@ -484,11 +484,11 @@ void TextureEditorView::commitVariantValueToModel(const PropertyName &propertyNa m_locked = false; } -void TextureEditorView::commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value) +void TextureEditorView::commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value) { m_locked = true; - PropertyName name = propertyName; + PropertyNameView name = propertyName; name.chop(5); try { @@ -503,7 +503,7 @@ void TextureEditorView::commitAuxValueToModel(const PropertyName &propertyName, m_locked = false; } -void TextureEditorView::removePropertyFromModel(const PropertyName &propertyName) +void TextureEditorView::removePropertyFromModel(PropertyNameView propertyName) { m_locked = true; executeInTransaction("MaterialEditorView:removePropertyFromModel", [&] { @@ -565,18 +565,21 @@ void TextureEditorView::propertiesRemoved(const QList &propert if (node.isRootNode()) m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported()); + auto propertyName = property.name().toByteArray(); if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { // TODO: workaround for bug QDS-8539. To be removed once it is fixed. if (node.metaInfo().property(property.name()).propertyType().isUrl()) { resetPuppet(); } else { - setValue(m_selectedTexture, property.name(), - QmlObjectNode(m_selectedTexture).instanceValue(property.name())); + setValue(m_selectedTexture, + propertyName, + QmlObjectNode(m_selectedTexture).instanceValue(propertyName)); } } - if (property.name() == "materials" && (node == m_selectedModel - || QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { + if (propertyName == "materials" + && (node == m_selectedModel + || QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { m_qmlBackEnd->contextObject()->setHasSingleModelSelection(false); } @@ -594,10 +597,16 @@ void TextureEditorView::variantPropertiesChanged(const QList &p if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { if (property.isDynamic()) m_dynamicPropertiesModel->updateItem(property); - if (m_selectedTexture.property(property.name()).isBindingProperty()) - setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).instanceValue(property.name())); - else - setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).modelValue(property.name())); + auto propertyName = property.name().toByteArray(); + if (m_selectedTexture.property(propertyName).isBindingProperty()) { + setValue(m_selectedTexture, + propertyName, + QmlObjectNode(m_selectedTexture).instanceValue(propertyName)); + } else { + setValue(m_selectedTexture, + propertyName, + QmlObjectNode(m_selectedTexture).modelValue(propertyName)); + } } dynamicPropertiesModel()->dispatchPropertyChanges(property); @@ -615,17 +624,25 @@ void TextureEditorView::bindingPropertiesChanged(const QList &p if (property.isAliasExport()) m_qmlBackEnd->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedTexture).isAliasExported()); + auto propertyName = property.name().toByteArray(); + if (node == m_selectedTexture || QmlObjectNode(m_selectedTexture).propertyChangeForCurrentState() == node) { if (property.isDynamic()) m_dynamicPropertiesModel->updateItem(property); - if (QmlObjectNode(m_selectedTexture).modelNode().property(property.name()).isBindingProperty()) - setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).instanceValue(property.name())); - else - setValue(m_selectedTexture, property.name(), QmlObjectNode(m_selectedTexture).modelValue(property.name())); + if (QmlObjectNode(m_selectedTexture).modelNode().property(propertyName).isBindingProperty()) { + setValue(m_selectedTexture, + propertyName, + QmlObjectNode(m_selectedTexture).instanceValue(propertyName)); + } else { + setValue(m_selectedTexture, + propertyName, + QmlObjectNode(m_selectedTexture).modelValue(propertyName)); + } } - if (property.name() == "materials" && (node == m_selectedModel - || QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { + if (propertyName == "materials" + && (node == m_selectedModel + || QmlObjectNode(m_selectedModel).propertyChangeForCurrentState() == node)) { bool hasMaterials = QmlObjectNode(m_selectedModel).hasBindingProperty("materials"); m_qmlBackEnd->contextObject()->setHasSingleModelSelection(hasMaterials); } @@ -878,7 +895,9 @@ void TextureEditorView::dragEnded() } // 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_qmlBackEnd->setValue(qmlObjectNode, name, value); diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h index 31378544a3f..28f76448538 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.h @@ -83,7 +83,7 @@ public slots: protected: 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; private: @@ -96,9 +96,9 @@ private: void setupQmlBackend(); - void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); - void commitAuxValueToModel(const PropertyName &propertyName, const QVariant &value); - void removePropertyFromModel(const PropertyName &propertyName); + void commitVariantValueToModel(PropertyNameView propertyName, const QVariant &value); + void commitAuxValueToModel(PropertyNameView propertyName, const QVariant &value); + void removePropertyFromModel(PropertyNameView propertyName); void duplicateTexture(const ModelNode &texture); bool noValidSelection() const; diff --git a/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.cpp b/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.cpp index cb733e7690c..afa9769351c 100644 --- a/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.cpp +++ b/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.cpp @@ -268,7 +268,7 @@ PropertyMetaInfo metainfo(const AbstractProperty &property) 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); } diff --git a/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.h b/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.h index fc575411553..6d8e08cca34 100644 --- a/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.h +++ b/src/plugins/qmldesigner/designercore/designercoreutils/modelutils.h @@ -31,8 +31,7 @@ QMLDESIGNERCORE_EXPORT bool addImportWithCheck(const QString &importName, QMLDESIGNERCORE_EXPORT bool addImportWithCheck(const QString &importName, Model *model); QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const AbstractProperty &property); -QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const ModelNode &node, - const PropertyName &propertyName); +QMLDESIGNERCORE_EXPORT PropertyMetaInfo metainfo(const ModelNode &node, PropertyNameView propertyName); QMLDESIGNERCORE_EXPORT QString componentFilePath(const PathCacheType &pathCache, const NodeMetaInfo &metaInfo); diff --git a/src/plugins/qmldesigner/designercore/designercoreutils/stylesheetmerger.cpp b/src/plugins/qmldesigner/designercore/designercoreutils/stylesheetmerger.cpp index 4f744d54e6c..50059428841 100644 --- a/src/plugins/qmldesigner/designercore/designercoreutils/stylesheetmerger.cpp +++ b/src/plugins/qmldesigner/designercore/designercoreutils/stylesheetmerger.cpp @@ -89,7 +89,7 @@ void StylesheetMerger::syncNodeProperties(ModelNode &outputNode, const ModelNode continue; ModelNode newNode = createReplacementNode(oldNode, oldNode); // 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 outputNode.removeProperty(propertyName); outputNode.nodeProperty(propertyName).reparentHere(newNode); @@ -169,7 +169,8 @@ ModelNode StylesheetMerger::createReplacementNode(const ModelNode& styleNode, Mo continue; if (isTextAlignmentProperty(variantProperty) && !m_options.preserveTextAlignment && !styleNode.hasProperty(variantProperty.name())) continue; - propertyList.append(QPair(variantProperty.name(), variantProperty.value())); + propertyList.append(QPair(variantProperty.name().toByteArray(), + variantProperty.value())); } #ifdef QDS_USE_PROJECTSTORAGE @@ -278,7 +279,7 @@ void StylesheetMerger::replaceNode(ModelNode &replacedNode, ModelNode &newNode) for (const NodeProperty &prop : parentModelNode.nodeProperties()) { if (prop.modelNode().id() == replacedNode.id()) { isNodeProperty = true; - reparentName = prop.name(); + reparentName = prop.name().toByteArray(); } } ReparentInfo info; diff --git a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp index 88cbbda09a6..2807477b70a 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp @@ -10,18 +10,18 @@ namespace Internal { AddPropertyVisitor::AddPropertyVisitor(TextModifier &modifier, quint32 parentLocation, - const PropertyName &name, + PropertyNameView name, const QString &value, QmlRefactoring::PropertyType propertyType, const PropertyNameList &propertyOrder, - const TypeName &dynamicTypeName) : - QMLRewriter(modifier), - m_parentLocation(parentLocation), - m_name(name), - m_value(value), - m_propertyType(propertyType), - m_propertyOrder(propertyOrder), - m_dynamicTypeName(dynamicTypeName) + const TypeName &dynamicTypeName) + : QMLRewriter(modifier) + , m_parentLocation(parentLocation) + , m_name(name) + , m_value(value) + , m_propertyType(propertyType) + , m_propertyOrder(propertyOrder) + , m_dynamicTypeName(dynamicTypeName) { } diff --git a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h index e6440bf84b3..4710ecfb54d 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h +++ b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.h @@ -15,7 +15,7 @@ public: public: AddPropertyVisitor(TextModifier &modifier, quint32 parentLocation, - const PropertyName &name, + PropertyNameView name, const QString &value, QmlRefactoring::PropertyType propertyType, const PropertyNameList &propertyOrder, @@ -30,7 +30,7 @@ private: private: quint32 m_parentLocation; - PropertyName m_name; + PropertyNameView m_name; QString m_value; QmlRefactoring::PropertyType m_propertyType; PropertyNameList m_propertyOrder; diff --git a/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.cpp index 65d14bc11a9..73165b3f14f 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.cpp @@ -18,16 +18,16 @@ class Inserter: public QMLRewriter public: Inserter(TextModifier &modifier, quint32 targetParentObjectLocation, - const PropertyName &targetPropertyName, + PropertyNameView targetPropertyName, bool targetIsArrayBinding, TextModifier::MoveInfo moveInfo, - const PropertyNameList &propertyOrder): - QMLRewriter(modifier), - targetParentObjectLocation(targetParentObjectLocation), - targetPropertyName(targetPropertyName), - targetIsArrayBinding(targetIsArrayBinding), - moveInfo(moveInfo), - propertyOrder(propertyOrder) + const PropertyNameList &propertyOrder) + : QMLRewriter(modifier) + , targetParentObjectLocation(targetParentObjectLocation) + , targetPropertyName(targetPropertyName) + , targetIsArrayBinding(targetIsArrayBinding) + , moveInfo(moveInfo) + , propertyOrder(propertyOrder) {} protected: @@ -124,7 +124,7 @@ private: private: quint32 targetParentObjectLocation; - PropertyName targetPropertyName; + PropertyNameView targetPropertyName; bool targetIsArrayBinding; TextModifier::MoveInfo moveInfo; PropertyNameList propertyOrder; @@ -132,16 +132,16 @@ private: MoveObjectVisitor::MoveObjectVisitor(TextModifier &modifier, quint32 objectLocation, - const PropertyName &targetPropertyName, + PropertyNameView targetPropertyName, bool targetIsArrayBinding, quint32 targetParentObjectLocation, - const PropertyNameList &propertyOrder): - QMLRewriter(modifier), - objectLocation(objectLocation), - targetPropertyName(targetPropertyName), - targetIsArrayBinding(targetIsArrayBinding), - targetParentObjectLocation(targetParentObjectLocation), - propertyOrder(propertyOrder) + const PropertyNameList &propertyOrder) + : QMLRewriter(modifier) + , objectLocation(objectLocation) + , targetPropertyName(targetPropertyName) + , targetIsArrayBinding(targetIsArrayBinding) + , targetParentObjectLocation(targetParentObjectLocation) + , propertyOrder(propertyOrder) { } diff --git a/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.h b/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.h index 53659b748f5..5619261b540 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.h +++ b/src/plugins/qmldesigner/designercore/filemanager/moveobjectvisitor.h @@ -13,7 +13,7 @@ class MoveObjectVisitor: public QMLRewriter public: MoveObjectVisitor(QmlDesigner::TextModifier &modifier, quint32 objectLocation, - const QmlDesigner::PropertyName &targetPropertyName, + PropertyNameView targetPropertyName, bool targetIsArrayBinding, quint32 targetParentObjectLocation, const PropertyNameList &propertyOrder); @@ -31,7 +31,7 @@ private: private: QList parents; quint32 objectLocation; - PropertyName targetPropertyName; + PropertyNameView targetPropertyName; bool targetIsArrayBinding; quint32 targetParentObjectLocation; PropertyNameList propertyOrder; diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp index 34796d9a4c5..648741293c7 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp @@ -63,7 +63,9 @@ bool QmlRefactoring::removeImport(const Import &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) return false; @@ -83,7 +85,7 @@ bool QmlRefactoring::addToObjectMemberList(int parentLocation, const QString &co } bool QmlRefactoring::addProperty(int parentLocation, - const PropertyName &name, + PropertyNameView name, const QString &value, PropertyType propertyType, const TypeName &dynamicTypeName) @@ -95,7 +97,10 @@ bool QmlRefactoring::addProperty(int parentLocation, 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) return false; @@ -117,7 +122,10 @@ bool QmlRefactoring::changeObjectType(int nodeLocation, const QString &newType) 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) return false; @@ -150,7 +158,7 @@ bool QmlRefactoring::removeObject(int nodeLocation) return visit(qmlDocument->qmlProgram()); } -bool QmlRefactoring::removeProperty(int parentLocation, const PropertyName &name) +bool QmlRefactoring::removeProperty(int parentLocation, PropertyNameView name) { if (parentLocation < 0 || name.isEmpty()) return false; diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h index 9427acffde7..54194ab1360 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.h @@ -30,21 +30,27 @@ public: bool addImport(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 addProperty(int parentLocation, - const PropertyName &name, + PropertyNameView name, const QString &value, PropertyType propertyType, 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 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 removeObject(int nodeLocation); - bool removeProperty(int parentLocation, const PropertyName &name); + bool removeProperty(int parentLocation, PropertyNameView name); private: QmlJS::Document::Ptr qmlDocument; diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp index 20b22ade170..b5b1feb8b6f 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp @@ -231,9 +231,10 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AS } // FIXME: duplicate code in the QmlJS::Rewriter class, remove this -QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, - const QmlDesigner::PropertyName &propertyName, - const QmlDesigner::PropertyNameList &propertyOrder) +QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter( + QmlJS::AST::UiObjectMemberList *members, + PropertyNameView propertyName, + const QmlDesigner::PropertyNameList &propertyOrder) { if (!members) return nullptr; // empty members diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h index fe0b6933ea8..efbc25a0e27 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h @@ -52,7 +52,10 @@ protected: 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 QmlDesigner::PropertyName &propertyName, const PropertyNameList &propertyOrder); + static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter( + QmlJS::AST::UiObjectMemberList *members, + PropertyNameView propertyName, + const PropertyNameList &propertyOrder); protected: bool didRewriting() const diff --git a/src/plugins/qmldesigner/designercore/include/abstractproperty.h b/src/plugins/qmldesigner/designercore/include/abstractproperty.h index 811be48870f..67a8b0084ee 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractproperty.h +++ b/src/plugins/qmldesigner/designercore/include/abstractproperty.h @@ -3,9 +3,12 @@ #pragma once +#include "qmldesignercorelib_global.h" + +#include + #include #include -#include "qmldesignercorelib_global.h" #include @@ -53,12 +56,12 @@ public: AbstractProperty &operator=(AbstractProperty &&) noexcept = default; ~AbstractProperty(); AbstractProperty(const AbstractProperty &property, AbstractView *view); - AbstractProperty(const PropertyName &propertyName, + AbstractProperty(PropertyNameView propertyName, const Internal::InternalNodePointer &internalNode, Model *model, AbstractView *view); - const PropertyName &name() const; + PropertyNameView name() const & { return m_propertyName; } bool isValid() const; explicit operator bool() const { return isValid(); } @@ -139,7 +142,7 @@ protected: Internal::ModelPrivate *privateModel() const; private: - PropertyName m_propertyName; + Utils::SmallString m_propertyName; Internal::InternalNodePointer m_internalNode; QPointer m_model; QPointer m_view; diff --git a/src/plugins/qmldesigner/designercore/include/bindingproperty.h b/src/plugins/qmldesigner/designercore/include/bindingproperty.h index 022ae17cf08..a32aee3b2af 100644 --- a/src/plugins/qmldesigner/designercore/include/bindingproperty.h +++ b/src/plugins/qmldesigner/designercore/include/bindingproperty.h @@ -39,10 +39,12 @@ public: static QVariant convertToLiteral(const TypeName &typeName, const QString &expression); - BindingProperty(const PropertyName &propertyName, + BindingProperty(Utils::SmallStringView propertyName, const Internal::InternalNodePointer &internalNode, Model *model, - AbstractView *view); + AbstractView *view) + : AbstractProperty(propertyName, internalNode, model, view) + {} private: ModelNode resolveBinding(const QString &binding, ModelNode currentNode) const; diff --git a/src/plugins/qmldesigner/designercore/include/modelnode.h b/src/plugins/qmldesigner/designercore/include/modelnode.h index 63d4190116a..b0e5eeb7308 100644 --- a/src/plugins/qmldesigner/designercore/include/modelnode.h +++ b/src/plugins/qmldesigner/designercore/include/modelnode.h @@ -110,14 +110,14 @@ public: //### - AbstractProperty property(const PropertyName &name) const; - VariantProperty variantProperty(const PropertyName &name) const; - BindingProperty bindingProperty(const PropertyName &name) const; - SignalHandlerProperty signalHandlerProperty(const PropertyName &name) const; - SignalDeclarationProperty signalDeclarationProperty(const PropertyName &name) const; - NodeListProperty nodeListProperty(const PropertyName &name) const; - NodeProperty nodeProperty(const PropertyName &name) const; - NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; + AbstractProperty property(PropertyNameView name) const; + VariantProperty variantProperty(PropertyNameView name) const; + BindingProperty bindingProperty(PropertyNameView name) const; + SignalHandlerProperty signalHandlerProperty(PropertyNameView name) const; + SignalDeclarationProperty signalDeclarationProperty(PropertyNameView name) const; + NodeListProperty nodeListProperty(PropertyNameView name) const; + NodeProperty nodeProperty(PropertyNameView name) const; + NodeAbstractProperty nodeAbstractProperty(PropertyNameView name) const; NodeAbstractProperty defaultNodeAbstractProperty() const; NodeListProperty defaultNodeListProperty() const; NodeProperty defaultNodeProperty() const; diff --git a/src/plugins/qmldesigner/designercore/include/nodeabstractproperty.h b/src/plugins/qmldesigner/designercore/include/nodeabstractproperty.h index a0ff96b0d58..1790810f8b9 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeabstractproperty.h +++ b/src/plugins/qmldesigner/designercore/include/nodeabstractproperty.h @@ -35,10 +35,12 @@ public: friend auto qHash(const NodeAbstractProperty &property) { qHash(AbstractProperty(property)); } - NodeAbstractProperty(const PropertyName &propertyName, + NodeAbstractProperty(PropertyNameView propertyName, const Internal::InternalNodePointer &internalNode, Model *model, - AbstractView *view); + AbstractView *view) + : AbstractProperty(propertyName, internalNode, model, view) + {} protected: NodeAbstractProperty(const Internal::InternalNodeAbstractPropertyPointer &property, Model *model, AbstractView *view); diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h index a6f8f9a27d5..9e35aca428b 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h @@ -51,12 +51,12 @@ public: QPixmap renderPixmap() const; QPixmap blurredRenderPixmap() const; - QVariant property(const PropertyName &name) const; - bool hasProperty(const PropertyName &name) const; - bool hasBindingForProperty(const PropertyName &name) const; - QPair anchor(const PropertyName &name) const; - bool hasAnchor(const PropertyName &name) const; - TypeName instanceType(const PropertyName &name) const; + QVariant property(PropertyNameView name) const; + bool hasProperty(PropertyNameView name) const; + bool hasBindingForProperty(PropertyNameView name) const; + QPair anchor(PropertyNameView name) const; + bool hasAnchor(PropertyNameView name) const; + TypeName instanceType(PropertyNameView name) const; qint32 parentId() const; qint32 instanceId() const; @@ -72,7 +72,7 @@ public: QStringList allStateNames() const; protected: - void setProperty(const PropertyName &name, const QVariant &value); + void setProperty(PropertyNameView name, const QVariant &value); InformationName setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, @@ -94,10 +94,13 @@ protected: InformationName setInformationIsAnchoredByChildren(bool isAnchoredByChildren); InformationName setInformationIsAnchoredBySibling(bool isAnchoredBySibling); InformationName setInformationHasContent(bool hasContent); - InformationName setInformationHasAnchor(const PropertyName &sourceAnchorLine, bool hasAnchor); - InformationName setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId); - InformationName setInformationInstanceTypeForProperty(const PropertyName &property, const TypeName &type); - InformationName setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty); + InformationName setInformationHasAnchor(PropertyNameView sourceAnchorLine, bool hasAnchor); + InformationName setInformationAnchor(PropertyNameView sourceAnchorLine, + const PropertyName &targetAnchorLine, + qint32 targetInstanceId); + InformationName setInformationInstanceTypeForProperty(PropertyNameView property, + const TypeName &type); + InformationName setInformationHasBindingForProperty(PropertyNameView, bool hasProperty); InformationName setAllStates(const QStringList &states); void setParentId(qint32 instanceId); diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index 4156d62551c..24e2a9258e2 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -240,7 +240,8 @@ private: // functions void handleQsbProcessExit(Utils::Process *qsbProcess, const QString &shader); void updateQsbPathToFilterMap(); void updateRotationBlocks(); - void maybeResetOnPropertyChange(const PropertyName &name, const ModelNode &node, + void maybeResetOnPropertyChange(PropertyNameView name, + const ModelNode &node, PropertyChangeFlags flags); private: diff --git a/src/plugins/qmldesigner/designercore/include/nodelistproperty.h b/src/plugins/qmldesigner/designercore/include/nodelistproperty.h index 2f7a4423f09..d056957adcb 100644 --- a/src/plugins/qmldesigner/designercore/include/nodelistproperty.h +++ b/src/plugins/qmldesigner/designercore/include/nodelistproperty.h @@ -166,10 +166,13 @@ public: using reference = ModelNode; NodeListProperty(); - NodeListProperty(const PropertyName &propertyName, + + NodeListProperty(PropertyNameView propertyName, const Internal::InternalNodePointer &internalNode, Model *model, - AbstractView *view); + AbstractView *view) + : NodeAbstractProperty(propertyName, internalNode, model, view) + {} QList toModelNodeList() const; QList toQmlObjectNodeList() const; void slide(int, int) const; diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h index fd3f2f9be8d..887990c95e6 100644 --- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h +++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h @@ -94,7 +94,7 @@ public: bool hasProperty(::Utils::SmallStringView propertyName) const; PropertyMetaInfos properties() const; PropertyMetaInfos localProperties() const; - PropertyMetaInfo property(const PropertyName &propertyName) const; + PropertyMetaInfo property(PropertyNameView propertyName) const; PropertyNameList signalNames() const; PropertyNameList slotNames() const; PropertyName defaultPropertyName() const; diff --git a/src/plugins/qmldesigner/designercore/include/nodeproperty.h b/src/plugins/qmldesigner/designercore/include/nodeproperty.h index c0c266c6f3d..b9afe1d4188 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeproperty.h +++ b/src/plugins/qmldesigner/designercore/include/nodeproperty.h @@ -24,10 +24,13 @@ public: void setDynamicTypeNameAndsetModelNode(const TypeName &typeName, const ModelNode &modelNode); NodeProperty(); - NodeProperty(const PropertyName &propertyName, + + NodeProperty(PropertyNameView propertyName, const Internal::InternalNodePointer &internalNode, Model *model, - AbstractView *view); + AbstractView *view) + : NodeAbstractProperty(propertyName, internalNode, model, view) + {} }; } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/propertymetainfo.h b/src/plugins/qmldesigner/designercore/include/propertymetainfo.h index 42429d1480d..4221d5eb8d7 100644 --- a/src/plugins/qmldesigner/designercore/include/propertymetainfo.h +++ b/src/plugins/qmldesigner/designercore/include/propertymetainfo.h @@ -9,6 +9,8 @@ #include #include +#include + #include #include @@ -25,7 +27,8 @@ class QMLDESIGNERCORE_EXPORT PropertyMetaInfo public: PropertyMetaInfo(); PropertyMetaInfo(std::shared_ptr nodeMetaInfoPrivateData, - const PropertyName &propertyName); + PropertyNameView propertyName); + PropertyMetaInfo([[maybe_unused]] PropertyDeclarationId id, [[maybe_unused]] NotNullPointer projectStorage) #ifdef QDS_USE_PROJECTSTORAGE diff --git a/src/plugins/qmldesigner/designercore/include/qml3dnode.h b/src/plugins/qmldesigner/designercore/include/qml3dnode.h index 280691c7a9f..7dbabac046a 100644 --- a/src/plugins/qmldesigner/designercore/include/qml3dnode.h +++ b/src/plugins/qmldesigner/designercore/include/qml3dnode.h @@ -30,8 +30,8 @@ public: static bool isValidQml3DNode(const ModelNode &modelNode); static bool isValidVisualRoot(const ModelNode &modelNode); - bool handleEulerRotation(const PropertyName &name); - bool isBlocked(const PropertyName &propName) const; + bool handleEulerRotation(PropertyNameView name); + bool isBlocked(PropertyNameView propName) const; friend auto qHash(const Qml3DNode &node) { return qHash(node.modelNode()); } diff --git a/src/plugins/qmldesigner/designercore/include/qmlchangeset.h b/src/plugins/qmldesigner/designercore/include/qmlchangeset.h index 67d7a910840..bc2043809f4 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlchangeset.h +++ b/src/plugins/qmldesigner/designercore/include/qmlchangeset.h @@ -34,7 +34,7 @@ public: bool isValid() const; explicit operator bool() const { return isValid(); } static bool isValidQmlPropertyChanges(const ModelNode &modelNode); - void removeProperty(const PropertyName &name); + void removeProperty(PropertyNameView name); }; } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h index e11f201cdb2..c2ac5579900 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h @@ -214,7 +214,7 @@ public: static const PropertyNameList &mouseSignals() { return s_mouseSignals; } protected: - QList transitionsForProperty(const PropertyName &propertyName, const ModelNode &modelNode); + QList transitionsForProperty(PropertyNameView propertyName, const ModelNode &modelNode); private: static PropertyNameList s_mouseSignals; diff --git a/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h b/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h index a4fa1ab8ed8..71adf56e69d 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlobjectnode.h @@ -51,26 +51,26 @@ public: QmlModelState currentState() const; QmlTimeline currentTimeline() const; - void setVariantProperty(const PropertyName &name, const QVariant &value); - void setBindingProperty(const PropertyName &name, const QString &expression); - NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; + void setVariantProperty(PropertyNameView name, const QVariant &value); + void setBindingProperty(PropertyNameView name, const QString &expression); + NodeAbstractProperty nodeAbstractProperty(PropertyNameView name) const; NodeAbstractProperty defaultNodeAbstractProperty() const; - NodeProperty nodeProperty(const PropertyName &name) const; - NodeListProperty nodeListProperty(const PropertyName &name) const; + NodeProperty nodeProperty(PropertyNameView name) const; + NodeListProperty nodeListProperty(PropertyNameView name) const; - bool instanceHasValue(const PropertyName &name) const; - QVariant instanceValue(const PropertyName &name) const; - TypeName instanceType(const PropertyName &name) const; + bool instanceHasValue(PropertyNameView name) const; + QVariant instanceValue(PropertyNameView name) const; + TypeName instanceType(PropertyNameView name) const; - bool hasProperty(const PropertyName &name) const; - bool hasBindingProperty(const PropertyName &name) const; - bool instanceHasBinding(const PropertyName &name) const; - bool propertyAffectedByCurrentState(const PropertyName &name) const; - QVariant modelValue(const PropertyName &name) const; - bool isTranslatableText(const PropertyName &name) const; - QString stripedTranslatableText(const PropertyName &name) const; - BindingProperty bindingProperty(const PropertyName &name) const; - QString expression(const PropertyName &name) const; + bool hasProperty(PropertyNameView name) const; + bool hasBindingProperty(PropertyNameView name) const; + bool instanceHasBinding(PropertyNameView name) const; + bool propertyAffectedByCurrentState(PropertyNameView name) const; + QVariant modelValue(PropertyNameView name) const; + bool isTranslatableText(PropertyNameView name) const; + QString stripedTranslatableText(PropertyNameView name) const; + BindingProperty bindingProperty(PropertyNameView name) const; + QString expression(PropertyNameView name) const; bool isInBaseState() const; bool timelineIsActive() const; QmlPropertyChanges propertyChangeForCurrentState() const; @@ -87,7 +87,7 @@ public: QList allAffectingStates() const; QList allAffectingStatesOperations() const; - void removeProperty(const PropertyName &name); + void removeProperty(PropertyNameView name); void setParent(const QmlObjectNode &newParent); @@ -99,7 +99,7 @@ public: bool hasDefaultPropertyName() 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, const DesignerSettings &designerSettings); diff --git a/src/plugins/qmldesigner/designercore/include/qmltimeline.h b/src/plugins/qmldesigner/designercore/include/qmltimeline.h index 7a2809f5287..2cad8d2b901 100644 --- a/src/plugins/qmldesigner/designercore/include/qmltimeline.h +++ b/src/plugins/qmldesigner/designercore/include/qmltimeline.h @@ -25,8 +25,8 @@ public: static bool isValidQmlTimeline(const ModelNode &modelNode); void destroy(); - QmlTimelineKeyframeGroup keyframeGroup(const ModelNode &modelNode, const PropertyName &propertyName); - bool hasTimeline(const ModelNode &modelNode, const PropertyName &propertyName); + QmlTimelineKeyframeGroup keyframeGroup(const ModelNode &modelNode, PropertyNameView propertyName); + bool hasTimeline(const ModelNode &modelNode, PropertyNameView propertyName); qreal startKeyframe() const; qreal endKeyframe() const; @@ -45,8 +45,7 @@ public: QList keyframeGroupsForTarget(const ModelNode &target) const; void destroyKeyframesForTarget(const ModelNode &target); - void removeKeyframesForTargetAndProperty(const ModelNode &target, - const PropertyName &propertyName); + void removeKeyframesForTargetAndProperty(const ModelNode &target, PropertyNameView propertyName); static bool hasActiveTimeline(AbstractView *view); @@ -54,13 +53,13 @@ public: void toogleRecording(bool b) 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; - void insertKeyframe(const ModelNode &target, const PropertyName &propertyName); + void insertKeyframe(const ModelNode &target, PropertyNameView propertyName); private: - void addKeyframeGroupIfNotExists(const ModelNode &node, const PropertyName &propertyName); + void addKeyframeGroupIfNotExists(const ModelNode &node, PropertyNameView propertyName); QList allKeyframeGroups() const; }; diff --git a/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframegroup.h b/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframegroup.h index a319c5ac319..632ea93f212 100644 --- a/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframegroup.h +++ b/src/plugins/qmldesigner/designercore/include/qmltimelinekeyframegroup.h @@ -28,7 +28,7 @@ public: void setTarget(const ModelNode &target); PropertyName propertyName() const; - void setPropertyName(const PropertyName &propertyName); + void setPropertyName(PropertyNameView propertyName); void setValue(const QVariant &value, qreal frame); QVariant value(qreal frame) const; diff --git a/src/plugins/qmldesigner/designercore/include/qmlvisualnode.h b/src/plugins/qmldesigner/designercore/include/qmlvisualnode.h index a299d379bcd..f155f4f4687 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlvisualnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlvisualnode.h @@ -100,7 +100,7 @@ public: bool isFlowWildcard() const; private: - void setDoubleProperty(const PropertyName &name, double value); + void setDoubleProperty(PropertyNameView name, double value); }; class QMLDESIGNERCORE_EXPORT QmlModelStateGroup diff --git a/src/plugins/qmldesigner/designercore/include/signalhandlerproperty.h b/src/plugins/qmldesigner/designercore/include/signalhandlerproperty.h index 671e61c9823..1d43aa9e6bc 100644 --- a/src/plugins/qmldesigner/designercore/include/signalhandlerproperty.h +++ b/src/plugins/qmldesigner/designercore/include/signalhandlerproperty.h @@ -21,10 +21,15 @@ public: SignalHandlerProperty(); SignalHandlerProperty(const SignalHandlerProperty &property, AbstractView *view); - static PropertyName prefixAdded(const PropertyName &propertyName); - static PropertyName prefixRemoved(const PropertyName &propertyName); + static PropertyName prefixAdded(PropertyNameView 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 @@ -39,7 +44,13 @@ public: SignalDeclarationProperty(); 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 diff --git a/src/plugins/qmldesigner/designercore/include/variantproperty.h b/src/plugins/qmldesigner/designercore/include/variantproperty.h index dfa6073ff01..ab531912cc8 100644 --- a/src/plugins/qmldesigner/designercore/include/variantproperty.h +++ b/src/plugins/qmldesigner/designercore/include/variantproperty.h @@ -37,7 +37,13 @@ public: VariantProperty(); 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); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp index 414a05683e3..2290ce5e0d9 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp @@ -43,18 +43,17 @@ public: bool isInLayoutable{false}; bool directUpdates{false}; - - QHash propertyValues; - QHash hasBindingForProperty; - QHash hasAnchors; - QHash instanceTypes; + std::map> propertyValues; + std::map> hasBindingForProperty; + std::map> hasAnchors; + std::map> instanceTypes; QPixmap renderPixmap; QPixmap blurredRenderPixmap; QString errorMessage; - QHash > anchors; + std::map, std::less<>> anchors; QStringList allStates; }; @@ -285,17 +284,32 @@ int NodeInstance::penWidth() const return 1; } -QVariant NodeInstance::property(const PropertyName &name) const +namespace { + +template +auto value(const std::map &dict, + PropertyNameView key, + typename std::map::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 (d->propertyValues.contains(name)) { - return d->propertyValues.value(name); + if (auto found = d->propertyValues.find(name); found != d->propertyValues.end()) { + return found->second; } else { // Query may be for a subproperty, e.g. scale.x - const int index = name.indexOf('.'); + const auto index = name.indexOf('.'); if (index != -1) { - PropertyName parentPropName = name.left(index); - QVariant varValue = d->propertyValues.value(parentPropName); + PropertyNameView parentPropName = name.left(index); + QVariant varValue = value(d->propertyValues, parentPropName); if (varValue.typeId() == QVariant::Vector2D) { auto value = varValue.value(); char subProp = name.right(1)[0]; @@ -361,7 +375,7 @@ QVariant NodeInstance::property(const PropertyName &name) const return QVariant(); } -bool NodeInstance::hasProperty(const PropertyName &name) const +bool NodeInstance::hasProperty(PropertyNameView name) const { if (isValid()) return d->propertyValues.contains(name); @@ -369,18 +383,18 @@ bool NodeInstance::hasProperty(const PropertyName &name) const return false; } -bool NodeInstance::hasBindingForProperty(const PropertyName &name) const +bool NodeInstance::hasBindingForProperty(PropertyNameView name) const { if (isValid()) - return d->hasBindingForProperty.value(name, false); + return value(d->hasBindingForProperty, name, false); return false; } -TypeName NodeInstance::instanceType(const PropertyName &name) const +TypeName NodeInstance::instanceType(PropertyNameView name) const { if (isValid()) - return d->instanceTypes.value(name); + return value(d->instanceTypes, name); return TypeName(); } @@ -393,28 +407,28 @@ qint32 NodeInstance::parentId() const return false; } -bool NodeInstance::hasAnchor(const PropertyName &name) const +bool NodeInstance::hasAnchor(PropertyNameView name) const { if (isValid()) - return d->hasAnchors.value(name, false); + return value(d->hasAnchors, name, false); return false; } -QPair NodeInstance::anchor(const PropertyName &name) const +QPair NodeInstance::anchor(PropertyNameView name) const { if (isValid()) - return d->anchors.value(name, QPair(PropertyName(), qint32(-1))); + return value(d->anchors, name, QPair(PropertyName(), qint32(-1))); return QPair(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) { - PropertyName parentPropName = name.left(index); - QVariant oldValue = d->propertyValues.value(parentPropName); + PropertyNameView parentPropName = name.left(index); + QVariant oldValue = QmlDesigner::value(d->propertyValues, parentPropName); QVariant newValueVar; bool update = false; if (oldValue.typeId() == QVariant::Vector2D) { @@ -464,12 +478,12 @@ void NodeInstance::setProperty(const PropertyName &name, const QVariant &value) newValueVar = newValue; } if (update) { - d->propertyValues.insert(parentPropName, newValueVar); + d->propertyValues.emplace(parentPropName, newValueVar); return; } } - d->propertyValues.insert(name, value); + d->propertyValues.emplace(name, value); } QPixmap NodeInstance::renderPixmap() const @@ -671,41 +685,50 @@ InformationName NodeInstance::setInformationHasContent(bool hasContent) return NoInformationChange; } -InformationName NodeInstance::setInformationHasAnchor(const PropertyName &sourceAnchorLine, bool hasAnchor) +InformationName NodeInstance::setInformationHasAnchor(PropertyNameView sourceAnchorLine, bool hasAnchor) { - if (d->hasAnchors.value(sourceAnchorLine) != hasAnchor) { - d->hasAnchors.insert(sourceAnchorLine, hasAnchor); + if (auto found = d->hasAnchors.find(sourceAnchorLine); + found == d->hasAnchors.end() || found->second != hasAnchor) { + d->hasAnchors.emplace_hint(found, sourceAnchorLine, hasAnchor); return HasAnchor; } return NoInformationChange; } -InformationName NodeInstance::setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId) +InformationName NodeInstance::setInformationAnchor(PropertyNameView sourceAnchorLine, + const PropertyName &targetAnchorLine, + qint32 targetInstanceId) { - QPair anchorPair = QPair(targetAnchorLine, targetInstanceId); - if (d->anchors.value(sourceAnchorLine) != anchorPair) { - d->anchors.insert(sourceAnchorLine, anchorPair); + std::pair anchorPair = std::pair(targetAnchorLine, + targetInstanceId); + if (auto found = d->anchors.find(sourceAnchorLine); + found == d->anchors.end() || found->second != anchorPair) { + d->anchors.emplace_hint(found, sourceAnchorLine, anchorPair); return Anchor; } 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) { - d->instanceTypes.insert(property, type); + if (auto found = d->instanceTypes.find(property); + found == d->instanceTypes.end() || found->second != type) { + d->instanceTypes.emplace_hint(found, property, type); return InstanceTypeForProperty; } return NoInformationChange; } -InformationName NodeInstance::setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty) +InformationName NodeInstance::setInformationHasBindingForProperty(PropertyNameView property, + bool hasProperty) { - if (d->hasBindingForProperty.value(property) != hasProperty) { - d->hasBindingForProperty.insert(property, hasProperty); + if (auto found = d->hasBindingForProperty.find(property); + found == d->hasBindingForProperty.end() || found->second != hasProperty) { + d->hasBindingForProperty.emplace_hint(found, property, hasProperty); return HasBindingForProperty; } diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index ed85cb5e1da..d965b9ae177 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -470,7 +470,7 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList& m_nodeInstanceServer->removeProperties(createRemovePropertiesCommand(nonNodePropertyList)); for (const AbstractProperty &property : propertyList) { - const PropertyName &name = property.name(); + const PropertyNameView name = property.name(); if (name == "anchors.fill") { resetHorizontalAnchors(property.parentModelNode()); resetVerticalAnchors(property.parentModelNode()); @@ -602,7 +602,7 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty &listProperty) { QTC_ASSERT(m_nodeInstanceServer, return); QVector containerList; - PropertyName propertyName = listProperty.name(); + PropertyNameView propertyName = listProperty.name(); qint32 containerInstanceId = -1; ModelNode containerNode = listProperty.parentModelNode(); if (hasInstanceForModelNode(containerNode)) @@ -613,7 +613,11 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty &listProperty) qint32 instanceId = -1; if (hasInstanceForModelNode(node)) { instanceId = instanceForModelNode(node).instanceId(); - ReparentContainer container(instanceId, containerInstanceId, propertyName, containerInstanceId, propertyName); + ReparentContainer container(instanceId, + containerInstanceId, + propertyName.toByteArray(), + containerInstanceId, + propertyName.toByteArray()); containerList.append(container); } } @@ -1135,7 +1139,11 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand() for (const NodeInstance &instance : std::as_const(instanceList)) { if (instance.modelNode().hasParentProperty()) { 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); } } @@ -1167,7 +1175,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand() const QString expression = fullyQualifyPropertyIfApplies(property); PropertyBindingContainer container(instance.instanceId(), - property.name(), + property.name().toByteArray(), expression, property.dynamicTypeName()); bindingContainerList.append(container); @@ -1312,7 +1320,11 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const for (const NodeInstance &instance : instanceList) { if (instance.modelNode().hasParentProperty()) { 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); } } @@ -1334,8 +1346,11 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const if (oldPropertyParent.isValid() && hasInstanceForModelNode(oldPropertyParent.parentModelNode())) oldParentInstanceId = instanceForModelNode(oldPropertyParent.parentModelNode()).instanceId(); - - ReparentContainer container(instanceForModelNode(node).instanceId(), oldParentInstanceId, oldPropertyParent.name(), newParentInstanceId, newPropertyParent.name()); + ReparentContainer container(instanceForModelNode(node).instanceId(), + oldParentInstanceId, + oldPropertyParent.name().toByteArray(), + newParentInstanceId, + newPropertyParent.name().toByteArray()); containerList.append(container); @@ -1380,7 +1395,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList nodeMetaInfoPrivateData, - [[maybe_unused]] const PropertyName &propertyName) + [[maybe_unused]] PropertyNameView propertyName) #ifndef QDS_USE_PROJECTSTORAGE : m_nodeMetaInfoPrivateData{nodeMetaInfoPrivateData} - , m_propertyName{propertyName} + , m_propertyName{propertyName.toByteArray()} #endif {} diff --git a/src/plugins/qmldesigner/designercore/model/abstractproperty.cpp b/src/plugins/qmldesigner/designercore/model/abstractproperty.cpp index d8db3ac269d..82ffc76943f 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractproperty.cpp @@ -15,6 +15,8 @@ #include #include +#include + namespace QmlDesigner { /*! @@ -23,20 +25,25 @@ namespace QmlDesigner { \brief The AbstractProperty class is a value holder for a property. */ -AbstractProperty::AbstractProperty(const PropertyName &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view) - : m_propertyName(propertyName), - m_internalNode(internalNode), - m_model(model), - m_view(view) +AbstractProperty::AbstractProperty(PropertyNameView propertyName, + const Internal::InternalNodePointer &internalNode, + Model *model, + AbstractView *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"); } -AbstractProperty::AbstractProperty(const Internal::InternalPropertyPointer &property, Model* model, AbstractView *view) - : m_propertyName(property->name()), - m_internalNode(property->propertyOwner()), - m_model(model), - m_view(view) +AbstractProperty::AbstractProperty(const Internal::InternalPropertyPointer &property, + Model *model, + AbstractView *view) + : m_propertyName(property->name()) + , m_internalNode(property->propertyOwner()) + , m_model(model) + , m_view(view) { } @@ -66,17 +73,7 @@ AbstractView *AbstractProperty::view() const 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. A property is valid if the belonging model node @@ -319,12 +316,13 @@ TypeName AbstractProperty::dynamicTypeName() const QDebug operator<<(QDebug debug, const AbstractProperty &property) { return debug.nospace() << "AbstractProperty(" - << (property.isValid() ? property.name() : PropertyName("invalid")) << ')'; + << (property.isValid() ? property.name() : PropertyNameView("invalid")) + << ')'; } QTextStream &operator<<(QTextStream &stream, const AbstractProperty &property) { - stream << "AbstractProperty(" << property.name() << ')'; + stream << "AbstractProperty(" << property.name().toByteArray() << ')'; return stream; } diff --git a/src/plugins/qmldesigner/designercore/model/bindingproperty.cpp b/src/plugins/qmldesigner/designercore/model/bindingproperty.cpp index 23c17dc61a3..3086dbcd8f2 100644 --- a/src/plugins/qmldesigner/designercore/model/bindingproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/bindingproperty.cpp @@ -25,15 +25,7 @@ BindingProperty::BindingProperty() = default; BindingProperty::BindingProperty(const BindingProperty &property, AbstractView *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) { @@ -361,7 +353,7 @@ void BindingProperty::setDynamicTypeNameAndExpression(const TypeName &typeName, QDebug operator<<(QDebug debug, const BindingProperty &property) { if (!property.isValid()) - return debug.nospace() << "BindingProperty(" << PropertyName("invalid") << ')'; + return debug.nospace() << "BindingProperty(" << "invalid" << ')'; else 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) { if (!property.isValid()) - stream << "BindingProperty(" << PropertyName("invalid") << ')'; + stream << "BindingProperty(" << "invalid" << ')'; else - stream << "BindingProperty(" << property.name() << " " << property.expression() << ')'; + stream << "BindingProperty(" << property.name().toByteArray() << " " + << property.expression() << ')'; return stream; } diff --git a/src/plugins/qmldesigner/designercore/model/internalbindingproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalbindingproperty.cpp index 2e7542c79b1..8c99041b08d 100644 --- a/src/plugins/qmldesigner/designercore/model/internalbindingproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalbindingproperty.cpp @@ -6,7 +6,7 @@ namespace QmlDesigner { namespace Internal { -InternalBindingProperty::InternalBindingProperty(const PropertyName &name, +InternalBindingProperty::InternalBindingProperty(PropertyNameView name, const InternalNodePointer &propertyOwner) : InternalProperty(name, propertyOwner, PropertyType::Binding) { diff --git a/src/plugins/qmldesigner/designercore/model/internalbindingproperty.h b/src/plugins/qmldesigner/designercore/model/internalbindingproperty.h index 9ad0e19fc9e..6744a814925 100644 --- a/src/plugins/qmldesigner/designercore/model/internalbindingproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalbindingproperty.h @@ -14,7 +14,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::Binding; - InternalBindingProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); + InternalBindingProperty(PropertyNameView name, const InternalNodePointer &propertyOwner); bool isValid() const override; diff --git a/src/plugins/qmldesigner/designercore/model/internalnode.cpp b/src/plugins/qmldesigner/designercore/model/internalnode.cpp index d4a7c1ba584..4211633d7c6 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalnode.cpp @@ -129,8 +129,17 @@ AuxiliaryDatasForType InternalNode::auxiliaryData(AuxiliaryDataType type) const PropertyNameList InternalNode::propertyNameList() const { - return Utils::transform(m_nameProperties, - [](const auto &entry) { return entry.first; }); + return Utils::transform(m_nameProperties, [](const auto &entry) { + return entry.first.toQByteArray(); + }); +} + +PropertyNameViews InternalNode::propertyNameViews() const +{ + return Utils::transform(m_nameProperties, + [](const auto &entry) -> PropertyNameView { + return entry.first; + }); } QList InternalNode::allSubNodes() const diff --git a/src/plugins/qmldesigner/designercore/model/internalnode_p.h b/src/plugins/qmldesigner/designercore/model/internalnode_p.h index e2d364cb792..9e3a32ef7f6 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnode_p.h +++ b/src/plugins/qmldesigner/designercore/model/internalnode_p.h @@ -144,7 +144,7 @@ public: auto nodeProperty(PropertyNameView name) const { return property(name); } template - Type *addProperty(const PropertyName &name) + Type *addProperty(PropertyNameView name) { auto newProperty = std::make_shared(name, shared_from_this()); auto pointer = newProperty.get(); @@ -153,32 +153,32 @@ public: return pointer; } - auto addBindingProperty(const PropertyName &name) + auto addBindingProperty(PropertyNameView name) { return addProperty(name); } - auto addSignalHandlerProperty(const PropertyName &name) + auto addSignalHandlerProperty(PropertyNameView name) { return addProperty(name); } - auto addSignalDeclarationProperty(const PropertyName &name) + auto addSignalDeclarationProperty(PropertyNameView name) { return addProperty(name); } - auto addNodeListProperty(const PropertyName &name) + auto addNodeListProperty(PropertyNameView name) { return addProperty(name); } - auto addVariantProperty(const PropertyName &name) + auto addVariantProperty(PropertyNameView name) { return addProperty(name); } - auto addNodeProperty(const PropertyName &name, const TypeName &dynamicTypeName) + auto addNodeProperty(PropertyNameView name, const TypeName &dynamicTypeName) { auto property = addProperty(name); property->setDynamicTypeName(dynamicTypeName); @@ -187,6 +187,9 @@ public: } PropertyNameList propertyNameList() const; + PropertyNameViews propertyNameViews() const; + + bool hasProperties() const { return m_nameProperties.size(); } QList allSubNodes() const; QList allDirectSubNodes() const; @@ -215,7 +218,7 @@ public: m_nameProperties.erase(found); // C++ 23 -> m_nameProperties.erase(name) } - using PropertyDict = std::map>; + using PropertyDict = std::map>; PropertyDict::const_iterator begin() const { return m_nameProperties.begin(); } diff --git a/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.cpp index 6dff33436e4..d7afff29b3b 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.cpp @@ -7,7 +7,7 @@ namespace QmlDesigner { namespace Internal { -InternalNodeAbstractProperty::InternalNodeAbstractProperty(const PropertyName &name, +InternalNodeAbstractProperty::InternalNodeAbstractProperty(PropertyNameView name, const InternalNode::Pointer &propertyOwner, PropertyType propertyType) : InternalProperty(name, propertyOwner, propertyType) diff --git a/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.h b/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.h index 7205fe7377d..5a10861dfc5 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalnodeabstractproperty.h @@ -24,7 +24,7 @@ public: bool isValid() const override; protected: - InternalNodeAbstractProperty(const PropertyName &name, + InternalNodeAbstractProperty(PropertyNameView name, const InternalNodePointer &propertyOwner, PropertyType propertyType); virtual void remove(const InternalNodePointer &node) = 0; diff --git a/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.cpp index 975927c097c..49fa67f9c2c 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.cpp @@ -8,7 +8,7 @@ namespace QmlDesigner { namespace Internal { -InternalNodeListProperty::InternalNodeListProperty(const PropertyName &name, +InternalNodeListProperty::InternalNodeListProperty(PropertyNameView name, const InternalNodePointer &propertyOwner) : InternalNodeAbstractProperty(name, propertyOwner, PropertyType::NodeList) { diff --git a/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.h b/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.h index 01b508b80ab..9072e571afc 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalnodelistproperty.h @@ -17,7 +17,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::NodeList; - InternalNodeListProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); + InternalNodeListProperty(PropertyNameView name, const InternalNodePointer &propertyOwner); bool isValid() const override; diff --git a/src/plugins/qmldesigner/designercore/model/internalnodeproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalnodeproperty.cpp index ff9d71d6fdb..d6bf0daf68a 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodeproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalnodeproperty.cpp @@ -7,7 +7,7 @@ namespace QmlDesigner { namespace Internal { -InternalNodeProperty::InternalNodeProperty(const PropertyName &name, +InternalNodeProperty::InternalNodeProperty(PropertyNameView name, const InternalNode::Pointer &propertyOwner) : InternalNodeAbstractProperty(name, propertyOwner, PropertyType::Node) { diff --git a/src/plugins/qmldesigner/designercore/model/internalnodeproperty.h b/src/plugins/qmldesigner/designercore/model/internalnodeproperty.h index bd4b66304e7..b1572962c25 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnodeproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalnodeproperty.h @@ -14,7 +14,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::Node; - InternalNodeProperty(const PropertyName &name, const InternalNodePointer &node); + InternalNodeProperty(PropertyNameView name, const InternalNodePointer &node); bool isValid() const override; bool isEmpty() const override; diff --git a/src/plugins/qmldesigner/designercore/model/internalproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalproperty.cpp index 06a1d903739..7f8417a0ad6 100644 --- a/src/plugins/qmldesigner/designercore/model/internalproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalproperty.cpp @@ -41,7 +41,7 @@ namespace Internal { InternalProperty::~InternalProperty() = default; -InternalProperty::InternalProperty(const PropertyName &name, +InternalProperty::InternalProperty(PropertyNameView name, const InternalNode::Pointer &propertyOwner, PropertyType propertyType) : m_name(name) @@ -57,7 +57,7 @@ bool InternalProperty::isValid() const return !m_propertyOwner.expired() && !m_name.isEmpty(); } -PropertyName InternalProperty::name() const +PropertyNameView InternalProperty::name() const { return m_name; } diff --git a/src/plugins/qmldesigner/designercore/model/internalproperty.h b/src/plugins/qmldesigner/designercore/model/internalproperty.h index f5ca983969c..3f30fb9c2d8 100644 --- a/src/plugins/qmldesigner/designercore/model/internalproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalproperty.h @@ -103,7 +103,7 @@ public: virtual bool isValid() const; - PropertyName name() const; + PropertyNameView name() const; bool isBindingProperty() const { return m_propertyType == PropertyType::Binding; } bool isVariantProperty() const { return m_propertyType == PropertyType::Variant; } @@ -182,14 +182,14 @@ public: PropertyType type() const { return m_propertyType; } protected: // functions - InternalProperty(const PropertyName &name, + InternalProperty(PropertyNameView name, const InternalNodePointer &propertyOwner, PropertyType propertyType); void setDynamicTypeName(const TypeName &name); private: - PropertyName m_name; + Utils::SmallString m_name; TypeName m_dynamicType; std::weak_ptr m_propertyOwner; PropertyType m_propertyType = PropertyType::None; diff --git a/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.cpp index d199ad4b8c9..61197feedb2 100644 --- a/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.cpp @@ -6,7 +6,7 @@ namespace QmlDesigner { namespace Internal { -InternalSignalHandlerProperty::InternalSignalHandlerProperty(const PropertyName &name, +InternalSignalHandlerProperty::InternalSignalHandlerProperty(PropertyNameView name, const InternalNodePointer &propertyOwner) : InternalProperty(name, propertyOwner, PropertyType::SignalHandler) { @@ -46,7 +46,7 @@ void InternalSignalDeclarationProperty::setSignature(const QString &signature) } InternalSignalDeclarationProperty::InternalSignalDeclarationProperty( - const PropertyName &name, const InternalNodePointer &propertyOwner) + PropertyNameView name, const InternalNodePointer &propertyOwner) : InternalProperty(name, propertyOwner, PropertyType::SignalDeclaration) { setDynamicTypeName("signal"); diff --git a/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.h b/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.h index f0d88e2d239..35b589ec0ac 100644 --- a/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalsignalhandlerproperty.h @@ -14,7 +14,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::SignalHandler; - InternalSignalHandlerProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); + InternalSignalHandlerProperty(PropertyNameView name, const InternalNodePointer &propertyOwner); bool isValid() const override; @@ -31,8 +31,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::SignalDeclaration; - InternalSignalDeclarationProperty(const PropertyName &name, - const InternalNodePointer &propertyOwner); + InternalSignalDeclarationProperty(PropertyNameView name, const InternalNodePointer &propertyOwner); bool isValid() const override; diff --git a/src/plugins/qmldesigner/designercore/model/internalvariantproperty.cpp b/src/plugins/qmldesigner/designercore/model/internalvariantproperty.cpp index 04ff6fff708..c031f73ba8c 100644 --- a/src/plugins/qmldesigner/designercore/model/internalvariantproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/internalvariantproperty.cpp @@ -6,8 +6,7 @@ namespace QmlDesigner { namespace Internal { -InternalVariantProperty::InternalVariantProperty(const PropertyName &name, - const InternalNodePointer &node) +InternalVariantProperty::InternalVariantProperty(PropertyNameView name, const InternalNodePointer &node) : InternalProperty(name, node, PropertyType::Variant) { } diff --git a/src/plugins/qmldesigner/designercore/model/internalvariantproperty.h b/src/plugins/qmldesigner/designercore/model/internalvariantproperty.h index f9bb85d38d7..bf97c3d68a3 100644 --- a/src/plugins/qmldesigner/designercore/model/internalvariantproperty.h +++ b/src/plugins/qmldesigner/designercore/model/internalvariantproperty.h @@ -14,7 +14,7 @@ public: using Pointer = std::shared_ptr; static constexpr PropertyType type = PropertyType::Variant; - InternalVariantProperty(const PropertyName &name, const InternalNodePointer &propertyOwner); + InternalVariantProperty(PropertyNameView name, const InternalNodePointer &propertyOwner); bool isValid() const override; diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 1adebbfee36..cbfa695da63 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -347,9 +347,9 @@ InternalNodePointer ModelPrivate::createNode(TypeNameView typeName, notifyNodeCreated(newNode); - if (!newNode->propertyNameList().isEmpty()) + if (newNode->hasProperties()) notifyVariantPropertiesChanged(newNode, - newNode->propertyNameList(), + newNode->propertyNameViews(), AbstractView::PropertiesAdded); return newNode; @@ -473,7 +473,7 @@ void ModelPrivate::removeNode(const InternalNodePointer &node) removeNodeFromModel(node); InternalNodePointer parentNode; - PropertyName parentPropertyName; + PropertyNameView parentPropertyName; if (oldParentProperty) { parentNode = oldParentProperty->propertyOwner(); parentPropertyName = oldParentProperty->name(); @@ -923,7 +923,7 @@ void ModelPrivate::notifyNodeAboutToBeRemoved(const InternalNodePointer &interna void ModelPrivate::notifyNodeRemoved(const InternalNodePointer &removedNode, const InternalNodePointer &parentNode, - const PropertyName &parentPropertyName, + PropertyNameView parentPropertyName, AbstractView::PropertyChangeFlags propertyChange) { notifyNormalViewsLast([&](AbstractView *view) { @@ -1026,12 +1026,12 @@ void ModelPrivate::notifyScriptFunctionsChanged(const InternalNodePointer &node, } void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &node, - const PropertyNameList &propertyNameList, + const PropertyNameViews &propertyNameViews, AbstractView::PropertyChangeFlags propertyChange) { notifyNodeInstanceViewLast([&](AbstractView *view) { QList propertyList; - for (const PropertyName &propertyName : propertyNameList) { + for (PropertyNameView propertyName : propertyNameViews) { VariantProperty property(propertyName, node, m_model, view); propertyList.append(property); } @@ -1042,9 +1042,9 @@ void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &nod void ModelPrivate::notifyNodeAboutToBeReparent(const InternalNodePointer &node, const InternalNodePointer &newParent, - const PropertyName &newPropertyName, + PropertyNameView newPropertyName, const InternalNodePointer &oldParent, - const PropertyName &oldPropertyName, + PropertyNameView oldPropertyName, AbstractView::PropertyChangeFlags propertyChange) { notifyNodeInstanceViewLast([&](AbstractView *view) { @@ -1069,7 +1069,7 @@ void ModelPrivate::notifyNodeAboutToBeReparent(const InternalNodePointer &node, void ModelPrivate::notifyNodeReparent(const InternalNodePointer &node, const InternalNodeAbstractProperty *newPropertyParent, const InternalNodePointer &oldParent, - const PropertyName &oldPropertyName, + PropertyNameView oldPropertyName, AbstractView::PropertyChangeFlags propertyChange) { notifyNodeInstanceViewLast([&](AbstractView *view) { @@ -1348,7 +1348,7 @@ void ModelPrivate::removeProperties(const QList &properties) } void ModelPrivate::setBindingProperty(const InternalNodePointer &node, - const PropertyName &name, + PropertyNameView name, const QString &expression) { AbstractView::PropertyChangeFlags propertyChange = AbstractView::NoAdditionalChanges; @@ -1381,7 +1381,9 @@ void ModelPrivate::setBindingProperties(const ModelResourceSet::SetExpressions & 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; InternalSignalHandlerProperty *signalHandlerProperty = nullptr; @@ -1396,7 +1398,9 @@ void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &node, con 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; InternalSignalDeclarationProperty *signalDeclarationProperty = nullptr; @@ -1411,7 +1415,9 @@ void ModelPrivate::setSignalDeclarationProperty(const InternalNodePointer &node, 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; InternalVariantProperty *variantProperty = nullptr; @@ -1424,11 +1430,11 @@ void ModelPrivate::setVariantProperty(const InternalNodePointer &node, const Pro variantProperty->setValue(value); variantProperty->resetDynamicTypeName(); - notifyVariantPropertiesChanged(node, PropertyNameList({name}), propertyChange); + notifyVariantPropertiesChanged(node, PropertyNameViews({name}), propertyChange); } void ModelPrivate::setDynamicVariantProperty(const InternalNodePointer &node, - const PropertyName &name, + PropertyNameView name, const TypeName &dynamicPropertyType, const QVariant &value) { @@ -1442,11 +1448,11 @@ void ModelPrivate::setDynamicVariantProperty(const InternalNodePointer &node, } variantProperty->setDynamicValue(dynamicPropertyType, value); - notifyVariantPropertiesChanged(node, PropertyNameList({name}), propertyChange); + notifyVariantPropertiesChanged(node, PropertyNameViews({name}), propertyChange); } void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &node, - const PropertyName &name, + PropertyNameView name, const TypeName &dynamicPropertyType, const QString &expression) { @@ -1465,7 +1471,7 @@ void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &node, } void ModelPrivate::reparentNode(const InternalNodePointer &parentNode, - const PropertyName &name, + PropertyNameView name, const InternalNodePointer &childNode, bool list, const TypeName &dynamicTypeName) @@ -1474,7 +1480,7 @@ void ModelPrivate::reparentNode(const InternalNodePointer &parentNode, InternalNodeAbstractPropertyPointer oldParentProperty(childNode->parentProperty()); InternalNodePointer oldParentNode; - PropertyName oldParentPropertyName; + Utils::SmallString oldParentPropertyName; if (oldParentProperty && oldParentProperty->isValid()) { oldParentNode = childNode->parentProperty()->propertyOwner(); oldParentPropertyName = childNode->parentProperty()->name(); @@ -1519,7 +1525,7 @@ void ModelPrivate::clearParent(const InternalNodePointer &node) { InternalNodeAbstractPropertyPointer oldParentProperty(node->parentProperty()); InternalNodePointer oldParentNode; - PropertyName oldParentPropertyName; + Utils::SmallString oldParentPropertyName; if (oldParentProperty->isValid()) { oldParentNode = node->parentProperty()->propertyOwner(); oldParentPropertyName = node->parentProperty()->name(); @@ -1563,7 +1569,10 @@ void ModelPrivate::setNodeSource(const InternalNodePointer &node, const QString 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); Q_ASSERT(nodeList); diff --git a/src/plugins/qmldesigner/designercore/model/model_p.h b/src/plugins/qmldesigner/designercore/model/model_p.h index d4ae814c45c..d32a0973d62 100644 --- a/src/plugins/qmldesigner/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/designercore/model/model_p.h @@ -50,7 +50,7 @@ class InternalVariantProperty; class InternalNodeAbstractProperty; class InternalNodeListProperty; -using PropertyPair = QPair; +using PropertyPair = std::pair; class ModelPrivate; @@ -162,19 +162,19 @@ public: void notifyNodeCreated(const InternalNodePointer &newNode); void notifyNodeAboutToBeReparent(const InternalNodePointer &node, const InternalNodePointer &newParent, - const PropertyName &newPropertyName, + PropertyNameView newPropertyName, const InternalNodePointer &oldParent, - const PropertyName &oldPropertyName, + PropertyNameView oldPropertyName, AbstractView::PropertyChangeFlags propertyChange); void notifyNodeReparent(const InternalNodePointer &node, const InternalNodeAbstractProperty *newPropertyParent, const InternalNodePointer &oldParent, - const PropertyName &oldPropertyName, + PropertyNameView oldPropertyName, AbstractView::PropertyChangeFlags propertyChange); void notifyNodeAboutToBeRemoved(const InternalNodePointer &node); void notifyNodeRemoved(const InternalNodePointer &removedNode, const InternalNodePointer &parentNode, - const PropertyName &parentPropertyName, + PropertyNameView parentPropertyName, AbstractView::PropertyChangeFlags propertyChange); void notifyNodeIdChanged(const InternalNodePointer &node, const QString &newId, const QString &oldId); void notifyNodeTypeChanged(const InternalNodePointer &node, const TypeName &type, int majorVersion, int minorVersion); @@ -192,7 +192,9 @@ public: void notifySignalDeclarationPropertiesChanged( const QVector &propertyList, 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 notifyNodeOrderChanged(const QmlDesigner::Internal::InternalNodeListProperty *internalListProperty, @@ -260,24 +262,42 @@ public: void notifyUsedImportsChanged(const Imports &usedImportsChanged); //node state property manipulation - void addProperty(const InternalNodePointer &node, const PropertyName &name); - void setPropertyValue(const InternalNodePointer &node,const PropertyName &name, const QVariant &value); + void addProperty(const InternalNodePointer &node, PropertyNameView name); + void setPropertyValue(const InternalNodePointer &node, PropertyNameView name, const QVariant &value); void removePropertyAndRelatedResources(InternalProperty *property); void removeProperty(InternalProperty *property); void removeProperties(const QList &properties); void setBindingProperty(const InternalNodePointer &node, - const PropertyName &name, + PropertyNameView name, const QString &expression); void setBindingProperties(const ModelResourceSet::SetExpressions &setExpressions); - void setSignalHandlerProperty(const InternalNodePointer &node, const PropertyName &name, const QString &source); - void setSignalDeclarationProperty(const InternalNodePointer &node, const PropertyName &name, const QString &signature); - void setVariantProperty(const InternalNodePointer &node, const PropertyName &name, const QVariant &value); - void setDynamicVariantProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &propertyType, const QVariant &value); - void setDynamicBindingProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression); - void reparentNode(const InternalNodePointer &parentNode, const PropertyName &name, const InternalNodePointer &childNode, - bool list = true, const TypeName &dynamicTypeName = TypeName()); - void changeNodeOrder(const InternalNodePointer &parentNode, const PropertyName &listPropertyName, int from, int to); + void setSignalHandlerProperty(const InternalNodePointer &node, + PropertyNameView name, + const QString &source); + void setSignalDeclarationProperty(const InternalNodePointer &node, + PropertyNameView name, + const QString &signature); + void setVariantProperty(const InternalNodePointer &node, + 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); void clearParent(const InternalNodePointer &node); void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion); diff --git a/src/plugins/qmldesigner/designercore/model/modelnode.cpp b/src/plugins/qmldesigner/designercore/model/modelnode.cpp index f483f5ca6b3..f5bce0d96ee 100644 --- a/src/plugins/qmldesigner/designercore/model/modelnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelnode.cpp @@ -338,7 +338,7 @@ bool ModelNode::hasParentProperty() const \return BindingProperty named name */ -BindingProperty ModelNode::bindingProperty(const PropertyName &name) const +BindingProperty ModelNode::bindingProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -346,7 +346,7 @@ BindingProperty ModelNode::bindingProperty(const PropertyName &name) const return BindingProperty(name, m_internalNode, model(), view()); } -SignalHandlerProperty ModelNode::signalHandlerProperty(const PropertyName &name) const +SignalHandlerProperty ModelNode::signalHandlerProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -354,7 +354,7 @@ SignalHandlerProperty ModelNode::signalHandlerProperty(const PropertyName &name) return SignalHandlerProperty(name, m_internalNode, model(), view()); } -SignalDeclarationProperty ModelNode::signalDeclarationProperty(const PropertyName &name) const +SignalDeclarationProperty ModelNode::signalDeclarationProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -372,7 +372,7 @@ SignalDeclarationProperty ModelNode::signalDeclarationProperty(const PropertyNam \return NodeProperty named name */ -NodeProperty ModelNode::nodeProperty(const PropertyName &name) const +NodeProperty ModelNode::nodeProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -390,7 +390,7 @@ NodeProperty ModelNode::nodeProperty(const PropertyName &name) const \return NodeListProperty named name */ -NodeListProperty ModelNode::nodeListProperty(const PropertyName &name) const +NodeListProperty ModelNode::nodeListProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -398,7 +398,7 @@ NodeListProperty ModelNode::nodeListProperty(const PropertyName &name) const return NodeListProperty(name, m_internalNode, model(), view()); } -NodeAbstractProperty ModelNode::nodeAbstractProperty(const PropertyName &name) const +NodeAbstractProperty ModelNode::nodeAbstractProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -431,7 +431,7 @@ NodeProperty ModelNode::defaultNodeProperty() const \return VariantProperty named name */ -VariantProperty ModelNode::variantProperty(const PropertyName &name) const +VariantProperty ModelNode::variantProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -439,7 +439,7 @@ VariantProperty ModelNode::variantProperty(const PropertyName &name) const return VariantProperty(name, m_internalNode, model(), view()); } -AbstractProperty ModelNode::property(const PropertyName &name) const +AbstractProperty ModelNode::property(PropertyNameView name) const { if (!isValid()) return {}; diff --git a/src/plugins/qmldesigner/designercore/model/nodeabstractproperty.cpp b/src/plugins/qmldesigner/designercore/model/nodeabstractproperty.cpp index f131137ae87..66d9974f217 100644 --- a/src/plugins/qmldesigner/designercore/model/nodeabstractproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/nodeabstractproperty.cpp @@ -13,6 +13,8 @@ #include +#include + namespace QmlDesigner { 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) : AbstractProperty(property, model, view) {} @@ -218,12 +215,14 @@ bool operator !=(const NodeAbstractProperty &property1, const NodeAbstractProper 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) { - stream << "NodeAbstractProperty(" << property.name() << ')'; + stream << "NodeAbstractProperty(" << property.name().toByteArray() << ')'; return stream; } diff --git a/src/plugins/qmldesigner/designercore/model/nodelistproperty.cpp b/src/plugins/qmldesigner/designercore/model/nodelistproperty.cpp index 51ca5eb7050..3f9e54bd975 100644 --- a/src/plugins/qmldesigner/designercore/model/nodelistproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/nodelistproperty.cpp @@ -23,14 +23,6 @@ Internal::NodeListPropertyIterator::value_type Internal::NodeListPropertyIterato 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) : NodeAbstractProperty(internalNodeListProperty, model, view) { diff --git a/src/plugins/qmldesigner/designercore/model/nodeproperty.cpp b/src/plugins/qmldesigner/designercore/model/nodeproperty.cpp index 330b7e75e93..e8988c7433e 100644 --- a/src/plugins/qmldesigner/designercore/model/nodeproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/nodeproperty.cpp @@ -10,12 +10,6 @@ namespace QmlDesigner { 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) { if (!isValid()) diff --git a/src/plugins/qmldesigner/designercore/model/signalhandlerproperty.cpp b/src/plugins/qmldesigner/designercore/model/signalhandlerproperty.cpp index fcae441e529..28bceb42a45 100644 --- a/src/plugins/qmldesigner/designercore/model/signalhandlerproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/signalhandlerproperty.cpp @@ -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) { Internal::WriteLocker locker(model()); @@ -56,11 +51,11 @@ QString SignalHandlerProperty::source() const return QString(); } -PropertyName SignalHandlerProperty::prefixAdded(const PropertyName &propertyName) +PropertyName SignalHandlerProperty::prefixAdded(PropertyNameView propertyName) { QString nameAsString = QString::fromUtf8(propertyName); - if (nameAsString.startsWith("on")) - return propertyName; + if (propertyName.startsWith("on")) + return propertyName.toByteArray(); QChar firstChar = nameAsString.at(0).toUpper(); nameAsString[0] = firstChar; @@ -69,11 +64,11 @@ PropertyName SignalHandlerProperty::prefixAdded(const PropertyName &propertyName return nameAsString.toLatin1(); } -PropertyName SignalHandlerProperty::prefixRemoved(const PropertyName &propertyName) +PropertyName SignalHandlerProperty::prefixRemoved(PropertyNameView propertyName) { QString nameAsString = QString::fromUtf8(propertyName); if (!nameAsString.startsWith("on")) - return propertyName; + return propertyName.toByteArray(); nameAsString.remove(0, 2); QChar firstChar = nameAsString.at(0).toLower(); @@ -89,15 +84,6 @@ SignalDeclarationProperty::SignalDeclarationProperty(const SignalDeclarationProp : 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) { Internal::WriteLocker locker(model()); diff --git a/src/plugins/qmldesigner/designercore/model/variantproperty.cpp b/src/plugins/qmldesigner/designercore/model/variantproperty.cpp index 37d52ceb19f..a64f372a8ea 100644 --- a/src/plugins/qmldesigner/designercore/model/variantproperty.cpp +++ b/src/plugins/qmldesigner/designercore/model/variantproperty.cpp @@ -7,7 +7,7 @@ #include "model.h" #include "model_p.h" - +#include 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) { if (!isValid()) @@ -114,7 +109,9 @@ QDebug operator<<(QDebug debug, 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; } diff --git a/src/plugins/qmldesigner/designercore/qmltools/qml3dnode.cpp b/src/plugins/qmldesigner/designercore/qmltools/qml3dnode.cpp index 12befa942f1..05e4bbf2aef 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qml3dnode.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qml3dnode.cpp @@ -39,7 +39,7 @@ bool Qml3DNode::isValidVisualRoot(const ModelNode &modelNode) && (modelNode.metaInfo().isQtQuick3DNode() || modelNode.metaInfo().isQtQuick3DMaterial()); } -bool Qml3DNode::handleEulerRotation(const PropertyName &name) +bool Qml3DNode::handleEulerRotation(PropertyNameView name) { if (isBlocked(name)) return false; @@ -50,7 +50,7 @@ bool Qml3DNode::handleEulerRotation(const PropertyName &name) return true; } -bool Qml3DNode::isBlocked(const PropertyName &propName) const +bool Qml3DNode::isBlocked(PropertyNameView propName) const { if (modelNode().isValid() && propName.startsWith("eulerRotation")) return modelNode().auxiliaryDataWithDefault(rotBlockProperty).toBool(); diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmlanchors.cpp index c717a698174..e43ceeb49bc 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmlanchors.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmlanchors.cpp @@ -12,20 +12,30 @@ namespace QmlDesigner { static PropertyName lineTypeToString(AnchorLineType lineType) { switch (lineType) { - case AnchorLineLeft: return PropertyName("left"); - case AnchorLineTop: return PropertyName("top"); - case AnchorLineRight: return PropertyName("right"); - case AnchorLineBottom: return PropertyName("bottom"); - case AnchorLineHorizontalCenter: return PropertyName("horizontalCenter"); - case AnchorLineVerticalCenter: return PropertyName("verticalCenter"); - case AnchorLineBaseline: return PropertyName("baseline"); - case AnchorLineFill: return PropertyName("fill"); - case AnchorLineCenter: return PropertyName("centerIn"); - default: return PropertyName(); + case AnchorLineLeft: + return QByteArrayLiteral("left"); + case AnchorLineTop: + return QByteArrayLiteral("top"); + case AnchorLineRight: + return QByteArrayLiteral("right"); + case AnchorLineBottom: + return QByteArrayLiteral("bottom"); + case AnchorLineHorizontalCenter: + 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") return AnchorLineLeft; @@ -49,30 +59,52 @@ static AnchorLineType propertyNameToLineType(const PropertyName & name) return AnchorLineInvalid; } -static PropertyName marginPropertyName(AnchorLineType lineType) +static PropertyNameView marginPropertyName(AnchorLineType lineType) { switch (lineType) { - case AnchorLineLeft: return PropertyName("anchors.leftMargin"); - case AnchorLineTop: return PropertyName("anchors.topMargin"); - case AnchorLineRight: return PropertyName("anchors.rightMargin"); - case AnchorLineBottom: return PropertyName("anchors.bottomMargin"); - case AnchorLineHorizontalCenter: return PropertyName("anchors.horizontalCenterOffset"); - case AnchorLineVerticalCenter: return PropertyName("anchors.verticalCenterOffset"); - default: return PropertyName(); + case AnchorLineLeft: + return {"anchors.leftMargin"}; + case AnchorLineTop: + return {"anchors.topMargin"}; + case AnchorLineRight: + return {"anchors.rightMargin"}; + 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); - - if (typeString.isEmpty()) - return PropertyName(); - else - return PropertyName("anchors.") + typeString; + switch (lineType) { + case AnchorLineLeft: + return {"anchors.left"}; + case AnchorLineTop: + return {"anchors.top"}; + 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) { } @@ -95,7 +127,7 @@ bool QmlAnchors::modelHasAnchors() const bool QmlAnchors::modelHasAnchor(AnchorLineType sourceAnchorLineType) const { - const PropertyName propertyName = anchorPropertyName(sourceAnchorLineType); + const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLineType); if (sourceAnchorLineType & AnchorLineFill) return qmlItemNode().modelNode().hasBindingProperty(propertyName) || qmlItemNode().modelNode().hasBindingProperty("anchors.fill"); @@ -117,7 +149,7 @@ AnchorLine QmlAnchors::modelAnchor(AnchorLineType sourceAnchorLineType) const targetAnchorLinePair.first = lineTypeToString(sourceAnchorLineType); } else { AbstractProperty binding = qmlItemNode().modelNode().bindingProperty(anchorPropertyName(sourceAnchorLineType)).resolveToProperty(); - targetAnchorLinePair.first = binding.name(); + targetAnchorLinePair.first = binding.name().toByteArray(); targetAnchorLinePair.second = binding.parentModelNode(); } @@ -146,7 +178,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine, removeAnchor(sourceAnchorLine); } - const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); + const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine); ModelNode targetModelNode = targetQmlItemNode.modelNode(); QString targetExpression = targetModelNode.validId(); if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode()) @@ -296,7 +328,7 @@ void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine) { qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){ if (qmlItemNode().isInBaseState()) { - const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); + const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine); if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) { qmlItemNode().modelNode().removeProperty("anchors.fill"); qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression(QLatin1String("parent.top")); @@ -344,7 +376,7 @@ bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const if (!qmlItemNode().isValid()) return false; - const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); + const PropertyNameView propertyName = anchorPropertyName(sourceAnchorLine); if (sourceAnchorLine & AnchorLineFill) 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 { - PropertyName propertyName = marginPropertyName(sourceAnchorLineType); + PropertyNameView propertyName = marginPropertyName(sourceAnchorLineType); qmlItemNode().setVariantProperty(propertyName, qRound(margin)); } @@ -506,7 +538,7 @@ double QmlAnchors::instanceMargin(AnchorLineType sourceAnchorLineType) const void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType) { if (qmlItemNode().isInBaseState()) { - PropertyName propertyName = marginPropertyName(sourceAnchorLineType); + PropertyNameView propertyName = marginPropertyName(sourceAnchorLineType); qmlItemNode().modelNode().removeProperty(propertyName); } } diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmlchangeset.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmlchangeset.cpp index 134a9a91375..e77656b9672 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmlchangeset.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmlchangeset.cpp @@ -78,7 +78,7 @@ bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &mode return isValidQmlModelNodeFacade(modelNode) && modelNode.metaInfo().isQtQuickStateOperation(); } -void QmlPropertyChanges::removeProperty(const PropertyName &name) +void QmlPropertyChanges::removeProperty(PropertyNameView name) { RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("QmlPropertyChanges::removeProperty"))); if (name == "name") diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmlitemnode.cpp index 6e3b739096f..eb1b2329af3 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmlitemnode.cpp @@ -1009,7 +1009,7 @@ ModelNode QmlFlowViewNode::createTransition() return transition; } -QList QmlFlowViewNode::transitionsForProperty(const PropertyName &propertyName, +QList QmlFlowViewNode::transitionsForProperty(PropertyNameView propertyName, const ModelNode &modelNode) { QList list; diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmlobjectnode.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmlobjectnode.cpp index 45bfabbf7f6..a4153fc4464 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmlobjectnode.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmlobjectnode.cpp @@ -30,7 +30,7 @@ namespace QmlDesigner { -void QmlObjectNode::setVariantProperty(const PropertyName &name, const QVariant &value) +void QmlObjectNode::setVariantProperty(PropertyNameView name, const QVariant &value) { if (!isValid()) return; @@ -77,7 +77,7 @@ void QmlObjectNode::setVariantProperty(const PropertyName &name, const QVariant } } -void QmlObjectNode::setBindingProperty(const PropertyName &name, const QString &expression) +void QmlObjectNode::setBindingProperty(PropertyNameView name, const QString &expression) { if (!isValid()) return; @@ -123,13 +123,12 @@ bool QmlObjectNode::isRootModelNode() const actual instance. The return value is not the value in the model, but the value of a real instantiated instance of this object. */ -QVariant QmlObjectNode::instanceValue(const PropertyName &name) const +QVariant QmlObjectNode::instanceValue(PropertyNameView name) const { return nodeInstance().property(name); } - -bool QmlObjectNode::hasProperty(const PropertyName &name) const +bool QmlObjectNode::hasProperty(PropertyNameView name) const { if (!isValid()) return false; @@ -143,7 +142,7 @@ bool QmlObjectNode::hasProperty(const PropertyName &name) const return modelNode().hasProperty(name); } -bool QmlObjectNode::hasBindingProperty(const PropertyName &name) const +bool QmlObjectNode::hasBindingProperty(PropertyNameView name) const { if (!isValid()) return false; @@ -157,7 +156,7 @@ bool QmlObjectNode::hasBindingProperty(const PropertyName &name) const return modelNode().hasBindingProperty(name); } -NodeAbstractProperty QmlObjectNode::nodeAbstractProperty(const PropertyName &name) const +NodeAbstractProperty QmlObjectNode::nodeAbstractProperty(PropertyNameView name) const { return modelNode().nodeAbstractProperty(name); } @@ -167,22 +166,22 @@ NodeAbstractProperty QmlObjectNode::defaultNodeAbstractProperty() const return modelNode().defaultNodeAbstractProperty(); } -NodeProperty QmlObjectNode::nodeProperty(const PropertyName &name) const +NodeProperty QmlObjectNode::nodeProperty(PropertyNameView name) const { return modelNode().nodeProperty(name); } -NodeListProperty QmlObjectNode::nodeListProperty(const PropertyName &name) const +NodeListProperty QmlObjectNode::nodeListProperty(PropertyNameView name) const { return modelNode().nodeListProperty(name); } -bool QmlObjectNode::instanceHasValue(const PropertyName &name) const +bool QmlObjectNode::instanceHasValue(PropertyNameView name) const { return nodeInstance().hasProperty(name); } -bool QmlObjectNode::propertyAffectedByCurrentState(const PropertyName &name) const +bool QmlObjectNode::propertyAffectedByCurrentState(PropertyNameView name) const { if (!isValid()) return false; @@ -199,7 +198,7 @@ bool QmlObjectNode::propertyAffectedByCurrentState(const PropertyName &name) con return currentState().propertyChanges(modelNode()).modelNode().hasProperty(name); } -QVariant QmlObjectNode::modelValue(const PropertyName &name) const +QVariant QmlObjectNode::modelValue(PropertyNameView name) const { if (!isValid()) return false; @@ -233,7 +232,7 @@ QVariant QmlObjectNode::modelValue(const PropertyName &name) const return propertyChanges.modelNode().variantProperty(name).value(); } -bool QmlObjectNode::isTranslatableText(const PropertyName &name) const +bool QmlObjectNode::isTranslatableText(PropertyNameView name) const { if (modelNode().metaInfo().isValid() && modelNode().metaInfo().hasProperty(name) && modelNode().metaInfo().property(name).propertyType().isString()) { @@ -249,7 +248,7 @@ bool QmlObjectNode::isTranslatableText(const PropertyName &name) const return false; } -QString QmlObjectNode::stripedTranslatableText(const PropertyName &name) const +QString QmlObjectNode::stripedTranslatableText(PropertyNameView name) const { if (modelNode().hasBindingProperty(name)) { static QRegularExpression regularExpressionPattern( @@ -263,7 +262,7 @@ QString QmlObjectNode::stripedTranslatableText(const PropertyName &name) const return instanceValue(name).toString(); } -BindingProperty QmlObjectNode::bindingProperty(const PropertyName &name) const +BindingProperty QmlObjectNode::bindingProperty(PropertyNameView name) const { if (!isValid()) return {}; @@ -282,7 +281,7 @@ BindingProperty QmlObjectNode::bindingProperty(const PropertyName &name) const return propertyChanges.modelNode().bindingProperty(name); } -QString QmlObjectNode::expression(const PropertyName &name) const +QString QmlObjectNode::expression(PropertyNameView name) const { return bindingProperty(name).expression(); } @@ -487,7 +486,7 @@ QList QmlObjectNode::getAllConnections() const model. */ -void QmlObjectNode::removeProperty(const PropertyName &name) +void QmlObjectNode::removeProperty(PropertyNameView name) { if (!isValid()) return; @@ -528,7 +527,7 @@ bool QmlObjectNode::isAncestorOf(const QmlObjectNode &objectNode) const return modelNode().isAncestorOf(objectNode.modelNode()); } -QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, const PropertyName &name) +QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, PropertyNameView name) { Q_ASSERT(modelNode.view()->nodeInstanceView()->hasInstanceForModelNode(modelNode)); return modelNode.view()->nodeInstanceView()->instanceForModelNode(modelNode).property(name); @@ -569,12 +568,12 @@ QString QmlObjectNode::convertToCorrectTranslatableFunction(const QString &text, return generateTranslatableText(stripedTranslatableTextFunction(text), designerSettings); } -TypeName QmlObjectNode::instanceType(const PropertyName &name) const +TypeName QmlObjectNode::instanceType(PropertyNameView name) const { return nodeInstance().instanceType(name); } -bool QmlObjectNode::instanceHasBinding(const PropertyName &name) const +bool QmlObjectNode::instanceHasBinding(PropertyNameView name) const { return nodeInstance().hasBindingForProperty(name); } diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmltextgenerator.cpp index 921f838ff90..e332feba19a 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmltextgenerator.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmltextgenerator.cpp @@ -38,7 +38,7 @@ static bool isLowPrecisionProperties(PropertyNameView property) return std::find(std::begin(properties), std::end(properties), property) != std::end(properties); } -static QString doubleToString(const PropertyName &propertyName, double d) +static QString doubleToString(PropertyNameView propertyName, double d) { int precision = 5; if (propertyName.contains("anchors") || propertyName.contains("font") diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmltimeline.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmltimeline.cpp index ae0f675d793..85c4db30c5f 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmltimeline.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmltimeline.cpp @@ -41,7 +41,8 @@ void QmlTimeline::destroy() modelNode().destroy(); } -QmlTimelineKeyframeGroup QmlTimeline::keyframeGroup(const ModelNode &node, const PropertyName &propertyName) +QmlTimelineKeyframeGroup QmlTimeline::keyframeGroup(const ModelNode &node, + PropertyNameView propertyName) { if (isValid()) { addKeyframeGroupIfNotExists(node, propertyName); @@ -60,7 +61,7 @@ QmlTimelineKeyframeGroup QmlTimeline::keyframeGroup(const ModelNode &node, const return QmlTimelineKeyframeGroup(); //not found } -bool QmlTimeline::hasTimeline(const ModelNode &node, const PropertyName &propertyName) +bool QmlTimeline::hasTimeline(const ModelNode &node, PropertyNameView propertyName) { if (isValid()) { for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) { @@ -185,7 +186,7 @@ void QmlTimeline::destroyKeyframesForTarget(const ModelNode &target) } void QmlTimeline::removeKeyframesForTargetAndProperty(const ModelNode &target, - const PropertyName &propertyName) + PropertyNameView propertyName) { for (QmlTimelineKeyframeGroup frames : keyframeGroupsForTarget(target)) { if (frames.propertyName() == propertyName) @@ -236,7 +237,7 @@ void QmlTimeline::resetGroupRecording() const } } -void QmlTimeline::addKeyframeGroupIfNotExists(const ModelNode &node, const PropertyName &propertyName) +void QmlTimeline::addKeyframeGroupIfNotExists(const ModelNode &node, PropertyNameView propertyName) { if (!isValid()) return; @@ -253,8 +254,7 @@ void QmlTimeline::addKeyframeGroupIfNotExists(const ModelNode &node, const Prope } } - -bool QmlTimeline::hasKeyframeGroup(const ModelNode &node, const PropertyName &propertyName) const +bool QmlTimeline::hasKeyframeGroup(const ModelNode &node, PropertyNameView propertyName) const { for (const QmlTimelineKeyframeGroup &frames : allKeyframeGroups()) { if (frames.target().isValid() @@ -279,7 +279,7 @@ bool QmlTimeline::hasKeyframeGroupForTarget(const ModelNode &node) const return false; } -void QmlTimeline::insertKeyframe(const ModelNode &target, const PropertyName &propertyName) +void QmlTimeline::insertKeyframe(const ModelNode &target, PropertyNameView propertyName) { ModelNode targetNode = target; QmlTimelineKeyframeGroup timelineFrames(keyframeGroup(targetNode, propertyName)); diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmltimelinekeyframegroup.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmltimelinekeyframegroup.cpp index 7cee6095bb4..c692ccaed04 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmltimelinekeyframegroup.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmltimelinekeyframegroup.cpp @@ -57,7 +57,7 @@ PropertyName QmlTimelineKeyframeGroup::propertyName() const return modelNode().variantProperty("property").value().toString().toUtf8(); } -void QmlTimelineKeyframeGroup::setPropertyName(const PropertyName &propertyName) +void QmlTimelineKeyframeGroup::setPropertyName(PropertyNameView propertyName) { modelNode().variantProperty("property").setValue(QString::fromUtf8(propertyName)); } diff --git a/src/plugins/qmldesigner/designercore/qmltools/qmlvisualnode.cpp b/src/plugins/qmldesigner/designercore/qmltools/qmlvisualnode.cpp index 61f13157a96..5e919a40c9b 100644 --- a/src/plugins/qmldesigner/designercore/qmltools/qmlvisualnode.cpp +++ b/src/plugins/qmldesigner/designercore/qmltools/qmlvisualnode.cpp @@ -206,7 +206,7 @@ void QmlVisualNode::translate(const QVector3D &vector) setPosition(position() + vector); } -void QmlVisualNode::setDoubleProperty(const PropertyName &name, double value) +void QmlVisualNode::setDoubleProperty(PropertyNameView name, double value) { modelNode().variantProperty(name).setValue(value); } @@ -389,7 +389,7 @@ QmlObjectNode QmlVisualNode::createQmlObjectNode(AbstractView *view, } if (parentProperty.isValid()) { - const PropertyName propertyName = parentProperty.name(); + const PropertyNameView propertyName = parentProperty.name(); const ModelNode parentNode = parentProperty.parentModelNode(); const NodeMetaInfo metaInfo = parentNode.metaInfo(); diff --git a/src/plugins/qmldesigner/designercore/rewriter/rewriteaction.cpp b/src/plugins/qmldesigner/designercore/rewriter/rewriteaction.cpp index 3d301488612..94d5e905aa2 100644 --- a/src/plugins/qmldesigner/designercore/rewriter/rewriteaction.cpp +++ b/src/plugins/qmldesigner/designercore/rewriter/rewriteaction.cpp @@ -8,6 +8,8 @@ #include "nodelistproperty.h" #include "nodemetainfo.h" +#include + using namespace QmlDesigner; using namespace QmlDesigner::Internal; using namespace QmlDesigner; @@ -287,7 +289,7 @@ bool ReparentNodeRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePo const bool isArrayBinding = m_targetProperty.isNodeListProperty(); bool result = false; - PropertyName targetPropertyName; + PropertyNameView targetPropertyName; if (!m_targetProperty.isDefaultProperty()) targetPropertyName = m_targetProperty.name(); diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp index 0d5f65cf8d2..8530743d5fb 100644 --- a/src/plugins/qmldesigner/documentmanager.cpp +++ b/src/plugins/qmldesigner/documentmanager.cpp @@ -41,12 +41,13 @@ namespace QmlDesigner { Q_LOGGING_CATEGORY(documentManagerLog, "qtc.qtquickdesigner.documentmanager", QtWarningMsg) -inline static QmlDesigner::DesignDocument *designDocument() +namespace { +QmlDesigner::DesignDocument *designDocument() { return QmlDesigner::QmlDesignerPlugin::instance()->documentManager().currentDesignDocument(); } -inline static QHash getProperties(const ModelNode &node) +QHash getProperties(const ModelNode &node) { QHash propertyHash; if (QmlObjectNode::isValidQmlObjectNode(node)) { @@ -55,7 +56,8 @@ inline static QHash getProperties(const ModelNode &node) if (abstractProperty.isVariantProperty() || (abstractProperty.isBindingProperty() && !abstractProperty.name().contains("anchors."))) - propertyHash.insert(abstractProperty.name(), QmlObjectNode(node).instanceValue(abstractProperty.name())); + propertyHash.insert(abstractProperty.name().toByteArray(), + QmlObjectNode(node).instanceValue(abstractProperty.name())); } if (QmlItemNode::isValidQmlItemNode(node)) { @@ -73,7 +75,7 @@ inline static QHash getProperties(const ModelNode &node) return propertyHash; } -inline static void applyProperties(ModelNode &node, const QHash &propertyHash) +void applyProperties(ModelNode &node, const QHash &propertyHash) { const auto auxiliaryData = node.auxiliaryData(AuxiliaryDataType::NodeInstancePropertyOverwrite); for (const auto &element : auxiliaryData) @@ -94,7 +96,7 @@ inline static void applyProperties(ModelNode &node, const QHashviewManager().nextFileIsCalledInternally(); Core::EditorManager::openEditor(FilePath::fromString(fileName), @@ -102,17 +104,17 @@ static void openFileComponentForFile(const QString &fileName) Core::EditorManager::DoNotMakeVisible); } -static void openFileComponent(const ModelNode &modelNode) +void openFileComponent(const ModelNode &modelNode) { openFileComponentForFile(ModelUtils::componentFilePath(modelNode)); } -static void openFileComponentForDelegate(const ModelNode &modelNode) +void openFileComponentForDelegate(const ModelNode &modelNode) { openFileComponent(modelNode.nodeProperty("delegate").modelNode()); } -static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode) +void openComponentSourcePropertyOfLoader(const ModelNode &modelNode) { QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally(); @@ -136,7 +138,7 @@ static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode) Core::EditorManager::DoNotMakeVisible); } -static void openSourcePropertyOfLoader(const ModelNode &modelNode) +void openSourcePropertyOfLoader(const ModelNode &modelNode) { QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally(); @@ -149,14 +151,13 @@ static void openSourcePropertyOfLoader(const ModelNode &modelNode) Core::EditorManager::DoNotMakeVisible); } - -static void handleComponent(const ModelNode &modelNode) +void handleComponent(const ModelNode &modelNode) { if (modelNode.nodeSourceType() == ModelNode::NodeWithComponentSource) designDocument()->changeToSubComponent(modelNode); } -static void handleDelegate(const ModelNode &modelNode) +void handleDelegate(const ModelNode &modelNode) { if (modelNode.metaInfo().isView() && modelNode.hasNodeProperty("delegate") @@ -164,7 +165,7 @@ static void handleDelegate(const ModelNode &modelNode) designDocument()->changeToSubComponent(modelNode.nodeProperty("delegate").modelNode()); } -static void handleTabComponent(const ModelNode &modelNode) +void handleTabComponent(const ModelNode &modelNode) { if (modelNode.hasNodeProperty("component") && modelNode.nodeProperty("component").modelNode().nodeSourceType() == ModelNode::NodeWithComponentSource) { @@ -172,7 +173,7 @@ static void handleTabComponent(const ModelNode &modelNode) } } -inline static void openInlineComponent(const ModelNode &modelNode) +void openInlineComponent(const ModelNode &modelNode) { if (!modelNode.metaInfo().isValid()) return; @@ -182,7 +183,7 @@ inline static void openInlineComponent(const ModelNode &modelNode) handleTabComponent(modelNode); } -static bool isFileComponent(const ModelNode &node) +bool isFileComponent(const ModelNode &node) { if (node.isValid() && node.metaInfo().isValid() @@ -192,7 +193,7 @@ static bool isFileComponent(const ModelNode &node) return false; } -static bool hasDelegateWithFileComponent(const ModelNode &node) +bool hasDelegateWithFileComponent(const ModelNode &node) { if (node.isValid() && node.metaInfo().isValid() @@ -204,7 +205,7 @@ static bool hasDelegateWithFileComponent(const ModelNode &node) return false; } -static bool isLoaderWithSourceComponent(const ModelNode &modelNode) +bool isLoaderWithSourceComponent(const ModelNode &modelNode) { if (modelNode.isValid() && modelNode.metaInfo().isQtQuickLoader()) { if (modelNode.hasNodeProperty("sourceComponent")) @@ -216,7 +217,7 @@ static bool isLoaderWithSourceComponent(const ModelNode &modelNode) return false; } -static bool hasSourceWithFileComponent(const ModelNode &modelNode) +bool hasSourceWithFileComponent(const ModelNode &modelNode) { if (modelNode.isValid() && modelNode.metaInfo().isQtQuickLoader() && modelNode.hasVariantProperty("source")) @@ -225,6 +226,8 @@ static bool hasSourceWithFileComponent(const ModelNode &modelNode) return false; } +} // namespace + void DocumentManager::setCurrentDesignDocument(Core::IEditor *editor) { if (editor) { diff --git a/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp b/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp index f75e30cbdfe..7b63452c11c 100644 --- a/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp +++ b/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp @@ -29,16 +29,6 @@ static bool isMultilanguagePresent() != specs.cend(); } -static FilePath getMultilanguageDatabaseFilePath(ProjectExplorer::Target *target) -{ - if (target) { - auto filePath = target->project()->projectDirectory().pathAppended("translations.db"); - if (filePath.exists()) - return filePath; - } - return {}; -} - static QObject *getPlugin(const QString &pluginName) { const ExtensionSystem::PluginSpecs &specs = ExtensionSystem::PluginManager::plugins(); diff --git a/tests/unit/tests/printers/gtest-creator-printing.cpp b/tests/unit/tests/printers/gtest-creator-printing.cpp index 0a1f8708032..f329f5d452d 100644 --- a/tests/unit/tests/printers/gtest-creator-printing.cpp +++ b/tests/unit/tests/printers/gtest-creator-printing.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace std { template ostream &operator<<(ostream &out, const QVector &vector) { diff --git a/tests/unit/tests/printers/gtest-qt-printing.cpp b/tests/unit/tests/printers/gtest-qt-printing.cpp index f432d87398c..970eae8fd96 100644 --- a/tests/unit/tests/printers/gtest-qt-printing.cpp +++ b/tests/unit/tests/printers/gtest-qt-printing.cpp @@ -12,10 +12,10 @@ QT_BEGIN_NAMESPACE -std::ostream &operator<<(std::ostream &out, const QByteArray &byteArray) +std::ostream &operator<<(std::ostream &out, QByteArrayView byteArray) { if (byteArray.contains('\n')) { - QByteArray formattedArray = byteArray; + QByteArray formattedArray = byteArray.toByteArray(); formattedArray.replace("\n", "\n\t"); out << "\n\t"; out.write(formattedArray.data(), formattedArray.size()); @@ -28,6 +28,11 @@ std::ostream &operator<<(std::ostream &out, const QByteArray &byteArray) return out; } +std::ostream &operator<<(std::ostream &out, const QByteArray &byteArray) +{ + return out << QByteArrayView{byteArray}; +} + std::ostream &operator<<(std::ostream &out, const QString &text) { return out << text.toUtf8(); diff --git a/tests/unit/tests/printers/gtest-qt-printing.h b/tests/unit/tests/printers/gtest-qt-printing.h index 97e6822a7bd..a81994be167 100644 --- a/tests/unit/tests/printers/gtest-qt-printing.h +++ b/tests/unit/tests/printers/gtest-qt-printing.h @@ -39,6 +39,7 @@ std::ostream &operator<<(std::ostream &out, const QVariant &QVariant); std::ostream &operator<<(std::ostream &out, const QString &text); std::ostream &operator<<(std::ostream &out, QStringView text); std::ostream &operator<<(std::ostream &out, const QByteArray &byteArray); +std::ostream &operator<<(std::ostream &out, QByteArrayView byteArray); std::ostream &operator<<(std::ostream &out, const QTextCharFormat &format); std::ostream &operator<<(std::ostream &out, const QImage &image); std::ostream &operator<<(std::ostream &out, const QIcon &icon);