Add Delete functionality. Still buggy.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "widget/menu/menu.h"
|
||||
#include "widget/menu/menushared.h"
|
||||
#include "window/mainwindow/mainwindow.h"
|
||||
#include "widget/timelinewidget/timelinewidget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -633,6 +634,24 @@ void ProjectExplorer::DeleteSelected()
|
||||
// Get all sequences.
|
||||
QList<ItemPtr> sequences = model_.project()->get_items_of_type(Item::kSequence);
|
||||
|
||||
QList<Block*> blocks;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new ProjectViewModel::DeleteFootageCommand(&model_, item_ptr, blocks, command);
|
||||
|
||||
}
|
||||
if (response == kCancel) {
|
||||
delete command;
|
||||
|
||||
Reference in New Issue
Block a user