[vlc-commits] Qt: PL: Request missing art for visible items

Francois Cartegnie git at videolan.org
Thu Jun 7 12:53:06 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun  6 12:45:20 2012 +0200| [a4a89127debce365a970f877b739bdac04274ab3] | committer: Francois Cartegnie

Qt: PL: Request missing art for visible items

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

 modules/gui/qt4/components/playlist/playlist_model.cpp |   16 +++++++++++++++-
 modules/gui/qt4/components/playlist/playlist_model.hpp |    1 +
 modules/gui/qt4/components/playlist/standardpanel.cpp  |    1 +
 modules/gui/qt4/components/playlist/views.cpp          |    7 +++++++
 modules/gui/qt4/components/playlist/views.hpp          |    1 +
 modules/gui/qt4/components/playlist/vlc_model.cpp      |   15 ++++++++++-----
 modules/gui/qt4/components/playlist/vlc_model.hpp      |    1 +
 modules/gui/qt4/input_manager.cpp                      |    8 ++++++++
 8 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 4998b74..3a9f550 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -688,7 +688,6 @@ void PLModel::rebuild( playlist_item_t *p_root )
 
     /* And signal the view */
     reset();
-
     if( p_root ) emit rootIndexChanged();
 }
 
@@ -910,6 +909,21 @@ void PLModel::clearPlaylist()
     doDelete(l);
 }
 
+void PLModel::ensureArtRequested( const QModelIndex &index )
+{
+    if ( index.isValid() && hasChildren( index ) )
+    {
+        int nbnodes = rowCount( index );
+        QModelIndex child;
+        for( int row = 0 ; row < nbnodes ; row++ )
+        {
+            child = index.child( row, 0 );
+            if ( child.isValid() && getArtUrl( child ).isEmpty() )
+                THEMIM->getIM()->requestArtUpdate( getItem( child )->inputItem() );
+        }
+    }
+}
+
 /*********** Popup *********/
 bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
 {
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index ea3bfb2..133928f 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -121,6 +121,7 @@ signals:
 public slots:
     virtual void activateItem( const QModelIndex &index );
     void clearPlaylist();
+    void ensureArtRequested( const QModelIndex &index );
 private:
     /* General */
     PLItem *rootItem;
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index badb68c..7dccb55 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -216,6 +216,7 @@ void StandardPLPanel::browseInto( const QModelIndex &index )
 
         /* Store new rootindexid*/
         currentRootIndexId = model->itemId( index );
+        model->ensureArtRequested( index );
     }
 
     emit viewChanged( index );
diff --git a/modules/gui/qt4/components/playlist/views.cpp b/modules/gui/qt4/components/playlist/views.cpp
index 3e6794c..c66cd71 100644
--- a/modules/gui/qt4/components/playlist/views.cpp
+++ b/modules/gui/qt4/components/playlist/views.cpp
@@ -350,6 +350,13 @@ void PlListView::keyPressEvent( QKeyEvent *event )
         QListView::keyPressEvent( event );
 }
 
+void PlTreeView::setModel( QAbstractItemModel * model )
+{
+    QTreeView::setModel( model );
+    CONNECT( this, expanded( const QModelIndex & ),
+             model, ensureArtRequested( const QModelIndex & ) );
+}
+
 void PlTreeView::startDrag ( Qt::DropActions supportedActions )
 {
     plViewStartDrag( this, supportedActions );
diff --git a/modules/gui/qt4/components/playlist/views.hpp b/modules/gui/qt4/components/playlist/views.hpp
index 74abb1a..38285d8 100644
--- a/modules/gui/qt4/components/playlist/views.hpp
+++ b/modules/gui/qt4/components/playlist/views.hpp
@@ -93,6 +93,7 @@ protected:
     virtual void startDrag ( Qt::DropActions supportedActions );
     virtual void dragMoveEvent ( QDragMoveEvent * event );
     virtual void keyPressEvent( QKeyEvent *event );
+    virtual void setModel( QAbstractItemModel * );
 };
 
 class PicFlowView : public QAbstractItemView
diff --git a/modules/gui/qt4/components/playlist/vlc_model.cpp b/modules/gui/qt4/components/playlist/vlc_model.cpp
index cd1ec1d..ede9773 100644
--- a/modules/gui/qt4/components/playlist/vlc_model.cpp
+++ b/modules/gui/qt4/components/playlist/vlc_model.cpp
@@ -38,13 +38,18 @@ QString VLCModel::getMeta( const QModelIndex & index, int meta )
         data().toString();
 }
 
+QString VLCModel::getArtUrl( const QModelIndex & index )
+{
+    return index.model()->index( index.row(),
+                    columnFromMeta( COLUMN_COVER ),
+                    index.parent() )
+           .data().toString();
+}
+
 QPixmap VLCModel::getArtPixmap( const QModelIndex & index, const QSize & size )
 {
-    QString artUrl;
-    artUrl = index.model()->index( index.row(),
-                                  columnFromMeta( COLUMN_COVER ),
-                                  index.parent() )
-                                  .data().toString();
+    QString artUrl = VLCModel::getArtUrl( index ) ;
+
     QPixmap artPix;
 
     QString key = artUrl + QString("%1%2").arg(size.width()).arg(size.height());
diff --git a/modules/gui/qt4/components/playlist/vlc_model.hpp b/modules/gui/qt4/components/playlist/vlc_model.hpp
index c443cb3..8d29492 100644
--- a/modules/gui/qt4/components/playlist/vlc_model.hpp
+++ b/modules/gui/qt4/components/playlist/vlc_model.hpp
@@ -58,6 +58,7 @@ public:
     virtual ~VLCModel();
     static QString getMeta( const QModelIndex & index, int meta );
     static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size );
+    static QString getArtUrl( const QModelIndex & index );
 
     static int columnToMeta( int _column )
     {
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 0b710ad..671b4e0 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -639,6 +639,14 @@ void InputManager::requestArtUpdate( input_item_t *p_item )
 
     if ( p_item )
     {
+        /* check if it has already been enqueued */
+        if ( p_item->p_meta )
+        {
+            int status = vlc_meta_GetStatus( p_item->p_meta );
+            if ( status & ( ITEM_ART_NOTFOUND|ITEM_ART_FETCHED|
+                            ITEM_ARTURL_FETCHED|ITEM_PREPARSED ) )
+                return;
+        }
         playlist_AskForArtEnqueue( pl_Get(p_intf), p_item );
         /* No input will signal the cover art to update,
              * let's do it ourself */



More information about the vlc-commits mailing list