Commit a4a89127 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: PL: Request missing art for visible items

parent 2d6e1751
...@@ -688,7 +688,6 @@ void PLModel::rebuild( playlist_item_t *p_root ) ...@@ -688,7 +688,6 @@ void PLModel::rebuild( playlist_item_t *p_root )
/* And signal the view */ /* And signal the view */
reset(); reset();
if( p_root ) emit rootIndexChanged(); if( p_root ) emit rootIndexChanged();
} }
...@@ -910,6 +909,21 @@ void PLModel::clearPlaylist() ...@@ -910,6 +909,21 @@ void PLModel::clearPlaylist()
doDelete(l); 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 *********/ /*********** Popup *********/
bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list ) bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
{ {
......
...@@ -121,6 +121,7 @@ signals: ...@@ -121,6 +121,7 @@ signals:
public slots: public slots:
virtual void activateItem( const QModelIndex &index ); virtual void activateItem( const QModelIndex &index );
void clearPlaylist(); void clearPlaylist();
void ensureArtRequested( const QModelIndex &index );
private: private:
/* General */ /* General */
PLItem *rootItem; PLItem *rootItem;
......
...@@ -216,6 +216,7 @@ void StandardPLPanel::browseInto( const QModelIndex &index ) ...@@ -216,6 +216,7 @@ void StandardPLPanel::browseInto( const QModelIndex &index )
/* Store new rootindexid*/ /* Store new rootindexid*/
currentRootIndexId = model->itemId( index ); currentRootIndexId = model->itemId( index );
model->ensureArtRequested( index );
} }
emit viewChanged( index ); emit viewChanged( index );
......
...@@ -350,6 +350,13 @@ void PlListView::keyPressEvent( QKeyEvent *event ) ...@@ -350,6 +350,13 @@ void PlListView::keyPressEvent( QKeyEvent *event )
QListView::keyPressEvent( 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 ) void PlTreeView::startDrag ( Qt::DropActions supportedActions )
{ {
plViewStartDrag( this, supportedActions ); plViewStartDrag( this, supportedActions );
......
...@@ -93,6 +93,7 @@ protected: ...@@ -93,6 +93,7 @@ protected:
virtual void startDrag ( Qt::DropActions supportedActions ); virtual void startDrag ( Qt::DropActions supportedActions );
virtual void dragMoveEvent ( QDragMoveEvent * event ); virtual void dragMoveEvent ( QDragMoveEvent * event );
virtual void keyPressEvent( QKeyEvent *event ); virtual void keyPressEvent( QKeyEvent *event );
virtual void setModel( QAbstractItemModel * );
}; };
class PicFlowView : public QAbstractItemView class PicFlowView : public QAbstractItemView
......
...@@ -38,13 +38,18 @@ QString VLCModel::getMeta( const QModelIndex & index, int meta ) ...@@ -38,13 +38,18 @@ QString VLCModel::getMeta( const QModelIndex & index, int meta )
data().toString(); 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 ) QPixmap VLCModel::getArtPixmap( const QModelIndex & index, const QSize & size )
{ {
QString artUrl; QString artUrl = VLCModel::getArtUrl( index ) ;
artUrl = index.model()->index( index.row(),
columnFromMeta( COLUMN_COVER ),
index.parent() )
.data().toString();
QPixmap artPix; QPixmap artPix;
QString key = artUrl + QString("%1%2").arg(size.width()).arg(size.height()); QString key = artUrl + QString("%1%2").arg(size.width()).arg(size.height());
......
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
virtual ~VLCModel(); virtual ~VLCModel();
static QString getMeta( const QModelIndex & index, int meta ); static QString getMeta( const QModelIndex & index, int meta );
static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size ); static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size );
static QString getArtUrl( const QModelIndex & index );
static int columnToMeta( int _column ) static int columnToMeta( int _column )
{ {
......
...@@ -639,6 +639,14 @@ void InputManager::requestArtUpdate( input_item_t *p_item ) ...@@ -639,6 +639,14 @@ void InputManager::requestArtUpdate( input_item_t *p_item )
if ( 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 ); playlist_AskForArtEnqueue( pl_Get(p_intf), p_item );
/* No input will signal the cover art to update, /* No input will signal the cover art to update,
* let's do it ourself */ * let's do it ourself */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment