[vlc-commits] qt/mlvideomodel: Add support for parented media(s) in the MLVideoModel::Loader

Benjamin Arnaud git at videolan.org
Tue Apr 20 12:49:03 UTC 2021


vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Tue Apr 13 16:47:33 2021 +0200| [7d0b66b5c2a9e6a3ad0d543258d03c679360895c] | committer: Pierre Lamot

qt/mlvideomodel: Add support for parented media(s) in the MLVideoModel::Loader

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7d0b66b5c2a9e6a3ad0d543258d03c679360895c
---

 modules/gui/qt/medialibrary/mlvideomodel.cpp | 43 +++++++++++++++++++---------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlvideomodel.cpp b/modules/gui/qt/medialibrary/mlvideomodel.cpp
index 1301a81bdc..2b8e1dcfd7 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.cpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.cpp
@@ -139,26 +139,41 @@ MLVideoModel::createLoader() const
     return new Loader(*this);
 }
 
-size_t MLVideoModel::Loader::count() const
+size_t MLVideoModel::Loader::count() const /* override */
 {
-    MLQueryParams params = getParams();
-    auto queryParams = params.toCQueryParams();
+    vlc_ml_query_params_t params = getParams().toCQueryParams();
 
-    return vlc_ml_count_video_media(m_ml, &queryParams);
+    int64_t id = m_parent.id;
+
+    if (id <= 0)
+        return vlc_ml_count_video_media(m_ml, &params);
+    else
+        return vlc_ml_count_media_of(m_ml, &params, m_parent.type, id);
 }
 
 std::vector<std::unique_ptr<MLItem>>
-MLVideoModel::Loader::load(size_t index, size_t count) const
+MLVideoModel::Loader::load(size_t index, size_t count) const /* override */
 {
-    MLQueryParams params = getParams(index, count);
-    auto queryParams = params.toCQueryParams();
+    vlc_ml_query_params_t params = getParams(index, count).toCQueryParams();
+
+    ml_unique_ptr<vlc_ml_media_list_t> list;
+
+    int64_t id = m_parent.id;
 
-    ml_unique_ptr<vlc_ml_media_list_t> media_list{ vlc_ml_list_video_media(
-                m_ml, &queryParams ) };
-    if ( media_list == nullptr )
+    if (id <= 0)
+        list.reset(vlc_ml_list_video_media(m_ml, &params));
+    else
+        list.reset(vlc_ml_list_media_of(m_ml, &params, m_parent.type, id));
+
+    if (list == nullptr)
         return {};
-    std::vector<std::unique_ptr<MLItem>> res;
-    for( vlc_ml_media_t &media: ml_range_iterate<vlc_ml_media_t>( media_list ) )
-        res.emplace_back( std::make_unique<MLVideo>(m_ml, &media) );
-    return res;
+
+    std::vector<std::unique_ptr<MLItem>> result;
+
+    for (const vlc_ml_media_t & media : ml_range_iterate<vlc_ml_media_t>(list))
+    {
+        result.emplace_back(std::make_unique<MLVideo>(m_ml, &media));
+    }
+
+    return result;
 }



More information about the vlc-commits mailing list