project: remove array element when deleting a folder's subitem

Fixes #1639
This commit is contained in:
itsmattkc
2021-05-23 10:38:30 +10:00
parent 6ff9ab9f54
commit 09dc79f9f6
4 changed files with 117 additions and 55 deletions
+18
View File
@@ -24,6 +24,7 @@
#include "node/project/footage/footage.h"
#include "node/project/sequence/sequence.h"
#include "ui/icons/icons.h"
#include "widget/nodeview/nodeviewundo.h"
namespace olive {
@@ -155,4 +156,21 @@ void FolderAddChild::undo()
folder_->InputArrayRemoveLast(Folder::kChildInput);
}
void Folder::RemoveElementCommand::redo()
{
if (!subcommand_) {
remove_index_ = folder_->index_of_child_in_array(child_);
if (remove_index_ != -1) {
NodeInput connected_input(folder_, Folder::kChildInput, remove_index_);
subcommand_ = new MultiUndoCommand();
subcommand_->add_child(new NodeEdgeRemoveCommand(folder_->GetConnectedOutput(connected_input), connected_input));
subcommand_->add_child(new Node::ArrayRemoveCommand(folder_, Folder::kChildInput, remove_index_));
}
}
if (subcommand_) {
subcommand_->redo();
}
}
}