[vlc-devel] [PATCH 2/6] qt/mlplaylistmodel: Add the 'thumbnailUpdated' function

Benjamin Arnaud benjamin.arnaud at videolabs.io
Wed Apr 7 08:29:30 UTC 2021


---
 .../gui/qt/medialibrary/mlplaylistmodel.cpp   | 36 +++++++++++--------
 .../gui/qt/medialibrary/mlplaylistmodel.hpp   |  8 +++--
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlplaylistmodel.cpp b/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
index 8993ade0ed..2207da6796 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
@@ -270,35 +270,41 @@ ListCacheLoader<std::unique_ptr<MLItem>> * MLPlaylistModel::createLoader() const
 }
 
 //-------------------------------------------------------------------------------------------------
-// Private functions
+// Protected MLBaseModel reimplementation
+//-------------------------------------------------------------------------------------------------
 
-QList<int> MLPlaylistModel::getRows(const QModelIndexList & indexes) const
+void MLPlaylistModel::onVlcMlEvent(const MLEvent & event) /* override */
 {
-    QList<int> rows;
-
-    for (const QModelIndex & index : indexes)
+    if (event.i_type == VLC_ML_EVENT_PLAYLIST_UPDATED)
     {
-        rows.append(index.row());
+        m_need_reset = true;
+
+        // NOTE: Maybe we should call this from MLBaseModel ?
+        emit resetRequested();
     }
 
-    return rows;
+    MLBaseModel::onVlcMlEvent(event);
+}
+
+void MLPlaylistModel::thumbnailUpdated(int idx) /* override */
+{
+    emit dataChanged(index(idx), index(idx), { MEDIA_THUMBNAIL });
 }
 
 //-------------------------------------------------------------------------------------------------
-// Private MLBaseModel reimplementation
+// Private functions
 //-------------------------------------------------------------------------------------------------
 
-void MLPlaylistModel::onVlcMlEvent(const MLEvent & event) /* override */
+QList<int> MLPlaylistModel::getRows(const QModelIndexList & indexes) const
 {
-    if (event.i_type == VLC_ML_EVENT_PLAYLIST_UPDATED)
-    {
-        m_need_reset = true;
+    QList<int> rows;
 
-        // NOTE: Maybe we should call this from MLBaseModel ?
-        emit resetRequested();
+    for (const QModelIndex & index : indexes)
+    {
+        rows.append(index.row());
     }
 
-    MLBaseModel::onVlcMlEvent(event);
+    return rows;
 }
 
 //=================================================================================================
diff --git a/modules/gui/qt/medialibrary/mlplaylistmodel.hpp b/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
index 2fb9b663c9..50ead3348d 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
@@ -69,12 +69,14 @@ protected: // MLBaseModel implementation
 
     ListCacheLoader<std::unique_ptr<MLItem>> * createLoader() const override;
 
+protected: // MLBaseModel reimplementation
+    void onVlcMlEvent(const MLEvent & event) override;
+
+    void thumbnailUpdated(int idx) override;
+
 private: // Functions
     QList<int> getRows(const QModelIndexList & indexes) const;
 
-private: // MLBaseModel implementation
-    void onVlcMlEvent(const MLEvent & event) override;
-
 private:
     struct Loader : public MLBaseModel::BaseLoader
     {
-- 
2.25.1



More information about the vlc-devel mailing list