mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
* Fixed Listening Along.
This commit is contained in:
parent
262aaee142
commit
27b4c0b2c4
@ -28,7 +28,7 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source, Tomahawk::PlaylistModes::LatchMode latchMode )
|
||||
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source* source, Tomahawk::PlaylistModes::LatchMode latchMode )
|
||||
: PlaylistInterface()
|
||||
, m_source( source )
|
||||
, m_currentItem( 0 )
|
||||
@ -53,7 +53,18 @@ SourcePlaylistInterface::~SourcePlaylistInterface()
|
||||
void
|
||||
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 );
|
||||
|
||||
if ( nextResult() )
|
||||
return 0;
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
@ -73,23 +84,22 @@ SourcePlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::nextResult() const
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
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();
|
||||
return m_currentItem;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
m_gotNextItem = false;
|
||||
|
||||
if ( m_source.data()->currentTrack()->numResults() )
|
||||
{
|
||||
m_currentItem = m_source.data()->currentTrack()->results().first();
|
||||
}
|
||||
else
|
||||
m_currentItem = result_ptr();
|
||||
|
||||
@ -129,7 +139,10 @@ QList<Tomahawk::query_ptr>
|
||||
SourcePlaylistInterface::tracks() const
|
||||
{
|
||||
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
|
||||
SourcePlaylistInterface::queryAt( qint64 index ) const
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
||||
Tomahawk::result_ptr res = nextResult();
|
||||
return res->toQuery();
|
||||
if ( index == 1 )
|
||||
{
|
||||
Tomahawk::result_ptr res = nextResult();
|
||||
return res->toQuery();
|
||||
}
|
||||
else
|
||||
return Tomahawk::query_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::resultAt( qint64 index ) const
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
||||
return nextResult();
|
||||
if ( index == 1 )
|
||||
return nextResult();
|
||||
else
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual Tomahawk::result_ptr resultAt( 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 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user