timeline: relink duplicated clips

This commit is contained in:
itsmattkc
2022-06-10 10:34:51 -07:00
parent 046b1cc498
commit e27c53bea8
+18 -1
View File
@@ -689,6 +689,8 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
InsertGapsAtGhostDestination(command);
}
QMap<Node*, Node*> relinks;
// Now we can re-add each clip
foreach (const GhostBlockPair& p, blocks_moving) {
Block* block = p.block;
@@ -696,7 +698,10 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
if (duplicate_clips) {
// Duplicate rather than move
// Place the copy instead of the original block
block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
Block *new_block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
relinks.insert(block, new_block);
block = new_block;
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(block)) {
new_clip->waveform() = static_cast<ClipBlock*>(p.block)->waveform();
}
@@ -709,6 +714,18 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
p.ghost->GetAdjustedIn()));
}
if (!relinks.empty()) {
for (auto it=relinks.cbegin(); it!=relinks.cend(); it++) {
for (auto jt=it.key()->links().cbegin(); jt!=it.key()->links().cend(); jt++) {
Node *link = *jt;
Node *copy_link = relinks.value(link);
if (copy_link) {
command->add_child(new NodeLinkCommand(it.value(), copy_link, true));
}
}
}
}
// Adjust selections
TimelineWidgetSelections new_sel = parent()->GetSelections();
new_sel.ShiftTime(blocks_moving.first().ghost->GetInAdjustment());