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

* Implemented AlbumPlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser 2012-12-03 22:24:08 +01:00
parent 5ec024c550
commit 1e987af76b
2 changed files with 65 additions and 16 deletions

View File

@ -55,22 +55,18 @@ AlbumPlaylistInterface::~AlbumPlaylistInterface()
void
AlbumPlaylistInterface::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
AlbumPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
{
Q_UNUSED( itemsAway );
Q_UNUSED( rootIndex );
Q_ASSERT( false );
/*
qint64 p = m_currentTrack;
if ( rootIndex >= 0 )
p = rootIndex;
p += itemsAway;
if ( p < 0 )
@ -79,9 +75,7 @@ AlbumPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
if ( p >= m_queries.count() )
return -1;
return p;*/
return -1;
return p;
}
@ -252,3 +246,58 @@ AlbumPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
m_finished = true;
emit tracksLoaded( m_mode, m_collection );
}
qint64
AlbumPlaylistInterface::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
AlbumPlaylistInterface::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
AlbumPlaylistInterface::queryAt( qint64 index ) const
{
if ( index >= 0 && index < m_queries.count() )
{
return m_queries.at( index );
}
return Tomahawk::query_ptr();
}
result_ptr
AlbumPlaylistInterface::resultAt( qint64 index ) const
{
Tomahawk::query_ptr query = queryAt( index );
if ( query && query->numResults() )
return query->results().first();
return Tomahawk::result_ptr();
}

View File

@ -47,10 +47,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;