From a789ce82cabc7717118f90b888b473bdda1653b6 Mon Sep 17 00:00:00 2001 From: Mark Furneaux Date: Sun, 18 Mar 2018 22:03:04 -0400 Subject: [PATCH] Allow playing of tracks already in queue --- src/playlist/queue.cpp | 11 +++++++++++ src/ui/mainwindow.cpp | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/playlist/queue.cpp b/src/playlist/queue.cpp index 6e59c35b1..6c3d88ed6 100644 --- a/src/playlist/queue.cpp +++ b/src/playlist/queue.cpp @@ -152,6 +152,17 @@ void Queue::ToggleTracks(const QModelIndexList& source_indexes) { } void Queue::InsertFirst(const QModelIndexList& source_indexes) { + for (const QModelIndex& source_index : source_indexes) { + QModelIndex proxy_index = mapFromSource(source_index); + if (proxy_index.isValid()) { + // Already in the queue, so remove it to be reinserted later + const int row = proxy_index.row(); + beginRemoveRows(QModelIndex(), row, row); + source_indexes_.removeAt(row); + endRemoveRows(); + } + } + const int rows = source_indexes.count(); // Enqueue the tracks at the beginning beginInsertRows(QModelIndex(), 0, rows - 1); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 4c24d00b2..fffab3a16 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1763,10 +1763,10 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, else playlist_queue_->setText(tr("Toggle queue status")); - if (in_queue == 0 && not_in_queue == 1) - playlist_queue_play_next_->setText(tr("Play next")); - else if (in_queue == 0 && not_in_queue > 1) + if (all > 1) playlist_queue_play_next_->setText(tr("Play selected tracks next")); + else + playlist_queue_play_next_->setText(tr("Play next")); if (in_skipped == 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip track"));