[vlc-commits] qt: retrieve the artwork when available in network models

Pierre Lamot git at videolan.org
Thu Feb 13 11:06:35 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Feb  3 14:55:21 2020 +0100| [d3ba1b4672539189a07ed29177e4fe9aebc06ffe] | committer: Jean-Baptiste Kempf

qt: retrieve the artwork when available in network models

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d3ba1b4672539189a07ed29177e4fe9aebc06ffe
---

 modules/gui/qt/network/networkdevicemodel.cpp | 11 +++++++++++
 modules/gui/qt/network/networkdevicemodel.hpp |  1 +
 modules/gui/qt/network/networkmediamodel.cpp  | 11 +++++++++++
 modules/gui/qt/network/networkmediamodel.hpp  |  1 +
 4 files changed, 24 insertions(+)

diff --git a/modules/gui/qt/network/networkdevicemodel.cpp b/modules/gui/qt/network/networkdevicemodel.cpp
index c82740921d..ecc18b8d79 100644
--- a/modules/gui/qt/network/networkdevicemodel.cpp
+++ b/modules/gui/qt/network/networkdevicemodel.cpp
@@ -31,6 +31,7 @@ enum Role {
     NETWORK_PROTOCOL,
     NETWORK_SOURCE,
     NETWORK_TREE,
+    NETWORK_ARTWORK,
 };
 
 }
@@ -63,6 +64,8 @@ QVariant NetworkDeviceModel::data( const QModelIndex& index, int role ) const
             return item.mediaSource->description;
         case NETWORK_TREE:
             return QVariant::fromValue( NetworkTreeItem(item.mediaSource, item.inputItem.get()) );
+        case NETWORK_ARTWORK:
+            return item.artworkUrl;
         default:
             return {};
     }
@@ -77,6 +80,7 @@ QHash<int, QByteArray> NetworkDeviceModel::roleNames() const
         { NETWORK_PROTOCOL, "protocol" },
         { NETWORK_SOURCE, "source" },
         { NETWORK_TREE, "tree" },
+        { NETWORK_ARTWORK, "artwork" },
     };
 }
 
@@ -294,6 +298,13 @@ void NetworkDeviceModel::refreshDeviceList( MediaSourcePtr mediaSource, input_it
             item.mediaSource = mediaSource;
             item.inputItem = InputItemPtr(p_item);
 
+            char* artwork = input_item_GetArtworkURL( p_item.get() );
+            if (artwork)
+            {
+                item.artworkUrl = QUrl::fromEncoded(artwork);
+                free(artwork);
+            }
+
             auto it = std::upper_bound(begin( m_items ), end( m_items ), item, [](const Item& a, const Item& b) {
                 int comp =  QString::compare(a.name , b.name, Qt::CaseInsensitive );
                 if (comp == 0)
diff --git a/modules/gui/qt/network/networkdevicemodel.hpp b/modules/gui/qt/network/networkdevicemodel.hpp
index 0eb115ead3..e53c6a96d6 100644
--- a/modules/gui/qt/network/networkdevicemodel.hpp
+++ b/modules/gui/qt/network/networkdevicemodel.hpp
@@ -106,6 +106,7 @@ private:
         ItemType type;
         MediaSourcePtr mediaSource;
         InputItemPtr inputItem;
+        QUrl artworkUrl;
     };
 
     bool initializeMediaSources();
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index bbc0aa96bd..1e44d7476d 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -34,6 +34,7 @@ enum Role {
     NETWORK_PROTOCOL,
     NETWORK_TREE,
     NETWORK_SOURCE,
+    NETWORK_ARTWORK,
 };
 
 }
@@ -83,6 +84,8 @@ QVariant NetworkMediaModel::data( const QModelIndex& index, int role ) const
             return QVariant::fromValue( item.tree );
         case NETWORK_SOURCE:
             return item.mediaSource->description;
+        case NETWORK_ARTWORK:
+            return item.artworkUrl;
         default:
             return {};
     }
@@ -99,6 +102,7 @@ QHash<int, QByteArray> NetworkMediaModel::roleNames() const
         { NETWORK_PROTOCOL, "protocol" },
         { NETWORK_TREE, "tree" },
         { NETWORK_SOURCE, "source" },
+        { NETWORK_ARTWORK, "artwork" },
     };
 }
 
@@ -392,6 +396,13 @@ void NetworkMediaModel::refreshMediaList( MediaSourcePtr mediaSource,
         item.canBeIndexed = canBeIndexed( item.mainMrl , item.type );
         item.mediaSource = mediaSource;
 
+        char* artwork = input_item_GetArtworkURL(it.get());
+        if (artwork)
+        {
+            item.artworkUrl = QUrl::fromEncoded(artwork);
+            free(artwork);
+        }
+
         if ( item.canBeIndexed == true )
         {
             if ( vlc_ml_is_indexed( m_ml, qtu( item.mainMrl.toString( QUrl::FullyEncoded ) ),
diff --git a/modules/gui/qt/network/networkmediamodel.hpp b/modules/gui/qt/network/networkmediamodel.hpp
index 59dae326e6..08c5c64512 100644
--- a/modules/gui/qt/network/networkmediamodel.hpp
+++ b/modules/gui/qt/network/networkmediamodel.hpp
@@ -153,6 +153,7 @@ private:
         bool canBeIndexed;
         NetworkTreeItem tree;
         MediaSourcePtr mediaSource;
+        QUrl artworkUrl;
     };
 
 



More information about the vlc-commits mailing list