Commit 471b91e8 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Clip: Move the linked clip to the SequenceWorkflow Clip instance

parent 07fd3c83
......@@ -166,7 +166,7 @@ Rectangle {
function findClipItem( uuid ) {
for ( var i = 0; i < allClips.length; ++i ) {
if ( uuid === allClips[i].uuid )
if ( uuid === allClips[i].instanceUuid )
return allClips[i];
}
return null;
......
......@@ -42,8 +42,7 @@
Clip::Clip( QSharedPointer<Media> media, qint64 begin /*= 0*/, qint64 end /*= Backend::IInput::EndOfMedia */, const QUuid& uuid /*= QString()*/ ) :
Workflow::Helper( uuid ),
m_media( media ),
m_input( media->input()->cut( begin, end ) ),
m_isLinked( false )
m_input( media->input()->cut( begin, end ) )
{
Formats f;
if ( media->input()->hasAudio() == true )
......@@ -163,30 +162,6 @@ Clip::setBoundaries( qint64 begin, qint64 end )
m_input->setBoundaries( begin, end );
}
void
Clip::setLinkedClipUuid( const QUuid& uuid )
{
m_linkedClipUuid = uuid;
}
const QUuid&
Clip::linkedClipUuid() const
{
return m_linkedClipUuid;
}
void
Clip::setLinked( bool isLinked )
{
m_isLinked = isLinked;
}
bool
Clip::isLinked() const
{
return m_isLinked;
}
QVariant
Clip::toVariant() const
{
......@@ -198,13 +173,6 @@ Clip::toVariant() const
};
h.insert( "begin", begin() );
h.insert( "end", end() );
if ( isLinked() == true )
{
h.insert( "linkedClip", m_linkedClipUuid );
h.insert( "linked", true );
}
else
h.insert( "linked", false );
return QVariant( h );
}
......
......@@ -95,12 +95,6 @@ class Clip : public Workflow::Helper
virtual qint64 length() const override;
virtual void setBoundaries( qint64 begin, qint64 end ) override;
void setLinkedClipUuid( const QUuid& uuid );
const QUuid& linkedClipUuid() const;
void setLinked( bool isLinked );
bool isLinked() const;
const QStringList &metaTags() const;
void setMetaTags( const QStringList &tags );
bool matchMetaTag( const QString &tag ) const;
......@@ -122,9 +116,6 @@ class Clip : public Workflow::Helper
QStringList m_metaTags;
QString m_notes;
QUuid m_linkedClipUuid;
bool m_isLinked;
Formats m_formats;
signals:
......
......@@ -155,33 +155,40 @@ SequenceWorkflow::removeClip( const QUuid& uuid )
bool
SequenceWorkflow::linkClips( const QUuid& uuidA, const QUuid& uuidB )
{
auto clipA = clip( uuidA )->clip;
auto clipB = clip( uuidB )->clip;
auto clipA = clip( uuidA );
auto clipB = clip( uuidB );
if ( !clipA || !clipB )
{
vlmcCritical() << "Couldn't find clips: " << uuidA << " and " << uuidB;
return false;
}
clipA->setLinkedClipUuid( clipB->uuid() );
clipB->setLinkedClipUuid( clipA->uuid() );
clipA->setLinked( true );
clipB->setLinked( true );
clipA->linkedClips.append( clipB->uuid );
clipB->linkedClips.append( clipA->uuid );
return true;
}
bool
SequenceWorkflow::unlinkClips( const QUuid& uuidA, const QUuid& uuidB )
{
auto clipA = clip( uuidA )->clip;
auto clipB = clip( uuidB )->clip;
auto clipA = clip( uuidA );
auto clipB = clip( uuidB );
if ( !clipA || !clipB )
{
vlmcCritical() << "Couldn't find clips: " << uuidA << " and " << uuidB;
return false;
}
clipA->setLinked( false );
clipB->setLinked( false );
return true;
bool ret = true;
if ( clipA->linkedClips.removeOne( uuidB ) == false )
{
ret = false;
vlmcWarning() << "Failed to unlink" << uuidB << "from Clip instance" << uuidA;
}
if ( clipB->linkedClips.removeOne( uuidA ) == false )
{
ret = false;
vlmcWarning() << "Failed to unlink" << uuidA << "from Clip instance" << uuidB;
}
return ret;
}
QVariant
......@@ -196,10 +203,12 @@ SequenceWorkflow::toVariant() const
{ "clipUuid", c->clip->uuid().toString() },
{ "position", c->pos },
{ "trackId", c->trackId },
{ "linked", c->clip->isLinked() },
{ "linkedClip", c->clip->linkedClipUuid() },
{ "filters", EffectHelper::toVariant( c->clip->input() ) }
};
QList<QVariant> linkedClipList;
for ( const auto& uuid : c->linkedClips )
linkedClipList.append( uuid.toString() );
h["linkedClips"] = linkedClipList;
l << h;
}
QVariantHash h{ { "clips", l }, { "filters", EffectHelper::toVariant( m_multitrack ) } };
......@@ -224,10 +233,11 @@ SequenceWorkflow::loadFromVariant( const QVariant& variant )
addClip( clip, m["trackId"].toUInt(), m["position"].toLongLong(), uuid );
auto c = m_clips[uuid];
auto isLinked = m["linked"].toBool();
clip->setLinked( isLinked );
if ( isLinked == true )
clip->setLinkedClipUuid( m["linkedClip"].toString() );
auto linkedClipsList = m["linkedClip"].toList();
for ( const auto& uuid : linkedClipsList )
{
c->linkedClips.append( uuid.toUuid() );
}
EffectHelper::loadFromVariant( m["filters"], clip->input() );
......
......@@ -64,6 +64,7 @@ class SequenceWorkflow : public QObject
QUuid uuid;
quint32 trackId;
qint64 pos;
QVector<QUuid> linkedClips;
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment