1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-19 15:31:59 +02:00

* Implement itemAt and indexOfResult in PlayableProxyModelPlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser 2012-11-16 08:28:20 +01:00
parent 4f4a61a6d6
commit 6f98ab3a92
2 changed files with 39 additions and 8 deletions

View File

@ -79,13 +79,6 @@ PlayableProxyModelPlaylistInterface::tracks()
}
Tomahawk::result_ptr
PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway )
{
return siblingItem( itemsAway, false );
}
bool
PlayableProxyModelPlaylistInterface::hasNextItem()
{
@ -230,3 +223,39 @@ PlayableProxyModelPlaylistInterface::currentItem() const
return result_ptr();
}
Tomahawk::query_ptr
PlayableProxyModelPlaylistInterface::itemAt( unsigned int position ) const
{
if ( m_proxyModel.isNull() )
return query_ptr();
PlayableProxyModel* proxyModel = m_proxyModel.data();
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( position, 0 ) ) );
if ( item && item->query() )
return item->query();
return query_ptr();
}
int
PlayableProxyModelPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
{
if ( m_proxyModel.isNull() )
return -1;
PlayableProxyModel* proxyModel = m_proxyModel.data();
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
{
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) );
if ( item && item->result() == result )
{
return i;
}
}
return -1;
}

View File

@ -43,8 +43,10 @@ public:
virtual int trackCount() const;
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const;
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const;
virtual Tomahawk::result_ptr currentItem() const;
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
virtual bool hasNextItem();