timeline: auto-unlink blocks when they're deleted

This commit is contained in:
itsmattkc
2020-03-15 13:15:36 +11:00
parent 78baf7661f
commit b57b091ca4
5 changed files with 100 additions and 4 deletions
@@ -380,6 +380,8 @@ void TimelineWidget::DeleteSelectedInternal(const QList<Block *> &blocks,
}
if (remove_from_graph) {
new BlockUnlinkAllCommand(b, command);
new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(b->parent()), b, command);
}
}
+49
View File
@@ -715,3 +715,52 @@ void WorkareaSetRangeCommand::undo_internal()
{
points_->workarea()->set_range(old_range_);
}
BlockLinkCommand::BlockLinkCommand(const QList<Block *> &blocks, bool link, QUndoCommand *parent) :
UndoCommand(parent),
blocks_(blocks),
link_(link)
{
}
void BlockLinkCommand::redo_internal()
{
if (link_) {
Block::Link(blocks_);
} else {
Block::Unlink(blocks_);
}
}
void BlockLinkCommand::undo_internal()
{
if (link_) {
Block::Unlink(blocks_);
} else {
Block::Link(blocks_);
}
}
BlockUnlinkAllCommand::BlockUnlinkAllCommand(Block *block, QUndoCommand *parent) :
UndoCommand(parent),
block_(block)
{
}
void BlockUnlinkAllCommand::redo_internal()
{
unlinked_ = block_->linked_clips();
foreach (Block* link, unlinked_) {
Block::Unlink(block_, link);
}
}
void BlockUnlinkAllCommand::undo_internal()
{
foreach (Block* link, unlinked_) {
Block::Link(block_, link);
}
unlinked_.clear();
}
+30
View File
@@ -331,4 +331,34 @@ private:
};
class BlockLinkCommand : public UndoCommand {
public:
BlockLinkCommand(const QList<Block*>& blocks, bool link, QUndoCommand* parent = nullptr);
protected:
virtual void redo_internal() override;
virtual void undo_internal() override;
private:
QList<Block*> blocks_;
bool link_;
};
class BlockUnlinkAllCommand : public UndoCommand {
public:
BlockUnlinkAllCommand(Block* block, QUndoCommand* parent = nullptr);
protected:
virtual void redo_internal() override;
virtual void undo_internal() override;
private:
Block* block_;
QVector<Block*> unlinked_;
};
#endif // TIMELINEUNDOABLE_H