Merge branch 'master' into nodeview-redux

This commit is contained in:
itsmattkc
2021-05-23 10:49:11 +10:00
7 changed files with 154 additions and 57 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 {
@@ -154,4 +155,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();
}
}
}
+40
View File
@@ -115,6 +115,46 @@ public:
static const QString kChildInput;
class RemoveElementCommand : public UndoCommand
{
public:
RemoveElementCommand(Folder *folder, Node *child) :
folder_(folder),
child_(child),
subcommand_(nullptr)
{
}
virtual ~RemoveElementCommand() override
{
delete subcommand_;
}
virtual Project *GetRelevantProject() const override
{
return folder_->project();
}
virtual void redo() override;
virtual void undo() override
{
if (subcommand_) {
subcommand_->undo();
}
}
private:
Folder *folder_;
Node *child_;
int remove_index_;
MultiUndoCommand *subcommand_;
};
signals:
void BeginInsertItem(Node* n, int index);