From fe5848a47c6de9ca1f87593e047202f59649a8de Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sat, 20 Aug 2022 13:43:05 +0200 Subject: [PATCH] QmlDesigner: Use view instead of const & A span of constant elements is a view. Change-Id: I4fad60673bc2ba98491dfffb7c854beeeb0ae12b Reviewed-by: Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/components/debugview/debugview.cpp | 5 +++-- src/plugins/qmldesigner/designercore/include/auxiliarydata.h | 2 ++ src/plugins/qmldesigner/designercore/include/modelnode.h | 2 +- src/plugins/qmldesigner/designercore/model/internalnode_p.h | 2 +- src/plugins/qmldesigner/designercore/model/modelnode.cpp | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/qmldesigner/components/debugview/debugview.cpp b/src/plugins/qmldesigner/components/debugview/debugview.cpp index 86899d4373c..3c3147b56c1 100644 --- a/src/plugins/qmldesigner/components/debugview/debugview.cpp +++ b/src/plugins/qmldesigner/components/debugview/debugview.cpp @@ -313,11 +313,12 @@ void DebugView::selectedNodesChanged(const QList &selectedNodes /*sel } auto auxiliaryData = selectedNode.auxiliaryData(); + AuxiliaryDatas sortedaAuxiliaryData{auxiliaryData.begin(), auxiliaryData.end()}; - Utils::sort(auxiliaryData, [](const auto &first, const auto &second) { + Utils::sort(sortedaAuxiliaryData, [](const auto &first, const auto &second) { return first.first < second.first; }); - for (const auto &element : auxiliaryData) { + for (const auto &element : sortedaAuxiliaryData) { message << element.first.type << ' ' << element.first.name.data() << ' ' << element.second.toString() << lineBreak; } diff --git a/src/plugins/qmldesigner/designercore/include/auxiliarydata.h b/src/plugins/qmldesigner/designercore/include/auxiliarydata.h index 7c45d547600..176144062d2 100644 --- a/src/plugins/qmldesigner/designercore/include/auxiliarydata.h +++ b/src/plugins/qmldesigner/designercore/include/auxiliarydata.h @@ -28,6 +28,7 @@ #include #include +#include #include @@ -75,5 +76,6 @@ bool operator!=(const BasicAuxiliaryDataKey &first, const BasicAuxiliaryD using AuxiliaryDataKey = BasicAuxiliaryDataKey; using AuxiliaryDataKeyView = BasicAuxiliaryDataKey; using AuxiliaryDatas = std::vector>; +using AuxiliaryDatasView = Utils::span>; using AuxiliaryDatasForType = std::vector>; } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/modelnode.h b/src/plugins/qmldesigner/designercore/include/modelnode.h index c46cdd8f208..22b2afc1a62 100644 --- a/src/plugins/qmldesigner/designercore/include/modelnode.h +++ b/src/plugins/qmldesigner/designercore/include/modelnode.h @@ -214,7 +214,7 @@ public: bool hasAuxiliaryData(AuxiliaryDataKeyView key) const; bool hasAuxiliaryData(AuxiliaryDataType type, Utils::SmallStringView name) const; AuxiliaryDatasForType auxiliaryData(AuxiliaryDataType type) const; - const AuxiliaryDatas &auxiliaryData() const; + AuxiliaryDatasView auxiliaryData() const; QString customId() const; bool hasCustomId() const; diff --git a/src/plugins/qmldesigner/designercore/model/internalnode_p.h b/src/plugins/qmldesigner/designercore/model/internalnode_p.h index a0ec885aefd..19f039c406f 100644 --- a/src/plugins/qmldesigner/designercore/model/internalnode_p.h +++ b/src/plugins/qmldesigner/designercore/model/internalnode_p.h @@ -87,7 +87,7 @@ public: bool removeAuxiliaryData(AuxiliaryDataKeyView key); bool hasAuxiliaryData(AuxiliaryDataKeyView key) const; AuxiliaryDatasForType auxiliaryData(AuxiliaryDataType type) const; - const AuxiliaryDatas &auxiliaryData() const { return m_auxiliaryDatas; } + AuxiliaryDatasView auxiliaryData() const { return std::as_const(m_auxiliaryDatas); } InternalProperty::Pointer property(const PropertyName &name) const; InternalBindingProperty::Pointer bindingProperty(const PropertyName &name) const; diff --git a/src/plugins/qmldesigner/designercore/model/modelnode.cpp b/src/plugins/qmldesigner/designercore/model/modelnode.cpp index 29c48d4e3ba..9e1ab497eb3 100644 --- a/src/plugins/qmldesigner/designercore/model/modelnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelnode.cpp @@ -1136,7 +1136,7 @@ AuxiliaryDatasForType ModelNode::auxiliaryData(AuxiliaryDataType type) const return m_internalNode->auxiliaryData(type); } -const AuxiliaryDatas &ModelNode::auxiliaryData() const +AuxiliaryDatasView ModelNode::auxiliaryData() const { if (!isValid()) throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);