nodeparamview: support pasting values into multiple nodes of same type
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user