1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 08:34:34 +02: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 ) AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album* album, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
: Tomahawk::PlaylistInterface() : Tomahawk::PlaylistInterface()
, m_currentItem( 0 ) , m_currentItem( 0 )
, m_currentTrack( 0 )
, m_infoSystemLoaded( false ) , m_infoSystemLoaded( false )
, m_databaseLoaded( false ) , m_databaseLoaded( false )
, m_mode( mode ) , m_mode( mode )
@@ -55,7 +54,8 @@ AlbumPlaylistInterface::~AlbumPlaylistInterface()
void void
AlbumPlaylistInterface::setCurrentIndex( qint64 index ) AlbumPlaylistInterface::setCurrentIndex( qint64 index )
{ {
m_currentTrack = index; PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first(); m_currentItem = m_queries.at( index )->results().first();
} }
@@ -63,7 +63,7 @@ AlbumPlaylistInterface::setCurrentIndex( qint64 index )
qint64 qint64
AlbumPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const AlbumPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
{ {
qint64 p = m_currentTrack; qint64 p = m_currentIndex;
if ( rootIndex >= 0 ) if ( rootIndex >= 0 )
p = rootIndex; p = rootIndex;
@@ -181,6 +181,7 @@ AlbumPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData re
Pipeline::instance()->resolve( ql ); Pipeline::instance()->resolve( ql );
m_queries << ql; m_queries << ql;
checkQueries();
} }
break; break;
@@ -243,6 +244,8 @@ AlbumPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
else else
m_queries << tracks; m_queries << tracks;
checkQueries();
m_finished = true; m_finished = true;
emit tracksLoaded( m_mode, m_collection ); emit tracksLoaded( m_mode, m_collection );
} }
@@ -301,3 +304,13 @@ AlbumPlaylistInterface::resultAt( qint64 index ) const
return Tomahawk::result_ptr(); 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 ); void infoSystemFinished( const QString& infoId );
private: private:
void checkQueries();
QList< Tomahawk::query_ptr > m_queries; QList< Tomahawk::query_ptr > m_queries;
mutable result_ptr m_currentItem; mutable result_ptr m_currentItem;
mutable qint64 m_currentTrack;
bool m_infoSystemLoaded; bool m_infoSystemLoaded;
bool m_databaseLoaded; 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 ) ArtistPlaylistInterface::ArtistPlaylistInterface( Tomahawk::Artist* artist, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
: Tomahawk::PlaylistInterface() : Tomahawk::PlaylistInterface()
, m_currentItem( 0 ) , m_currentItem( 0 )
, m_currentTrack( 0 )
, m_infoSystemLoaded( false ) , m_infoSystemLoaded( false )
, m_databaseLoaded( false ) , m_databaseLoaded( false )
, m_mode( mode ) , m_mode( mode )
@@ -54,15 +53,16 @@ ArtistPlaylistInterface::~ArtistPlaylistInterface()
void void
ArtistPlaylistInterface::setCurrentIndex( qint64 index ) ArtistPlaylistInterface::setCurrentIndex( qint64 index )
{ {
m_currentTrack = index; PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
m_currentItem = m_queries.at( index )->results().first();
} }
qint64 qint64
ArtistPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const ArtistPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
{ {
qint64 p = m_currentTrack; qint64 p = m_currentIndex;
if ( rootIndex >= 0 ) if ( rootIndex >= 0 )
p = rootIndex; p = rootIndex;
@@ -162,6 +162,7 @@ ArtistPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData r
Pipeline::instance()->resolve( ql ); Pipeline::instance()->resolve( ql );
m_queries << ql; m_queries << ql;
checkQueries();
} }
break; break;
@@ -223,6 +224,8 @@ ArtistPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
else else
m_queries << tracks; m_queries << tracks;
checkQueries();
m_finished = true; m_finished = true;
emit tracksLoaded( m_mode, m_collection ); emit tracksLoaded( m_mode, m_collection );
} }
@@ -281,3 +284,13 @@ ArtistPlaylistInterface::resultAt( qint64 index ) const
return Tomahawk::result_ptr(); 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: private:
Q_DISABLE_COPY( ArtistPlaylistInterface ) Q_DISABLE_COPY( ArtistPlaylistInterface )
void checkQueries();
QList< Tomahawk::query_ptr > m_queries; QList< Tomahawk::query_ptr > m_queries;
mutable result_ptr m_currentItem; mutable result_ptr m_currentItem;
mutable qint64 m_currentTrack;
bool m_infoSystemLoaded; bool m_infoSystemLoaded;
bool m_databaseLoaded; bool m_databaseLoaded;