Commit 088a1548 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Refactoring clip splitting.

parent 188de93c
......@@ -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 );
}
......@@ -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;
};
}
}
......
......@@ -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 ) );
......
......@@ -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*
......
......@@ -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
{
......
......@@ -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.
......
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