diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 6d7b6449c..88725ce40 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -348,6 +348,11 @@ int Playlist::next_index() const { if (stop_after_.isValid() && current_index() == stop_after_.row()) return -1; + // Any queued items take priority + if (!queue_->is_empty()) { + return queue_->PeekNext(); + } + int next_virtual_index = NextVirtualIndex(current_virtual_index_); if (next_virtual_index >= virtual_items_.count()) { // We've gone off the end of the playlist. @@ -419,6 +424,10 @@ void Playlist::set_current_index(int i) { emit CurrentSongChanged(current_item_metadata()); } + if (current_item_index_.row() == queue_->PeekNext()) { + queue_->TakeNext(); + } + // Update the virtual index if (i == -1) current_virtual_index_ = -1; diff --git a/src/playlist/queue.cpp b/src/playlist/queue.cpp index bfa7d56e2..87949abd5 100644 --- a/src/playlist/queue.cpp +++ b/src/playlist/queue.cpp @@ -300,5 +300,21 @@ Qt::ItemFlags Queue::flags(const QModelIndex &index) const { flags |= Qt::ItemIsDropEnabled; return flags; - +} + +int Queue::PeekNext() const { + if (source_indexes_.isEmpty()) + return -1; + return source_indexes_.first().row(); +} + +int Queue::TakeNext() { + if (source_indexes_.isEmpty()) + return -1; + + beginRemoveRows(QModelIndex(), 0, 0); + int ret = source_indexes_.takeFirst().row(); + endRemoveRows(); + + return ret; } diff --git a/src/playlist/queue.h b/src/playlist/queue.h index 3e7ae7ceb..6d083f603 100644 --- a/src/playlist/queue.h +++ b/src/playlist/queue.h @@ -38,9 +38,10 @@ public: // Query the queue bool is_empty() const; int PositionOf(const QModelIndex& source_index) const; + int PeekNext() const; // Modify the queue - QModelIndex TakeNext(); + int TakeNext(); void ToggleTracks(const QModelIndexList& source_indexes); void Clear(); void Move(const QList& proxy_rows, int pos);