added link support to blocks

This commit is contained in:
itsmattkc
2019-10-16 22:33:52 +11:00
parent 578345693b
commit a63e8c8719
2 changed files with 45 additions and 2 deletions
+37 -1
View File
@@ -135,7 +135,7 @@ void Block::EdgeRemovedSlot(NodeEdgePtr edge)
}
void Block::Refresh()
{
{
// Set in point to the out point of the previous Node
if (previous() != nullptr) {
in_point_ = previous()->out();
@@ -228,3 +228,39 @@ void Block::CopyParameters(Block *source, Block *dest)
dest->set_length(source->length());
dest->set_media_in(source->media_in());
}
void Block::Link(Block *a, Block *b)
{
if (a == b) {
return;
}
// Assume both clips are already linked since Link() and Unlink() should be the only entry points to this array
if (a->linked_clips_.contains(b)) {
return;
}
a->linked_clips_.append(b);
b->linked_clips_.append(a);
}
void Block::Link(QList<Block *> blocks)
{
foreach (Block* a, blocks) {
foreach (Block* b, blocks) {
Link(a, b);
}
}
}
void Block::Unlink(Block *a, Block *b)
{
a->linked_clips_.removeOne(b);
b->linked_clips_.removeOne(a);
}
const QVector<Block*> &Block::linked_clips()
{
return linked_clips_;
}
+8 -1
View File
@@ -71,6 +71,11 @@ public:
const QString& block_name();
void set_block_name(const QString& name);
static void Link(Block* a, Block* b);
static void Link(QList<Block*> blocks);
static void Unlink(Block* a, Block* b);
const QVector<Block*>& linked_clips();
public slots:
/**
* @brief Refreshes internal cache of in/out points up to date
@@ -104,7 +109,7 @@ protected:
static void CopyParameters(Block* source, Block* dest);
private:
private:
NodeInput* previous_input_;
NodeOutput* block_output_;
@@ -121,6 +126,8 @@ private:
QString block_name_;
QVector<Block*> linked_clips_;
private slots:
void EdgeAddedSlot(NodeEdgePtr edge);