[vlmc-devel] commit: Clip: Adding a full id to be abble to find a Clip directly, without searching the entire tree. (Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Fri Mar 12 20:06:41 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Fri Mar 12 19:59:45 2010 +0100| [2e43400dd0ed10b515dcfc6bb4ff967149e92089] | committer: Hugo Beauzee-Luyssen 

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

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=2e43400dd0ed10b515dcfc6bb4ff967149e92089
---

 src/Gui/library/MediaCellView.cpp |    2 +-
 src/Gui/timeline/TracksView.cpp   |    4 ++--
 src/Library/MediaContainer.cpp    |   17 +++++++++++++++++
 src/Library/MediaContainer.h      |   10 +++++++++-
 src/Media/Clip.cpp                |   13 +++++++++++++
 src/Media/Clip.h                  |    9 +++++++++
 6 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/src/Gui/library/MediaCellView.cpp b/src/Gui/library/MediaCellView.cpp
index 3fd21ef..57ba250 100644
--- a/src/Gui/library/MediaCellView.cpp
+++ b/src/Gui/library/MediaCellView.cpp
@@ -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();
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 5076196..62517cb 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -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 )
diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index 2228971..e67f33f 100644
--- a/src/Library/MediaContainer.cpp
+++ b/src/Library/MediaContainer.cpp
@@ -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 )
 {
diff --git a/src/Library/MediaContainer.h b/src/Library/MediaContainer.h
index 2308788..3a2a1ee 100644
--- a/src/Library/MediaContainer.h
+++ b/src/Library/MediaContainer.h
@@ -42,11 +42,19 @@ 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.
      *
      *  This will emit the newClipLoaded signal.
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index 7ca722a..de126a8 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -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;
+}
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index 372db0e..a41caa6 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -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;
         /**



More information about the Vlmc-devel mailing list