[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: export `vlc::playlist::toMediaList()`

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Nov 26 05:13:58 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
e2d5314c by Fatih Uzunoglu at 2023-11-26T04:53:17+00:00
qt: export `vlc::playlist::toMediaList()`

- - - - -
8810b7cc by Fatih Uzunoglu at 2023-11-26T04:53:17+00:00
qt: parse foreign items in MLPlaylistModel::insert()

- - - - -
6ab048bb by Fatih Uzunoglu at 2023-11-26T04:53:17+00:00
qml: allow dropping urls into playlists

- - - - -


3 changed files:

- modules/gui/qt/medialibrary/mlplaylistmodel.cpp
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/playlist/playlist_controller.hpp


Changes:

=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.cpp
=====================================
@@ -30,6 +30,9 @@
 #include "mlhelper.hpp"
 #include "mlplaylistmedia.hpp"
 
+#include "playlist/playlist_controller.hpp"
+#include "playlist/media.hpp"
+
 //-------------------------------------------------------------------------------------------------
 // Static variables
 
@@ -63,37 +66,31 @@ static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
     if (unlikely(m_transactionPending))
         return;
 
-    //build the list of MRL to insert in the playlist
-    std::vector<QString> mrlList;
-    for (const QVariant & variant : items)
-    {
-        if (variant.canConvert<SharedInputItem>() == false)
-            continue;
-
-
-        if (const char * psz_uri = ((variant.value<SharedInputItem>())->psz_uri))
-            mrlList.emplace_back(psz_uri);
-    }
+    QVector<vlc::playlist::Media> medias = vlc::playlist::toMediaList(items);
 
     m_transactionPending = true;
 
     m_mediaLib->runOnMLThread(this,
     //ML thread
-    [mrlList, id, at](vlc_medialibrary_t* ml) {
+    [medias, id, at](vlc_medialibrary_t* ml) {
         int insertPos = at;
-        for (const QString& uri : mrlList)
+        for (const auto& media : medias)
         {
-            vlc_ml_media_t * media = vlc_ml_get_media_by_mrl(ml, qtu(uri));
+            assert(media.raw());
+
+            const char * const uri = media.raw()->psz_uri;
+
+            vlc_ml_media_t * ml_media = vlc_ml_get_media_by_mrl(ml, uri);
 
-            if (media == nullptr)
+            if (ml_media == nullptr)
             {
-                media = vlc_ml_new_external_media(ml, qtu(uri));
-                if (media == nullptr)
+                ml_media = vlc_ml_new_external_media(ml, uri);
+                if (ml_media == nullptr)
                     continue;
             }
 
-            vlc_ml_playlist_insert(ml, id, media->i_id, insertPos);
-            vlc_ml_media_release(media);
+            vlc_ml_playlist_insert(ml, id, ml_media->i_id, insertPos);
+            vlc_ml_media_release(ml_media);
 
             insertPos++;
         }


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -145,8 +145,12 @@ MainInterface.MainTableView {
     function isDroppable(drop, index) {
         if (drop.source === dragItem) {
             return Helpers.itemsMovable(selectionModel.sortedSelectedIndexesFlat, index)
+        } else if (Helpers.isValidInstanceOf(drop.source, Widgets.DragItem)) {
+            return true
+        } else if (drop.hasUrls) {
+            return true
         } else {
-            return Helpers.isValidInstanceOf(drop.source, Widgets.DragItem)
+            return false
         }
     }
 
@@ -169,6 +173,12 @@ MainInterface.MainTableView {
                 .then(inputItems => {
                     model.insert(inputItems, destinationIndex)
                 })
+        } else if (drop.hasUrls) {
+            const urlList = []
+            for (let url in drop.urls)
+                urlList.push(drop.urls[url])
+
+            model.insert(urlList, destinationIndex)
         }
 
         root.forceActiveFocus()


=====================================
modules/gui/qt/playlist/playlist_controller.hpp
=====================================
@@ -34,9 +34,11 @@
 #include "playlist_item.hpp"
 
 namespace vlc {
-  namespace playlist {
+namespace playlist {
 
-  using vlc_playlist_locker = vlc_locker<vlc_playlist_t, vlc_playlist_Lock, vlc_playlist_Unlock>;
+QVector<vlc::playlist::Media> toMediaList(const QVariantList &sources);
+
+using vlc_playlist_locker = vlc_locker<vlc_playlist_t, vlc_playlist_Lock, vlc_playlist_Unlock>;
 
 class PlaylistControllerPrivate;
 class PlaylistController : public QObject
@@ -194,7 +196,7 @@ private:
     QScopedPointer<PlaylistControllerPrivate> d_ptr;
 };
 
-  } // namespace playlist
+} // namespace playlist
 } // namespace vlc
 
 #endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6f882e125519d1030855c262d11ed916b1150850...6ab048bb1ba19fc0078186f138958ad0e109f992

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6f882e125519d1030855c262d11ed916b1150850...6ab048bb1ba19fc0078186f138958ad0e109f992
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list