created function that splits and preserves links

This commit is contained in:
itsmattkc
2019-10-17 10:51:50 +11:00
parent 2860fe33a0
commit 276478c6d0
6 changed files with 112 additions and 8 deletions
+20 -4
View File
@@ -54,15 +54,31 @@ void TimelineWidget::RazorTool::MouseRelease(TimelineViewMouseEvent *event)
// Always split at the same time
rational split_time = drag_start_.GetFrame();
QUndoCommand* command = new QUndoCommand();
QVector<Block*> blocks_to_split;
foreach (const TrackReference& track, split_tracks_) {
new TrackSplitAtTimeCommand(parent()->GetTrackFromReference(track), split_time, command);
foreach (const TrackReference& track_ref, split_tracks_) {
TrackOutput* track = parent()->GetTrackFromReference(track_ref);
Block* block_at_time = track->NearestBlockBefore(split_time);
// Ensure there's a valid block here
if (block_at_time != track
&& !blocks_to_split.contains(block_at_time)) {
blocks_to_split.append(block_at_time);
// Add links if no alt is held
if (!(event->GetModifiers() & Qt::AltModifier)) {
foreach (Block* link, block_at_time->linked_clips()) {
if (!blocks_to_split.contains(link)) {
blocks_to_split.append(link);
}
}
}
}
}
split_tracks_.clear();
olive::undo_stack.pushIfHasChildren(command);
olive::undo_stack.push(new BlockSplitPreservingLinksCommand(blocks_to_split, {split_time}));
dragging_ = false;
}