[vlmc-devel] Remove TrackWorkflow::type()
Yikai Lu
git at videolan.org
Wed Jun 1 18:14:56 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed May 4 20:05:42 2016 +0900| [24f875142e6a6e727e339ddaf7ef4eeba91120db] | committer: Hugo Beauzée-Luyssen
Remove TrackWorkflow::type()
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> https://code.videolan.org/videolan/vlmc/commit/24f875142e6a6e727e339ddaf7ef4eeba91120db
---
src/Commands/Commands.cpp | 2 --
src/Gui/timeline/TracksView.cpp | 77 +++++++++++++++++++++--------------------
src/Workflow/TrackWorkflow.cpp | 7 ----
src/Workflow/TrackWorkflow.h | 2 --
4 files changed, 40 insertions(+), 48 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index b3ecb90..7fbd72a 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -117,8 +117,6 @@ Commands::Clip::Move::Move( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
m_newPos( newPos )
{
- Q_ASSERT( oldTrack->type() == newTrack->type() );
-
m_oldPos = oldTrack->getClipPosition( clipHelper->uuid() );
connect( clipHelper->clip(), SIGNAL( destroyed() ), this, SLOT( invalidate() ) );
retranslate();
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 514eb2c..b30c9b3 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -248,64 +248,64 @@ TracksView::addItem( TrackWorkflow *tw, Workflow::Helper *helper, qint64 start )
if ( m_itemsLoaded.contains( helper->uuid() ) )
return ;
qint32 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 )
- {
- if ( track + 1 >= m_numVideoTrack )
- {
- int nbTrackToAdd = ( track + 2 ) - m_numVideoTrack;
- for ( int i = 0; i < nbTrackToAdd; ++i )
- addTrack( Workflow::VideoTrack );
- }
- }
- else if ( trackType == Workflow::AudioTrack )
- {
- if ( track + 1 >= m_numAudioTrack )
- {
- int nbTrackToAdd = ( track + 2 ) - m_numAudioTrack;
- for ( int i = 0; i < nbTrackToAdd; ++i )
- addTrack( Workflow::AudioTrack );
- }
- }
AbstractGraphicsItem *item = nullptr;
ClipHelper *clipHelper = qobject_cast<ClipHelper*>( helper );
if ( clipHelper != nullptr )
{
AbstractGraphicsMediaItem *mediaItem = nullptr;
- if ( trackType == Workflow::VideoTrack )
+
+ bool hasVideo = clipHelper->formats() & ClipHelper::Video;
+ bool hasAudio = clipHelper->formats() & ClipHelper::Audio;
+
+ // If there is not enough tracks to insert
+ // the clip do it now.
+ if ( hasVideo )
{
+ if ( track + 1 >= m_numVideoTrack )
+ {
+ int nbTrackToAdd = ( track + 2 ) - m_numVideoTrack;
+ for ( int i = 0; i < nbTrackToAdd; ++i )
+ addTrack( Workflow::VideoTrack );
+ }
mediaItem = new GraphicsMovieItem( clipHelper );
connect( mediaItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
- else if ( trackType == Workflow::AudioTrack )
+ else if ( hasAudio )
{
+ if ( track + 1 >= m_numAudioTrack )
+ {
+ int nbTrackToAdd = ( track + 2 ) - m_numAudioTrack;
+ for ( int i = 0; i < nbTrackToAdd; ++i )
+ addTrack( Workflow::AudioTrack );
+ }
mediaItem = new GraphicsAudioItem( clipHelper );
connect( mediaItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
+
item = mediaItem;
m_itemsLoaded.insert( helper->uuid() );
item->m_tracksView = this;
item->setHeight( item->itemHeight() );
- item->setTrack( getTrack( trackType, track ) );
+ if ( hasVideo )
+ item->setTrack( getTrack( Workflow::VideoTrack, track ) );
+ else if ( hasAudio )
+ item->setTrack( getTrack( Workflow::AudioTrack, track ) );
item->setStartPos( start );
item->m_oldTrack = tw;
moveItem( item, track, start );
//If the item has some effects:
foreach ( EffectHelper *effectHelper, clipHelper->clipWorkflow()->effects( Effect::Filter ) )
{
- addEffectItem( effectHelper, trackType, track, start );
+ addEffectItem( effectHelper, Workflow::VideoTrack, track, start );
}
}
else
{
EffectHelper *effectHelper = qobject_cast<EffectHelper*>( helper );
- addEffectItem( effectHelper, trackType, track, start );
+ addEffectItem( effectHelper, Workflow::VideoTrack, track, start );
}
updateDuration();
}
@@ -743,18 +743,21 @@ TracksView::findPosition( AbstractGraphicsItem *item, qint32 track, qint64 time
void
TracksView::removeItem( TrackWorkflow *tw, const QUuid &uuid )
{
- GraphicsTrack *track = getTrack( tw->type(), tw->trackId() );
+ for ( int i = 0; i < Workflow::NbTrackType; ++i )
+ {
+ GraphicsTrack *track = getTrack( (Workflow::TrackType)i, tw->trackId() );
- if ( track == nullptr )
- return ;
- QList<QGraphicsItem*> trackItems = track->childItems();;
+ if ( track == nullptr )
+ return ;
+ QList<QGraphicsItem*> trackItems = track->childItems();;
- for ( int i = 0; i < trackItems.size(); ++i )
- {
- AbstractGraphicsItem *item = dynamic_cast<AbstractGraphicsItem*>( trackItems.at( i ) );
- if ( !item || item->uuid() != uuid )
- continue;
- removeItem( item );
+ for ( int i = 0; i < trackItems.size(); ++i )
+ {
+ AbstractGraphicsItem *item = dynamic_cast<AbstractGraphicsItem*>( trackItems.at( i ) );
+ if ( !item || item->uuid() != uuid )
+ continue;
+ removeItem( item );
+ }
}
}
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 08213ef..1a5eb23 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -46,7 +46,6 @@
TrackWorkflow::TrackWorkflow( quint32 trackId ) :
m_length( 0 ),
- m_trackType( Workflow::NbTrackType ),
m_trackId( trackId )
{
m_clipsLock = new QReadWriteLock;
@@ -675,12 +674,6 @@ TrackWorkflow::trackId() const
return m_trackId;
}
-Workflow::TrackType
-TrackWorkflow::type() const
-{
- return m_trackType;
-}
-
EffectsEngine::EffectList*
TrackWorkflow::filters()
{
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 6625068..d9369d2 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -94,7 +94,6 @@ class TrackWorkflow : public EffectUser
void stopFrameComputing();
bool hasNoMoreFrameToRender( qint64 currentFrame ) const;
quint32 trackId() const;
- Workflow::TrackType type() const;
//FIXME: this is not thread safe if the list gets modified (but it can't be const, as it is intended to be modified...)
EffectsEngine::EffectList *filters();
EffectsEngine::EffectList *mixers();
@@ -123,7 +122,6 @@ class TrackWorkflow : public EffectUser
QReadWriteLock* m_clipsLock;
- const Workflow::TrackType m_trackType;
qint64 m_lastFrame[Workflow::NbTrackType];
Workflow::Frame *m_mixerBuffer;
const quint32 m_trackId;
More information about the Vlmc-devel
mailing list