diff --git a/src/core/player.cpp b/src/core/player.cpp index 86c7a6efd..557826d76 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -158,7 +158,10 @@ void Player::NextInternal(Engine::TrackChangeFlags change) { } void Player::NextItem(Engine::TrackChangeFlags change) { - int i = playlists_->active()->next_row(); + // Manual track changes override "Repeat track" + const bool ignore_repeat_track = change & Engine::Manual; + + int i = playlists_->active()->next_row(ignore_repeat_track); if (i == -1) { playlists_->active()->set_current_row(i); emit PlaylistFinished(); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index f3862343a..9ed408777 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -371,14 +371,14 @@ bool Playlist::FilterContainsVirtualIndex(int i) const { return proxy_->filterAcceptsRow(virtual_items_[i], QModelIndex()); } -int Playlist::NextVirtualIndex(int i) const { +int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode(); PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode(); bool album_only = repeat_mode == PlaylistSequence::Repeat_Album || shuffle_mode == PlaylistSequence::Shuffle_InsideAlbum; // This one's easy - if we have to repeat the current track then just return i - if (repeat_mode == PlaylistSequence::Repeat_Track) { + if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) { if (!FilterContainsVirtualIndex(i)) return virtual_items_.count(); // It's not in the filter any more return i; @@ -451,7 +451,7 @@ int Playlist::PreviousVirtualIndex(int i) const { return -1; } -int Playlist::next_row() const { +int Playlist::next_row(bool ignore_repeat_track) const { // Did we want to stop after this track? if (stop_after_.isValid() && current_row() == stop_after_.row()) return -1; @@ -461,7 +461,7 @@ int Playlist::next_row() const { return queue_->PeekNext(); } - int next_virtual_index = NextVirtualIndex(current_virtual_index_); + int next_virtual_index = NextVirtualIndex(current_virtual_index_, ignore_repeat_track); if (next_virtual_index >= virtual_items_.count()) { // We've gone off the end of the playlist. @@ -473,7 +473,7 @@ int Playlist::next_row() const { break; default: - next_virtual_index = NextVirtualIndex(-1); + next_virtual_index = NextVirtualIndex(-1, ignore_repeat_track); break; } } diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 2ab502443..567c26427 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -165,7 +165,7 @@ class Playlist : public QAbstractListModel { int current_row() const; int last_played_row() const; - int next_row() const; + int next_row(bool ignore_repeat_track = false) const; int previous_row() const; const QModelIndex current_index() const; @@ -294,7 +294,7 @@ class Playlist : public QAbstractListModel { void SetCurrentIsPaused(bool paused); void UpdateScrobblePoint(); void ReshuffleIndices(); - int NextVirtualIndex(int i) const; + int NextVirtualIndex(int i, bool ignore_repeat_track) const; int PreviousVirtualIndex(int i) const; bool FilterContainsVirtualIndex(int i) const; void TurnOnDynamicPlaylist(smart_playlists::GeneratorPtr gen);