[vlmc-devel] Clip: Add a getter for checking whether a clip is on the timeline

Yikai Lu git at videolan.org
Mon Dec 12 04:19:57 CET 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun Dec 11 21:08:09 2016 -0600| [51a0e59a6a662353ba76880f8425615eb42db034] | committer: Yikai Lu

Clip: Add a getter for checking whether a clip is on the timeline

> https://code.videolan.org/videolan/vlmc/commit/51a0e59a6a662353ba76880f8425615eb42db034
---

 src/Media/Clip.cpp                | 17 ++++++++++++++++-
 src/Media/Clip.h                  |  6 ++++++
 src/Workflow/SequenceWorkflow.cpp |  6 ++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index 6db8dbb..a9a3d9e 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -42,7 +42,8 @@
 Clip::Clip( QSharedPointer<Media> media, qint64 begin /*= 0*/, qint64 end /*= Backend::IInput::EndOfMedia */, const QUuid& uuid /*= QString()*/ ) :
         Workflow::Helper( uuid ),
         m_media( media ),
-        m_input( media->input()->cut( begin, end ) )
+        m_input( media->input()->cut( begin, end ) ),
+        m_onTimeline( false )
 {
 }
 
@@ -107,6 +108,20 @@ Clip::setNotes( const QString &notes )
     m_notes = notes;
 }
 
+bool
+Clip::onTimeline() const
+{
+    return m_onTimeline;
+}
+
+void
+Clip::setOnTimeline( bool onTimeline )
+{
+    if ( m_onTimeline != onTimeline )
+        emit onTimelineChanged( onTimeline );
+    m_onTimeline = onTimeline;
+}
+
 const QUuid&
 Clip::uuid() const
 {
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index 11f8535..24505ee 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -94,6 +94,9 @@ class   Clip : public Workflow::Helper
         const QString       &notes() const;
         void                setNotes( const QString &notes );
 
+        bool                onTimeline() const;
+        void                setOnTimeline( bool onTimeline );
+
         QVariant            toVariant() const;
 
         Backend::IInput* input();
@@ -105,11 +108,14 @@ class   Clip : public Workflow::Helper
         QStringList         m_metaTags;
         QString             m_notes;
 
+        bool                m_onTimeline;
+
     signals:
         /**
          *  \brief          Act just like QObject::destroyed(), but before the clip deletion.
          */
         void                unloaded( Clip* );
+        bool                onTimelineChanged( bool );
 };
 
 #endif //CLIP_H__
diff --git a/src/Workflow/SequenceWorkflow.cpp b/src/Workflow/SequenceWorkflow.cpp
index f9c9154..c23643e 100644
--- a/src/Workflow/SequenceWorkflow.cpp
+++ b/src/Workflow/SequenceWorkflow.cpp
@@ -76,6 +76,7 @@ SequenceWorkflow::addClip( QSharedPointer<::Clip> clip, quint32 trackId, qint32
                                            trackId, pos, isAudioClip );
     vlmcDebug() << "adding" << (isAudioClip ? "audio" : "video") <<  "clip instance:" << c->uuid;
     m_clips.insert( c->uuid, c ) ;
+    clip->setOnTimeline( true );
     emit clipAdded( c->uuid.toString() );
     return c->uuid;
 }
@@ -166,6 +167,11 @@ SequenceWorkflow::removeClip( const QUuid& uuid )
     t->remove( t->clipIndexAt( position ) );
     m_clips.erase( it );
     clip->disconnect( this );
+    bool onTimeline = false;
+    for ( const auto& clipInstance : m_clips )
+        if ( clipInstance->clip->uuid() == clip->uuid() )
+            onTimeline = true;
+    clip->setOnTimeline( onTimeline );
     emit clipRemoved( uuid.toString() );
     return c;
 



More information about the Vlmc-devel mailing list