1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Check prev/next availability in Album- & ArtistPlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser 2012-12-04 03:15:10 +01:00
parent 4467202c3b
commit 085907dfe7
4 changed files with 37 additions and 9 deletions

View File

@ -36,7 +36,6 @@ using namespace Tomahawk;
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album* album, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
: Tomahawk::PlaylistInterface()
, m_currentItem( 0 )
, m_currentTrack( 0 )
, m_infoSystemLoaded( false )
, m_databaseLoaded( false )
, m_mode( mode )
@ -55,7 +54,8 @@ AlbumPlaylistInterface::~AlbumPlaylistInterface()
void
AlbumPlaylistInterface::setCurrentIndex( qint64 index )
{
m_currentTrack = index;
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
}
@ -63,7 +63,7 @@ AlbumPlaylistInterface::setCurrentIndex( qint64 index )
qint64
AlbumPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
{
qint64 p = m_currentTrack;
qint64 p = m_currentIndex;
if ( rootIndex >= 0 )
p = rootIndex;
@ -181,6 +181,7 @@ AlbumPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData re
Pipeline::instance()->resolve( ql );
m_queries << ql;
checkQueries();
}
break;
@ -243,6 +244,8 @@ AlbumPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
else
m_queries << tracks;
checkQueries();
m_finished = true;
emit tracksLoaded( m_mode, m_collection );
}
@ -301,3 +304,13 @@ AlbumPlaylistInterface::resultAt( qint64 index ) const
return Tomahawk::result_ptr();
}
void
AlbumPlaylistInterface::checkQueries()
{
foreach ( const Tomahawk::query_ptr& query, m_queries )
{
connect( query.data(), SIGNAL( playableStateChanged( bool ) ), SLOT( onItemsChanged() ), Qt::UniqueConnection );
}
}

View File

@ -70,9 +70,10 @@ private slots:
void infoSystemFinished( const QString& infoId );
private:
void checkQueries();
QList< Tomahawk::query_ptr > m_queries;
mutable result_ptr m_currentItem;
mutable qint64 m_currentTrack;
bool m_infoSystemLoaded;
bool m_databaseLoaded;

View File

@ -35,7 +35,6 @@ using namespace Tomahawk;
ArtistPlaylistInterface::ArtistPlaylistInterface( Tomahawk::Artist* artist, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
: Tomahawk::PlaylistInterface()
, m_currentItem( 0 )
, m_currentTrack( 0 )
, m_infoSystemLoaded( false )
, m_databaseLoaded( false )
, m_mode( mode )
@ -54,15 +53,16 @@ ArtistPlaylistInterface::~ArtistPlaylistInterface()
void
ArtistPlaylistInterface::setCurrentIndex( qint64 index )
{
m_currentTrack = index;
m_currentItem = m_queries.at( index )->results().first();
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
}
qint64
ArtistPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
{
qint64 p = m_currentTrack;
qint64 p = m_currentIndex;
if ( rootIndex >= 0 )
p = rootIndex;
@ -162,6 +162,7 @@ ArtistPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData r
Pipeline::instance()->resolve( ql );
m_queries << ql;
checkQueries();
}
break;
@ -223,6 +224,8 @@ ArtistPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
else
m_queries << tracks;
checkQueries();
m_finished = true;
emit tracksLoaded( m_mode, m_collection );
}
@ -281,3 +284,13 @@ ArtistPlaylistInterface::resultAt( qint64 index ) const
return Tomahawk::result_ptr();
}
void
ArtistPlaylistInterface::checkQueries()
{
foreach ( const Tomahawk::query_ptr& query, m_queries )
{
connect( query.data(), SIGNAL( playableStateChanged( bool ) ), SLOT( onItemsChanged() ), Qt::UniqueConnection );
}
}

View File

@ -69,9 +69,10 @@ private slots:
private:
Q_DISABLE_COPY( ArtistPlaylistInterface )
void checkQueries();
QList< Tomahawk::query_ptr > m_queries;
mutable result_ptr m_currentItem;
mutable qint64 m_currentTrack;
bool m_infoSystemLoaded;
bool m_databaseLoaded;