1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-17 19:37:09 +02:00

* Fixed refreshing covers upon retrieval in AlbumModel / -Item.

This commit is contained in:
Christian Muehlhaeuser
2010-11-25 06:05:25 +01:00
parent 2a8d288524
commit 245b3b6951
4 changed files with 12 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ public:
explicit AlbumItem( const Tomahawk::album_ptr& album, AlbumItem* parent = 0, int row = -1 );
const Tomahawk::album_ptr& album() const { return m_album; };
void setCover( const QPixmap& cover ) { this->cover = cover; emit dataChanged(); }
AlbumItem* parent;
QList<AlbumItem*> children;

View File

@@ -257,7 +257,7 @@ AlbumModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const Tomah
QNetworkReply* reply = APP->nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
// connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
}
emit endInsertRows();
@@ -269,7 +269,6 @@ void
AlbumModel::onCoverArtDownloaded()
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
qDebug() << "attr:" << reply->request().attribute( QNetworkRequest::User );
QUrl redir = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl();
if ( redir.isEmpty() )
@@ -289,7 +288,7 @@ AlbumModel::onCoverArtDownloaded()
}
else
{
ai->cover = pm.scaled( QSize( 64, 64 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
ai->setCover( pm.scaled( QSize( 64, 64 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
}
}
@@ -304,3 +303,11 @@ AlbumModel::onCoverArtDownloaded()
reply->deleteLater();
}
void
AlbumModel::onDataChanged()
{
AlbumItem* p = (AlbumItem*)sender();
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
}

View File

@@ -74,6 +74,7 @@ protected:
private slots:
void onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const Tomahawk::collection_ptr& collection );
void onCoverArtDownloaded();
void onDataChanged();
private:
QPersistentModelIndex m_currentIndex;

View File

@@ -145,7 +145,6 @@ void
PlaylistModel::onDataChanged()
{
PlItem* p = (PlItem*)sender();
// emit itemSizeChanged( p->index );
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
}