1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

* Fixed Listening Along.

This commit is contained in:
Christian Muehlhaeuser
2012-11-28 10:49:43 +01:00
parent 262aaee142
commit 27b4c0b2c4
2 changed files with 34 additions and 17 deletions

View File

@@ -28,7 +28,7 @@
using namespace Tomahawk; using namespace Tomahawk;
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source, Tomahawk::PlaylistModes::LatchMode latchMode ) SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source* source, Tomahawk::PlaylistModes::LatchMode latchMode )
: PlaylistInterface() : PlaylistInterface()
, m_source( source ) , m_source( source )
, m_currentItem( 0 ) , m_currentItem( 0 )
@@ -53,7 +53,18 @@ SourcePlaylistInterface::~SourcePlaylistInterface()
void void
SourcePlaylistInterface::setCurrentIndex( qint64 index ) SourcePlaylistInterface::setCurrentIndex( qint64 index )
{ {
Q_UNUSED( index ); if ( index == 1 )
m_gotNextItem = false;
}
qint64
SourcePlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
{
if ( nextResult() == result )
return 1;
else
return -1;
} }
@@ -64,7 +75,7 @@ SourcePlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
Q_UNUSED( rootIndex ); Q_UNUSED( rootIndex );
if ( nextResult() ) if ( nextResult() )
return 0; return 1;
else else
return -1; return -1;
} }
@@ -73,23 +84,22 @@ SourcePlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
Tomahawk::result_ptr Tomahawk::result_ptr
SourcePlaylistInterface::nextResult() const SourcePlaylistInterface::nextResult() const
{ {
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
if ( !sourceValid() ) if ( !sourceValid() )
{ {
tDebug( LOGEXTRA ) << Q_FUNC_INFO << "Source no longer valid"; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Source no longer valid";
m_currentItem = Tomahawk::result_ptr(); m_currentItem = Tomahawk::result_ptr();
return m_currentItem; return m_currentItem;
} }
else if ( !hasNextResult() ) else if ( !hasNextResult() )
{ {
tDebug( LOGEXTRA ) << Q_FUNC_INFO << "This song was already fetched or the source isn't playing anything"; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "This song was already fetched or the source isn't playing anything";
return Tomahawk::result_ptr(); return Tomahawk::result_ptr();
} }
m_gotNextItem = false;
if ( m_source.data()->currentTrack()->numResults() ) if ( m_source.data()->currentTrack()->numResults() )
{
m_currentItem = m_source.data()->currentTrack()->results().first(); m_currentItem = m_source.data()->currentTrack()->results().first();
}
else else
m_currentItem = result_ptr(); m_currentItem = result_ptr();
@@ -129,7 +139,10 @@ QList<Tomahawk::query_ptr>
SourcePlaylistInterface::tracks() const SourcePlaylistInterface::tracks() const
{ {
QList<Tomahawk::query_ptr> tracks; QList<Tomahawk::query_ptr> tracks;
return tracks; // FIXME (with what?) if ( nextResult() )
tracks << nextResult()->toQuery();
return tracks;
} }
@@ -175,17 +188,21 @@ SourcePlaylistInterface::resolvingFinished( bool hasResults )
Tomahawk::query_ptr Tomahawk::query_ptr
SourcePlaylistInterface::queryAt( qint64 index ) const SourcePlaylistInterface::queryAt( qint64 index ) const
{ {
Q_UNUSED( index ); if ( index == 1 )
{
Tomahawk::result_ptr res = nextResult(); Tomahawk::result_ptr res = nextResult();
return res->toQuery(); return res->toQuery();
}
else
return Tomahawk::query_ptr();
} }
Tomahawk::result_ptr Tomahawk::result_ptr
SourcePlaylistInterface::resultAt( qint64 index ) const SourcePlaylistInterface::resultAt( qint64 index ) const
{ {
Q_UNUSED( index ); if ( index == 1 )
return nextResult();
return nextResult(); else
return Tomahawk::result_ptr();
} }

View File

@@ -46,7 +46,7 @@ public:
virtual void setCurrentIndex( qint64 index ); virtual void setCurrentIndex( qint64 index );
virtual Tomahawk::result_ptr resultAt( qint64 index ) const; virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
virtual Tomahawk::query_ptr queryAt( qint64 index ) const; virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; } virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const;
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; } virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const; virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const;