diff --git a/src/plugins/qmldesigner/libs/designercore/include/abstractview.h b/src/plugins/qmldesigner/libs/designercore/include/abstractview.h index aace9320aa1..0a684162f4d 100644 --- a/src/plugins/qmldesigner/libs/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/libs/designercore/include/abstractview.h @@ -225,11 +225,11 @@ public: void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion); void emitCustomNotification(const QString &identifier, - const QList &nodeList = {}, + Utils::span nodes = {}, const QList &data = {}) { if (isAttached()) - model()->emitCustomNotification(this, identifier, nodeList, data); + model()->emitCustomNotification(this, identifier, nodes, data); } const AbstractView *nodeInstanceView() const; diff --git a/src/plugins/qmldesigner/libs/designercore/include/model.h b/src/plugins/qmldesigner/libs/designercore/include/model.h index 262b2078283..fe4c5b74a55 100644 --- a/src/plugins/qmldesigner/libs/designercore/include/model.h +++ b/src/plugins/qmldesigner/libs/designercore/include/model.h @@ -266,7 +266,7 @@ public: const QList &warnings); QList selectedNodes(AbstractView *view) const; - void setSelectedModelNodes(const QList &selectedNodeList); + void setSelectedModelNodes(Utils::span selectedNodes); void clearMetaInfoCache(); @@ -291,14 +291,14 @@ public: ProjectStorageDependencies projectStorageDependencies() const; void emitInstancePropertyChange(AbstractView *view, - const QList> &propertyList); - void emitInstanceErrorChange(AbstractView *view, const QVector &instanceIds); - void emitInstancesCompleted(AbstractView *view, const QVector &nodeList); + Utils::span> properties); + void emitInstanceErrorChange(AbstractView *view, Utils::span instanceIds); + void emitInstancesCompleted(AbstractView *view, Utils::span nodes); void emitInstanceInformationsChange( AbstractView *view, const QMultiHash &informationChangeHash); - void emitInstancesRenderImageChanged(AbstractView *view, const QVector &nodeList); - void emitInstancesPreviewImageChanged(AbstractView *view, const QVector &nodeList); - void emitInstancesChildrenChanged(AbstractView *view, const QVector &nodeList); + void emitInstancesRenderImageChanged(AbstractView *view, Utils::span nodes); + void emitInstancesPreviewImageChanged(AbstractView *view, Utils::span nodes); + void emitInstancesChildrenChanged(AbstractView *view, Utils::span nodes); void emitInstanceToken(AbstractView *view, const QString &token, int number, @@ -318,7 +318,7 @@ public: void emitDocumentMessage(const QString &error); void emitCustomNotification(AbstractView *view, const QString &identifier, - const QList &nodeList = {}, + Utils::span nodes = {}, const QList &data = {}); void sendCustomNotificationTo(AbstractView *to, const CustomNotificationPackage &package); diff --git a/src/plugins/qmldesigner/libs/designercore/model/model.cpp b/src/plugins/qmldesigner/libs/designercore/model/model.cpp index 9e1b6959c59..31ae2875df6 100644 --- a/src/plugins/qmldesigner/libs/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/libs/designercore/model/model.cpp @@ -664,12 +664,12 @@ void ModelPrivate::notifyRootNodeTypeChanged(const QString &type, int majorVersi [&](AbstractView *view) { view->rootNodeTypeChanged(type, majorVersion, minorVersion); }); } -void ModelPrivate::notifyInstancePropertyChange(const QList> &propertyPairList) +void ModelPrivate::notifyInstancePropertyChange(Utils::span> properties) { notifyInstanceChanges([&](AbstractView *view) { using ModelNodePropertyPair = QPair; QList> adaptedPropertyList; - for (const ModelNodePropertyPair &propertyPair : propertyPairList) { + for (const ModelNodePropertyPair &propertyPair : properties) { ModelNodePropertyPair newPair(ModelNode{propertyPair.first.internalNode(), m_model, view}, propertyPair.second); adaptedPropertyList.append(newPair); } @@ -677,20 +677,20 @@ void ModelPrivate::notifyInstancePropertyChange(const QList &instanceIds) +void ModelPrivate::notifyInstanceErrorChange(Utils::span instanceIds) { notifyInstanceChanges([&](AbstractView *view) { QVector errorNodeList; - errorNodeList.reserve(instanceIds.size()); + errorNodeList.reserve(std::ssize(instanceIds)); for (qint32 instanceId : instanceIds) errorNodeList.emplace_back(m_model->d->nodeForInternalId(instanceId), m_model, view); view->instanceErrorChanged(errorNodeList); }); } -void ModelPrivate::notifyInstancesCompleted(const QVector &modelNodeVector) +void ModelPrivate::notifyInstancesCompleted(Utils::span modelNodes) { - auto internalNodes = toInternalNodeList(modelNodeVector); + auto internalNodes = toInternalNodeList(modelNodes); notifyInstanceChanges([&](AbstractView *view) { view->instancesCompleted(toModelNodeList(internalNodes, view)); @@ -718,27 +718,27 @@ void ModelPrivate::notifyInstancesInformationsChange( }); } -void ModelPrivate::notifyInstancesRenderImageChanged(const QVector &modelNodeVector) +void ModelPrivate::notifyInstancesRenderImageChanged(Utils::span nodes) { - auto internalNodes = toInternalNodeList(modelNodeVector); + auto internalNodes = toInternalNodeList(nodes); notifyInstanceChanges([&](AbstractView *view) { view->instancesRenderImageChanged(toModelNodeList(internalNodes, view)); }); } -void ModelPrivate::notifyInstancesPreviewImageChanged(const QVector &modelNodeVector) +void ModelPrivate::notifyInstancesPreviewImageChanged(Utils::span nodes) { - auto internalNodes = toInternalNodeList(modelNodeVector); + auto internalNodes = toInternalNodeList(nodes); notifyInstanceChanges([&](AbstractView *view) { view->instancesPreviewImageChanged(toModelNodeList(internalNodes, view)); }); } -void ModelPrivate::notifyInstancesChildrenChanged(const QVector &modelNodeVector) +void ModelPrivate::notifyInstancesChildrenChanged(Utils::span nodes) { - auto internalNodes = toInternalNodeList(modelNodeVector); + auto internalNodes = toInternalNodeList(nodes); notifyInstanceChanges([&](AbstractView *view) { view->instancesChildrenChanged(toModelNodeList(internalNodes, view)); @@ -812,10 +812,11 @@ void ModelPrivate::notifyRewriterEndTransaction() notifyNodeInstanceViewLast([&](AbstractView *view) { view->rewriterEndTransaction(); }); } -void ModelPrivate::notifyInstanceToken(const QString &token, int number, - const QVector &modelNodeVector) +void ModelPrivate::notifyInstanceToken(const QString &token, + int number, + Utils::span nodes) { - auto internalNodes = toInternalNodeList(modelNodeVector); + auto internalNodes = toInternalNodeList(nodes); notifyInstanceChanges([&](AbstractView *view) { view->instancesToken(token, number, toModelNodeList(internalNodes, view)); @@ -824,10 +825,10 @@ void ModelPrivate::notifyInstanceToken(const QString &token, int number, void ModelPrivate::notifyCustomNotification(const AbstractView *senderView, const QString &identifier, - const QList &modelNodeList, + Utils::span nodes, const QList &data) { - auto internalList = toInternalNodeList(modelNodeList); + auto internalList = toInternalNodeList(nodes); notifyNodeInstanceViewLast([&](AbstractView *view) { view->customNotification(senderView, identifier, toModelNodeList(internalList, view), data); }); @@ -1229,22 +1230,22 @@ void ModelPrivate::removeAuxiliaryData(const InternalNodePointer &node, const Au notifyAuxiliaryDataChanged(node, key, QVariant()); } -QList ModelPrivate::toModelNodeList(Utils::span nodeList, +QList ModelPrivate::toModelNodeList(Utils::span nodes, AbstractView *view) const { QList modelNodeList; - modelNodeList.reserve(nodeList.size()); - for (const InternalNodePointer &node : nodeList) + modelNodeList.reserve(std::ssize(nodes)); + for (const InternalNodePointer &node : nodes) modelNodeList.emplace_back(node, m_model, view); return modelNodeList; } -ModelPrivate::ManyNodes ModelPrivate::toInternalNodeList(const QList &modelNodeList) const +ModelPrivate::ManyNodes ModelPrivate::toInternalNodeList(Utils::span modelNodes) const { ManyNodes newNodeList; - newNodeList.reserve(modelNodeList.size()); - for (const ModelNode &modelNode : modelNodeList) + newNodeList.reserve(std::ssize(modelNodes)); + for (const ModelNode &modelNode : modelNodes) newNodeList.append(modelNode.internalNode()); return newNodeList; @@ -1813,7 +1814,7 @@ QmlDesigner::Imports createPossibleFileImports(const Utils::FilePath &path) bool append = false; item.iterateDirectory( - [&](const Utils::FilePath &item) { + [&](const Utils::FilePath &) { append = true; return Utils::IterationPolicy::Stop; }, @@ -2062,22 +2063,22 @@ ProjectStorageDependencies Model::projectStorageDependencies() const } void Model::emitInstancePropertyChange(AbstractView *view, - const QList> &propertyList) + Utils::span> properties) { if (d->nodeInstanceView() == view) // never remove check - d->notifyInstancePropertyChange(propertyList); + d->notifyInstancePropertyChange(properties); } -void Model::emitInstanceErrorChange(AbstractView *view, const QVector &instanceIds) +void Model::emitInstanceErrorChange(AbstractView *view, Utils::span instanceIds) { if (d->nodeInstanceView() == view) // never remove check d->notifyInstanceErrorChange(instanceIds); } -void Model::emitInstancesCompleted(AbstractView *view, const QVector &nodeVector) +void Model::emitInstancesCompleted(AbstractView *view, Utils::span nodes) { if (d->nodeInstanceView() == view) // never remove check - d->notifyInstancesCompleted(nodeVector); + d->notifyInstancesCompleted(nodes); } void Model::emitInstanceInformationsChange( @@ -2087,22 +2088,22 @@ void Model::emitInstanceInformationsChange( d->notifyInstancesInformationsChange(informationChangeHash); } -void Model::emitInstancesRenderImageChanged(AbstractView *view, const QVector &nodeVector) +void Model::emitInstancesRenderImageChanged(AbstractView *view, Utils::span nodes) { if (d->nodeInstanceView() == view) // never remove check - d->notifyInstancesRenderImageChanged(nodeVector); + d->notifyInstancesRenderImageChanged(nodes); } -void Model::emitInstancesPreviewImageChanged(AbstractView *view, const QVector &nodeVector) +void Model::emitInstancesPreviewImageChanged(AbstractView *view, Utils::span nodes) { if (d->nodeInstanceView() == view) // never remove check - d->notifyInstancesPreviewImageChanged(nodeVector); + d->notifyInstancesPreviewImageChanged(nodes); } -void Model::emitInstancesChildrenChanged(AbstractView *view, const QVector &nodeVector) +void Model::emitInstancesChildrenChanged(AbstractView *view, Utils::span nodes) { if (d->nodeInstanceView() == view) // never remove check - d->notifyInstancesChildrenChanged(nodeVector); + d->notifyInstancesChildrenChanged(nodes); } void Model::emitInstanceToken(AbstractView *view, @@ -2165,10 +2166,10 @@ void Model::emitDocumentMessage(const QList &errors, void Model::emitCustomNotification(AbstractView *view, const QString &identifier, - const QList &nodeList, + Utils::span nodes, const QList &data) { - d->notifyCustomNotification(view, identifier, nodeList, data); + d->notifyCustomNotification(view, identifier, nodes, data); } void Model::sendCustomNotificationTo(AbstractView *to, const CustomNotificationPackage &package) @@ -2300,11 +2301,11 @@ QList Model::selectedNodes(AbstractView *view) const return d->toModelNodeList(d->selectedNodes(), view); } -void Model::setSelectedModelNodes(const QList &selectedNodeList) +void Model::setSelectedModelNodes(Utils::span selectedNodes) { QList unlockedNodes; - for (const auto &modelNode : selectedNodeList) { + for (const auto &modelNode : selectedNodes) { if (!ModelUtils::isThisOrAncestorLocked(modelNode)) unlockedNodes.push_back(modelNode); } diff --git a/src/plugins/qmldesigner/libs/designercore/model/model_p.h b/src/plugins/qmldesigner/libs/designercore/model/model_p.h index b2a8a31d692..1dc8c0de2ab 100644 --- a/src/plugins/qmldesigner/libs/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/libs/designercore/model/model_p.h @@ -195,17 +195,17 @@ public: void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, - const QList &modelNodeList, + Utils::span nodes, const QList &data); void notifyCustomNotificationTo(AbstractView *view, const CustomNotificationPackage &package); - void notifyInstancePropertyChange(const QList> &propertyList); - void notifyInstanceErrorChange(const QVector &instanceIds); - void notifyInstancesCompleted(const QVector &modelNodeVector); + void notifyInstancePropertyChange(Utils::span> properties); + void notifyInstanceErrorChange(Utils::span instanceIds); + void notifyInstancesCompleted(Utils::span modelNodes); void notifyInstancesInformationsChange(const QMultiHash &informationChangeHash); - void notifyInstancesRenderImageChanged(const QVector &modelNodeVector); - void notifyInstancesPreviewImageChanged(const QVector &modelNodeVector); - void notifyInstancesChildrenChanged(const QVector &modelNodeVector); - void notifyInstanceToken(const QString &token, int number, const QVector &modelNodeVector); + void notifyInstancesRenderImageChanged(Utils::span nodes); + void notifyInstancesPreviewImageChanged(Utils::span nodes); + void notifyInstancesChildrenChanged(Utils::span nodes); + void notifyInstanceToken(const QString &token, int number, Utils::span nodes); void notifyCurrentStateChanged(const ModelNode &node); void notifyCurrentTimelineChanged(const ModelNode &node); @@ -334,7 +334,7 @@ private: void removePropertyWithoutNotification(InternalProperty *property); void removeAllSubNodes(const InternalNodePointer &node); void removeNodeFromModel(const InternalNodePointer &node); - ManyNodes toInternalNodeList(const QList &modelNodeList) const; + ManyNodes toInternalNodeList(Utils::span modelNodes) const; QList toModelNodeList(Utils::span nodeList, AbstractView *view) const; static QList toInternalProperties(const AbstractProperties &properties);