mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Implement itemAt and indexOfResult in PlayableProxyModelPlaylistInterface.
This commit is contained in:
@@ -79,13 +79,6 @@ PlayableProxyModelPlaylistInterface::tracks()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::result_ptr
|
|
||||||
PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway )
|
|
||||||
{
|
|
||||||
return siblingItem( itemsAway, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlayableProxyModelPlaylistInterface::hasNextItem()
|
PlayableProxyModelPlaylistInterface::hasNextItem()
|
||||||
{
|
{
|
||||||
@@ -230,3 +223,39 @@ PlayableProxyModelPlaylistInterface::currentItem() const
|
|||||||
return result_ptr();
|
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;
|
||||||
|
}
|
||||||
|
@@ -43,8 +43,10 @@ public:
|
|||||||
|
|
||||||
virtual int trackCount() const;
|
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 currentItem() const;
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
||||||
virtual bool hasNextItem();
|
virtual bool hasNextItem();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user