Simplify and clean up

Remove the Undo code for deleting a clip and replace it with simpler
parent/child undo relationship.

Move block gathering code to seperate function. It's quite brute
force and might lead to issues further down the line with more
complex composited node setups.
This commit is contained in:
Thomas Wilshaw
2020-09-29 11:31:03 +01:00
parent aef9078598
commit 8e6b42a160
4 changed files with 32 additions and 97 deletions
-48
View File
@@ -642,52 +642,4 @@ void ProjectViewModel::OfflineFootageCommand::undo_internal()
}
}
ProjectViewModel::DeleteFootageCommand::DeleteFootageCommand(ProjectViewModel *model, ItemPtr item,
QMap<Node *, StreamPtr> nodes, QUndoCommand *parent)
:
UndoCommand(parent),
model_(model),
item_(item),
nodes_(nodes)
{
deleteCommand_ = new QUndoCommand();
}
Project *ProjectViewModel::DeleteFootageCommand::GetRelevantProject() const
{
return model_->project();
}
void ProjectViewModel::DeleteFootageCommand::redo_internal()
{
QList<ItemPtr> sequences = model_->project()->get_items_of_type(Item::kSequence);
blocks_.clear();
foreach (ItemPtr seq, sequences) {
Sequence *s = static_cast<Sequence *>(seq.get());
// Loop through nodes in sequence
foreach (Node *node, s->nodes()) {
// For each Block see if it is linked to one of the Footage nodes add it to the delete list
if (node->IsBlock()) {
foreach (Node *input, nodes_.keys()) {
if (node->GetExclusiveDependencies().contains(input)) blocks_.append(static_cast<Block *>(node));
}
}
}
}
TimelineWidget::ReplaceBlocksWithGaps(blocks_, true, deleteCommand_);
Core::instance()->undo_stack()->pushIfHasChildren(deleteCommand_);
parent_ = item_->parent();
model_->RemoveChild(parent_, item_.get());
}
void ProjectViewModel::DeleteFootageCommand::undo_internal()
{
model_->AddChild(parent_, item_);
deleteCommand_->undo();
}
OLIVE_NAMESPACE_EXIT