[vlmc-devel] SequenceWorkflow: Fix project loading

Hugo Beauzée-Luyssen git at videolan.org
Fri Aug 19 11:53:56 CEST 2016


vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Aug 19 11:49:12 2016 +0200| [cf7c7d625f038a30774e594d18d44b1559e65117] | committer: Hugo Beauzée-Luyssen

SequenceWorkflow: Fix project loading

Clip linking isn't available yet

> https://code.videolan.org/videolan/vlmc/commit/cf7c7d625f038a30774e594d18d44b1559e65117
---

 src/Media/Clip.cpp                | 12 -----------
 src/Media/Clip.h                  |  3 ---
 src/Media/Media.cpp               |  4 ++--
 src/Workflow/SequenceWorkflow.cpp | 44 +++++++++++++++++++--------------------
 4 files changed, 23 insertions(+), 40 deletions(-)

diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index 47faeeb..a605677 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -206,7 +206,6 @@ Clip::toVariant() const
     }
     else
         h.insert( "linked", false );
-    h.insert( "filters", EffectHelper::toVariant( m_input.get() ) );
     return QVariant( h );
 
 }
@@ -230,14 +229,3 @@ Clip::input()
 {
     return m_input.get();
 }
-
-void
-Clip::loadFilters( const QVariantMap& m )
-{
-    if ( m.contains( "filters" ) )
-    {
-        const auto& filters = m["filters"].toList();
-        for ( const auto& f : filters )
-            EffectHelper::loadFromVariant( f, input() );
-    }
-}
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index 8690f2a..c89a24e 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -115,9 +115,6 @@ class   Clip : public Workflow::Helper
 
         Backend::IInput* input();
 
-        //FIXME: This shouldn't be represented in the Library
-        void                loadFilters(const QVariantMap& v );
-
     private:
         QWeakPointer<Media>                 m_media;
         std::unique_ptr<Backend::IInput>    m_input;
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 4835dfd..4de46b5 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -232,9 +232,9 @@ Media::loadSubclip( const QVariantMap& m )
     const auto& uuid = m["uuid"].toUuid();
     const auto  begin = m["begin"].toLongLong();
     const auto  end = m["end"].toLongLong();
+    const auto  formats = m["formats"].toInt();
     auto clip = QSharedPointer<Clip>( new Clip( sharedFromThis(), begin, end, uuid ) );
-    //FIXME: This shouldn't be loaded from the library
-    clip->loadFilters( m );
+    clip->setFormats( static_cast<Clip::Formats>( formats ) );
 
     m_clips[uuid] = clip;
     emit subclipAdded( clip );
diff --git a/src/Workflow/SequenceWorkflow.cpp b/src/Workflow/SequenceWorkflow.cpp
index d1a0059..1b03623 100644
--- a/src/Workflow/SequenceWorkflow.cpp
+++ b/src/Workflow/SequenceWorkflow.cpp
@@ -209,9 +209,13 @@ SequenceWorkflow::toVariant() const
         auto clip = std::get<ClipTupleIndex::Clip>( it.value() );
         auto trackId = std::get<ClipTupleIndex::TrackId>( it.value() );
         auto position = std::get<ClipTupleIndex::Position>( it.value() );
-        auto    h = clip->toVariant().toHash();
-        h.insert( "position", position );
-        h.insert( "trackId", trackId );
+        QVariantHash h {
+            { "uuid", clip->uuid() },
+            { "position", position },
+            { "trackId", trackId },
+            { "filters", EffectHelper::toVariant( clip->input() ) }
+        };
+        //FIXME: Missing linking informations
         l << h;
     }
     QVariantHash h{ { "clips", l }, { "filters", EffectHelper::toVariant( m_multitrack ) } };
@@ -223,31 +227,25 @@ SequenceWorkflow::loadFromVariant( const QVariant& variant )
 {
     for ( auto& var : variant.toMap()["clips"].toList() )
     {
-        //FIXME!!!
+        auto m = var.toMap();
+        auto clip = Core::instance()->library()->clip( m["uuid"].toUuid() );
 
-//        auto m = var.toMap();
-//        auto parentClip = Core::instance()->library()->clip( m["parent"].toString() );
+        if ( clip == nullptr )
+        {
+            vlmcCritical() << "Couldn't find an acceptable parent to be added.";
+            continue;
+        }
 
-//        if ( parentClip == nullptr )
-//        {
-//            vlmcCritical() << "Couldn't find an acceptable parent to be added.";
-//            continue;
-//        }
+        addClip( clip, m["trackId"].toUInt(), m["position"].toLongLong() );
 
-//        auto c = std::make_shared<Clip>( parentClip, m["begin"].toLongLong(), m["end"].toLongLong() );
-//        c->setUuid( m["uuid"].toString() );
-//        c->setFormats( (Clip::Formats)m["formats"].toInt() );
+        auto isLinked = m["linked"].toBool();
+        clip->setLinked( isLinked );
+        if ( isLinked == true )
+            clip->setLinkedClipUuid( m["linkedClip"].toString() );
 
-//        addClip( c, m["trackId"].toUInt(), m["position"].toLongLong() );
+        EffectHelper::loadFromVariant( m["filters"], clip->input() );
 
-//        auto isLinked = m["linked"].toBool();
-//        c->setLinked( isLinked );
-//        if ( isLinked == true )
-//            c->setLinkedClipUuid( m["linkedClip"].toString() );
-
-//        EffectHelper::loadFromVariant( m["filters"], c->input() );
-
-//        emit Core::instance()->workflow()->clipAdded( c->uuid().toString() );
+        emit Core::instance()->workflow()->clipAdded( clip->uuid().toString() );
     }
     EffectHelper::loadFromVariant( variant.toMap()["filters"], m_multitrack );
 }



More information about the Vlmc-devel mailing list