Commit 570cbf5d authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored code that buils.

However, it should not work (if it does, that's a ***ing miracle :o )
parent d82ec08e
......@@ -32,26 +32,34 @@ void Commands::trigger( QUndoCommand* command )
UndoStack::getInstance()->push( command );
}
Commands::MainWorkflow::AddClip::AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos ) :
m_workflow( workflow ), m_clip( clip ), m_trackNumber( trackNumber ), m_pos( pos )
Commands::MainWorkflow::AddClip::AddClip( ::MainWorkflow* workflow, Clip* clip,
unsigned int trackNumber, qint64 pos,
TrackWorkflow::TrackType trackType ) :
m_workflow( workflow ),
m_clip( clip ),
m_trackNumber( trackNumber ),
m_pos( pos ),
m_trackType( trackType )
{
setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
}
void Commands::MainWorkflow::AddClip::redo()
{
m_workflow->addClip( m_clip, m_trackNumber, m_pos );
m_workflow->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
}
void Commands::MainWorkflow::AddClip::undo()
{
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber );
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber, m_trackType );
}
Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos ) :
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos,
TrackWorkflow::TrackType trackType ) :
m_workflow( workflow ), m_uuid( uuid ), m_oldTrack( oldTrack ),
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos )
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos ),
m_trackType( trackType )
{
setText( QObject::tr( "Moving clip" ) );
m_undoRedoAction = false;
......@@ -59,13 +67,13 @@ Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUui
void Commands::MainWorkflow::MoveClip::redo()
{
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_undoRedoAction );
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
void Commands::MainWorkflow::MoveClip::undo()
{
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_undoRedoAction );
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
......@@ -77,21 +85,22 @@ Commands::MainWorkflow::RemoveClips::RemoveClips( ::MainWorkflow* workflow, cons
void Commands::MainWorkflow::RemoveClips::redo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber );
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber, m_clips.at( i ).trackType );
}
void Commands::MainWorkflow::RemoveClips::undo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos );
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos, m_clips.at( i ).trackType );
}
Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
qint64 newBegin, qint64 newEnd ) :
qint64 newBegin, qint64 newEnd, TrackWorkflow::TrackType trackType ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
m_newEnd( newEnd ),
m_trackType( trackType )
{
m_clip = mainWorkflow->getClip( uuid, trackId );
m_clip = mainWorkflow->getClip( uuid, trackId, m_trackType );
m_oldBegin = m_clip->getBegin();
m_oldEnd = m_clip->getEnd();
}
......
......@@ -44,12 +44,13 @@ namespace Commands
Clip* clip;
quint32 trackNumber;
qint64 pos;
TrackWorkflow::TrackType trackType;
};
NEW_COMMAND( AddClip )
{
public:
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos );
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos, TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
private:
......@@ -57,13 +58,15 @@ namespace Commands
Clip* m_clip;
unsigned int m_trackNumber;
qint64 m_pos;
TrackWorkflow::TrackType m_trackType;
};
NEW_COMMAND( MoveClip )
{
public:
MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos );
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack,
qint64 newPos, TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
......@@ -75,6 +78,7 @@ namespace Commands
qint64 m_pos;
qint64 m_oldPos;
bool m_undoRedoAction;
TrackWorkflow::TrackType m_trackType;
};
NEW_COMMAND( RemoveClips )
......@@ -93,7 +97,8 @@ namespace Commands
{
public:
ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
qint64 newBegin, qint64 newEnd );
qint64 newBegin, qint64 newEnd,
TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
private:
......@@ -103,6 +108,7 @@ namespace Commands
qint64 m_newBegin;
qint64 m_newEnd;
Clip* m_clip;
TrackWorkflow::TrackType m_trackType;
};
}
}
......
......@@ -36,7 +36,7 @@ Timeline::Timeline( QWidget *parent ) :
m_instance = this;
m_ui.setupUi( this );
m_mainWorkflow = new MainWorkflow( MAX_TRACKS );
m_mainWorkflow = MainWorkflow::getInstance();
m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
......@@ -66,7 +66,7 @@ Timeline::Timeline( QWidget *parent ) :
Timeline::~Timeline()
{
delete m_mainWorkflow;
MainWorkflow::destroyInstance();
}
void Timeline::changeEvent( QEvent *e )
......
......@@ -42,7 +42,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
//TODO should be defined by the settings
m_tracksHeight = 25;
m_tracksCount = mainWorkflow->getTrackCount();
m_tracksCount = mainWorkflow->getTrackCount( TrackWorkflow::Video );
m_fps = FPS;
m_numAudioTrack = 0;
......@@ -426,7 +426,8 @@ void TracksView::dropEvent( QDropEvent* event )
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
m_dragItem->clip(),
m_dragItem->trackNumber(),
(qint64)mappedXPos ) );
(qint64)mappedXPos,
TrackWorkflow::Video ) );
m_dragItem = NULL;
}
}
......@@ -576,7 +577,8 @@ void TracksView::mouseReleaseEvent( QMouseEvent* event )
movieItem->oldTrackNumber,
movieItem->oldPosition,
movieItem->trackNumber(),
(qint64)movieItem->pos().x() ) );
(qint64)movieItem->pos().x(),
TrackWorkflow::Video ) );
movieItem->oldTrackNumber = movieItem->trackNumber();
movieItem->oldPosition = movieItem->pos().x();
m_actionMove = false;
......@@ -714,5 +716,6 @@ void TracksView::split( GraphicsMovieItem* item, qint64 frame )
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
newclip,
item->trackNumber(),
item->pos().x() + frame ) );
item->pos().x() + frame,
TrackWorkflow::Video ) );
}
......@@ -364,3 +364,8 @@ void MainWorkflow::tracksRenderCompleted()
}
m_synchroneRenderWaitCondition->wakeAll();
}
int MainWorkflow::getTrackCount( TrackWorkflow::TrackType trackType ) const
{
return m_tracks[trackType]->getTrackCount();
}
......@@ -110,12 +110,13 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void clear();
void setFullSpeedRender( bool value );
int getTrackCount( TrackWorkflow::TrackType trackType ) const;
private:
static unsigned char* blackOutput;
private:
MainWorkflow( int trackCount );
MainWorkflow( int trackCount = 64 );
~MainWorkflow();
void computeLength();
void activateTrack( unsigned int trackId );
......
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