added convenience undo command for removing a node and its exclusive deps

This commit is contained in:
itsmattkc
2019-12-19 01:44:18 +11:00
parent 3fb7b40b61
commit 05e10962f9
5 changed files with 22 additions and 11 deletions
+1 -4
View File
@@ -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);
+9
View File
@@ -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);
}
+10
View File
@@ -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
+1 -6
View File
@@ -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);
}
}
}
+1 -1
View File
@@ -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);
}
}
}