added convenience undo command for removing a node and its exclusive deps
This commit is contained in:
@@ -172,10 +172,7 @@ void SpeedDurationDialog::accept()
|
||||
new TrackRippleRemoveBlockCommand(TrackOutput::TrackFromBlock(next_block), next_block, command);
|
||||
|
||||
// Delete node and its exclusive deps
|
||||
QList<Node*> gap_and_its_deps;
|
||||
gap_and_its_deps.append(next_block);
|
||||
gap_and_its_deps.append(next_block->GetExclusiveDependencies());
|
||||
new NodeRemoveCommand(static_cast<NodeGraph*>(next_block->parent()), gap_and_its_deps, command);
|
||||
new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(next_block->parent()), next_block, command);
|
||||
} else {
|
||||
// Otherwise we can just resize it
|
||||
new BlockResizeCommand(next_block, next_block->out() - new_clip_length, command);
|
||||
|
||||
@@ -125,3 +125,12 @@ void NodeRemoveCommand::undo()
|
||||
|
||||
edges_.clear();
|
||||
}
|
||||
|
||||
NodeRemoveWithExclusiveDeps::NodeRemoveWithExclusiveDeps(NodeGraph *graph, Node *node, QUndoCommand *parent)
|
||||
{
|
||||
QList<Node*> node_and_its_deps;
|
||||
node_and_its_deps.append(node);
|
||||
node_and_its_deps.append(node->GetExclusiveDependencies());
|
||||
|
||||
remove_command_ = new NodeRemoveCommand(graph, node_and_its_deps, this);
|
||||
}
|
||||
|
||||
@@ -78,4 +78,14 @@ private:
|
||||
QList<NodeEdgePtr> edges_;
|
||||
};
|
||||
|
||||
class NodeRemoveWithExclusiveDeps : public QUndoCommand {
|
||||
public:
|
||||
NodeRemoveWithExclusiveDeps(NodeGraph* graph,
|
||||
Node* node,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
private:
|
||||
NodeRemoveCommand* remove_command_;
|
||||
};
|
||||
|
||||
#endif // NODEVIEWUNDO_H
|
||||
|
||||
@@ -445,12 +445,7 @@ void TimelineWidget::DeleteSelectedInternal(const QList<Block *> blocks, bool re
|
||||
}
|
||||
|
||||
if (remove_from_graph) {
|
||||
QList<Node*> block_and_its_exclusive_deps;
|
||||
|
||||
block_and_its_exclusive_deps.append(b);
|
||||
block_and_its_exclusive_deps.append(b->GetExclusiveDependencies());
|
||||
|
||||
new NodeRemoveCommand(static_cast<NodeGraph*>(b->parent()), block_and_its_exclusive_deps, command);
|
||||
new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(b->parent()), b, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev
|
||||
// Assumed the Block was a Gap and it was reduced to zero length, remove it here
|
||||
new TrackRippleRemoveBlockCommand(parent()->GetTrackFromReference(ghost->Track()), b, command);
|
||||
|
||||
new NodeRemoveCommand(static_cast<NodeGraph*>(b->parent()), {b}, command);
|
||||
new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(b->parent()), b, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user