nodeparamview: support pasting values into multiple nodes of same type

This commit is contained in:
itsmattkc
2022-05-10 17:32:48 -07:00
parent 8b87e376a0
commit fc8bba956b
2 changed files with 12 additions and 6 deletions
+11 -6
View File
@@ -523,16 +523,21 @@ void NodeParamView::SetSelectedNodes(const QVector<Node::ContextPair> &nodes, bo
}
Node *NodeParamView::GetNodeWithID(const QString &id)
{
return GetNodeWithIDAndIgnoreList(id, QVector<Node*>());
}
Node *NodeParamView::GetNodeWithIDAndIgnoreList(const QString &id, const QVector<Node *> &ignore)
{
for (NodeParamViewItem *item : selected_nodes_) {
if (item->GetNode()->id() == id) {
if (item->GetNode()->id() == id && !ignore.contains(item->GetNode())) {
return item->GetNode();
}
}
for (NodeParamViewContext *ctx : context_items_) {
for (NodeParamViewItem *item : ctx->GetItems()) {
if (item->GetNode()->id() == id) {
if (item->GetNode()->id() == id && !ignore.contains(item->GetNode())) {
return item->GetNode();
}
}
@@ -601,12 +606,12 @@ bool NodeParamView::Paste()
}
// Determine if any nodes of this type are already in the editor
QVector<Node*> ignore_nodes;
QMap<Node*, Node*> existing_nodes;
for (Node *n : res.GetLoadedNodes()) {
if (Node *existing = GetNodeWithID(n->id())) {
if (!existing_nodes.contains(existing)) {
existing_nodes.insert(existing, n);
}
if (Node *existing = GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) {
existing_nodes.insert(existing, n);
ignore_nodes.append(existing);
}
}
+1
View File
@@ -65,6 +65,7 @@ public:
void SetSelectedNodes(const QVector<Node::ContextPair> &nodes, bool emit_signal = true);
Node *GetNodeWithID(const QString &id);
Node *GetNodeWithIDAndIgnoreList(const QString &id, const QVector<Node*> &ignore);
const QVector<Node*> &GetContexts() const
{