[vlmc-devel] commit: Refactoring clip splitting. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Aug 26 23:03:10 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Aug 26 22:55:36 2010 +0200| [088a154818040d1e941851eda07e1b4a88dac93e] | committer: Hugo Beauzée-Luyssen 

Refactoring clip splitting.

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

 src/Commands/Commands.cpp                      |   20 +++++++++++---------
 src/Commands/Commands.h                        |    8 ++++----
 src/Gui/timeline/AbstractGraphicsMediaItem.cpp |    6 ------
 src/Gui/timeline/TracksView.cpp                |    6 +++---
 src/Workflow/MainWorkflow.cpp                  |   24 ------------------------
 src/Workflow/MainWorkflow.h                    |    7 -------
 6 files changed, 18 insertions(+), 53 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 5a05c2b..0d1d03d 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -156,30 +156,32 @@ void Commands::MainWorkflow::ResizeClip::undo()
     m_clipHelper->setBoundaries( m_oldBegin, m_oldEnd );
 }
 
-Commands::MainWorkflow::SplitClip::SplitClip( ClipHelper* toSplit, quint32 trackId,
-                           qint64 newClipPos, qint64 newClipBegin, Workflow::TrackType trackType ) :
+Commands::MainWorkflow::SplitClip::SplitClip( TrackWorkflow *tw, ClipHelper *toSplit,
+                                             qint64 newClipPos, qint64 newClipBegin ) :
+    m_trackWorkflow( tw ),
     m_toSplit( toSplit ),
     m_newClip( NULL ),
-    m_trackId( trackId ),
     m_newClipPos( newClipPos ),
-    m_newClipBegin( newClipBegin ),
-    m_trackType( trackType )
+    m_newClipBegin( newClipBegin )
 {
+    m_newClip = new ClipHelper( toSplit->clip(), newClipBegin, toSplit->end() );
+    m_oldEnd = toSplit->end();
     setText( QObject::tr("Splitting clip") );
 }
 
 Commands::MainWorkflow::SplitClip::~SplitClip()
 {
-    if ( m_newClip != NULL )
-        delete m_newClip;
+    delete m_newClip;
 }
 
 void    Commands::MainWorkflow::SplitClip::redo()
 {
-//    m_newClip = ::MainWorkflow::getInstance()->split( m_toSplit, m_newClip, m_trackId, m_newClipPos, m_newClipBegin, m_trackType );
+    m_trackWorkflow->addClip( m_newClip, m_newClipPos );
+    m_toSplit->setEnd( m_newClipBegin );
 }
 
 void    Commands::MainWorkflow::SplitClip::undo()
 {
-//    ::MainWorkflow::getInstance()->unsplit( m_toSplit, m_newClip, m_trackId, m_trackType );
+    m_trackWorkflow->removeClip( m_newClip->uuid() );
+    m_toSplit->setEnd( m_oldEnd );
 }
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index 85cd8bd..b7cd53b 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -130,18 +130,18 @@ namespace Commands
         NEW_COMMAND( SplitClip )
         {
             public:
-                SplitClip( ClipHelper* toSplit, quint32 trackId, qint64 newClipPos,
-                           qint64 newClipBegin, Workflow::TrackType trackType );
+                SplitClip( TrackWorkflow *tw, ClipHelper* toSplit, qint64 newClipPos,
+                           qint64 newClipBegin );
                 ~SplitClip();
                 virtual void    redo();
                 virtual void    undo();
             private:
+                TrackWorkflow               *m_trackWorkflow;
                 ClipHelper*                 m_toSplit;
                 ClipHelper*                 m_newClip;
-                quint32                     m_trackId;
                 qint64                      m_newClipPos;
                 qint64                      m_newClipBegin;
-                Workflow::TrackType         m_trackType;
+                qint64                      m_oldEnd;
         };
     }
 }
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 56a661a..267ef17 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -292,12 +292,6 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
         {
             m_resizeExpected = true;
             qint64 oldLength = m_clipHelper->length();
-//            Commands::trigger( new Commands::MainWorkflow::ResizeClip( clip()->getUuid(),
-//                                                                       0, size, startPos(),
-//                                                                       startPos() + oldLength,
-//                                                                       startPos() + ( oldLength - size ),
-//
-//                                                                       ))
             track()->trackWorkflow()->moveClip( m_clipHelper->uuid(), startPos() + ( oldLength - size ) );
             m_clipHelper->setBegin( startPos() + ( oldLength - size ) );
             setStartPos( startPos() + ( oldLength - size ) );
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 6acd84c..06fe941 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -1188,9 +1188,9 @@ TracksView::split( AbstractGraphicsMediaItem *item, qint64 frame )
     //item->startPos() is the position of the splitted clip (in frame)
     //therefore, the position of the newly created clip is
     //the splitted clip pos + the splitting point (ie startPos() + frame)
-    Commands::trigger( new Commands::MainWorkflow::SplitClip( item->clipHelper(), item->trackNumber(),
-                                                              item->startPos() + frame, frame + item->clipHelper()->begin(),
-                                                              item->mediaType() ) );
+    Commands::trigger( new Commands::MainWorkflow::SplitClip( item->track()->trackWorkflow(),
+                                            item->clipHelper(), item->startPos() + frame,
+                                            frame + item->clipHelper()->begin() ) );
 }
 
 AbstractGraphicsMediaItem*
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 540ea0f..64df2b5 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -398,30 +398,6 @@ MainWorkflow::setFullSpeedRender( bool val )
         m_tracks[i]->setFullSpeedRender( val );
 }
 
-//ClipHelper*
-//MainWorkflow::split( ClipHelper* toSplit, ClipHelper* newClip, quint32 trackId,
-//                     qint64 newClipPos, qint64 newClipBegin, Workflow::TrackType trackType )
-//{
-//    QMutexLocker    lock( m_renderStartedMutex );
-
-//    if ( newClip == NULL )
-//        newClip = new ClipHelper( toSplit->clip(), newClipBegin, toSplit->end() );
-
-//    toSplit->setEnd( newClipBegin );
-//    addClip( newClip, trackId, newClipPos, trackType, true );
-//    return newClip;
-//}
-
-void
-MainWorkflow::unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId,
-                       Workflow::TrackType trackType )
-{
-    QMutexLocker    lock( m_renderStartedMutex );
-
-//    removeClip( splitted->uuid(), trackId, trackType );
-    origin->setEnd( splitted->end() );
-}
-
 bool
 MainWorkflow::contains( const QUuid &uuid ) const
 {
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index fc0242c..19377c7 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -236,13 +236,6 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
          */
         void                    setFullSpeedRender( bool val );
 
-//        ClipHelper*             split( ClipHelper* toSplit, ClipHelper* newClip, quint32 trackId,
-//                                       qint64 newClipPos, qint64 newClipBegin,
-//                                       Workflow::TrackType trackType );
-
-        void                    unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId,
-                                         Workflow::TrackType trackType );
-
         /**
          *  \return     true if the current workflow contains the clip which the uuid was
          *              passed. Falsed otherwise.



More information about the Vlmc-devel mailing list