Commit 2b5ace6a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Clip: Remove dependency on MediaContainer

parent e9d52b31
......@@ -46,7 +46,6 @@ Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= Backend::IInput::
m_parent( media->baseClip() ),
m_isLinked( false )
{
m_childs = new MediaContainer( this );
m_rootClip = media->baseClip();
Formats f;
if ( media->input()->hasAudio() == true )
......@@ -63,7 +62,6 @@ Clip::Clip( Clip *parent, qint64 begin /*= -1*/, qint64 end /*= -2*/,
m_rootClip( parent->rootClip() ),
m_parent( parent )
{
m_childs = new MediaContainer( this );
if ( begin == -1 )
begin = parent->begin();
else
......@@ -80,7 +78,6 @@ Clip::Clip( Clip *parent, qint64 begin /*= -1*/, qint64 end /*= -2*/,
Clip::~Clip()
{
emit unloaded( this );
delete m_childs;
if ( isRootClip() == true )
delete m_media;
}
......@@ -242,28 +239,19 @@ Clip::parent() const
return m_parent;
}
MediaContainer*
Clip::mediaContainer()
{
return m_childs;
}
const MediaContainer*
Clip::mediaContainer() const
{
return m_childs;
}
bool
Clip::addSubclip( Clip *clip )
{
return m_childs->addClip( clip );
if ( m_subclips.contains( clip->uuid() ) == true )
return false;
m_subclips[clip->uuid()] = clip;
emit subclipAdded( clip );
}
void
Clip::clear()
{
m_childs->clear();
m_subclips.clear();
}
bool
......@@ -313,13 +301,12 @@ QVariant
Clip::toVariantFull() const
{
QVariantHash h = toVariant().toHash();
if ( m_childs->count() > 0 )
{
QVariantList l;
for ( const auto& c : m_childs->clips() )
l << c->toVariant();
h.insert( "subClips", l );
}
if ( m_subclips.isEmpty() == true )
return h;
QVariantList l;
for ( const auto& c : m_subclips.values() )
l << c->toVariant();
h.insert( "subClips", l );
return h;
}
......@@ -416,7 +403,7 @@ Clip::loadVariant( const QVariantMap& m )
{
auto children = m["subClips"].toList();
for ( const auto& clipMap : children )
m_childs->addClip( fromVariant( clipMap, this ) );
addSubclip( fromVariant( clipMap, this ) );
}
if ( m.contains( "filters" ) )
{
......
......@@ -30,6 +30,7 @@
# define CLIP_H__
#include "Workflow/Helper.h"
#include <QHash>
#include <QStringList>
#include <QUuid>
#include <QXmlStreamWriter>
......@@ -37,7 +38,6 @@
#include <memory>
class MediaContainer;
class Media;
class Clip : public Workflow::Helper
......@@ -89,8 +89,8 @@ class Clip : public Workflow::Helper
Clip *parent();
const Clip *parent() const;
MediaContainer* mediaContainer();
const MediaContainer* mediaContainer() const;
const QHash<QUuid, Clip*>& clips() const;
/**
\brief Returns an unique Uuid for this clip (which is NOT the
......@@ -164,7 +164,7 @@ class Clip : public Workflow::Helper
*/
Clip* m_rootClip;
MediaContainer* m_childs;
QHash<QUuid, Clip*> m_subclips;
Clip* m_parent;
......@@ -181,6 +181,19 @@ class Clip : public Workflow::Helper
* \brief Act just like QObject::destroyed(), but before the clip deletion.
*/
void unloaded( Clip* );
/**
* \brief This signal should be emitted to tell a new sublip have been added
* \param Clip The newly added subclip
*/
void subclipAdded( Clip* );
/**
* \brief This signal should be emiteted when a subclip has been removed
* This signal pass a QUuid as the clip may be deleted when the signal reaches its
* slot.
* \param uuid The removed clip uuid
*/
void subclipRemoved( const QUuid& );
};
Q_DECLARE_OPERATORS_FOR_FLAGS( Clip::Formats )
......
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