moved block links to node links
Seems like it might be useful to have this as part of the node architecture as a whole
This commit is contained in:
@@ -113,9 +113,8 @@ void NodeRemoveAndDisconnectCommand::prep()
|
||||
command_ = new QUndoCommand();
|
||||
|
||||
// If this is a block, remove all links
|
||||
Block* block = dynamic_cast<Block*>(node_);
|
||||
if (block) {
|
||||
new BlockUnlinkAllCommand(block, command_);
|
||||
if (node_->HasLinks()) {
|
||||
new NodeUnlinkAllCommand(node_, command_);
|
||||
}
|
||||
|
||||
// Disconnect everything
|
||||
|
||||
@@ -230,6 +230,114 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeLinkCommand : public UndoCommand {
|
||||
public:
|
||||
NodeLinkCommand(Node* a, Node* b, bool link, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
a_(a),
|
||||
b_(b),
|
||||
link_(link)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return a_->parent()->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override
|
||||
{
|
||||
if (link_) {
|
||||
done_ = Node::Link(a_, b_);
|
||||
} else {
|
||||
done_ = Node::Unlink(a_, b_);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override
|
||||
{
|
||||
if (done_) {
|
||||
if (link_) {
|
||||
Node::Unlink(a_, b_);
|
||||
} else {
|
||||
Node::Link(a_, b_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Node* a_;
|
||||
Node* b_;
|
||||
bool link_;
|
||||
bool done_;
|
||||
|
||||
};
|
||||
|
||||
class NodeUnlinkAllCommand : public UndoCommand {
|
||||
public:
|
||||
NodeUnlinkAllCommand(Node* node, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
node_(node)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return node_->parent()->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override
|
||||
{
|
||||
unlinked_ = node_->links();
|
||||
|
||||
foreach (Node* link, unlinked_) {
|
||||
Node::Unlink(node_, link);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override
|
||||
{
|
||||
foreach (Node* link, unlinked_) {
|
||||
Node::Link(node_, link);
|
||||
}
|
||||
|
||||
unlinked_.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
Node* node_;
|
||||
|
||||
QVector<Node*> unlinked_;
|
||||
|
||||
};
|
||||
|
||||
class NodeLinkManyCommand : public UndoCommand {
|
||||
public:
|
||||
NodeLinkManyCommand(const QVector<Node*> nodes, bool link, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
nodes_(nodes)
|
||||
{
|
||||
foreach (Node* a, nodes_) {
|
||||
foreach (Node* b, nodes_) {
|
||||
if (a != b) {
|
||||
new NodeLinkCommand(a, b, link, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return nodes_.first()->parent()->project();
|
||||
}
|
||||
|
||||
private:
|
||||
QVector<Node*> nodes_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWUNDO_H
|
||||
|
||||
@@ -500,117 +500,6 @@ private:
|
||||
Block* before_;
|
||||
};
|
||||
|
||||
class BlockLinkCommand : public UndoCommand {
|
||||
public:
|
||||
BlockLinkCommand(Block* a, Block* b, bool link, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
a_(a),
|
||||
b_(b),
|
||||
link_(link)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return a_->parent()->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override
|
||||
{
|
||||
if (link_) {
|
||||
done_ = Block::Link(a_, b_);
|
||||
} else {
|
||||
done_ = Block::Unlink(a_, b_);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override
|
||||
{
|
||||
if (done_) {
|
||||
if (link_) {
|
||||
Block::Unlink(a_, b_);
|
||||
} else {
|
||||
Block::Link(a_, b_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Block* a_;
|
||||
|
||||
Block* b_;
|
||||
|
||||
bool link_;
|
||||
|
||||
bool done_;
|
||||
|
||||
};
|
||||
|
||||
class BlockUnlinkAllCommand : public UndoCommand {
|
||||
public:
|
||||
BlockUnlinkAllCommand(Block* block, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
block_(block)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return static_cast<Sequence*>(block_->parent())->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override
|
||||
{
|
||||
unlinked_ = block_->linked_clips();
|
||||
|
||||
foreach (Block* link, unlinked_) {
|
||||
Block::Unlink(block_, link);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override
|
||||
{
|
||||
foreach (Block* link, unlinked_) {
|
||||
Block::Link(block_, link);
|
||||
}
|
||||
|
||||
unlinked_.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
QVector<Block*> unlinked_;
|
||||
|
||||
};
|
||||
|
||||
class BlockLinkManyCommand : public UndoCommand {
|
||||
public:
|
||||
BlockLinkManyCommand(const QVector<Block*> blocks, bool link, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent),
|
||||
blocks_(blocks)
|
||||
{
|
||||
foreach (Block* a, blocks_) {
|
||||
foreach (Block* b, blocks_) {
|
||||
if (a != b) {
|
||||
new BlockLinkCommand(a, b, link, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return blocks_.first()->parent()->project();
|
||||
}
|
||||
|
||||
private:
|
||||
QVector<Block*> blocks_;
|
||||
|
||||
};
|
||||
|
||||
class BlockSplitCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitCommand(Block* block, rational point, QUndoCommand* parent = nullptr) :
|
||||
@@ -833,7 +722,7 @@ protected:
|
||||
// These blocks are linked, ensure all the splits are linked too
|
||||
|
||||
foreach (const QVector<Block*>& split_list, split_blocks) {
|
||||
BlockLinkCommand* blc = new BlockLinkCommand(split_list.at(i), split_list.at(j), true);
|
||||
NodeLinkCommand* blc = new NodeLinkCommand(split_list.at(i), split_list.at(j), true);
|
||||
blc->redo();
|
||||
commands_.append(blc);
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ void TimelineWidget::OverwriteFootageAtPlayhead(const QVector<Footage *> &footag
|
||||
|
||||
void TimelineWidget::ToggleLinksOnSelected()
|
||||
{
|
||||
QVector<Block*> blocks;
|
||||
QVector<Node*> blocks;
|
||||
bool link = true;
|
||||
|
||||
foreach (Block* item, GetSelectedBlocks()) {
|
||||
@@ -551,7 +551,7 @@ void TimelineWidget::ToggleLinksOnSelected()
|
||||
return;
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(new BlockLinkManyCommand(blocks, link));
|
||||
Core::instance()->undo_stack()->push(new NodeLinkManyCommand(blocks, link));
|
||||
}
|
||||
|
||||
void TimelineWidget::CopySelected(bool cut)
|
||||
@@ -1050,7 +1050,7 @@ void TimelineWidget::SetViewBeamCursor(const TimelineCoordinate &coord)
|
||||
|
||||
void TimelineWidget::SetBlockLinksSelected(Block* block, bool selected)
|
||||
{
|
||||
foreach (Block* link, block->linked_clips()) {
|
||||
foreach (Block* link, block->block_links()) {
|
||||
if (selected) {
|
||||
AddSelection(link);
|
||||
} else {
|
||||
@@ -1385,7 +1385,7 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, bool select_lin
|
||||
}
|
||||
|
||||
if (select_links) {
|
||||
foreach (Block* link, b->linked_clips()) {
|
||||
foreach (Block* link, b->block_links()) {
|
||||
if (!rubberband_now_selected_.contains(link)) {
|
||||
AddSelection(link);
|
||||
rubberband_now_selected_.append(link);
|
||||
|
||||
@@ -93,7 +93,7 @@ void PointerTool::MousePress(TimelineViewMouseEvent *event)
|
||||
// If not holding alt, deselect all links as well
|
||||
if (!(event->GetModifiers() & Qt::AltModifier)) {
|
||||
parent()->SetBlockLinksSelected(clicked_item_, false);
|
||||
deselected_blocks.append(clicked_item_->linked_clips());
|
||||
deselected_blocks.append(clicked_item_->block_links());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void PointerTool::MousePress(TimelineViewMouseEvent *event)
|
||||
// If not holding alt, select all links as well
|
||||
if (!(event->GetModifiers() & Qt::AltModifier)) {
|
||||
parent()->SetBlockLinksSelected(clicked_item_, true);
|
||||
selected_blocks.append(clicked_item_->linked_clips());
|
||||
selected_blocks.append(clicked_item_->block_links());
|
||||
}
|
||||
|
||||
parent()->SignalSelectedBlocks(selected_blocks);
|
||||
|
||||
@@ -77,7 +77,7 @@ void RazorTool::MouseRelease(TimelineViewMouseEvent *event)
|
||||
|
||||
// Add links if no alt is held
|
||||
if (!(event->GetModifiers() & Qt::AltModifier)) {
|
||||
foreach (Block* link, block_at_time->linked_clips()) {
|
||||
foreach (Block* link, block_at_time->block_links()) {
|
||||
if (!blocks_to_split.contains(link)) {
|
||||
blocks_to_split.append(link);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user