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

Fixing clip addition.

Removing some of the nasty forest booleans !
parent ee5c4dad
......@@ -85,8 +85,6 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
// Clip actions
connect( m_mainWorkflow, SIGNAL( clipAdded( ClipHelper*, uint, qint64, Workflow::TrackType ) ),
this, SLOT( actionAddClip(ClipHelper*, uint, qint64, Workflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved( QUuid, uint, qint64, Workflow::TrackType ) ),
this, SLOT( actionMoveClip(QUuid, uint, qint64, Workflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved( const QUuid&, uint, Workflow::TrackType ) ),
......@@ -163,11 +161,6 @@ void Timeline::setTool( ToolButtons button )
tracksView()->setTool( button );
}
void Timeline::actionAddClip( ClipHelper* clipHelper, unsigned int track, qint64 start, Workflow::TrackType trackType )
{
tracksView()->addMediaItem( clipHelper, track, trackType, start );
}
void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, Workflow::TrackType )
{
tracksView()->moveMediaItem( uuid, track, time );
......
......@@ -82,14 +82,6 @@ public slots:
* \brief Change the currently selected tool.
*/
void setTool( ToolButtons button );
/**
* \brief Insert an item into the timeline.
* \param clip Clip to insert.
* \param track The track's number.
* \param start The position in frames.
* \param
*/
void actionAddClip( ClipHelper* clip, unsigned int track, qint64 start, Workflow::TrackType trackType );
/**
* \brief Move an item in the timeline.
* \param uuid The Universally Unique Identifier of the item.
......
......@@ -30,8 +30,9 @@
#include "GraphicsCursorItem.h"
#include "GraphicsTrack.h"
#include "Media.h"
#include "WorkflowRenderer.h"
#include "TrackWorkflow.h"
#include "UndoStack.h"
#include "WorkflowRenderer.h"
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
......@@ -120,6 +121,8 @@ TracksView::addVideoTrack()
m_cursorLine->setHeight( m_layout->contentsRect().height() );
m_scene->invalidate(); // Redraw the background
m_numVideoTrack++;
connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ),
this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) );
emit videoTrackAdded( track );
}
......@@ -133,6 +136,8 @@ TracksView::addAudioTrack()
m_cursorLine->setHeight( m_layout->contentsRect().height() );
m_scene->invalidate(); // Redraw the background
m_numAudioTrack++;
connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ),
this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) );
emit audioTrackAdded( track );
}
......@@ -218,10 +223,18 @@ TracksView::removeClip( const QUuid& uuid )
}
void
TracksView::addMediaItem( ClipHelper *ch, unsigned int track, Workflow::TrackType trackType, qint64 start )
TracksView::addMediaItem( TrackWorkflow *tw, ClipHelper *ch, qint64 start )
{
Q_ASSERT( ch );
//If for some reasons the clip was already loaded, don't add it twice.
//This would likely happen when adding a clip from the timeline, as an element will
//already be created (by the drag and drop operation)
if ( m_clipsLoaded.contains( ch->uuid() ) )
return ;
quint32 track = tw->trackId();
Workflow::TrackType trackType = tw->type();
// If there is not enough tracks to insert
// the clip do it now.
if ( trackType == Workflow::VideoTrack )
......@@ -256,7 +269,7 @@ TracksView::addMediaItem( ClipHelper *ch, unsigned int track, Workflow::TrackTyp
connect( item, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
m_clipsLoaded.insert( ch->uuid() );
item->m_tracksView = this;
item->setHeight( tracksHeight() );
item->setTrack( getTrack( trackType, track ) );
......
......@@ -30,6 +30,7 @@
#include <QWidget>
#include <QGraphicsView>
#include <QSet>
class QWheelEvent;
class QGraphicsWidget;
......@@ -39,6 +40,8 @@ class TracksScene;
class GraphicsMovieItem;
class GraphicsAudioItem;
class MainWorkflow;
class TrackWorkflow;
class ClipHelper;
class WorkflowRenderer;
class ItemPosition
......@@ -201,8 +204,7 @@ public slots:
* \param trackType The type of the track (Audio or Video)
* \param start The position in frames.
*/
void addMediaItem( ClipHelper *clipHelper, unsigned int track,
Workflow::TrackType trackType, qint64 start );
void addMediaItem( TrackWorkflow* tw, ClipHelper *clipHelper, qint64 start );
/**
* \brief Move an item in the timeline.
* \param uuid The Universally Unique Identifier of the item.
......@@ -342,6 +344,7 @@ private:
AbstractGraphicsMediaItem::From m_actionResizeType;
AbstractGraphicsMediaItem *m_actionItem;
GraphicsTrack *m_lastKnownTrack;
QSet<QUuid> m_clipsLoaded;
signals:
/**
......
......@@ -436,17 +436,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* are activated (ie. they all reached end)
*/
void mainWorkflowEndReached();
/**
* \brief Emitted when a clip is added
*
* \param clip The clip that has been added
* \param trackId The id of the track in which the clip has been added
* \param pos The position of the new Clip
* \param trackType The type of the clip that has been added
* \sa addClip( Clip*, unsigned int, qint64, TrackType )
*/
void clipAdded( ClipHelper* clip, unsigned int trackId,
qint64 pos, Workflow::TrackType trackType );
/**
* \brief Emitted when a clip is removed
* \param uuid The clip that has been removed's uuid.
......
......@@ -35,7 +35,7 @@ TrackHandler::TrackHandler( unsigned int nbTracks, Workflow::TrackType trackType
m_tracks = new Toggleable<TrackWorkflow*>[nbTracks];
for ( unsigned int i = 0; i < nbTracks; ++i )
{
m_tracks[i].setPtr( new TrackWorkflow( trackType ) );
m_tracks[i].setPtr( new TrackWorkflow( trackType, i ) );
connect( m_tracks[i], SIGNAL( lengthChanged( qint64 ) ),
this, SLOT( lengthUpdated(qint64) ) );
}
......
......@@ -41,10 +41,11 @@
#include <QtDebug>
TrackWorkflow::TrackWorkflow( Workflow::TrackType type ) :
TrackWorkflow::TrackWorkflow( Workflow::TrackType type, quint32 trackId ) :
m_length( 0 ),
m_trackType( type ),
m_lastFrame( 0 )
m_lastFrame( 0 ),
m_trackId( trackId )
{
m_renderOneFrameMutex = new QMutex;
m_clipsLock = new QReadWriteLock;
......@@ -88,6 +89,7 @@ TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
{
QWriteLocker lock( m_clipsLock );
m_clips.insert( start, cw );
emit clipAdded( this, cw->getClipHelper(), start );
computeLength();
}
......@@ -588,3 +590,15 @@ TrackWorkflow::stopFrameComputing()
++it;
}
}
quint32
TrackWorkflow::trackId() const
{
return m_trackId;
}
Workflow::TrackType
TrackWorkflow::type() const
{
return m_trackType;
}
......@@ -47,7 +47,7 @@ class TrackWorkflow : public QObject
Q_OBJECT
public:
TrackWorkflow( Workflow::TrackType type );
TrackWorkflow( Workflow::TrackType type, quint32 trackId );
~TrackWorkflow();
Workflow::OutputBuffer *getOutput( qint64 currentFrame,
......@@ -92,6 +92,8 @@ class TrackWorkflow : public QObject
void stopFrameComputing();
bool hasNoMoreFrameToRender( qint64 currentFrame ) const;
quint32 trackId() const;
Workflow::TrackType type() const;
private:
void computeLength();
......@@ -117,13 +119,15 @@ class TrackWorkflow : public QObject
QReadWriteLock* m_clipsLock;
Workflow::TrackType m_trackType;
const Workflow::TrackType m_trackType;
qint64 m_lastFrame;
Workflow::Frame *m_mixerBuffer;
double m_fps;
const quint32 m_trackId;
signals:
void lengthChanged( qint64 newLength );
void lengthChanged( qint64 newLength );
void clipAdded( TrackWorkflow*, ClipHelper*, qint64 );
};
#endif // TRACKWORKFLOW_H
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