Add play next from library

This commit is contained in:
Mark Furneaux 2018-03-18 22:44:00 -04:00
parent a789ce82ca
commit 3626d84964
12 changed files with 89 additions and 55 deletions

View File

@ -27,12 +27,13 @@ class MimeData : public QMimeData {
Q_OBJECT Q_OBJECT
public: public:
MimeData(bool clear = false, bool play_now = false, bool enqueue = false, MimeData(bool clear = false, bool play_now = false, bool enqueue = false, bool enqueue_next_now = false,
bool open_in_new_playlist = false) bool open_in_new_playlist = false)
: override_user_settings_(false), : override_user_settings_(false),
clear_first_(clear), clear_first_(clear),
play_now_(play_now), play_now_(play_now),
enqueue_now_(enqueue), enqueue_now_(enqueue),
enqueue_next_now_(enqueue_next_now),
open_in_new_playlist_(open_in_new_playlist), open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()), name_for_new_playlist_(QString()),
from_doubleclick_(false) {} from_doubleclick_(false) {}
@ -53,6 +54,9 @@ class MimeData : public QMimeData {
// If this is set then the items are added to the queue after being inserted. // If this is set then the items are added to the queue after being inserted.
bool enqueue_now_; bool enqueue_now_;
// If this is set then the items are added to the beginning of the queue after being inserted.
bool enqueue_next_now_;
// If this is set then the items are inserted into a newly created playlist. // If this is set then the items are inserted into a newly created playlist.
bool open_in_new_playlist_; bool open_in_new_playlist_;

View File

@ -392,6 +392,9 @@ void LibraryView::contextMenuEvent(QContextMenuEvent* e) {
add_to_playlist_enqueue_ = context_menu_->addAction( add_to_playlist_enqueue_ = context_menu_->addAction(
IconLoader::Load("go-next", IconLoader::Base), tr("Queue track"), this, IconLoader::Load("go-next", IconLoader::Base), tr("Queue track"), this,
SLOT(AddToPlaylistEnqueue())); SLOT(AddToPlaylistEnqueue()));
add_to_playlist_enqueue_next_ = context_menu_->addAction(
IconLoader::Load("go-next", IconLoader::Base), tr("Play next"), this,
SLOT(AddToPlaylistEnqueueNext()));
context_menu_->addSeparator(); context_menu_->addSeparator();
search_for_this_ = context_menu_->addAction( search_for_this_ = context_menu_->addAction(
IconLoader::Load("system-search", IconLoader::Base), IconLoader::Load("system-search", IconLoader::Base),
@ -616,6 +619,14 @@ void LibraryView::AddToPlaylistEnqueue() {
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(data);
} }
void LibraryView::AddToPlaylistEnqueueNext() {
QMimeData* data = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
mime_data->enqueue_next_now_ = true;
}
emit AddToPlaylistSignal(data);
}
void LibraryView::OpenInNewPlaylist() { void LibraryView::OpenInNewPlaylist() {
QMimeData* data = model()->mimeData(selectedIndexes()); QMimeData* data = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {

View File

@ -92,6 +92,7 @@ signals:
void Load(); void Load();
void AddToPlaylist(); void AddToPlaylist();
void AddToPlaylistEnqueue(); void AddToPlaylistEnqueue();
void AddToPlaylistEnqueueNext();
void OpenInNewPlaylist(); void OpenInNewPlaylist();
void Organise(); void Organise();
void CopyToDevice(); void CopyToDevice();
@ -131,6 +132,7 @@ signals:
QAction* load_; QAction* load_;
QAction* add_to_playlist_; QAction* add_to_playlist_;
QAction* add_to_playlist_enqueue_; QAction* add_to_playlist_enqueue_;
QAction* add_to_playlist_enqueue_next_;
QAction* open_in_new_playlist_; QAction* open_in_new_playlist_;
QAction* organise_; QAction* organise_;
QAction* copy_to_device_; QAction* copy_to_device_;

View File

@ -152,14 +152,14 @@ Playlist::~Playlist() {
template <typename T> template <typename T>
void Playlist::InsertSongItems(const SongList& songs, int pos, bool play_now, void Playlist::InsertSongItems(const SongList& songs, int pos, bool play_now,
bool enqueue) { bool enqueue, bool enqueue_next) {
PlaylistItemList items; PlaylistItemList items;
for (const Song& song : songs) { for (const Song& song : songs) {
items << PlaylistItemPtr(new T(song)); items << PlaylistItemPtr(new T(song));
} }
InsertItems(items, pos, play_now, enqueue); InsertItems(items, pos, play_now, enqueue, enqueue_next);
} }
QVariant Playlist::headerData(int section, Qt::Orientation, int role) const { QVariant Playlist::headerData(int section, Qt::Orientation, int role) const {
@ -703,7 +703,7 @@ void Playlist::InsertDynamicItems(int count) {
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), connect(inserter, SIGNAL(PlayRequested(QModelIndex)),
SIGNAL(PlayRequested(QModelIndex))); SIGNAL(PlayRequested(QModelIndex)));
inserter->Load(this, -1, false, false, dynamic_playlist_, count); inserter->Load(this, -1, false, false, false, dynamic_playlist_, count);
} }
Qt::ItemFlags Playlist::flags(const QModelIndex& index) const { Qt::ItemFlags Playlist::flags(const QModelIndex& index) const {
@ -733,12 +733,14 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
bool play_now = false; bool play_now = false;
bool enqueue_now = false; bool enqueue_now = false;
bool enqueue_next_now = false;
if (const MimeData* mime_data = qobject_cast<const MimeData*>(data)) { if (const MimeData* mime_data = qobject_cast<const MimeData*>(data)) {
if (mime_data->clear_first_) { if (mime_data->clear_first_) {
Clear(); Clear();
} }
play_now = mime_data->play_now_; play_now = mime_data->play_now_;
enqueue_now = mime_data->enqueue_now_; enqueue_now = mime_data->enqueue_now_;
enqueue_next_now = mime_data->enqueue_next_now_;
} }
if (const SongMimeData* song_data = qobject_cast<const SongMimeData*>(data)) { if (const SongMimeData* song_data = qobject_cast<const SongMimeData*>(data)) {
@ -748,33 +750,33 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
if (song_data->backend && if (song_data->backend &&
song_data->backend->songs_table() == Library::kSongsTable) song_data->backend->songs_table() == Library::kSongsTable)
InsertSongItems<LibraryPlaylistItem>(song_data->songs, row, play_now, InsertSongItems<LibraryPlaylistItem>(song_data->songs, row, play_now,
enqueue_now); enqueue_now, enqueue_next_now);
else if (song_data->backend && else if (song_data->backend &&
song_data->backend->songs_table() == MagnatuneService::kSongsTable) song_data->backend->songs_table() == MagnatuneService::kSongsTable)
InsertSongItems<MagnatunePlaylistItem>(song_data->songs, row, play_now, InsertSongItems<MagnatunePlaylistItem>(song_data->songs, row, play_now,
enqueue_now); enqueue_now, enqueue_next_now);
else if (song_data->backend && else if (song_data->backend &&
song_data->backend->songs_table() == JamendoService::kSongsTable) song_data->backend->songs_table() == JamendoService::kSongsTable)
InsertSongItems<JamendoPlaylistItem>(song_data->songs, row, play_now, InsertSongItems<JamendoPlaylistItem>(song_data->songs, row, play_now,
enqueue_now); enqueue_now, enqueue_next_now);
else else
InsertSongItems<SongPlaylistItem>(song_data->songs, row, play_now, InsertSongItems<SongPlaylistItem>(song_data->songs, row, play_now,
enqueue_now); enqueue_now, enqueue_next_now);
} else if (const InternetMimeData* internet_data = } else if (const InternetMimeData* internet_data =
qobject_cast<const InternetMimeData*>(data)) { qobject_cast<const InternetMimeData*>(data)) {
// Dragged from the Internet pane // Dragged from the Internet pane
InsertInternetItems(internet_data->model, internet_data->indexes, row, InsertInternetItems(internet_data->model, internet_data->indexes, row,
play_now, enqueue_now); play_now, enqueue_now, enqueue_next_now);
} else if (const InternetSongMimeData* internet_song_data = } else if (const InternetSongMimeData* internet_song_data =
qobject_cast<const InternetSongMimeData*>(data)) { qobject_cast<const InternetSongMimeData*>(data)) {
InsertInternetItems(internet_song_data->service, internet_song_data->songs, InsertInternetItems(internet_song_data->service, internet_song_data->songs,
row, play_now, enqueue_now); row, play_now, enqueue_now, enqueue_next_now);
} else if (const GeneratorMimeData* generator_data = } else if (const GeneratorMimeData* generator_data =
qobject_cast<const GeneratorMimeData*>(data)) { qobject_cast<const GeneratorMimeData*>(data)) {
InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now); InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now, enqueue_next_now);
} else if (const PlaylistItemMimeData* item_data = } else if (const PlaylistItemMimeData* item_data =
qobject_cast<const PlaylistItemMimeData*>(data)) { qobject_cast<const PlaylistItemMimeData*>(data)) {
InsertItems(item_data->items_, row, play_now, enqueue_now); InsertItems(item_data->items_, row, play_now, enqueue_now, enqueue_next_now);
} else if (data->hasFormat(kRowsMimetype)) { } else if (data->hasFormat(kRowsMimetype)) {
// Dragged from the playlist // Dragged from the playlist
// Rearranging it is tricky... // Rearranging it is tricky...
@ -809,7 +811,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
if (items.count() > kUndoItemLimit) { if (items.count() > kUndoItemLimit) {
// Too big to keep in the undo stack. Also clear the stack because it // Too big to keep in the undo stack. Also clear the stack because it
// might have been invalidated. // might have been invalidated.
InsertItemsWithoutUndo(items, row, false); InsertItemsWithoutUndo(items, row, false, false);
undo_stack_->clear(); undo_stack_->clear();
} else { } else {
undo_stack_->push( undo_stack_->push(
@ -828,26 +830,26 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
SongLoaderInserter* inserter = new SongLoaderInserter( SongLoaderInserter* inserter = new SongLoaderInserter(
task_manager_, library_, backend_->app()->player()); task_manager_, library_, backend_->app()->player());
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
inserter->LoadAudioCD(this, row, play_now, enqueue_now); inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now);
} else if (data->hasUrls()) { } else if (data->hasUrls()) {
// URL list dragged from the file list or some other app // URL list dragged from the file list or some other app
InsertUrls(data->urls(), row, play_now, enqueue_now); InsertUrls(data->urls(), row, play_now, enqueue_now, enqueue_next_now);
} }
return true; return true;
} }
void Playlist::InsertUrls(const QList<QUrl>& urls, int pos, bool play_now, void Playlist::InsertUrls(const QList<QUrl>& urls, int pos, bool play_now,
bool enqueue) { bool enqueue, bool enqueue_next) {
SongLoaderInserter* inserter = new SongLoaderInserter( SongLoaderInserter* inserter = new SongLoaderInserter(
task_manager_, library_, backend_->app()->player()); task_manager_, library_, backend_->app()->player());
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
inserter->Load(this, pos, play_now, enqueue, urls); inserter->Load(this, pos, play_now, enqueue, enqueue_next, urls);
} }
void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos, void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
// Hack: If the generator hasn't got a library set then use the main one // Hack: If the generator hasn't got a library set then use the main one
if (!generator->library()) { if (!generator->library()) {
generator->set_library(library_); generator->set_library(library_);
@ -857,7 +859,7 @@ void Playlist::InsertSmartPlaylist(GeneratorPtr generator, int pos,
new GeneratorInserter(task_manager_, library_, this); new GeneratorInserter(task_manager_, library_, this);
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
inserter->Load(this, pos, play_now, enqueue, generator); inserter->Load(this, pos, play_now, enqueue, enqueue_next, generator);
if (generator->is_dynamic()) { if (generator->is_dynamic()) {
TurnOnDynamicPlaylist(generator); TurnOnDynamicPlaylist(generator);
@ -976,7 +978,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int>& dest_rows) {
} }
void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos, void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
if (itemsIn.isEmpty()) return; if (itemsIn.isEmpty()) return;
PlaylistItemList items = itemsIn; PlaylistItemList items = itemsIn;
@ -1026,18 +1028,18 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
if (items.count() > kUndoItemLimit) { if (items.count() > kUndoItemLimit) {
// Too big to keep in the undo stack. Also clear the stack because it // Too big to keep in the undo stack. Also clear the stack because it
// might have been invalidated. // might have been invalidated.
InsertItemsWithoutUndo(items, pos, enqueue); InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next);
undo_stack_->clear(); undo_stack_->clear();
} else { } else {
undo_stack_->push( undo_stack_->push(
new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue)); new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next));
} }
if (play_now) emit PlayRequested(index(start, 0)); if (play_now) emit PlayRequested(index(start, 0));
} }
void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos, void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
bool enqueue) { bool enqueue, bool enqueue_next) {
if (items.isEmpty()) return; if (items.isEmpty()) return;
const int start = pos == -1 ? items_.count() : pos; const int start = pos == -1 ? items_.count() : pos;
@ -1072,22 +1074,30 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
queue_->ToggleTracks(indexes); queue_->ToggleTracks(indexes);
} }
if (enqueue_next) {
QModelIndexList indexes;
for (int i = start; i <= end; ++i) {
indexes << index(i, 0);
}
queue_->InsertFirst(indexes);
}
Save(); Save();
ReshuffleIndices(); ReshuffleIndices();
} }
void Playlist::InsertLibraryItems(const SongList& songs, int pos, bool play_now, void Playlist::InsertLibraryItems(const SongList& songs, int pos, bool play_now,
bool enqueue) { bool enqueue, bool enqueue_next) {
InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue); InsertSongItems<LibraryPlaylistItem>(songs, pos, play_now, enqueue, enqueue_next);
} }
void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now, void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now,
bool enqueue) { bool enqueue, bool enqueue_next) {
InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue); InsertSongItems<SongPlaylistItem>(songs, pos, play_now, enqueue, enqueue_next);
} }
void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos, void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
PlaylistItemList items; PlaylistItemList items;
for (const Song& song : songs) { for (const Song& song : songs) {
if (song.is_library_song()) { if (song.is_library_song()) {
@ -1096,12 +1106,12 @@ void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
items << PlaylistItemPtr(new SongPlaylistItem(song)); items << PlaylistItemPtr(new SongPlaylistItem(song));
} }
} }
InsertItems(items, pos, play_now, enqueue); InsertItems(items, pos, play_now, enqueue, enqueue_next);
} }
void Playlist::InsertInternetItems(const InternetModel* model, void Playlist::InsertInternetItems(const InternetModel* model,
const QModelIndexList& items, int pos, const QModelIndexList& items, int pos,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
PlaylistItemList playlist_items; PlaylistItemList playlist_items;
QList<QUrl> song_urls; QList<QUrl> song_urls;
@ -1120,23 +1130,23 @@ void Playlist::InsertInternetItems(const InternetModel* model,
} }
if (!song_urls.isEmpty()) { if (!song_urls.isEmpty()) {
InsertUrls(song_urls, pos, play_now, enqueue); InsertUrls(song_urls, pos, play_now, enqueue, enqueue_next);
play_now = false; play_now = false;
} }
InsertItems(playlist_items, pos, play_now, enqueue); InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
} }
void Playlist::InsertInternetItems(InternetService* service, void Playlist::InsertInternetItems(InternetService* service,
const SongList& songs, int pos, const SongList& songs, int pos,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
PlaylistItemList playlist_items; PlaylistItemList playlist_items;
for (const Song& song : songs) { for (const Song& song : songs) {
playlist_items << shared_ptr<PlaylistItem>( playlist_items << shared_ptr<PlaylistItem>(
new InternetPlaylistItem(service, song)); new InternetPlaylistItem(service, song));
} }
InsertItems(playlist_items, pos, play_now, enqueue); InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
} }
void Playlist::UpdateItems(const SongList& songs) { void Playlist::UpdateItems(const SongList& songs) {

View File

@ -235,18 +235,18 @@ class Playlist : public QAbstractListModel {
// Changing the playlist // Changing the playlist
void InsertItems(const PlaylistItemList& items, int pos = -1, void InsertItems(const PlaylistItemList& items, int pos = -1,
bool play_now = false, bool enqueue = false); bool play_now = false, bool enqueue = false, bool enqueue_next = false);
void InsertLibraryItems(const SongList& items, int pos = -1, void InsertLibraryItems(const SongList& items, int pos = -1,
bool play_now = false, bool enqueue = false); bool play_now = false, bool enqueue = false, bool enqueue_next = false);
void InsertSongs(const SongList& items, int pos = -1, bool play_now = false, void InsertSongs(const SongList& items, int pos = -1, bool play_now = false,
bool enqueue = false); bool enqueue = false, bool enqueue_next = false);
void InsertSongsOrLibraryItems(const SongList& items, int pos = -1, void InsertSongsOrLibraryItems(const SongList& items, int pos = -1,
bool play_now = false, bool enqueue = false); bool play_now = false, bool enqueue = false, bool enqueue_next = false);
void InsertSmartPlaylist(smart_playlists::GeneratorPtr gen, int pos = -1, void InsertSmartPlaylist(smart_playlists::GeneratorPtr gen, int pos = -1,
bool play_now = false, bool enqueue = false); bool play_now = false, bool enqueue = false, bool enqueue_next = false);
void InsertInternetItems(InternetService* service, const SongList& songs, void InsertInternetItems(InternetService* service, const SongList& songs,
int pos = -1, bool play_now = false, int pos = -1, bool play_now = false,
bool enqueue = false); bool enqueue = false, bool enqueue_next = false);
void ReshuffleIndices(); void ReshuffleIndices();
// If this playlist contains the current item, this method will apply the // If this playlist contains the current item, this method will apply the
@ -335,7 +335,7 @@ class Playlist : public QAbstractListModel {
void SetColumnAlignment(const ColumnAlignmentMap& alignment); void SetColumnAlignment(const ColumnAlignmentMap& alignment);
void InsertUrls(const QList<QUrl>& urls, int pos = -1, bool play_now = false, void InsertUrls(const QList<QUrl>& urls, int pos = -1, bool play_now = false,
bool enqueue = false); bool enqueue = false, bool enqueue_next = false);
// Removes items with given indices from the playlist. This operation is not // Removes items with given indices from the playlist. This operation is not
// undoable. // undoable.
void RemoveItemsWithoutUndo(const QList<int>& indices); void RemoveItemsWithoutUndo(const QList<int>& indices);
@ -366,18 +366,18 @@ signals:
void InsertInternetItems(const InternetModel* model, void InsertInternetItems(const InternetModel* model,
const QModelIndexList& items, int pos, bool play_now, const QModelIndexList& items, int pos, bool play_now,
bool enqueue); bool enqueue, bool enqueue_next = false);
template <typename T> template <typename T>
void InsertSongItems(const SongList& songs, int pos, bool play_now, void InsertSongItems(const SongList& songs, int pos, bool play_now,
bool enqueue); bool enqueue, bool enqueue_next = false);
void InsertDynamicItems(int count); void InsertDynamicItems(int count);
// Modify the playlist without changing the undo stack. These are used by // Modify the playlist without changing the undo stack. These are used by
// our friends in PlaylistUndoCommands // our friends in PlaylistUndoCommands
void InsertItemsWithoutUndo(const PlaylistItemList& items, int pos, void InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
bool enqueue = false); bool enqueue = false, bool enqueue_next = false);
PlaylistItemList RemoveItemsWithoutUndo(int pos, int count); PlaylistItemList RemoveItemsWithoutUndo(int pos, int count);
void MoveItemsWithoutUndo(const QList<int>& source_rows, int pos); void MoveItemsWithoutUndo(const QList<int>& source_rows, int pos);
void MoveItemWithoutUndo(int source, int dest); void MoveItemWithoutUndo(int source, int dest);

View File

@ -23,13 +23,13 @@ namespace PlaylistUndoCommands {
Base::Base(Playlist* playlist) : QUndoCommand(0), playlist_(playlist) {} Base::Base(Playlist* playlist) : QUndoCommand(0), playlist_(playlist) {}
InsertItems::InsertItems(Playlist* playlist, const PlaylistItemList& items, InsertItems::InsertItems(Playlist* playlist, const PlaylistItemList& items,
int pos, bool enqueue) int pos, bool enqueue, bool enqueue_next)
: Base(playlist), items_(items), pos_(pos), enqueue_(enqueue) { : Base(playlist), items_(items), pos_(pos), enqueue_(enqueue), enqueue_next_(enqueue_next) {
setText(tr("add %n songs", "", items_.count())); setText(tr("add %n songs", "", items_.count()));
} }
void InsertItems::redo() { void InsertItems::redo() {
playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_); playlist_->InsertItemsWithoutUndo(items_, pos_, enqueue_, enqueue_next_);
} }
void InsertItems::undo() { void InsertItems::undo() {

View File

@ -40,8 +40,7 @@ class Base : public QUndoCommand {
class InsertItems : public Base { class InsertItems : public Base {
public: public:
InsertItems(Playlist* playlist, const PlaylistItemList& items, int pos, InsertItems(Playlist* playlist, const PlaylistItemList& items, int pos, bool enqueue = false, bool enqueue_next = false);
bool enqueue = false);
void undo(); void undo();
void redo(); void redo();
@ -56,6 +55,7 @@ class InsertItems : public Base {
PlaylistItemList items_; PlaylistItemList items_;
int pos_; int pos_;
bool enqueue_; bool enqueue_;
bool enqueue_next_;
}; };
class RemoveItems : public Base { class RemoveItems : public Base {

View File

@ -37,11 +37,12 @@ SongLoaderInserter::SongLoaderInserter(TaskManager* task_manager,
SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); } SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); }
void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now, void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
bool enqueue, const QList<QUrl>& urls) { bool enqueue, bool enqueue_next, const QList<QUrl>& urls) {
destination_ = destination; destination_ = destination;
row_ = row; row_ = row;
play_now_ = play_now; play_now_ = play_now;
enqueue_ = enqueue; enqueue_ = enqueue;
enqueue_next_ = enqueue_next;
connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed())); connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed()));
connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs())); connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs()));
@ -78,11 +79,12 @@ void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now,
// In the meantime, MusicBrainz will be queried to get songs' metadata. // In the meantime, MusicBrainz will be queried to get songs' metadata.
// AudioCDTagsLoaded will be called next, and playlist's items will be updated. // AudioCDTagsLoaded will be called next, and playlist's items will be updated.
void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row, void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row,
bool play_now, bool enqueue) { bool play_now, bool enqueue, bool enqueue_next) {
destination_ = destination; destination_ = destination;
row_ = row; row_ = row;
play_now_ = play_now; play_now_ = play_now;
enqueue_ = enqueue; enqueue_ = enqueue;
enqueue_next_ = enqueue_next;
SongLoader* loader = new SongLoader(library_, player_, this); SongLoader* loader = new SongLoader(library_, player_, this);
NewClosure(loader, SIGNAL(AudioCDTracksLoaded()), NewClosure(loader, SIGNAL(AudioCDTracksLoaded()),

View File

@ -39,9 +39,9 @@ class SongLoaderInserter : public QObject {
LibraryBackendInterface* library, const Player* player); LibraryBackendInterface* library, const Player* player);
~SongLoaderInserter(); ~SongLoaderInserter();
void Load(Playlist* destination, int row, bool play_now, bool enqueue, void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next,
const QList<QUrl>& urls); const QList<QUrl>& urls);
void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue); void LoadAudioCD(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_now);
signals: signals:
void Error(const QString& message); void Error(const QString& message);
@ -64,6 +64,7 @@ signals:
int row_; int row_;
bool play_now_; bool play_now_;
bool enqueue_; bool enqueue_;
bool enqueue_next_;
SongList songs_; SongList songs_;

View File

@ -43,7 +43,7 @@ static PlaylistItemList Generate(GeneratorPtr generator, int dynamic_count) {
} }
void GeneratorInserter::Load(Playlist* destination, int row, bool play_now, void GeneratorInserter::Load(Playlist* destination, int row, bool play_now,
bool enqueue, GeneratorPtr generator, bool enqueue, bool enqueue_next, GeneratorPtr generator,
int dynamic_count) { int dynamic_count) {
task_id_ = task_manager_->StartTask(tr("Loading smart playlist")); task_id_ = task_manager_->StartTask(tr("Loading smart playlist"));
@ -51,6 +51,7 @@ void GeneratorInserter::Load(Playlist* destination, int row, bool play_now,
row_ = row; row_ = row;
play_now_ = play_now; play_now_ = play_now;
enqueue_ = enqueue; enqueue_ = enqueue;
enqueue_next_ = enqueue_next;
is_dynamic_ = generator->is_dynamic(); is_dynamic_ = generator->is_dynamic();
connect(generator.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(generator.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString)));

View File

@ -40,7 +40,7 @@ class GeneratorInserter : public QObject {
GeneratorInserter(TaskManager* task_manager, LibraryBackend* library, GeneratorInserter(TaskManager* task_manager, LibraryBackend* library,
QObject* parent); QObject* parent);
void Load(Playlist* destination, int row, bool play_now, bool enqueue, void Load(Playlist* destination, int row, bool play_now, bool enqueue, bool enqueue_next,
GeneratorPtr generator, int dynamic_count = 0); GeneratorPtr generator, int dynamic_count = 0);
signals: signals:
@ -59,6 +59,7 @@ signals:
int row_; int row_;
bool play_now_; bool play_now_;
bool enqueue_; bool enqueue_;
bool enqueue_next_;
bool is_dynamic_; bool is_dynamic_;
}; };

View File

@ -1782,6 +1782,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
else else
playlist_queue_->setIcon(IconLoader::Load("go-next", IconLoader::Base)); playlist_queue_->setIcon(IconLoader::Load("go-next", IconLoader::Base));
playlist_queue_play_next_->setIcon(IconLoader::Load("go-next", IconLoader::Base));
if (!index.isValid()) { if (!index.isValid()) {
ui_->action_selection_set_value->setVisible(false); ui_->action_selection_set_value->setVisible(false);
ui_->action_edit_value->setVisible(false); ui_->action_edit_value->setVisible(false);