mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Implemented ArtistPlaylistInterface.
This commit is contained in:
parent
1e987af76b
commit
c9139f8a7e
@ -54,22 +54,18 @@ ArtistPlaylistInterface::~ArtistPlaylistInterface()
|
||||
void
|
||||
ArtistPlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
Q_ASSERT( false );
|
||||
|
||||
/* m_currentTrack = index;
|
||||
m_currentItem = m_queries.at( index )->results().first();*/
|
||||
m_currentTrack = index;
|
||||
m_currentItem = m_queries.at( index )->results().first();
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
ArtistPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
|
||||
{
|
||||
Q_UNUSED( itemsAway );
|
||||
Q_UNUSED( rootIndex );
|
||||
Q_ASSERT( false );
|
||||
qint64 p = m_currentTrack;
|
||||
if ( rootIndex >= 0 )
|
||||
p = rootIndex;
|
||||
|
||||
/* qint64 p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
@ -78,9 +74,7 @@ ArtistPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
|
||||
if ( p >= m_queries.count() )
|
||||
return -1;
|
||||
|
||||
return p;*/
|
||||
|
||||
return -1;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@ -232,3 +226,58 @@ ArtistPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
|
||||
m_finished = true;
|
||||
emit tracksLoaded( m_mode, m_collection );
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
ArtistPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
int i = 0;
|
||||
foreach ( const Tomahawk::query_ptr& query, m_queries )
|
||||
{
|
||||
if ( query->numResults() && query->results().contains( result ) )
|
||||
return i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
ArtistPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
int i = 0;
|
||||
foreach ( const Tomahawk::query_ptr& q, m_queries )
|
||||
{
|
||||
if ( q->equals( query ) )
|
||||
return i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
query_ptr
|
||||
ArtistPlaylistInterface::queryAt( qint64 index ) const
|
||||
{
|
||||
if ( index >= 0 && index < m_queries.count() )
|
||||
{
|
||||
return m_queries.at( index );
|
||||
}
|
||||
|
||||
return Tomahawk::query_ptr();
|
||||
}
|
||||
|
||||
|
||||
result_ptr
|
||||
ArtistPlaylistInterface::resultAt( qint64 index ) const
|
||||
{
|
||||
Tomahawk::query_ptr query = queryAt( index );
|
||||
if ( query && query->numResults() )
|
||||
return query->results().first();
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ public:
|
||||
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const;
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
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;
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const;
|
||||
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user