forked from qt-creator/qt-creator
QmlDesigner: Fix compilation for GCC 10
QList and std::span don't interact well on GCC 10. GCC 11 is fixing it but we still have to support old compiler. QVarLengthArray is fixing it. It has the advantage to reduce allocations too. Change-Id: I4d17aee334258776de7d40aaa248e815f988fb0c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -328,7 +328,6 @@ private:
|
||||
Kind m_kind = Kind::Other;
|
||||
};
|
||||
|
||||
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(
|
||||
Utils::span<const Internal::InternalNodePointer> nodeList,
|
||||
Model *model,
|
||||
|
@@ -45,7 +45,13 @@ class GlobalAnnotationStatus;
|
||||
class Comment;
|
||||
class Annotation;
|
||||
|
||||
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
template<typename Result = QVarLengthArray<Internal::InternalNodePointer, 1024>>
|
||||
QMLDESIGNERCORE_EXPORT Result toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
|
||||
extern template QMLDESIGNERCORE_EXPORT QVarLengthArray<Internal::InternalNodePointer, 1024>
|
||||
toInternalNodeList<QVarLengthArray<Internal::InternalNodePointer, 1024>>(const QList<ModelNode> &nodeList);
|
||||
extern template QMLDESIGNERCORE_EXPORT QVarLengthArray<Internal::InternalNodePointer, 32>
|
||||
toInternalNodeList<QVarLengthArray<Internal::InternalNodePointer, 32>>(const QList<ModelNode> &nodeList);
|
||||
|
||||
using PropertyListType = QList<QPair<PropertyName, QVariant> >;
|
||||
using AuxiliaryPropertyListType = QList<QPair<AuxiliaryDataKey, QVariant>>;
|
||||
@@ -59,7 +65,9 @@ inline constexpr AuxiliaryDataKeyView transitionExpandedPropery{AuxiliaryDataTyp
|
||||
class QMLDESIGNERCORE_EXPORT ModelNode
|
||||
{
|
||||
friend QMLDESIGNERCORE_EXPORT QDebug operator<<(QDebug debug, const ModelNode &modelNode);
|
||||
friend QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
template<typename Result>
|
||||
friend QMLDESIGNERCORE_EXPORT Result toInternalNodeList(const QList<ModelNode> &nodeList);
|
||||
|
||||
friend Model;
|
||||
friend AbstractView;
|
||||
friend NodeListProperty;
|
||||
|
@@ -411,15 +411,6 @@ QList<ModelNode> toModelNodeList(Utils::span<const Internal::InternalNode::Point
|
||||
return newNodeList;
|
||||
}
|
||||
|
||||
QList<Internal::InternalNode::Pointer> toInternalNodeList(const QList<ModelNode> &nodeList)
|
||||
{
|
||||
QList<Internal::InternalNode::Pointer> newNodeList;
|
||||
for (const ModelNode &node : nodeList)
|
||||
newNodeList.append(node.internalNode());
|
||||
|
||||
return newNodeList;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the list of nodes to the actual selected nodes specified by
|
||||
\a selectedNodeList if the node or its ancestors are not locked.
|
||||
@@ -466,7 +457,7 @@ QList<ModelNode> AbstractView::selectedModelNodes() const
|
||||
ModelNode AbstractView::firstSelectedModelNode() const
|
||||
{
|
||||
if (hasSelectedModelNodes())
|
||||
return ModelNode(model()->d->selectedNodes().constFirst(), model(), this);
|
||||
return ModelNode(model()->d->selectedNodes().front(), model(), this);
|
||||
|
||||
return ModelNode();
|
||||
}
|
||||
@@ -474,7 +465,7 @@ ModelNode AbstractView::firstSelectedModelNode() const
|
||||
ModelNode AbstractView::singleSelectedModelNode() const
|
||||
{
|
||||
if (hasSingleSelectedModelNode())
|
||||
return ModelNode(model()->d->selectedNodes().constFirst(), model(), this);
|
||||
return ModelNode(model()->d->selectedNodes().front(), model(), this);
|
||||
|
||||
return ModelNode();
|
||||
}
|
||||
|
@@ -120,9 +120,9 @@ PropertyNameViews InternalNode::propertyNameViews() const
|
||||
return CoreUtils::to<PropertyNameViews>(m_nameProperties | std::views::keys);
|
||||
}
|
||||
|
||||
QList<InternalNode::Pointer> InternalNode::allSubNodes() const
|
||||
InternalNode::ManyNodes InternalNode::allSubNodes() const
|
||||
{
|
||||
QList<InternalNode::Pointer> nodes;
|
||||
ManyNodes nodes;
|
||||
nodes.reserve(1024);
|
||||
|
||||
addSubNodes(nodes);
|
||||
@@ -130,7 +130,7 @@ QList<InternalNode::Pointer> InternalNode::allSubNodes() const
|
||||
return nodes;
|
||||
}
|
||||
|
||||
void InternalNode::addSubNodes(QList<InternalNodePointer> &nodes, const InternalProperty *property)
|
||||
void InternalNode::addSubNodes(ManyNodes &nodes, const InternalProperty *property)
|
||||
{
|
||||
switch (property->type()) {
|
||||
case PropertyType::NodeList:
|
||||
@@ -148,24 +148,30 @@ void InternalNode::addSubNodes(QList<InternalNodePointer> &nodes, const Internal
|
||||
}
|
||||
}
|
||||
|
||||
void InternalNode::addSubNodes(QList<InternalNodePointer> &nodes) const
|
||||
void InternalNode::addSubNodes(ManyNodes &nodes) const
|
||||
{
|
||||
for (const auto &entry : m_nameProperties)
|
||||
addSubNodes(nodes, entry.second.get());
|
||||
}
|
||||
|
||||
void InternalNode::addDirectSubNodes(QList<InternalNodePointer> &nodes) const
|
||||
void InternalNode::addDirectSubNodes(ManyNodes &nodes) const
|
||||
{
|
||||
for (const auto &entry : m_nameProperties)
|
||||
addDirectSubNodes(nodes, entry.second.get());
|
||||
}
|
||||
|
||||
void InternalNode::addDirectSubNodes(QList<InternalNodePointer> &nodes,
|
||||
const InternalProperty *property)
|
||||
namespace {
|
||||
void append(InternalNode::ManyNodes &nodes, auto &appendNodes)
|
||||
{
|
||||
std::copy(appendNodes.begin(), appendNodes.end(), std::back_inserter(nodes));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void InternalNode::addDirectSubNodes(ManyNodes &nodes, const InternalProperty *property)
|
||||
{
|
||||
switch (property->type()) {
|
||||
case PropertyType::NodeList:
|
||||
nodes.append(property->to<PropertyType::NodeList>()->nodes());
|
||||
append(nodes, property->to<PropertyType::NodeList>()->nodes());
|
||||
break;
|
||||
case PropertyType::Node:
|
||||
nodes.append(property->to<PropertyType::Node>()->node());
|
||||
@@ -179,9 +185,9 @@ void InternalNode::addDirectSubNodes(QList<InternalNodePointer> &nodes,
|
||||
}
|
||||
}
|
||||
|
||||
QList<InternalNode::Pointer> InternalNode::allDirectSubNodes() const
|
||||
InternalNode::ManyNodes InternalNode::allDirectSubNodes() const
|
||||
{
|
||||
QList<InternalNode::Pointer> nodes;
|
||||
ManyNodes nodes;
|
||||
nodes.reserve(96);
|
||||
|
||||
addDirectSubNodes(nodes);
|
||||
|
@@ -50,6 +50,8 @@ class InternalNode : public std::enable_shared_from_this<InternalNode>
|
||||
public:
|
||||
using Pointer = std::shared_ptr<InternalNode>;
|
||||
using WeakPointer = std::weak_ptr<InternalNode>;
|
||||
using FewNodes = QVarLengthArray<Pointer, 32>;
|
||||
using ManyNodes = QVarLengthArray<Pointer, 1024>;
|
||||
|
||||
explicit InternalNode(TypeNameView typeName,
|
||||
int majorVersion,
|
||||
@@ -193,12 +195,12 @@ public:
|
||||
|
||||
bool hasProperties() const { return m_nameProperties.size(); }
|
||||
|
||||
QList<InternalNode::Pointer> allSubNodes() const;
|
||||
QList<InternalNode::Pointer> allDirectSubNodes() const;
|
||||
void addSubNodes(QList<InternalNodePointer> &nodes) const;
|
||||
void addDirectSubNodes(QList<InternalNodePointer> &nodes) const;
|
||||
static void addSubNodes(QList<InternalNodePointer> &nodes, const InternalProperty *property);
|
||||
static void addDirectSubNodes(QList<InternalNodePointer> &nodes, const InternalProperty *property);
|
||||
ManyNodes allSubNodes() const;
|
||||
ManyNodes allDirectSubNodes() const;
|
||||
void addSubNodes(ManyNodes &nodes) const;
|
||||
void addDirectSubNodes(ManyNodes &nodes) const;
|
||||
static void addSubNodes(ManyNodes &nodes, const InternalProperty *property);
|
||||
static void addDirectSubNodes(ManyNodes &nodes, const InternalProperty *property);
|
||||
|
||||
friend bool operator<(const InternalNode::Pointer &firstNode,
|
||||
const InternalNode::Pointer &secondNode)
|
||||
|
@@ -21,12 +21,12 @@ bool InternalNodeListProperty::isValid() const
|
||||
|
||||
bool InternalNodeListProperty::isEmpty() const
|
||||
{
|
||||
return m_nodeList.isEmpty();
|
||||
return m_nodes.isEmpty();
|
||||
}
|
||||
|
||||
int InternalNodeListProperty::count() const
|
||||
{
|
||||
return m_nodeList.size();
|
||||
return m_nodes.size();
|
||||
}
|
||||
|
||||
int InternalNodeListProperty::indexOf(const InternalNode::Pointer &node) const
|
||||
@@ -34,53 +34,54 @@ int InternalNodeListProperty::indexOf(const InternalNode::Pointer &node) const
|
||||
if (!node)
|
||||
return -1;
|
||||
|
||||
return m_nodeList.indexOf(node);
|
||||
return m_nodes.indexOf(node);
|
||||
}
|
||||
|
||||
void InternalNodeListProperty::add(const InternalNode::Pointer &internalNode)
|
||||
{
|
||||
Q_ASSERT(!m_nodeList.contains(internalNode));
|
||||
Q_ASSERT(!m_nodes.contains(internalNode));
|
||||
|
||||
auto flowToken = traceToken.tickWithFlow("add node"_t);
|
||||
internalNode->traceToken.tick(flowToken, "node added"_t);
|
||||
|
||||
m_nodeList.append(internalNode);
|
||||
m_nodes.append(internalNode);
|
||||
}
|
||||
|
||||
void InternalNodeListProperty::remove(const InternalNodePointer &internalNode)
|
||||
{
|
||||
Q_ASSERT(m_nodeList.contains(internalNode));
|
||||
Q_ASSERT(m_nodes.contains(internalNode));
|
||||
|
||||
auto flowToken = traceToken.tickWithFlow("remove node"_t);
|
||||
internalNode->traceToken.tick(flowToken, "node removed"_t);
|
||||
|
||||
m_nodeList.removeAll(internalNode);
|
||||
m_nodes.removeAll(internalNode);
|
||||
}
|
||||
|
||||
const QList<InternalNode::Pointer> &InternalNodeListProperty::nodeList() const
|
||||
const InternalNodeListProperty::FewNodes &InternalNodeListProperty::nodeList() const
|
||||
{
|
||||
return m_nodeList;
|
||||
return m_nodes;
|
||||
}
|
||||
|
||||
void InternalNodeListProperty::slide(int from, int to)
|
||||
{
|
||||
traceToken.tick("slide"_t, keyValue("from", from), keyValue("to", to));
|
||||
|
||||
InternalNode::Pointer internalNode = m_nodeList.takeAt(from);
|
||||
m_nodeList.insert(to, internalNode);
|
||||
InternalNode::Pointer internalNode = m_nodes.at(from);
|
||||
m_nodes.remove(from);
|
||||
m_nodes.insert(to, internalNode);
|
||||
}
|
||||
|
||||
void InternalNodeListProperty::addSubNodes(QList<InternalNodePointer> &container) const
|
||||
void InternalNodeListProperty::addSubNodes(ManyNodes &container) const
|
||||
{
|
||||
for (const auto &node : std::as_const(m_nodeList)) {
|
||||
for (const auto &node : std::as_const(m_nodes)) {
|
||||
container.push_back(node);
|
||||
node->addSubNodes(container);
|
||||
}
|
||||
}
|
||||
|
||||
QList<InternalNode::Pointer> InternalNodeListProperty::allSubNodes() const
|
||||
InternalNodeListProperty::ManyNodes InternalNodeListProperty::allSubNodes() const
|
||||
{
|
||||
QList<InternalNode::Pointer> nodes;
|
||||
ManyNodes nodes;
|
||||
nodes.reserve(1024);
|
||||
|
||||
addSubNodes(nodes);
|
||||
|
@@ -15,6 +15,9 @@ class InternalNodeListProperty final : public InternalNodeAbstractProperty
|
||||
{
|
||||
public:
|
||||
using Pointer = std::shared_ptr<InternalNodeListProperty>;
|
||||
using FewNodes = QVarLengthArray<InternalNodePointer, 32>;
|
||||
using ManyNodes = QVarLengthArray<InternalNodePointer, 1024>;
|
||||
|
||||
static constexpr PropertyType type = PropertyType::NodeList;
|
||||
|
||||
InternalNodeListProperty(PropertyNameView name, const InternalNodePointer &propertyOwner);
|
||||
@@ -22,46 +25,49 @@ public:
|
||||
bool isValid() const override;
|
||||
|
||||
bool isEmpty() const override;
|
||||
int size() const { return m_nodeList.size(); }
|
||||
|
||||
int size() const { return m_nodes.size(); }
|
||||
|
||||
int count() const override;
|
||||
int indexOf(const InternalNodePointer &node) const override;
|
||||
|
||||
const InternalNodePointer &at(int index) const
|
||||
{
|
||||
Q_ASSERT(index >= 0 && index < m_nodeList.size());
|
||||
return m_nodeList[index];
|
||||
Q_ASSERT(index >= 0 && index < m_nodes.size());
|
||||
return m_nodes[index];
|
||||
}
|
||||
|
||||
InternalNodePointer &at(int index)
|
||||
{
|
||||
Q_ASSERT(index >= 0 && index < m_nodeList.size());
|
||||
return m_nodeList[index];
|
||||
Q_ASSERT(index >= 0 && index < m_nodes.size());
|
||||
return m_nodes[index];
|
||||
}
|
||||
|
||||
InternalNodePointer &find(InternalNodePointer node)
|
||||
{
|
||||
auto found = std::find(m_nodeList.begin(), m_nodeList.end(), node);
|
||||
auto found = std::find(m_nodes.begin(), m_nodes.end(), node);
|
||||
|
||||
return *found;
|
||||
}
|
||||
|
||||
QList<InternalNodePointer> allSubNodes() const;
|
||||
const QList<InternalNodePointer> &nodeList() const;
|
||||
ManyNodes allSubNodes() const;
|
||||
const FewNodes &nodeList() const;
|
||||
void slide(int from, int to);
|
||||
|
||||
void addSubNodes(QList<InternalNodePointer> &container) const;
|
||||
void addSubNodes(ManyNodes &container) const;
|
||||
|
||||
QList<InternalNodePointer>::iterator begin() { return m_nodeList.begin(); }
|
||||
FewNodes::iterator begin() { return m_nodes.begin(); }
|
||||
|
||||
QList<InternalNodePointer>::iterator end() { return m_nodeList.end(); }
|
||||
FewNodes::iterator end() { return m_nodes.end(); }
|
||||
|
||||
const QList<InternalNodePointer> &nodes() const { return m_nodeList; }
|
||||
const FewNodes &nodes() const { return m_nodes; }
|
||||
|
||||
protected:
|
||||
void add(const InternalNodePointer &node) override;
|
||||
void remove(const InternalNodePointer &node) override;
|
||||
|
||||
private:
|
||||
QList<InternalNodePointer> m_nodeList;
|
||||
FewNodes m_nodes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -60,9 +60,9 @@ void InternalNodeProperty::add(const InternalNode::Pointer &node)
|
||||
m_node = node;
|
||||
}
|
||||
|
||||
QList<InternalNode::Pointer> InternalNodeProperty::allSubNodes() const
|
||||
InternalNodeProperty::ManyNodes InternalNodeProperty::allSubNodes() const
|
||||
{
|
||||
QList<InternalNode::Pointer> nodes;
|
||||
ManyNodes nodes;
|
||||
nodes.reserve(1024);
|
||||
|
||||
addSubNodes(nodes);
|
||||
@@ -70,7 +70,7 @@ QList<InternalNode::Pointer> InternalNodeProperty::allSubNodes() const
|
||||
return nodes;
|
||||
}
|
||||
|
||||
void InternalNodeProperty::addSubNodes(QList<InternalNodePointer> &container) const
|
||||
void InternalNodeProperty::addSubNodes(ManyNodes &container) const
|
||||
{
|
||||
container.push_back(m_node);
|
||||
m_node->addSubNodes(container);
|
||||
|
@@ -12,6 +12,8 @@ class InternalNodeProperty : public InternalNodeAbstractProperty
|
||||
{
|
||||
public:
|
||||
using Pointer = std::shared_ptr<InternalNodeProperty>;
|
||||
using ManyNodes = QVarLengthArray<InternalNodePointer, 1024>;
|
||||
|
||||
static constexpr PropertyType type = PropertyType::Node;
|
||||
|
||||
InternalNodeProperty(PropertyNameView name, const InternalNodePointer &node);
|
||||
@@ -21,8 +23,8 @@ public:
|
||||
int count() const override;
|
||||
int indexOf(const InternalNodePointer &node) const override;
|
||||
|
||||
QList<InternalNodePointer> allSubNodes() const;
|
||||
void addSubNodes(QList<InternalNodePointer> &container) const;
|
||||
ManyNodes allSubNodes() const;
|
||||
void addSubNodes(ManyNodes &container) const;
|
||||
|
||||
const InternalNodePointer &node() const { return m_node; }
|
||||
|
||||
|
@@ -367,12 +367,12 @@ void ModelPrivate::removeNodeFromModel(const InternalNodePointer &node)
|
||||
|
||||
node->resetParentProperty();
|
||||
|
||||
m_selectedInternalNodeList.removeAll(node);
|
||||
m_selectedInternalNodes.removeAll(node);
|
||||
if (!node->id.isEmpty())
|
||||
m_idNodeHash.remove(node->id);
|
||||
node->isValid = false;
|
||||
node->traceToken.end();
|
||||
std::erase(m_nodes, node);
|
||||
m_nodes.removeOne(node);
|
||||
m_internalIdNodeHash.remove(node->internalId);
|
||||
}
|
||||
|
||||
@@ -677,10 +677,10 @@ void ModelPrivate::notifyInstanceErrorChange(const QVector<qint32> &instanceIds)
|
||||
|
||||
void ModelPrivate::notifyInstancesCompleted(const QVector<ModelNode> &modelNodeVector)
|
||||
{
|
||||
QVector<InternalNodePointer> internalVector(toInternalNodeVector(modelNodeVector));
|
||||
auto internalNodes = toInternalNodeList(modelNodeVector);
|
||||
|
||||
notifyInstanceChanges([&](AbstractView *view) {
|
||||
view->instancesCompleted(toModelNodeVector(internalVector, view));
|
||||
view->instancesCompleted(toModelNodeList(internalNodes, view));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -707,28 +707,28 @@ void ModelPrivate::notifyInstancesInformationsChange(
|
||||
|
||||
void ModelPrivate::notifyInstancesRenderImageChanged(const QVector<ModelNode> &modelNodeVector)
|
||||
{
|
||||
QVector<InternalNodePointer> internalVector(toInternalNodeVector(modelNodeVector));
|
||||
auto internalNodes = toInternalNodeList(modelNodeVector);
|
||||
|
||||
notifyInstanceChanges([&](AbstractView *view) {
|
||||
view->instancesRenderImageChanged(toModelNodeVector(internalVector, view));
|
||||
view->instancesRenderImageChanged(toModelNodeList(internalNodes, view));
|
||||
});
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyInstancesPreviewImageChanged(const QVector<ModelNode> &modelNodeVector)
|
||||
{
|
||||
QVector<InternalNodePointer> internalVector(toInternalNodeVector(modelNodeVector));
|
||||
auto internalNodes = toInternalNodeList(modelNodeVector);
|
||||
|
||||
notifyInstanceChanges([&](AbstractView *view) {
|
||||
view->instancesPreviewImageChanged(toModelNodeVector(internalVector, view));
|
||||
view->instancesPreviewImageChanged(toModelNodeList(internalNodes, view));
|
||||
});
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyInstancesChildrenChanged(const QVector<ModelNode> &modelNodeVector)
|
||||
{
|
||||
QVector<InternalNodePointer> internalVector(toInternalNodeVector(modelNodeVector));
|
||||
auto internalNodes = toInternalNodeList(modelNodeVector);
|
||||
|
||||
notifyInstanceChanges([&](AbstractView *view) {
|
||||
view->instancesChildrenChanged(toModelNodeVector(internalVector, view));
|
||||
view->instancesChildrenChanged(toModelNodeList(internalNodes, view));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -802,10 +802,10 @@ void ModelPrivate::notifyRewriterEndTransaction()
|
||||
void ModelPrivate::notifyInstanceToken(const QString &token, int number,
|
||||
const QVector<ModelNode> &modelNodeVector)
|
||||
{
|
||||
QVector<InternalNodePointer> internalVector(toInternalNodeVector(modelNodeVector));
|
||||
auto internalNodes = toInternalNodeList(modelNodeVector);
|
||||
|
||||
notifyInstanceChanges([&](AbstractView *view) {
|
||||
view->instancesToken(token, number, toModelNodeVector(internalVector, view));
|
||||
view->instancesToken(token, number, toModelNodeList(internalNodes, view));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -814,7 +814,7 @@ void ModelPrivate::notifyCustomNotification(const AbstractView *senderView,
|
||||
const QList<ModelNode> &modelNodeList,
|
||||
const QList<QVariant> &data)
|
||||
{
|
||||
QList<InternalNodePointer> internalList(toInternalNodeList(modelNodeList));
|
||||
auto internalList = toInternalNodeList(modelNodeList);
|
||||
notifyNodeInstanceViewLast([&](AbstractView *view) {
|
||||
view->customNotification(senderView, identifier, toModelNodeList(internalList, view), data);
|
||||
});
|
||||
@@ -1159,7 +1159,7 @@ void ModelPrivate::notifyNodeOrderChanged(const InternalNodeListProperty *intern
|
||||
});
|
||||
}
|
||||
|
||||
void ModelPrivate::setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList)
|
||||
void ModelPrivate::setSelectedNodes(const FewNodes &selectedNodeList)
|
||||
{
|
||||
auto sortedSelectedList = Utils::filtered(selectedNodeList, [](const auto &node) {
|
||||
return node && node->isValid;
|
||||
@@ -1169,7 +1169,7 @@ void ModelPrivate::setSelectedNodes(const QList<InternalNodePointer> &selectedNo
|
||||
sortedSelectedList.erase(std::unique(sortedSelectedList.begin(), sortedSelectedList.end()),
|
||||
sortedSelectedList.end());
|
||||
|
||||
if (sortedSelectedList == m_selectedInternalNodeList)
|
||||
if (sortedSelectedList == m_selectedInternalNodes)
|
||||
return;
|
||||
|
||||
auto flowToken = traceToken.tickWithFlow("selected model nodes"_t);
|
||||
@@ -1177,21 +1177,21 @@ void ModelPrivate::setSelectedNodes(const QList<InternalNodePointer> &selectedNo
|
||||
if constexpr (decltype(traceToken)::categoryIsActive()) { // the compiler should optimize it away but to be sure
|
||||
std::set_difference(sortedSelectedList.begin(),
|
||||
sortedSelectedList.end(),
|
||||
m_selectedInternalNodeList.begin(),
|
||||
m_selectedInternalNodeList.end(),
|
||||
m_selectedInternalNodes.begin(),
|
||||
m_selectedInternalNodes.end(),
|
||||
Utils::make_iterator([&](const auto &node) {
|
||||
node->traceToken.tick(flowToken, "select model node"_t);
|
||||
}));
|
||||
}
|
||||
|
||||
const QList<InternalNodePointer> lastSelectedNodeList = m_selectedInternalNodeList;
|
||||
m_selectedInternalNodeList = sortedSelectedList;
|
||||
const auto lastSelectedNodeList = std::move(m_selectedInternalNodes);
|
||||
m_selectedInternalNodes = sortedSelectedList;
|
||||
|
||||
if constexpr (decltype(traceToken)::categoryIsActive()) { // the compiler should optimize it away but to be sure
|
||||
std::set_difference(lastSelectedNodeList.begin(),
|
||||
lastSelectedNodeList.end(),
|
||||
m_selectedInternalNodeList.begin(),
|
||||
m_selectedInternalNodeList.end(),
|
||||
m_selectedInternalNodes.begin(),
|
||||
m_selectedInternalNodes.end(),
|
||||
Utils::make_iterator([&](const auto &node) {
|
||||
node->traceToken.tick(flowToken, "deselect model node"_t);
|
||||
}));
|
||||
@@ -1204,9 +1204,9 @@ void ModelPrivate::clearSelectedNodes()
|
||||
{
|
||||
auto tracer = traceToken.begin("clear selected model nodes"_t);
|
||||
|
||||
const QList<InternalNodePointer> lastSelectedNodeList = m_selectedInternalNodeList;
|
||||
m_selectedInternalNodeList.clear();
|
||||
changeSelectedNodes(m_selectedInternalNodeList, lastSelectedNodeList);
|
||||
auto lastSelectedNodeList = m_selectedInternalNodes;
|
||||
m_selectedInternalNodes.clear();
|
||||
changeSelectedNodes(m_selectedInternalNodes, lastSelectedNodeList);
|
||||
}
|
||||
|
||||
void ModelPrivate::removeAuxiliaryData(const InternalNodePointer &node, const AuxiliaryDataKeyView &key)
|
||||
@@ -1217,7 +1217,8 @@ void ModelPrivate::removeAuxiliaryData(const InternalNodePointer &node, const Au
|
||||
notifyAuxiliaryDataChanged(node, key, QVariant());
|
||||
}
|
||||
|
||||
QList<ModelNode> ModelPrivate::toModelNodeList(const QList<InternalNodePointer> &nodeList, AbstractView *view) const
|
||||
QList<ModelNode> ModelPrivate::toModelNodeList(std::span<const InternalNodePointer> nodeList,
|
||||
AbstractView *view) const
|
||||
{
|
||||
QList<ModelNode> modelNodeList;
|
||||
modelNodeList.reserve(nodeList.size());
|
||||
@@ -1227,19 +1228,9 @@ QList<ModelNode> ModelPrivate::toModelNodeList(const QList<InternalNodePointer>
|
||||
return modelNodeList;
|
||||
}
|
||||
|
||||
QVector<ModelNode> ModelPrivate::toModelNodeVector(const QVector<InternalNodePointer> &nodeVector, AbstractView *view) const
|
||||
ModelPrivate::ManyNodes ModelPrivate::toInternalNodeList(const QList<ModelNode> &modelNodeList) const
|
||||
{
|
||||
QVector<ModelNode> modelNodeVector;
|
||||
modelNodeVector.reserve(nodeVector.size());
|
||||
for (const InternalNodePointer &node : nodeVector)
|
||||
modelNodeVector.emplace_back(node, m_model, view);
|
||||
|
||||
return modelNodeVector;
|
||||
}
|
||||
|
||||
QList<InternalNodePointer> ModelPrivate::toInternalNodeList(const QList<ModelNode> &modelNodeList) const
|
||||
{
|
||||
QList<InternalNodePointer> newNodeList;
|
||||
ManyNodes newNodeList;
|
||||
newNodeList.reserve(modelNodeList.size());
|
||||
for (const ModelNode &modelNode : modelNodeList)
|
||||
newNodeList.append(modelNode.internalNode());
|
||||
@@ -1247,16 +1238,6 @@ QList<InternalNodePointer> ModelPrivate::toInternalNodeList(const QList<ModelNod
|
||||
return newNodeList;
|
||||
}
|
||||
|
||||
QVector<InternalNodePointer> ModelPrivate::toInternalNodeVector(const QVector<ModelNode> &modelNodeVector) const
|
||||
{
|
||||
QVector<InternalNodePointer> newNodeVector;
|
||||
newNodeVector.reserve(modelNodeVector.size());
|
||||
for (const ModelNode &modelNode : modelNodeVector)
|
||||
newNodeVector.append(modelNode.internalNode());
|
||||
|
||||
return newNodeVector;
|
||||
}
|
||||
|
||||
QList<InternalProperty *> ModelPrivate::toInternalProperties(const AbstractProperties &properties)
|
||||
{
|
||||
QList<InternalProperty *> internalProperties;
|
||||
@@ -1290,8 +1271,8 @@ QList<std::tuple<InternalBindingProperty *, QString>> ModelPrivate::toInternalBi
|
||||
return internalProperties;
|
||||
}
|
||||
|
||||
void ModelPrivate::changeSelectedNodes(const QList<InternalNodePointer> &newSelectedNodeList,
|
||||
const QList<InternalNodePointer> &oldSelectedNodeList)
|
||||
void ModelPrivate::changeSelectedNodes(const FewNodes &newSelectedNodeList,
|
||||
const FewNodes &oldSelectedNodeList)
|
||||
{
|
||||
for (const QPointer<AbstractView> &view : std::as_const(m_viewList)) {
|
||||
Q_ASSERT(view != nullptr);
|
||||
@@ -1305,14 +1286,15 @@ void ModelPrivate::changeSelectedNodes(const QList<InternalNodePointer> &newSele
|
||||
}
|
||||
}
|
||||
|
||||
QList<InternalNodePointer> ModelPrivate::selectedNodes() const
|
||||
const ModelPrivate::FewNodes &ModelPrivate::selectedNodes() const
|
||||
{
|
||||
for (const InternalNodePointer &node : m_selectedInternalNodeList) {
|
||||
static FewNodes empty;
|
||||
for (const InternalNodePointer &node : m_selectedInternalNodes) {
|
||||
if (!node->isValid)
|
||||
return {};
|
||||
return empty;
|
||||
}
|
||||
|
||||
return m_selectedInternalNodeList;
|
||||
return m_selectedInternalNodes;
|
||||
}
|
||||
|
||||
void ModelPrivate::selectNode(const InternalNodePointer &node)
|
||||
@@ -1320,14 +1302,14 @@ void ModelPrivate::selectNode(const InternalNodePointer &node)
|
||||
if (selectedNodes().contains(node))
|
||||
return;
|
||||
|
||||
QList<InternalNodePointer> selectedNodeList(selectedNodes());
|
||||
FewNodes selectedNodeList(selectedNodes());
|
||||
selectedNodeList += node;
|
||||
setSelectedNodes(selectedNodeList);
|
||||
}
|
||||
|
||||
void ModelPrivate::deselectNode(const InternalNodePointer &node)
|
||||
{
|
||||
QList<InternalNodePointer> selectedNodeList(selectedNodes());
|
||||
FewNodes selectedNodeList(selectedNodes());
|
||||
bool isRemoved = selectedNodeList.removeOne(node);
|
||||
|
||||
if (isRemoved)
|
||||
@@ -1697,16 +1679,17 @@ bool ModelPrivate::hasNodeForInternalId(qint32 internalId) const
|
||||
{
|
||||
return m_internalIdNodeHash.contains(internalId);
|
||||
}
|
||||
QList<InternalNodePointer> ModelPrivate::allNodesOrdered() const
|
||||
|
||||
ModelPrivate::ManyNodes ModelPrivate::allNodesOrdered() const
|
||||
{
|
||||
if (!m_rootInternalNode || !m_rootInternalNode->isValid)
|
||||
return {};
|
||||
|
||||
// the nodes must be ordered.
|
||||
|
||||
QList<InternalNodePointer> nodeList;
|
||||
ManyNodes nodeList;
|
||||
nodeList.append(m_rootInternalNode);
|
||||
nodeList.append(m_rootInternalNode->allSubNodes());
|
||||
m_rootInternalNode->addSubNodes(nodeList);
|
||||
// FIXME: This is horribly expensive compared to a loop.
|
||||
|
||||
auto nodesSorted = nodeList;
|
||||
@@ -1716,7 +1699,7 @@ QList<InternalNodePointer> ModelPrivate::allNodesOrdered() const
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
std::vector<InternalNodePointer> ModelPrivate::allNodesUnordered() const
|
||||
ModelPrivate::ManyNodes ModelPrivate::allNodesUnordered() const
|
||||
{
|
||||
return m_nodes;
|
||||
}
|
||||
@@ -2251,7 +2234,7 @@ void Model::setSelectedModelNodes(const QList<ModelNode> &selectedNodeList)
|
||||
unlockedNodes.push_back(modelNode);
|
||||
}
|
||||
|
||||
d->setSelectedNodes(toInternalNodeList(unlockedNodes));
|
||||
d->setSelectedNodes(toInternalNodeList<Internal::InternalNode::FewNodes>(unlockedNodes));
|
||||
}
|
||||
|
||||
void Model::clearMetaInfoCache()
|
||||
|
@@ -79,6 +79,9 @@ class ModelPrivate : public QObject,
|
||||
friend Internal::WriteLocker;
|
||||
|
||||
public:
|
||||
using FewNodes = QVarLengthArray<InternalNodePointer, 32>;
|
||||
using ManyNodes = QVarLengthArray<InternalNodePointer, 1024>;
|
||||
|
||||
ModelPrivate(Model *model,
|
||||
ProjectStorageDependencies m_projectStorageDependencies,
|
||||
const TypeName &type,
|
||||
@@ -226,13 +229,12 @@ public:
|
||||
void notifyRewriterBeginTransaction();
|
||||
void notifyRewriterEndTransaction();
|
||||
|
||||
void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
|
||||
void setSelectedNodes(const FewNodes &selectedNodeList);
|
||||
void clearSelectedNodes();
|
||||
QList<InternalNodePointer> selectedNodes() const;
|
||||
const FewNodes &selectedNodes() const;
|
||||
void selectNode(const InternalNodePointer &node);
|
||||
void deselectNode(const InternalNodePointer &node);
|
||||
void changeSelectedNodes(const QList<InternalNodePointer> &newSelectedNodeList,
|
||||
const QList<InternalNodePointer> &oldSelectedNodeList);
|
||||
void changeSelectedNodes(const FewNodes &newSelectedNodeList, const FewNodes &oldSelectedNodeList);
|
||||
|
||||
void setAuxiliaryData(const InternalNodePointer &node,
|
||||
const AuxiliaryDataKeyView &key,
|
||||
@@ -296,8 +298,8 @@ public:
|
||||
InternalNodePointer nodeForInternalId(qint32 internalId) const;
|
||||
bool hasNodeForInternalId(qint32 internalId) const;
|
||||
|
||||
std::vector<InternalNodePointer> allNodesUnordered() const;
|
||||
QList<InternalNodePointer> allNodesOrdered() const;
|
||||
ManyNodes allNodesUnordered() const;
|
||||
ManyNodes allNodesOrdered() const;
|
||||
|
||||
bool isWriteLocked() const;
|
||||
|
||||
@@ -330,10 +332,9 @@ private:
|
||||
void removePropertyWithoutNotification(InternalProperty *property);
|
||||
void removeAllSubNodes(const InternalNodePointer &node);
|
||||
void removeNodeFromModel(const InternalNodePointer &node);
|
||||
QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &modelNodeList) const;
|
||||
QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &nodeList, AbstractView *view) const;
|
||||
QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &nodeVector, AbstractView *view) const;
|
||||
QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &modelNodeVector) const;
|
||||
ManyNodes toInternalNodeList(const QList<ModelNode> &modelNodeList) const;
|
||||
QList<ModelNode> toModelNodeList(std::span<const InternalNodePointer> nodeList,
|
||||
AbstractView *view) const;
|
||||
static QList<InternalProperty *> toInternalProperties(const AbstractProperties &properties);
|
||||
static QList<std::tuple<QmlDesigner::Internal::InternalBindingProperty *, QString>>
|
||||
toInternalBindingProperties(const ModelResourceSet::SetExpressions &setExpressions);
|
||||
@@ -355,10 +356,10 @@ private:
|
||||
Imports m_possibleImportList;
|
||||
Imports m_usedImportList;
|
||||
QList<QPointer<AbstractView>> m_viewList;
|
||||
QList<InternalNodePointer> m_selectedInternalNodeList;
|
||||
FewNodes m_selectedInternalNodes;
|
||||
QHash<QString,InternalNodePointer> m_idNodeHash;
|
||||
QHash<qint32, InternalNodePointer> m_internalIdNodeHash;
|
||||
std::vector<InternalNodePointer> m_nodes;
|
||||
ManyNodes m_nodes;
|
||||
InternalNodePointer m_currentStateNode;
|
||||
InternalNodePointer m_rootInternalNode;
|
||||
InternalNodePointer m_currentTimelineNode;
|
||||
|
@@ -1399,4 +1399,19 @@ QString ModelNode::behaviorPropertyName() const
|
||||
return m_internalNode->behaviorPropertyName;
|
||||
}
|
||||
|
||||
template<typename Result>
|
||||
Result toInternalNodeList(const QList<ModelNode> &nodeList)
|
||||
{
|
||||
Result newNodeList;
|
||||
for (const ModelNode &node : nodeList)
|
||||
newNodeList.append(node.internalNode());
|
||||
|
||||
return newNodeList;
|
||||
}
|
||||
|
||||
template QMLDESIGNERCORE_EXPORT QVarLengthArray<Internal::InternalNodePointer, 1024> toInternalNodeList<
|
||||
QVarLengthArray<Internal::InternalNodePointer, 1024>>(const QList<ModelNode> &nodeList);
|
||||
template QMLDESIGNERCORE_EXPORT QVarLengthArray<Internal::InternalNodePointer, 32> toInternalNodeList<
|
||||
QVarLengthArray<Internal::InternalNodePointer, 32>>(const QList<ModelNode> &nodeList);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -40,12 +40,12 @@ Internal::InternalNodeListPropertyPointer &NodeListProperty::internalNodeListPro
|
||||
return m_internalNodeListProperty;
|
||||
}
|
||||
|
||||
static QList<ModelNode> internalNodesToModelNodes(const QList<Internal::InternalNode::Pointer> &inputList, Model* model, AbstractView *view)
|
||||
static QList<ModelNode> internalNodesToModelNodes(const auto &inputList, Model *model, AbstractView *view)
|
||||
{
|
||||
QList<ModelNode> modelNodeList;
|
||||
for (const Internal::InternalNode::Pointer &internalNode : inputList) {
|
||||
for (const Internal::InternalNode::Pointer &internalNode : inputList)
|
||||
modelNodeList.append(ModelNode(internalNode, model, view));
|
||||
}
|
||||
|
||||
return modelNodeList;
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <sqlitedatabase.h>
|
||||
#include <tracing/qmldesignertracing.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/set_algorithm.h>
|
||||
|
||||
#include <QDirIterator>
|
||||
@@ -273,8 +274,8 @@ void ProjectStorageUpdater::update(Update update)
|
||||
keyValue("qml types paths", qmlTypesPaths)};
|
||||
|
||||
Storage::Synchronization::SynchronizationPackage package;
|
||||
WatchedSourceIdsIds watchedSourceIds{Utils::span{directories}.size()};
|
||||
NotUpdatedSourceIds notUpdatedSourceIds{Utils::span{directories}.size()};
|
||||
WatchedSourceIdsIds watchedSourceIds{Utils::usize(directories)};
|
||||
NotUpdatedSourceIds notUpdatedSourceIds{Utils::usize(directories)};
|
||||
|
||||
updateDirectories(directories, package, notUpdatedSourceIds, watchedSourceIds);
|
||||
updateQmlTypes(qmlTypesPaths, package, notUpdatedSourceIds, watchedSourceIds);
|
||||
|
Reference in New Issue
Block a user