Commit 2e43400d authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Clip: Adding a full id to be abble to find a Clip directly, without searching the entire tree.

parent 91724201
......@@ -177,7 +177,7 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
return;
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toAscii() );
mimeData->setData( "vlmc/uuid", m_clip->fullId().toAscii() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
const Media* parent = m_clip->getMedia();
......
......@@ -289,8 +289,8 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) )
event->acceptProposedAction();
QUuid uuid = QUuid( QString( event->mimeData()->data( "vlmc/uuid" ) ) );
Clip *clip = Library::getInstance()->clip( uuid );
QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
Clip *clip = Library::getInstance()->clip( fullId );
if ( !clip ) return;
if ( clip->getMedia()->hasAudioTrack() == false &&
clip->getMedia()->hasVideoTrack() == false )
......
......@@ -41,6 +41,23 @@ MediaContainer::clip( const QUuid& uuid )
return NULL;
}
Clip*
MediaContainer::clip( const QString &uuid )
{
MediaContainer *mc = this;
Clip *clip;
QStringList ids = uuid.split( '/' );
foreach ( QString id, ids )
{
clip = mc->clip( QUuid( id ) );
if ( clip == NULL )
return NULL;
mc = clip->getChilds();
}
return clip;
}
void
MediaContainer::addMedia( Media *media )
{
......
......@@ -42,10 +42,18 @@ public:
* \brief returns the clip that match the unique identifier
* \param uuid the unique identifier of the media
* \return a pointer to the required clip, or NULL if no clips matches
* \sa media( const QUuid& uuid )
*/
Clip* clip( const QUuid& uuid );
/**
* \brief returns the clip that match the unique identifier
*
* The identifier may be a full id (ie the full path, starting at the root clip)
* \param uuid the unique identifier of the media
* \return a pointer to the required clip, or NULL if no clips matches
*/
Clip* clip( const QString& uuid );
/**
* \brief Add an already preparsed media.
*
......
......@@ -321,3 +321,16 @@ Clip::save( QXmlStreamWriter &project )
}
project.writeEndElement();
}
QString
Clip::fullId() const
{
const Clip* c = this;
QString id = m_uuid.toString();
while ( c->isRootClip() == false )
{
c = c->getParent();
id = c->uuid() + '/' + id;
}
return id;
}
......@@ -126,6 +126,15 @@ class Clip : public QObject
void save( QXmlStreamWriter& project );
/**
* \brief Generates a full Clip id
*
* A full id is the list of all the parent Clip's UUID, separated by '/'
* IE, {uuid1}/{uuid2}/{uuid2}/{current-clip-uuid}
* \return The full Clip id.
*/
QString fullId() const;
private:
Media *m_media;
/**
......
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