[vlc-commits] qt: allow to enqueue network item using model indexes
Pierre Lamot
git at videolan.org
Wed Jun 3 12:06:47 CEST 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Feb 27 18:27:13 2020 +0100| [c658f1a8ee9fedd27444aa1769c2f5fb633b1c8e] | committer: Pierre Lamot
qt: allow to enqueue network item using model indexes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c658f1a8ee9fedd27444aa1769c2f5fb633b1c8e
---
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();
More information about the vlc-commits
mailing list