Commit 48db69f0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Clip: cleaning up the mess with CTORs

Please : Do NOT add anyother contructor. There is enough right now.
parent 19b72513
......@@ -45,74 +45,43 @@ Clip::Clip( Media *parent, const QString& uuid ) :
computeLength();
}
Clip::Clip( Clip *creator, qint64 begin, qint64 end ) :
m_parent( creator->getParent() ),
Clip::Clip( Clip *clip, qint64 begin /*= 0*/, qint64 end /*= -1*/ ) :
m_parent( clip->m_parent ),
m_begin( begin ),
m_end( end ),
m_maxBegin( begin ),
m_maxEnd( end )
m_metaTags( clip->m_metaTags ),
m_notes( clip->m_notes ),
m_maxBegin( clip->m_begin ),
m_maxEnd( clip->m_end )
{
if ( begin == -1 )
m_begin = clip->begin();
if ( end == -1 )
m_end = clip->end();
m_uuid = QUuid::createUuid();
computeLength();
}
Clip::Clip( Media *parent, qint64 begin, qint64 end /*= -1*/ ) :
Clip::Clip( Media *parent, qint64 begin, qint64 end /*= -1*/,
const QString &uuid /*= QString()*/ ) :
m_parent( parent ),
m_begin( begin ),
m_end( end ),
m_maxBegin( begin ),
m_maxEnd( end )
{
//FIXME: WTF ?
Q_ASSERT( parent->inputType() == Media::File || ( begin == 0 && end == m_parent->nbFrames() ) );
if ( parent->inputType() == Media::File && end < 0 )
if ( end < 0 )
{
m_end = parent->nbFrames();
m_maxEnd = m_end;
}
m_uuid = QUuid::createUuid();
computeLength();
}
Clip::Clip( const Clip *clip ) :
m_parent( clip->m_parent ),
m_begin( clip->m_begin ),
m_end( clip->m_end ),
m_length( clip->m_length ),
m_lengthSeconds( clip->m_lengthSeconds ),
m_metaTags( clip->m_metaTags ),
m_notes( clip->m_notes ),
m_maxBegin( clip->m_begin ),
m_maxEnd( clip->m_end )
{
m_uuid = QUuid::createUuid();
}
Clip::Clip( const QUuid &uuid, qint64 begin, qint64 end ) :
m_begin( begin),
m_end( end ),
m_maxBegin( begin ),
m_maxEnd( end )
{
Q_UNUSED( end );
Media* media = Library::getInstance()->media( uuid );
Q_ASSERT( media != NULL );
m_parent = media;
m_uuid = QUuid::createUuid();
computeLength();
}
Clip::Clip( Media *parent, qint64 begin, qint64 end, const QUuid &uuid )
: m_parent( parent ),
m_begin( begin ),
m_end( end ),
m_uuid( uuid )
{
if ( uuid.isEmpty() == true )
m_uuid = QUuid::createUuid();
else
m_uuid = QUuid( uuid );
computeLength();
}
Clip::~Clip()
{
}
......
......@@ -42,12 +42,34 @@ class Clip : public QObject
public:
static const int DefaultFPS;
/**
* \brief Construct the base clip for a Media.
*
* This clip will represent the whole media as a Clip.
* \param parent The media to represent.
* \param uuid A forced unique id. If not given, a new unique id will be generated.
*/
Clip( Media *parent, const QString& uuid = QString() );
Clip( Media *parent, qint64 begin, qint64 end = -1 );
Clip( Clip *creator, qint64 begin, qint64 end );
Clip( const Clip *clip );
Clip( const QUuid &uuid, qint64 begin = 0, qint64 end = -1 );
Clip( Media *parent, qint64 begin, qint64 end, const QUuid &uuid );
/**
* \brief Constructs a Clip that is a subpart of a Media.
*
* \param parent The media to represent.
* \param begin The clip beginning (in frames, from the parent's beginning)
* \param end The end, in frames, from the parent's beginning. If not given,
* the end of the parent will be used.
* \param uuid A unique identifier. If not given, one will be generated.
*/
Clip( Media *parent, qint64 begin, qint64 end = -1, const QString &uuid = QString() );
/**
* \brief Clones a Clip, potentially with a new begin and end.
*
* \param creator The clip to clone.
* \param begin The clip beginning (in frames, from the parent's beginning).
* If not given, 0 is assumed.
* \param end The end, in frames, from the parent's beginning. If not given,
* the end of the parent will be used.
*/
Clip( Clip *creator, qint64 begin = -1, qint64 end = -1 );
virtual ~Clip();
qint64 begin() const;
......
......@@ -312,7 +312,7 @@ MainWorkflow::loadProject( const QDomElement &project )
{
//Iterate over clip fields:
QDomElement clipProperty = clip.firstChild().toElement();
QUuid parent;
QUuid parentUuid;
qint64 begin;
qint64 end;
qint64 startPos;
......@@ -324,7 +324,7 @@ MainWorkflow::loadProject( const QDomElement &project )
bool ok;
if ( tagName == "parent" )
parent = QUuid( clipProperty.text() );
parentUuid = QUuid( clipProperty.text() );
else if ( tagName == "begin" )
{
begin = clipProperty.text().toLongLong( &ok );
......@@ -368,9 +368,10 @@ MainWorkflow::loadProject( const QDomElement &project )
clipProperty = clipProperty.nextSibling().toElement();
}
if ( Library::getInstance()->media( parent ) != NULL )
if ( Library::getInstance()->media( parentUuid ) != NULL )
{
Clip *c = new Clip( parent, begin, end );
Clip *c = new Clip( Library::getInstance()->media( parentUuid ),
begin, end, parentUuid.toString() );
addClip( c, trackId, startPos, trackType );
}
......
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