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

TrackHandler: Watch for TrackWorkflow length changed.

parent cc3bdb65
......@@ -36,6 +36,8 @@ TrackHandler::TrackHandler( unsigned int nbTracks, Workflow::TrackType trackType
for ( unsigned int i = 0; i < nbTracks; ++i )
{
m_tracks[i].setPtr( new TrackWorkflow( trackType ) );
connect( m_tracks[i], SIGNAL( lengthChanged( qint64 ) ),
this, SLOT( lengthUpdated(qint64) ) );
}
}
......@@ -274,3 +276,22 @@ TrackHandler::stopFrameComputing()
for ( unsigned int i = 0; i < m_trackCount; ++i )
m_tracks[i]->stopFrameComputing();
}
void
TrackHandler::lengthUpdated( qint64 newLength )
{
//If the new length is bigger, or if the track that has been resized was the
if ( newLength > m_length )
m_length = newLength;
else
{
qint64 maxLength = 0;
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
if ( m_tracks[i]->getLength() > maxLength )
maxLength = m_tracks[i]->getLength();
}
m_length = maxLength;
}
}
......@@ -115,6 +115,9 @@ class TrackHandler : public QObject
unsigned int m_highestTrackNumber;
bool m_endReached;
private slots:
void lengthUpdated( qint64 newLength );
signals:
void tracksEndReached();
};
......
......@@ -110,13 +110,23 @@ TrackWorkflow::addEffect( Effect *effect, const QUuid &uuid )
void
TrackWorkflow::computeLength()
{
bool changed = false;
if ( m_clips.count() == 0 )
{
if ( m_length != 0 )
changed = true;
m_length = 0;
return ;
}
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
m_length = (it.key() + it.value()->getClipHelper()->length() );
else
{
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
qint64 newLength = it.key() + it.value()->getClipHelper()->length();
if ( m_length != newLength )
changed = true;
m_length = newLength;
}
if ( changed == true )
emit lengthChanged( m_length );
}
qint64
......
......@@ -121,6 +121,9 @@ class TrackWorkflow : public QObject
qint64 m_lastFrame;
Workflow::Frame *m_mixerBuffer;
double m_fps;
signals:
void lengthChanged( qint64 newLength );
};
#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