[vlc-commits] qt: provide direct access to model data of network models
Pierre Lamot
git at videolan.org
Wed Jun 3 12:06:49 CEST 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon May 18 11:18:30 2020 +0200| [077f7e791fbdb4cec0781aa6cb54fb19c0bcd698] | committer: Pierre Lamot
qt: provide direct access to model data of network models
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=077f7e791fbdb4cec0781aa6cb54fb19c0bcd698
---
modules/gui/qt/network/networkdevicemodel.cpp | 10 ++++++++++
modules/gui/qt/network/networkdevicemodel.hpp | 2 ++
modules/gui/qt/network/networkmediamodel.cpp | 12 ++++++++++++
modules/gui/qt/network/networkmediamodel.hpp | 2 ++
4 files changed, 26 insertions(+)
diff --git a/modules/gui/qt/network/networkdevicemodel.cpp b/modules/gui/qt/network/networkdevicemodel.cpp
index 07e2dd4f69..ff9aa5d97e 100644
--- a/modules/gui/qt/network/networkdevicemodel.cpp
+++ b/modules/gui/qt/network/networkdevicemodel.cpp
@@ -204,6 +204,16 @@ bool NetworkDeviceModel::addAndPlay(const QModelIndexList& itemIdList)
return ret;
}
+QMap<QString, QVariant> NetworkDeviceModel::getDataAt(int idx)
+{
+ QMap<QString, QVariant> dataDict;
+ QHash<int,QByteArray> roles = roleNames();
+ for (auto role: roles.keys()) {
+ dataDict[roles[role]] = data(index(idx), role);
+ }
+ return dataDict;
+}
+
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 bc662f5c62..166870361f 100644
--- a/modules/gui/qt/network/networkdevicemodel.hpp
+++ b/modules/gui/qt/network/networkdevicemodel.hpp
@@ -89,6 +89,8 @@ public:
Q_INVOKABLE bool addAndPlay(const QVariantList& itemIdList);
Q_INVOKABLE bool addAndPlay(const QModelIndexList& itemIdList);
+ Q_INVOKABLE QMap<QString, QVariant> getDataAt(int index);
+
signals:
void ctxChanged();
void sdSourceChanged();
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index bd1ccda102..ddb87b5e2b 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -106,6 +106,18 @@ QHash<int, QByteArray> NetworkMediaModel::roleNames() const
};
}
+
+QMap<QString, QVariant> NetworkMediaModel::getDataAt(int idx)
+{
+ QMap<QString, QVariant> dataDict;
+ QHash<int,QByteArray> roles = roleNames();
+ for (auto role: roles.keys()) {
+ dataDict[roles[role]] = data(index(idx), role);
+ }
+ return dataDict;
+}
+
+
int NetworkMediaModel::rowCount(const QModelIndex& parent) const
{
if ( parent.isValid() )
diff --git a/modules/gui/qt/network/networkmediamodel.hpp b/modules/gui/qt/network/networkmediamodel.hpp
index ebf4634f86..ee368c1848 100644
--- a/modules/gui/qt/network/networkmediamodel.hpp
+++ b/modules/gui/qt/network/networkmediamodel.hpp
@@ -124,6 +124,8 @@ public:
inline bool getParsingPending() const { return m_parsingPending; }
int getCount() const;
+ Q_INVOKABLE QMap<QString, QVariant> getDataAt(int idx);
+
Q_INVOKABLE bool addToPlaylist( int index );
Q_INVOKABLE bool addToPlaylist(const QVariantList& itemIdList);
Q_INVOKABLE bool addToPlaylist(const QModelIndexList& itemIdList);
More information about the vlc-commits
mailing list