mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
* Fixed TWK-1215: Dupe tracks used to caused playback to loop.
This commit is contained in:
parent
997c7f6f68
commit
5c60f5d3cc
@ -58,8 +58,8 @@ PlaylistInterface::nextResult() const
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
||||
qint64
|
||||
PlaylistInterface::siblingResultIndex( int itemsAway, qint64 rootIndex ) const
|
||||
{
|
||||
qint64 idx = siblingIndex( itemsAway, rootIndex );
|
||||
QList< qint64 > safetyCheck;
|
||||
@ -73,12 +73,49 @@ PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
||||
|
||||
if ( query && query->playable() )
|
||||
{
|
||||
return query->results().first();
|
||||
return idx;
|
||||
}
|
||||
|
||||
idx = siblingIndex( itemsAway < 0 ? -1 : 1, idx );
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
||||
{
|
||||
qint64 idx = siblingResultIndex( itemsAway, rootIndex );
|
||||
if ( idx >= 0 )
|
||||
{
|
||||
Tomahawk::query_ptr query = queryAt( idx );
|
||||
|
||||
if ( query && query->playable() )
|
||||
{
|
||||
return query->results().first();
|
||||
}
|
||||
}
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
PlaylistInterface::setSiblingResult( int itemsAway, qint64 rootIndex )
|
||||
{
|
||||
qint64 idx = siblingResultIndex( itemsAway, rootIndex );
|
||||
if ( idx >= 0 )
|
||||
{
|
||||
Tomahawk::query_ptr query = queryAt( idx );
|
||||
|
||||
if ( query && query->playable() )
|
||||
{
|
||||
setCurrentIndex( idx );
|
||||
return query->results().first();
|
||||
}
|
||||
}
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,10 @@ public:
|
||||
virtual Tomahawk::result_ptr previousResult() const;
|
||||
|
||||
virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const = 0;
|
||||
virtual qint64 siblingResultIndex( int itemsAway, qint64 rootIndex = -1 ) const;
|
||||
virtual Tomahawk::result_ptr siblingResult( int itemsAway, qint64 rootIndex = -1 ) const;
|
||||
|
||||
virtual Tomahawk::result_ptr setSiblingResult( int itemsAway, qint64 rootIndex = -1 );
|
||||
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const = 0;
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const = 0;
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const = 0;
|
||||
|
@ -558,7 +558,7 @@ AudioEngine::loadPreviousTrack()
|
||||
Tomahawk::result_ptr result;
|
||||
if ( m_playlist.data()->previousResult() )
|
||||
{
|
||||
result = m_playlist.data()->previousResult();
|
||||
result = m_playlist.data()->setSiblingResult( -1 );
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ AudioEngine::loadNextTrack()
|
||||
|
||||
if ( m_playlist.data()->nextResult() )
|
||||
{
|
||||
result = m_playlist.data()->nextResult();
|
||||
result = m_playlist.data()->setSiblingResult( 1 );
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
}
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
|
||||
if ( result )
|
||||
{
|
||||
if ( m_playlist )
|
||||
if ( m_playlist && m_playlist->currentItem() != result )
|
||||
{
|
||||
m_playlist->setCurrentIndex( m_playlist->indexOfResult( result ) );
|
||||
}
|
||||
|
@ -154,14 +154,14 @@ TrackView::setProxyModel( PlayableProxyModel* model )
|
||||
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
||||
disconnect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
||||
}
|
||||
|
||||
|
||||
m_proxyModel = model;
|
||||
|
||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||
connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||
|
||||
|
||||
m_delegate = new PlaylistItemDelegate( this, m_proxyModel );
|
||||
setItemDelegate( m_delegate );
|
||||
|
||||
@ -360,6 +360,7 @@ TrackView::tryToPlayItem( const QModelIndex& index )
|
||||
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||
if ( item && !item->query().isNull() )
|
||||
{
|
||||
m_model->setCurrentIndex( m_proxyModel->mapToSource( index ) );
|
||||
AudioEngine::instance()->playItem( playlistInterface(), item->query() );
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user