Commit 648d2482 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Workflow: Creating an Uuid for every ClipWorkflow

parent 01d3c813
......@@ -60,7 +60,7 @@ Commands::MainWorkflow::AddClip::~AddClip()
void Commands::MainWorkflow::AddClip::redo()
{
::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
m_uuid = ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
}
void Commands::MainWorkflow::AddClip::undo()
......@@ -68,6 +68,12 @@ void Commands::MainWorkflow::AddClip::undo()
::MainWorkflow::getInstance()->removeClip( m_clip->uuid(), m_trackNumber, m_trackType );
}
const QUuid&
Commands::MainWorkflow::AddClip::uuid() const
{
return m_uuid;
}
Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, unsigned int newTrack, qint64 newPos,
::MainWorkflow::TrackType trackType ) :
......
......@@ -66,11 +66,13 @@ namespace Commands
virtual ~AddClip();
virtual void redo();
virtual void undo();
const QUuid &uuid() const;
private:
Clip* m_clip;
unsigned int m_trackNumber;
qint64 m_pos;
::MainWorkflow::TrackType m_trackType;
QUuid m_uuid;
};
NEW_COMMAND( MoveClip )
......
......@@ -63,8 +63,6 @@ ImportController::ImportController(QWidget *parent) :
<< Media::VideoExtensions.split(' ', QString::SkipEmptyParts)
<< Media::ImageExtensions.split(' ', QString::SkipEmptyParts);
m_filesModel->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot );
m_filesModel->sort( 2, Qt::AscendingOrder );
m_filesModel->sort( 0, Qt::AscendingOrder );
m_filesModel->setNameFilters( filters );
m_filesModel->setRootPath( "/" );
m_filesModel->setNameFilterDisables( false );
......@@ -80,6 +78,9 @@ ImportController::ImportController(QWidget *parent) :
m_ui->treeView->setColumnHidden( 1, true );
m_ui->treeView->setColumnHidden( 2, true );
m_ui->treeView->setColumnHidden( 3, true );
for ( int i = 0; i < m_filesModel->columnCount(); ++i )
m_ui->treeView->sortByColumn( i );
m_ui->forwardButton->setEnabled( true );
m_ui->progressBar->setHidden( true );
......
......@@ -170,6 +170,8 @@ private:
//FIXME: this is a nasty forest boolean
bool m_resizeExpected;
QUuid m_uuid;
};
#endif // ABSTRACTGRAPHICSMEDIAITEM_H
......@@ -694,10 +694,12 @@ TracksView::dropEvent( QDropEvent *event )
m_dragAudioItem->oldTrackNumber = m_dragAudioItem->trackNumber();
m_dragAudioItem->oldPosition = (qint64)mappedXPos;
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragAudioItem->clip(),
m_dragAudioItem->trackNumber(),
(qint64)mappedXPos,
MainWorkflow::AudioTrack ) );
Commands::MainWorkflow::AddClip*
clip = new Commands::MainWorkflow::AddClip( m_dragAudioItem->clip(),
m_dragAudioItem->trackNumber(),
(qint64)mappedXPos,
MainWorkflow::AudioTrack );
Commands::trigger( clip );
m_dragAudioItem = NULL;
}
......@@ -712,10 +714,12 @@ TracksView::dropEvent( QDropEvent *event )
m_dragVideoItem->oldTrackNumber = m_dragVideoItem->trackNumber();
m_dragVideoItem->oldPosition = (qint64)mappedXPos;
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragVideoItem->clip(),
m_dragVideoItem->trackNumber(),
(qint64)mappedXPos,
MainWorkflow::VideoTrack ) );
Commands::MainWorkflow::AddClip*
clip = new Commands::MainWorkflow::AddClip( m_dragVideoItem->clip(),
m_dragVideoItem->trackNumber(),
(qint64)mappedXPos,
MainWorkflow::VideoTrack );
Commands::trigger( clip );
m_dragVideoItem = NULL;
}
......
......@@ -43,6 +43,7 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
m_initWaitCond = new WaitCondition;
m_renderLock = new QMutex;
m_renderWaitCond = new QWaitCondition;
m_uuid = QUuid::createUuid();
}
ClipWorkflow::~ClipWorkflow()
......
......@@ -26,6 +26,7 @@
#include "mdate.h"
#include <QObject>
#include <QUuid>
class QMutex;
class QReadWriteLock;
......@@ -187,6 +188,18 @@ class ClipWorkflow : public QObject
*/
bool isResyncRequired();
/**
* \return The ClipWorkflow's UUID
*
* This is not to be confused with the clip's uuid. Many ClipWorkflow can base
* themselves on the same clip, and would have different uuid, though calling
* clip()->uuid() on them would return the same result.
*/
inline const QUuid &uuid() const
{
return m_uuid;
}
private:
void setState( State state );
void adjustBegin();
......@@ -244,6 +257,7 @@ class ClipWorkflow : public QObject
qint64 m_beginPausePts;
qint64 m_pauseDuration;
bool m_fullSpeedRender;
QUuid m_uuid;
private slots:
void loadingComplete();
......
......@@ -72,14 +72,15 @@ MainWorkflow::~MainWorkflow()
delete MainWorkflow::blackOutput;
}
void
const QUuid&
MainWorkflow::addClip( Clip *clip, unsigned int trackId,
qint64 start, MainWorkflow::TrackType trackType )
{
m_tracks[trackType]->addClip( clip, trackId, start );
const QUuid& uuid = m_tracks[trackType]->addClip( clip, trackId, start );
computeLength();
//Inform the GUI
emit clipAdded( clip, trackId, start, trackType );
return uuid;
}
void
......
......@@ -99,8 +99,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \param type The track type (audio or video)
* \sa removeClip( const QUuid&, unsigned int, MainWorkflow::TrackType )
* \sa clipAdded( Clip*, unsigned int, qint64, MainWorkflow::TrackType )
* \return The newly inserted ClipWorkflow's UUID.
*/
void addClip( Clip* clip, unsigned int trackId, qint64 start,
const QUuid& addClip( Clip* clip, unsigned int trackId, qint64 start,
TrackType type );
/**
......
......@@ -58,13 +58,13 @@ TrackHandler::~TrackHandler()
delete[] m_tracks;
}
void
const QUuid&
TrackHandler::addClip( Clip* clip, unsigned int trackId, qint64 start )
{
Q_ASSERT_X( trackId < m_trackCount, "MainWorkflow::addClip",
"The specified trackId isn't valid, for it's higher than the number of tracks");
m_tracks[trackId]->addClip( clip, start );
const QUuid& uuid = m_tracks[trackId]->addClip( clip, start );
//Now check if this clip addition has changed something about the workflow's length
if ( m_tracks[trackId]->getLength() > m_length )
......@@ -73,6 +73,7 @@ TrackHandler::addClip( Clip* clip, unsigned int trackId, qint64 start )
//if the track is deactivated, we need to reactivate it.
if ( m_tracks[trackId].deactivated() == true )
activateTrack( trackId );
return uuid;
}
void
......
......@@ -38,7 +38,15 @@ class TrackHandler : public QObject
TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType trackType );
~TrackHandler();
void addClip( Clip* clip, unsigned int trackId, qint64 start );
/**
* \brief Insert a clip in the workflow.
*
* This will instantiate a new ClipWorkflow and returns its uuid.
* \param clip The clip to insert.
* \param trackId The track identifier.
* \param start The new clip starting position.
*/
const QUuid &addClip( Clip* clip, unsigned int trackId, qint64 start );
/**
* Returns the number of tracks in this handler
*/
......
......@@ -62,7 +62,8 @@ TrackWorkflow::~TrackWorkflow()
delete m_renderOneFrameMutex;
}
void TrackWorkflow::addClip( Clip* clip, qint64 start )
const QUuid&
TrackWorkflow::addClip( Clip* clip, qint64 start )
{
ClipWorkflow* cw;
if ( m_trackType == MainWorkflow::VideoTrack )
......@@ -75,9 +76,11 @@ void TrackWorkflow::addClip( Clip* clip, qint64 start )
else
cw = new AudioClipWorkflow( clip );
addClip( cw, start );
return cw->uuid();
}
void TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
void
TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
{
QWriteLocker lock( m_clipsLock );
m_clips.insert( start, cw );
......@@ -85,7 +88,8 @@ void TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
}
//Must be called from a thread safe method (m_clipsLock locked)
void TrackWorkflow::computeLength()
void
TrackWorkflow::computeLength()
{
if ( m_clips.count() == 0 )
{
......
......@@ -60,7 +60,7 @@ class TrackWorkflow : public QObject
void moveClip( const QUuid& id, qint64 startingFrame );
Clip* removeClip( const QUuid& id );
ClipWorkflow* removeClipWorkflow( const QUuid& id );
void addClip( Clip*, qint64 start );
const QUuid &addClip( Clip*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
qint64 getClipPosition( const QUuid& uuid ) const;
Clip* getClip( const QUuid& uuid );
......
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