mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Use a closure to handle tracks async.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "AlbumPlaylistInterface.h"
|
#include "AlbumPlaylistInterface.h"
|
||||||
#include "PlayableItem.h"
|
#include "PlayableItem.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "utils/Closure.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
@@ -208,14 +209,12 @@ TreeModel::addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent, bool autoRefetch )
|
TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
Q_UNUSED( autoRefetch );
|
|
||||||
|
|
||||||
startLoading();
|
startLoading();
|
||||||
|
|
||||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
NewClosure( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||||
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
|
const_cast<TreeModel*>(this), SLOT( addTracks( Tomahawk::album_ptr, QModelIndex ) ), album, parent );
|
||||||
|
|
||||||
onTracksAdded( album->tracks( m_mode, m_collection ), parent );
|
onTracksAdded( album->tracks( m_mode, m_collection ), parent );
|
||||||
}
|
}
|
||||||
@@ -327,21 +326,6 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeModel::onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection )
|
|
||||||
{
|
|
||||||
if ( mode != m_mode || collection != m_collection )
|
|
||||||
return;
|
|
||||||
|
|
||||||
Tomahawk::Album* album = qobject_cast<Tomahawk::Album*>( sender() );
|
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << "Adding album:" << album->artist()->name() << album->name() << album->id();
|
|
||||||
QModelIndex idx = indexFromAlbum( album->weakRef().toStrongRef() );
|
|
||||||
tDebug() << Q_FUNC_INFO << "Adding tracks" << tracks.count() << "to index:" << idx;
|
|
||||||
onTracksAdded( tracks, idx );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QModelIndex
|
QModelIndex
|
||||||
TreeModel::indexFromArtist( const Tomahawk::artist_ptr& artist ) const
|
TreeModel::indexFromArtist( const Tomahawk::artist_ptr& artist ) const
|
||||||
{
|
{
|
||||||
|
@@ -56,7 +56,6 @@ public:
|
|||||||
//void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
|
//void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
|
||||||
|
|
||||||
void addArtists( const Tomahawk::artist_ptr& artist );
|
void addArtists( const Tomahawk::artist_ptr& artist );
|
||||||
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent, bool autoRefetch = false );
|
|
||||||
void fetchAlbums( const Tomahawk::artist_ptr& artist );
|
void fetchAlbums( const Tomahawk::artist_ptr& artist );
|
||||||
|
|
||||||
void getCover( const QModelIndex& index );
|
void getCover( const QModelIndex& index );
|
||||||
@@ -70,6 +69,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
|
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
|
||||||
|
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modeChanged( Tomahawk::ModelMode mode );
|
void modeChanged( Tomahawk::ModelMode mode );
|
||||||
@@ -82,7 +82,6 @@ private slots:
|
|||||||
void onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists );
|
void onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists );
|
||||||
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
|
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
|
||||||
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tomahawk::ModelMode m_mode;
|
Tomahawk::ModelMode m_mode;
|
||||||
|
@@ -152,7 +152,7 @@ AlbumInfoWidget::load( const album_ptr& album )
|
|||||||
m_headerWidget->setCaption( album->artist()->name() );
|
m_headerWidget->setCaption( album->artist()->name() );
|
||||||
|
|
||||||
m_tracksModel->startLoading();
|
m_tracksModel->startLoading();
|
||||||
m_tracksModel->addTracks( album, QModelIndex(), true );
|
m_tracksModel->addTracks( album, QModelIndex() );
|
||||||
|
|
||||||
onAlbumImageUpdated();
|
onAlbumImageUpdated();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user