[vlc-devel] [PATCH 5/7] qt: expose parsing completion in network model

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Oct 22 11:29:16 CEST 2019


Hi,

On Mon, Oct 21, 2019, at 6:08 PM, Pierre Lamot wrote:
> ---
>  .../components/mediacenter/mlnetworkdevicemodel.hpp   |  1 +
>  .../qt/components/mediacenter/mlnetworkmediamodel.cpp | 11 +++++++++++
>  .../qt/components/mediacenter/mlnetworkmediamodel.hpp |  5 +++++
>  .../mediacenter/mlnetworksourcelistener.cpp           |  9 ++++++++-
>  .../mediacenter/mlnetworksourcelistener.hpp           |  5 +++++
>  5 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git 
> a/modules/gui/qt/components/mediacenter/mlnetworkdevicemodel.hpp 
> b/modules/gui/qt/components/mediacenter/mlnetworkdevicemodel.hpp
> index df142402c7..7867da57bf 100644
> --- a/modules/gui/qt/components/mediacenter/mlnetworkdevicemodel.hpp
> +++ b/modules/gui/qt/components/mediacenter/mlnetworkdevicemodel.hpp
> @@ -112,6 +112,7 @@ private:
>      void onItemCleared( MediaSourcePtr mediaSource, input_item_node_t* 
> node ) override;
>      void onItemAdded( MediaSourcePtr mediaSource, input_item_node_t* 
> parent, input_item_node_t *const children[], size_t count ) override;
>      void onItemRemoved( MediaSourcePtr mediaSource, input_item_node_t 
> *const children[], size_t count ) override;
> +    inline void onItemPreparseEnded( MediaSourcePtr, input_item_node_t 
> *, enum input_item_preparse_status ) override {}
>  
>      void refreshDeviceList(MediaSourcePtr mediaSource, 
> input_item_node_t* const children[], size_t count , bool clear);
>  
> diff --git 
> a/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.cpp 
> b/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.cpp
> index f1a15d020f..e8f8609187 100644
> --- a/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.cpp
> +++ b/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.cpp
> @@ -259,6 +259,9 @@ bool MLNetworkMediaModel::initializeMediaSources()
>  
>  
>      vlc_media_tree_Preparse( tree, libvlc, m_treeItem.media.get() );
> +    m_parsingPending = true;
> +    emit parsingPendingChanged(m_parsingPending);
> +
>      m_listener = std::move( l );
>  
>      return true;
> @@ -319,6 +322,14 @@ void MLNetworkMediaModel::onItemRemoved( MediaSourcePtr,
>      }
>  }
>  
> +void MLNetworkMediaModel::onItemPreparseEnded(MediaSourcePtr 
> mediaSource, input_item_node_t* node, enum input_item_preparse_status 
> status)
> +{
> +    QMetaObject::invokeMethod(this, [this]() {
> +        m_parsingPending = false;
> +        emit parsingPendingChanged(false);
> +    });
> +}
> +
>  void MLNetworkMediaModel::refreshMediaList( MediaSourcePtr mediaSource,
>                                         input_item_node_t* const 
> children[], size_t count,
>                                         bool clear )
> diff --git 
> a/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.hpp 
> b/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.hpp
> index c21f44577e..a1a323b8e2 100644
> --- a/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.hpp
> +++ b/modules/gui/qt/components/mediacenter/mlnetworkmediamodel.hpp
> @@ -93,6 +93,7 @@ public:
>      Q_PROPERTY(ItemType type READ getType NOTIFY typeChanged)
>      Q_PROPERTY(bool indexed READ isIndexed WRITE setIndexed NOTIFY 
> isIndexedChanged)
>      Q_PROPERTY(bool canBeIndexed READ canBeIndexed NOTIFY 
> canBeIndexedChanged)
> +    Q_PROPERTY(bool parsingPending READ getParsingPending NOTIFY 
> parsingPendingChanged)
>  
>  
>      explicit MLNetworkMediaModel(QObject* parent = nullptr);
> @@ -117,6 +118,7 @@ public:
>      inline ItemType getType() const { return m_type; }
>      inline bool isIndexed() const { return m_indexed; }
>      inline bool canBeIndexed() const { return m_canBeIndexed; }
> +    inline bool getParsingPending() const { return m_parsingPending; }
>  
>      Q_INVOKABLE bool addToPlaylist( int index );
>      Q_INVOKABLE bool addToPlaylist(const QVariantList& itemIdList);
> @@ -129,6 +131,7 @@ signals:
>      void typeChanged();
>      void isIndexedChanged();
>      void canBeIndexedChanged();
> +    void parsingPendingChanged(bool);
>  
>      void ctxChanged();
>      void treeChanged();
> @@ -154,6 +157,7 @@ private:
>      void onItemCleared( MediaSourcePtr mediaSource, input_item_node_t* 
> node ) override;
>      void onItemAdded( MediaSourcePtr mediaSource, input_item_node_t* 
> parent, input_item_node_t *const children[], size_t count ) override;
>      void onItemRemoved( MediaSourcePtr mediaSource, input_item_node_t 
> *const children[], size_t count ) override;
> +    void onItemPreparseEnded( MediaSourcePtr mediaSource, 
> input_item_node_t* node, enum input_item_preparse_status status ) 
> override;
>  
>      void refreshMediaList(MediaSourcePtr s, input_item_node_t* const 
> children[], size_t count , bool clear);
>  
> @@ -166,6 +170,7 @@ private:
>      ItemType m_type = ItemType::TYPE_UNKNOWN;
>      bool m_indexed = false;
>      bool m_canBeIndexed  = false;
> +    bool m_parsingPending = false;

Shouldn't this be atomic?

>  
>  
>      std::vector<Item> m_items;
> diff --git 
> a/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.cpp 
> b/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.cpp
> index c7fcbb618d..7cedf90afa 100644
> --- a/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.cpp
> +++ b/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.cpp
> @@ -14,7 +14,8 @@ 
> MLNetworkSourceListener::MLNetworkSourceListener(MediaSourcePtr s, 
> SourceListene
>      static const vlc_media_tree_callbacks cbs {
>          &MLNetworkSourceListener::onItemCleared,
>          &MLNetworkSourceListener::onItemAdded,
> -        &MLNetworkSourceListener::onItemRemoved
> +        &MLNetworkSourceListener::onItemRemoved,
> +        &MLNetworkSourceListener::onItemPreparseEnded
>      };
>      auto l = vlc_media_tree_AddListener( s->tree, &cbs, this, true );
>      if ( l == nullptr )
> @@ -49,3 +50,9 @@ void MLNetworkSourceListener::onItemRemoved( 
> vlc_media_tree_t *, input_item_node
>      auto* self = static_cast<MLNetworkSourceListener*>( userdata );
>      self->cb->onItemRemoved( self->source, children, count );
>  }
> +
> +void MLNetworkSourceListener::onItemPreparseEnded(vlc_media_tree_t *, 
> input_item_node_t * node, enum input_item_preparse_status status, void 
> *userdata)
> +{
> +    auto* self = static_cast<MLNetworkSourceListener*>( userdata );
> +    self->cb->onItemPreparseEnded( self->source, node, status );
> +}
> diff --git 
> a/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.hpp 
> b/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.hpp
> index 210b91d76a..ca56d832b8 100644
> --- a/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.hpp
> +++ b/modules/gui/qt/components/mediacenter/mlnetworksourcelistener.hpp
> @@ -50,6 +50,7 @@ public:
>          virtual void onItemCleared( MediaSourcePtr mediaSource, 
> input_item_node_t* node ) = 0;
>          virtual void onItemAdded( MediaSourcePtr mediaSource, 
> input_item_node_t* parent, input_item_node_t *const children[], size_t 
> count ) = 0;
>          virtual void onItemRemoved( MediaSourcePtr mediaSource, 
> input_item_node_t *const children[], size_t count ) = 0;
> +        virtual void onItemPreparseEnded( MediaSourcePtr mediaSource, 
> input_item_node_t* node, enum input_item_preparse_status status ) = 0;
>      };
>  
>  public:
> @@ -71,6 +72,10 @@ public:
>                                 input_item_node_t *const children[], 
> size_t count,
>                                 void *userdata );
>  
> +    static void onItemPreparseEnded( vlc_media_tree_t *tree, 
> input_item_node_t *node,
> +                                     enum input_item_preparse_status 
> status,
> +                                     void *userdata );
> +
>      MediaSourcePtr source;
>      ListenerPtr listener = nullptr;
>      SourceListenerCb *cb = nullptr;
> -- 
> 2.17.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list