diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 461baf11b..c56d6464d 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -441,8 +441,9 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { if (!album_only) { ++i; - // Advance i until we find any track that is in the filter - while ((i < virtual_items_.count() && !FilterContainsVirtualIndex(i)) || queue_->SkipSourceRow(i)) { + // Advance i until we find any track that is in the filter, skipping + // the selected to be skipped + while ((i < virtual_items_.count() && !FilterContainsVirtualIndex(i)) || items_[virtual_items_[i]]->GetToSkip()) { ++i; } return i; @@ -2017,3 +2018,10 @@ bool Playlist::ApplyValidityOnCurrentSong(const QUrl& url, bool valid) { void Playlist::SetColumnAlignment(const ColumnAlignmentMap& alignment) { column_alignments_ = alignment; } + +void Playlist::SkipTracks(const QModelIndexList &source_indexes) { + foreach (const QModelIndex& source_index, source_indexes) { + PlaylistItemPtr track_to_skip = item_at(source_index.row()); + track_to_skip->SetToSkip(!((track_to_skip)->GetToSkip())); + } +} diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 8a24ce7f8..ac0a54615 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -84,6 +84,8 @@ class Playlist : public QAbstractListModel { QObject* parent = 0); ~Playlist(); + void SkipTracks(const QModelIndexList &source_indexes); + // Always add new columns to the end of this enum - the values are persisted enum Column { Column_Title = 0, @@ -354,7 +356,6 @@ class Playlist : public QAbstractListModel { void ItemReloadComplete(); void ItemsLoaded(); void SongInsertVetoListenerDestroyed(); - private: bool is_loading_; PlaylistFilter* proxy_; diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index b8c24e0f5..b671351c4 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -123,3 +123,9 @@ QColor PlaylistItem::GetCurrentForegroundColor() const { bool PlaylistItem::HasCurrentForegroundColor() const { return !foreground_colors_.isEmpty(); } +void PlaylistItem::SetToSkip(bool val) { + to_skip_ = val; +} +bool PlaylistItem::GetToSkip() const { + return to_skip_; +} diff --git a/src/playlist/playlistitem.h b/src/playlist/playlistitem.h index 449a1f421..5dce559ba 100644 --- a/src/playlist/playlistitem.h +++ b/src/playlist/playlistitem.h @@ -33,7 +33,7 @@ class SqlRow; class PlaylistItem : public boost::enable_shared_from_this { public: PlaylistItem(const QString& type) - : type_(type) {} + : to_skip_(false), type_(type) {} virtual ~PlaylistItem(); static PlaylistItem* NewFromType(const QString& type); @@ -91,8 +91,12 @@ class PlaylistItem : public boost::enable_shared_from_this { // invalid so you might want to check that its id is not equal to -1 // before actually using it. virtual bool IsLocalLibraryItem() const { return false; } + void SetToSkip(bool val); + bool GetToSkip() const; protected: + bool to_skip_; + enum DatabaseColumn { Column_LibraryId, Column_InternetService, diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 0facb87eb..9dc9cfb9a 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1313,6 +1313,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& int streams = 0; int in_queue = 0; int not_in_queue = 0; + int in_skipped = 0; + int not_in_skipped = 0; foreach (const QModelIndex& index, selection) { if (index.column() != 0) continue; @@ -1332,6 +1334,12 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& not_in_queue ++; else in_queue ++; + + if(item->GetToSkip()) { + in_skipped++; + } else { + not_in_skipped++; + } } int all = not_in_queue + in_queue; @@ -1366,10 +1374,18 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& playlist_queue_->setText(tr("Dequeue track")); else if (in_queue > 1 && not_in_queue == 0) playlist_queue_->setText(tr("Dequeue selected tracks")); + else if (in_skipped == 1 && not_in_skipped == 0) + playlist_skip_->setText(tr("Unskip track")); + else if (in_skipped > 1 && not_in_skipped == 0) + playlist_skip_->setText(tr("Unskip selected tracks")); else if (in_queue == 0 && not_in_queue == 1) playlist_queue_->setText(tr("Queue track")); else if (in_queue == 0 && not_in_queue > 1) playlist_queue_->setText(tr("Queue selected tracks")); + else if (in_skipped == 0 && not_in_skipped == 1) + playlist_skip_->setText(tr("Skip track")); + else if (in_skipped == 0 && not_in_skipped > 1) + playlist_skip_->setText(tr("Skip selected tracks")); else playlist_queue_->setText(tr("Toggle queue status")); @@ -1967,7 +1983,7 @@ void MainWindow::PlaylistSkip() { indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); } - app_->playlist_manager()->current()->queue()->SkipTracks(indexes); + app_->playlist_manager()->current()->SkipTracks(indexes); } void MainWindow::PlaylistCopyToDevice() {