timeline: allow pasting nodes into or over clips

This commit is contained in:
itsmattkc
2022-08-15 11:06:34 -07:00
parent 5853c114c2
commit f18461e69b
4 changed files with 58 additions and 12 deletions
+20 -10
View File
@@ -29,7 +29,6 @@
#include "common/functiontimer.h"
#include "common/timecodefunctions.h"
#include "node/output/viewer/viewer.h"
#include "node/project/serializer/serializer.h"
#include "widget/nodeparamview/nodeparamviewundo.h"
#include "widget/nodeview/nodeviewundo.h"
#include "widget/timeruler/timeruler.h"
@@ -611,26 +610,24 @@ bool NodeParamView::Paste()
}
}
return Paste(this, std::bind(&NodeParamView::GenerateExistingPasteMap, this, std::placeholders::_1));
}
bool NodeParamView::Paste(QWidget *parent, std::function<QHash<Node *, Node*>(const ProjectSerializer::Result &)> get_existing_map_function)
{
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("nodes"));
if (res.GetLoadedNodes().isEmpty()) {
return false;
}
// 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 = GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) {
existing_nodes.insert(existing, n);
ignore_nodes.append(existing);
}
}
QHash<Node*, Node*> existing_nodes = get_existing_map_function(res);
QVector<Node*> nodes_to_paste_as_new = res.GetLoadedNodes();
MultiUndoCommand *command = new MultiUndoCommand();
if (!existing_nodes.empty()) {
QMessageBox b(this);
QMessageBox b(parent);
b.setWindowTitle(tr("Paste Nodes"));
QStringList node_names;
@@ -870,6 +867,19 @@ void NodeParamView::ToggleSelect(NodeParamViewItem *item)
}
}
QHash<Node *, Node *> NodeParamView::GenerateExistingPasteMap(const ProjectSerializer::Result &r)
{
QVector<Node*> ignore_nodes;
QHash<Node*, Node*> existing_nodes;
for (Node *n : r.GetLoadedNodes()) {
if (Node *existing = GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) {
existing_nodes.insert(existing, n);
ignore_nodes.append(existing);
}
}
return existing_nodes;
}
void NodeParamView::UpdateGlobalScrollBar()
{
if (keyframe_view_) {