[vlmc-devel] commit: Refactor clips moving ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Mon Sep 13 01:25:08 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Sep 13 00:33:53 2010 +0200| [87ae7fb4325dec08f4cad56d292031980d2f9912] | committer: Hugo Beauzée-Luyssen 

Refactor clips moving

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

 src/EffectsEngine/EffectHelper.cpp             |   13 ++++++++++---
 src/EffectsEngine/EffectHelper.h               |    8 +++++---
 src/Gui/timeline/AbstractGraphicsItem.h        |    6 +++---
 src/Gui/timeline/AbstractGraphicsMediaItem.cpp |   10 ++++------
 src/Gui/timeline/AbstractGraphicsMediaItem.h   |    3 +--
 src/Gui/timeline/GraphicsEffectItem.cpp        |   10 ++++------
 src/Gui/timeline/GraphicsEffectItem.h          |    5 +++--
 src/Gui/timeline/TracksView.cpp                |   18 ++++++++++--------
 8 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index c16b61f..08abde5 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -43,15 +43,22 @@ EffectHelper::effectInstance() const
     return m_effectInstance;
 }
 
-const EffectUser*
-EffectHelper::target() const
+EffectUser*
+EffectHelper::target()
 {
     return m_target;
 }
 
+EffectUser*
+EffectHelper::oldTarget()
+{
+    return m_oldTarget;
+}
+
 void
-EffectHelper::setTarget( const EffectUser *target )
+EffectHelper::setTarget( EffectUser *target )
 {
+    m_oldTarget = m_target;
     m_target = target;
     m_begin = 0;
     if ( target != NULL )
diff --git a/src/EffectsEngine/EffectHelper.h b/src/EffectsEngine/EffectHelper.h
index e7afbac..ccc8850 100644
--- a/src/EffectsEngine/EffectHelper.h
+++ b/src/EffectsEngine/EffectHelper.h
@@ -42,12 +42,14 @@ class   EffectHelper : public Workflow::Helper
 
         EffectInstance          *effectInstance();
         const EffectInstance    *effectInstance() const;
-        const EffectUser        *target() const;
-        void                    setTarget( const EffectUser *target );
+        EffectUser              *target();
+        EffectUser              *oldTarget();
+        void                    setTarget( EffectUser *target );
 
     private:
         EffectInstance          *m_effectInstance;
-        const EffectUser        *m_target;
+        EffectUser              *m_target;
+        EffectUser              *m_oldTarget;
 };
 
 Q_DECLARE_METATYPE( EffectHelper* );
diff --git a/src/Gui/timeline/AbstractGraphicsItem.h b/src/Gui/timeline/AbstractGraphicsItem.h
index 6302f22..4b34d5a 100644
--- a/src/Gui/timeline/AbstractGraphicsItem.h
+++ b/src/Gui/timeline/AbstractGraphicsItem.h
@@ -29,6 +29,7 @@ class   GraphicsTrack;
 class   TrackWorkflow;
 class   TracksScene;
 class   TracksView;
+class   EffectUser;
 
 class   QUuid;
 
@@ -117,8 +118,7 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
         virtual qint64      end() const = 0;
         qint64              width() const;
 
-        virtual void        triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
-                                         Workflow::Helper *helper, qint64 pos ) = 0;
+        virtual void        triggerMove( EffectUser *target ) = 0;
         virtual void        triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
                                            qint64 newBegin, qint64 newEnd, qint64 pos ) = 0;
         virtual Workflow::Helper    *helper() = 0;
@@ -165,9 +165,9 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
         /// This pointer will be set when inserted in the tracksView.
         TracksView*                 m_tracksView;
         QColor                      m_itemColor;
+        TrackWorkflow               *m_oldTrack;
 
     private:
-        TrackWorkflow               *m_oldTrack;
         qint64                      m_width;
         qint64                      m_height;
         /// Pointer used to save the address of a linked item.
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 8d618c4..d83cc0a 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -274,14 +274,12 @@ AbstractGraphicsMediaItem::end() const
 }
 
 void
-AbstractGraphicsMediaItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
-                                   Workflow::Helper *helper, qint64 pos )
+AbstractGraphicsMediaItem::triggerMove( EffectUser *target )
 {
-    ClipHelper      *clipHelper = qobject_cast<ClipHelper*>( helper );
-    if ( clipHelper == NULL )
+    TrackWorkflow   *tw = qobject_cast<TrackWorkflow*>( target );
+    if ( tw == NULL )
         return ;
-    Commands::trigger( new Commands::Clip::Move( oldTrack, newTrack,
-                                                             clipHelper, pos ) );
+    Commands::trigger( new Commands::Clip::Move( m_oldTrack, tw, m_clipHelper, startPos() ) );
 }
 
 Workflow::Helper*
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index 876903f..beebe82 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -57,8 +57,7 @@ public:
     virtual qint64      end() const;
 
     virtual Workflow::Helper    *helper();
-    virtual void        triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
-                                     Workflow::Helper *helper, qint64 pos );
+    virtual void        triggerMove( EffectUser *target );
     virtual void        triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
                                        qint64 newBegin, qint64 newEnd, qint64 pos );
     virtual qint64              itemHeight() const;
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index 2116872..d4e8a24 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -25,6 +25,7 @@
 #include "Commands.h"
 #include "EffectHelper.h"
 #include "EffectInstance.h"
+#include "GraphicsTrack.h"
 #include "Timeline.h"
 #include "TracksView.h"
 #include "TrackWorkflow.h"
@@ -245,13 +246,10 @@ GraphicsEffectItem::helper()
 }
 
 void
-GraphicsEffectItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
-                                 Workflow::Helper *helper, qint64 pos )
+GraphicsEffectItem::triggerMove( EffectUser *target )
 {
-    EffectHelper    *eh = qobject_cast<EffectHelper*>( helper );
-    if ( eh == NULL )
-        return ;
-    Commands::trigger( new Commands::Effect::Move( eh, oldTrack, newTrack, pos ) );
+    Commands::trigger( new Commands::Effect::Move( m_effectHelper, m_effectHelper->oldTarget(),
+                                                   target, startPos() ) );
 }
 
 void
diff --git a/src/Gui/timeline/GraphicsEffectItem.h b/src/Gui/timeline/GraphicsEffectItem.h
index afee7fb..22453bf 100644
--- a/src/Gui/timeline/GraphicsEffectItem.h
+++ b/src/Gui/timeline/GraphicsEffectItem.h
@@ -26,6 +26,8 @@
 #include "AbstractGraphicsItem.h"
 #include "EffectsEngine.h"
 
+class   EffectUser;
+
 class   QUuid;
 
 class GraphicsEffectItem : public AbstractGraphicsItem
@@ -48,8 +50,7 @@ class GraphicsEffectItem : public AbstractGraphicsItem
         virtual qint64              maxBegin() const;
         virtual qint64              maxEnd() const;
         virtual Workflow::Helper    *helper();
-        virtual void                triggerMove(TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
-                                                Workflow::Helper *helper, qint64 pos);
+        virtual void                triggerMove( EffectUser *target );
         virtual void                triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
                                            qint64 newBegin, qint64 newEnd, qint64 pos );
         virtual qint64              itemHeight() const;
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 1787345..61818a3 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -229,7 +229,6 @@ TracksView::removeClip( const QUuid& uuid  )
 void
 TracksView::addItem( TrackWorkflow *tw, Workflow::Helper *helper, qint64 start )
 {
-    qDebug() << "Adding item:" << helper->uuid();
     Q_ASSERT( helper );
 
     //If for some reasons the clip was already loaded, don't add it twice.
@@ -1057,16 +1056,19 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
 
         UndoStack::getInstance()->beginMacro( "Move clip" );
 
-        m_actionItem->triggerMove( m_actionItem->m_oldTrack, m_actionItem->track()->trackWorkflow(),
-                                   m_actionItem->helper(), m_actionItem->startPos() );
+//        m_actionItem->triggerMove( m_oldTrack, m_actionItem->track()->trackWorkflow(),
+//                                   m_actionItem->helper(), m_actionItem->startPos() );
+        EffectUser  *target = m_actionItem->track()->trackWorkflow();
+//        GraphicsEffectItem  *effectItem = qobject_cast<GraphicsEffectItem*>( m_actionItem );
+//        if ( effectItem != NULL )
+//        {
+
+//        }
+        m_actionItem->triggerMove( target );
         // Update the linked item too
         if ( m_actionItem->groupItem() )
         {
-            //CHECK: This used to use m_actionItem and not m_actionItem->groupItem().
-            m_actionItem->groupItem()->triggerMove( m_actionItem->groupItem()->m_oldTrack,
-                                                    m_actionItem->groupItem()->track()->trackWorkflow(),
-                                                    m_actionItem->groupItem()->helper(),
-                                                    m_actionItem->startPos() );
+            m_actionItem->groupItem()->triggerMove( m_actionItem->groupItem()->track()->trackWorkflow() );
             m_actionItem->groupItem()->m_oldTrack = m_actionItem->groupItem()->track()->trackWorkflow();
         }
 



More information about the Vlmc-devel mailing list