Make Offlining footage an UndoCommand

Created a new UndoCommand in ProjectViewModel that set the footage
input to a nullptr and resets it to the correct stream on undo.
This commit is contained in:
Thomas Wilshaw
2020-09-28 14:33:58 +01:00
parent c1e345611d
commit 5bb9cb0cca
4 changed files with 75 additions and 13 deletions
+38
View File
@@ -25,6 +25,7 @@
#include <QUrl>
#include "core.h"
#include "node/input/media/media.h"
OLIVE_NAMESPACE_ENTER
@@ -603,4 +604,41 @@ void ProjectViewModel::RemoveItemCommand::undo_internal()
model_->AddChild(parent_, item_);
}
ProjectViewModel::OfflineFootageCommand::OfflineFootageCommand(ProjectViewModel* model, ItemPtr item,
QMap<Node*, StreamPtr> nodes, QUndoCommand* parent) :
UndoCommand(parent),
model_(model),
item_(item),
nodes_(nodes)
{
}
Project *ProjectViewModel::OfflineFootageCommand::GetRelevantProject() const
{
return model_->project();
}
void ProjectViewModel::OfflineFootageCommand::redo_internal()
{
QMap<Node *, StreamPtr>::const_iterator it = nodes_.constBegin();
while (it != nodes_.constEnd()) {
static_cast<MediaInput *>(it.key())->SetFootage(nullptr);
++it;
}
parent_ = item_->parent();
model_->RemoveChild(parent_, item_.get());
}
void ProjectViewModel::OfflineFootageCommand::undo_internal()
{
model_->AddChild(parent_, item_);
QMap<Node *, StreamPtr>::const_iterator it = nodes_.constBegin();
while (it != nodes_.constEnd()) {
static_cast<MediaInput *>(it.key())->SetFootage(it.value());
++it;
}
}
OLIVE_NAMESPACE_EXIT