[vlc-devel] [PATCH 11/16] qt: allow to enqueue network item using model indexes

Pierre Lamot pierre at videolabs.io
Wed May 27 17:06:52 CEST 2020


---
 modules/gui/qt/network/networkdevicemodel.cpp | 28 +++++++++++++++++++
 modules/gui/qt/network/networkdevicemodel.hpp |  2 ++
 modules/gui/qt/network/networkmediamodel.cpp  | 28 +++++++++++++++++++
 modules/gui/qt/network/networkmediamodel.hpp  |  2 ++
 4 files changed, 60 insertions(+)

diff --git a/modules/gui/qt/network/networkdevicemodel.cpp b/modules/gui/qt/network/networkdevicemodel.cpp
index 0501d2b95b..07e2dd4f69 100644
--- a/modules/gui/qt/network/networkdevicemodel.cpp
+++ b/modules/gui/qt/network/networkdevicemodel.cpp
@@ -147,6 +147,19 @@ bool NetworkDeviceModel::addToPlaylist(const QVariantList &itemIdList)
     return ret;
 }
 
+bool NetworkDeviceModel::addToPlaylist(const QModelIndexList &itemIdList)
+{
+    bool ret = false;
+    for (const QModelIndex& index: itemIdList)
+    {
+        if (!index.isValid())
+            continue;
+        ret |= addToPlaylist(index.row());
+    }
+    return ret;
+}
+
+
 bool NetworkDeviceModel::addAndPlay(int index)
 {
     if (!(m_ctx && m_sdSource != CAT_MYCOMPUTER))
@@ -176,6 +189,21 @@ bool NetworkDeviceModel::addAndPlay(const QVariantList& itemIdList)
     return ret;
 }
 
+bool NetworkDeviceModel::addAndPlay(const QModelIndexList& itemIdList)
+{
+    bool ret = false;
+    for (const QModelIndex& index: itemIdList)
+    {
+        if (!index.isValid())
+            continue;
+        if (!ret)
+            ret |= addAndPlay(index.row());
+        else
+            ret |= addToPlaylist(index.row());
+    }
+    return ret;
+}
+
 bool NetworkDeviceModel::initializeMediaSources()
 {
     auto libvlc = vlc_object_instance(m_ctx->getIntf());
diff --git a/modules/gui/qt/network/networkdevicemodel.hpp b/modules/gui/qt/network/networkdevicemodel.hpp
index 8706f7ba0f..bc662f5c62 100644
--- a/modules/gui/qt/network/networkdevicemodel.hpp
+++ b/modules/gui/qt/network/networkdevicemodel.hpp
@@ -84,8 +84,10 @@ public:
 
     Q_INVOKABLE bool addToPlaylist( int index );
     Q_INVOKABLE bool addToPlaylist(const QVariantList& itemIdList);
+    Q_INVOKABLE bool addToPlaylist(const QModelIndexList& itemIdList);
     Q_INVOKABLE bool addAndPlay( int index );
     Q_INVOKABLE bool addAndPlay(const QVariantList& itemIdList);
+    Q_INVOKABLE bool addAndPlay(const QModelIndexList& itemIdList);
 
 signals:
     void ctxChanged();
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index fd0a9f76ce..bd1ccda102 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -217,6 +217,18 @@ bool NetworkMediaModel::addToPlaylist(const QVariantList &itemIdList)
     return ret;
 }
 
+bool NetworkMediaModel::addToPlaylist(const QModelIndexList &itemIdList)
+{
+    bool ret = false;
+    for (const QModelIndex& index: itemIdList)
+    {
+        if (!index.isValid())
+            continue;
+        ret |= addToPlaylist(index.row());
+    }
+    return ret;
+}
+
 bool NetworkMediaModel::addAndPlay(int index)
 {
     if (!(m_ctx && m_hasTree))
@@ -251,6 +263,22 @@ bool NetworkMediaModel::addAndPlay(const QVariantList& itemIdList)
     return ret;
 }
 
+bool NetworkMediaModel::addAndPlay(const QModelIndexList& itemIdList)
+{
+    bool ret = false;
+    for (const QModelIndex& index: itemIdList)
+    {
+        if (!index.isValid())
+            continue;
+
+        if (!ret)
+            ret |= addAndPlay(index.row());
+        else
+            ret |= addToPlaylist(index.row());
+    }
+    return ret;
+}
+
 
 bool NetworkMediaModel::initializeMediaSources()
 {
diff --git a/modules/gui/qt/network/networkmediamodel.hpp b/modules/gui/qt/network/networkmediamodel.hpp
index 13bece16cb..ebf4634f86 100644
--- a/modules/gui/qt/network/networkmediamodel.hpp
+++ b/modules/gui/qt/network/networkmediamodel.hpp
@@ -126,8 +126,10 @@ public:
 
     Q_INVOKABLE bool addToPlaylist( int index );
     Q_INVOKABLE bool addToPlaylist(const QVariantList& itemIdList);
+    Q_INVOKABLE bool addToPlaylist(const QModelIndexList& itemIdList);
     Q_INVOKABLE bool addAndPlay( int index );
     Q_INVOKABLE bool addAndPlay(const QVariantList& itemIdList);
+    Q_INVOKABLE bool addAndPlay(const QModelIndexList& itemIdList);
 
 signals:
     void nameChanged();
-- 
2.25.1



More information about the vlc-devel mailing list