vlc | branch: master | Prince Gupta <guptaprince8...@gmail.com> | Tue Sep 8 17:47:58 2020 +0530| [4aacfd8529af84cd487e24ce06b0d6b1e44d1ec7] | committer: Pierre Lamot
qt: allow selective source name in NetworkDeviceModel Signed-off-by: Pierre Lamot <pie...@videolabs.io> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4aacfd8529af84cd487e24ce06b0d6b1e44d1ec7 --- modules/gui/qt/network/networkdevicemodel.cpp | 21 +++++++++++++++++++-- modules/gui/qt/network/networkdevicemodel.hpp | 9 +++++++++ .../qt/network/qml/NetworkHomeDeviceListView.qml | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt/network/networkdevicemodel.cpp b/modules/gui/qt/network/networkdevicemodel.cpp index 103609592e..281b236660 100644 --- a/modules/gui/qt/network/networkdevicemodel.cpp +++ b/modules/gui/qt/network/networkdevicemodel.cpp @@ -85,7 +85,7 @@ void NetworkDeviceModel::setCtx(QmlMainContext* ctx) m_ctx = ctx; m_ml = vlc_ml_instance_get( m_ctx->getIntf() ); } - if (m_ctx && m_sdSource != CAT_UNDEFINED) { + if (m_ctx && m_sdSource != CAT_UNDEFINED && !m_sourceName.isEmpty()) { initializeMediaSources(); } emit ctxChanged(); @@ -94,12 +94,21 @@ void NetworkDeviceModel::setCtx(QmlMainContext* ctx) void NetworkDeviceModel::setSdSource(SDCatType s) { m_sdSource = s; - if (m_ctx && m_sdSource != CAT_UNDEFINED) { + if (m_ctx && m_sdSource != CAT_UNDEFINED && !m_sourceName.isEmpty()) { initializeMediaSources(); } emit sdSourceChanged(); } +void NetworkDeviceModel::setSourceName(const QString& sourceName) +{ + m_sourceName = sourceName; + if (m_ctx && m_sdSource != CAT_UNDEFINED && !m_sourceName.isEmpty()) { + initializeMediaSources(); + } + emit sourceNameChanged(); +} + int NetworkDeviceModel::getCount() const { assert( m_items.size() < INT32_MAX ); @@ -211,6 +220,7 @@ bool NetworkDeviceModel::initializeMediaSources() endResetModel(); emit countChanged(); } + m_name = QString {}; auto provider = vlc_media_source_provider_Get( libvlc ); @@ -227,6 +237,13 @@ bool NetworkDeviceModel::initializeMediaSources() for ( auto i = 0u; i < nbProviders; ++i ) { auto meta = vlc_media_source_meta_list_Get( providerList.get(), i ); + const QString sourceName = qfu( meta->name ); + if ( m_sourceName != '*' && m_sourceName != sourceName ) + continue; + + m_name += m_name.isEmpty() ? qfu( meta->longname ) : ", " + qfu( meta->longname ); + emit nameChanged(); + auto mediaSource = vlc_media_source_provider_GetMediaSource( provider, meta->name ); if ( mediaSource == nullptr ) diff --git a/modules/gui/qt/network/networkdevicemodel.hpp b/modules/gui/qt/network/networkdevicemodel.hpp index 7bfeae761c..1096ec9349 100644 --- a/modules/gui/qt/network/networkdevicemodel.hpp +++ b/modules/gui/qt/network/networkdevicemodel.hpp @@ -76,6 +76,8 @@ public: Q_PROPERTY(QmlMainContext* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged) Q_PROPERTY(SDCatType sd_source READ getSdSource WRITE setSdSource NOTIFY sdSourceChanged) + Q_PROPERTY(QString name READ getName NOTIFY nameChanged) + Q_PROPERTY(QString source_name READ getSourceName WRITE setSourceName NOTIFY sourceNameChanged) Q_PROPERTY(int count READ getCount NOTIFY countChanged) public: @@ -87,9 +89,12 @@ public: void setCtx(QmlMainContext* ctx); void setSdSource(SDCatType s); + void setSourceName(const QString& sourceName); inline QmlMainContext* getCtx() { return m_ctx; } inline SDCatType getSdSource() { return m_sdSource; } + inline QString getName() { return m_name; } + inline QString getSourceName() { return m_sourceName; } int getCount() const; @@ -105,6 +110,8 @@ public: signals: void ctxChanged(); void sdSourceChanged(); + void sourceNameChanged(); + void nameChanged(); void countChanged(); private: @@ -140,6 +147,8 @@ private: QmlMainContext* m_ctx = nullptr; vlc_medialibrary_t* m_ml = nullptr; SDCatType m_sdSource = CAT_UNDEFINED; + QString m_sourceName; // '*' -> all sources + QString m_name; // source long name std::vector<std::unique_ptr<NetworkSourceListener>> m_listeners; }; diff --git a/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml b/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml index 2f0732feae..d7871c6341 100644 --- a/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml +++ b/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml @@ -57,6 +57,8 @@ Widgets.NavigableFocusScope { NetworkDeviceModel { id: deviceModel + + source_name: "*" } Util.SelectableDelegateModel { _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits