Add Delete functionality. Still buggy.

This commit is contained in:
Thomas Wilshaw
2020-09-29 00:06:38 +01:00
parent 602f96b2b6
commit 92db735022
3 changed files with 76 additions and 0 deletions
+33
View File
@@ -26,6 +26,7 @@
#include "core.h"
#include "node/input/media/media.h"
#include "widget/timelinewidget/timelinewidget.h"
OLIVE_NAMESPACE_ENTER
@@ -641,4 +642,36 @@ void ProjectViewModel::OfflineFootageCommand::undo_internal()
}
}
ProjectViewModel::DeleteFootageCommand::DeleteFootageCommand(ProjectViewModel* model, ItemPtr item,
QList<Block*> blocks, QUndoCommand* parent) :
UndoCommand(parent),
model_(model),
item_(item),
blocks_(blocks)
{
deleteCommand_ = new QUndoCommand();
removalCommand_ = new QUndoCommand();
}
Project *ProjectViewModel::DeleteFootageCommand::GetRelevantProject() const
{
return model_->project();
}
void ProjectViewModel::DeleteFootageCommand::redo_internal()
{
TimelineWidget::ReplaceBlocksWithGaps(blocks_, true, deleteCommand_);
Core::instance()->undo_stack()->pushIfHasChildren(deleteCommand_);
new ProjectViewModel::RemoveItemCommand(model_, item_, removalCommand_);
Core::instance()->undo_stack()->pushIfHasChildren(removalCommand_);
}
void ProjectViewModel::DeleteFootageCommand::undo_internal()
{
removalCommand_->undo();
deleteCommand_->undo();
}
OLIVE_NAMESPACE_EXIT
+24
View File
@@ -25,6 +25,7 @@
#include "project.h"
#include "undo/undocommand.h"
#include "node/block/block.h"
OLIVE_NAMESPACE_ENTER
@@ -215,6 +216,29 @@ public:
QMap<Node*, StreamPtr> nodes_;
};
class DeleteFootageCommand : public UndoCommand {
public:
DeleteFootageCommand(ProjectViewModel* model, ItemPtr item, QList<Block*> blocks, QUndoCommand* parent = nullptr);
virtual Project* GetRelevantProject() const override;
protected:
virtual void redo_internal() override;
virtual void undo_internal() override;
private:
ProjectViewModel* model_;
ItemPtr item_;
QList<Block*> blocks_;
QUndoCommand* deleteCommand_;
QUndoCommand* removalCommand_;
};
private:
/**
* @brief Retrieve the index of `item` in its parent