[vlmc-devel] commit: TracksView: Removing more ClipHelper occurences. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Sep 7 21:41:56 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Sep  6 21:51:59 2010 +0200| [533f860c73d2691f07a94ddefa3fda92e25b9aed] | committer: Hugo Beauzée-Luyssen 

TracksView: Removing more ClipHelper occurences.

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

 src/Gui/timeline/TracksView.cpp |   36 ++++++++++++++----------------------
 src/Gui/timeline/TracksView.h   |    7 +++----
 src/Workflow/TrackWorkflow.cpp  |    2 +-
 src/Workflow/TrackWorkflow.h    |    2 +-
 4 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index b9bac52..213b30b 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -128,8 +128,8 @@ TracksView::addTrack( Workflow::TrackType type )
     m_scene->invalidate(); // Redraw the background
     connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ),
              this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) );
-    connect( track->trackWorkflow(), SIGNAL( clipRemoved( TrackWorkflow*, ClipHelper* ) ),
-             this, SLOT( removeMediaItem( TrackWorkflow*, ClipHelper* ) ) );
+    connect( track->trackWorkflow(), SIGNAL( clipRemoved( TrackWorkflow*, const QUuid& ) ),
+             this, SLOT( removeMediaItem( TrackWorkflow*, const QUuid& ) ) );
     connect( track->trackWorkflow(), SIGNAL( clipMoved( TrackWorkflow*, const QUuid&, qint64 ) ),
              this, SLOT( moveMediaItem( TrackWorkflow*, const QUuid&, qint64 ) ) );
 
@@ -198,27 +198,20 @@ TracksView::clear()
 void
 TracksView::removeClip( const QUuid& uuid  )
 {
-    AbstractGraphicsMediaItem*      item;
-
     // Get the list of all items in the timeline
-    QList<AbstractGraphicsMediaItem*> items = mediaItems();
+    QList<AbstractGraphicsItem*> items = timelineItems();
 
     // Iterate over each item to check if their parent's uuid
     // is the one we would like to remove.
-    foreach( item, items )
+    foreach( AbstractGraphicsItem *item, items )
     {
-        if ( item->clipHelper()->clip()->uuid() == uuid ||
-             item->clipHelper()->clip()->isChild( uuid ) == true ) //This is probably useless now
+        if ( item->uuid() == uuid )
         {
-            // This item needs to be removed.
-            // Saving its values
-            QUuid itemUuid = item->uuid();
-
             // Remove the item from the timeline
-            removeMediaItem( item->track()->trackWorkflow(), item->clipHelper() );
+            removeMediaItem( item->track()->trackWorkflow(), item->uuid() );
 
             // Removing the item from the backend.
-            item->track()->trackWorkflow()->removeClip( itemUuid );
+            item->track()->trackWorkflow()->removeClip( item->uuid() );
         }
     }
 }
@@ -649,7 +642,7 @@ TracksView::findPosition( AbstractGraphicsItem *item, qint32 track, qint64 time
 }
 
 void
-TracksView::removeMediaItem( TrackWorkflow *tw, ClipHelper *ch )
+TracksView::removeMediaItem( TrackWorkflow *tw, const QUuid &uuid )
 {
     GraphicsTrack           *track = getTrack( tw->type(), tw->trackId() );
 
@@ -661,7 +654,7 @@ TracksView::removeMediaItem( TrackWorkflow *tw, ClipHelper *ch )
     {
         AbstractGraphicsMediaItem *item =
                 dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) );
-        if ( !item || item->uuid() != ch->uuid() ) continue;
+        if ( !item || item->uuid() != uuid ) continue;
         removeMediaItem( item );
     }
 }
@@ -1101,18 +1094,17 @@ TracksView::mediaItems( const QPoint &pos )
     return mediaCollisionList;
 }
 
-QList<AbstractGraphicsMediaItem*>
-TracksView::mediaItems()
+QList<AbstractGraphicsItem*>
+TracksView::timelineItems()
 {
     //TODO optimization needed!
     QGraphicsItem *item;
-    AbstractGraphicsMediaItem *ami;
-    QList<AbstractGraphicsMediaItem*> outlist;
+    QList<AbstractGraphicsItem*> outlist;
     QList<QGraphicsItem*> list = items();
     foreach( item, list )
     {
-        ami = dynamic_cast<AbstractGraphicsMediaItem*>( item );
-        if ( ami )
+        AbstractGraphicsItem *ami = dynamic_cast<AbstractGraphicsItem*>( item );
+        if ( ami != NULL )
             outlist.append( ami );
     }
     return outlist;
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index 005dc9f..a0dfec6 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -158,7 +158,7 @@ public:
      * \warning Calling this method can be excessively slow!
      * \sa mediaItems( const QPoint& pos )
      */
-    QList<AbstractGraphicsMediaItem*> mediaItems();
+    QList<AbstractGraphicsItem*> timelineItems();
     /**
      * \brief Remove multiple items from the timeline.
      * \param items A QList of pointers to AbstractGraphicsMediaItem.
@@ -218,11 +218,10 @@ public slots:
     void                    moveMediaItem( TrackWorkflow *tw, const QUuid& uuid, qint64 time );
     /**
      * \brief Remove an item from the timeline.
+     * \param tw    The targeted TrackWorkflow
      * \param uuid The Universally Unique Identifier of the item.
-     * \param track The current track of the item.
-     * \param trackType The type of the track (Audio or Video)
      */
-    void                    removeMediaItem( TrackWorkflow* tw, ClipHelper* ch );
+    void                    removeMediaItem( TrackWorkflow* tw, const QUuid& uuid );
     /**
      * \brief This is an overloaded method provided for convenience.
      * \param item A pointer to AbstractGraphicsMediaItem.
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 59663f6..5d92c52 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -400,7 +400,7 @@ Clip*       TrackWorkflow::removeClip( const QUuid& id )
             stopClipWorkflow( cw );
             computeLength();
             cw->disconnect();
-            emit clipRemoved( this, cw->getClipHelper() );
+            emit clipRemoved( this, cw->getClipHelper()->uuid() );
             delete cw;
             return clip;
         }
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 7459cff..364b4ca 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -129,7 +129,7 @@ class   TrackWorkflow : public EffectUser
     signals:
         void                lengthChanged( qint64 newLength );
         void                clipAdded( TrackWorkflow*, ClipHelper*, qint64 );
-        void                clipRemoved( TrackWorkflow*, ClipHelper* );
+        void                clipRemoved( TrackWorkflow*, const QUuid& );
         void                clipMoved( TrackWorkflow*, const QUuid&, qint64 );
 };
 



More information about the Vlmc-devel mailing list