diff --git a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp index bf43afa88..d578d541e 100644 --- a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp @@ -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; +} diff --git a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h index 543cf5e96..740ab4f76 100644 --- a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h +++ b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h @@ -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();