From fb33ba4cce3ae0a1db4b100540329d1e0825b571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bara?= Date: Tue, 15 Feb 2011 19:16:45 +0000 Subject: [PATCH] lookout for smart playlists in 'open in new playlists' functionality (Fixes issue #1465) --- src/library/libraryview.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/library/libraryview.cpp b/src/library/libraryview.cpp index a5a98c319..941852466 100644 --- a/src/library/libraryview.cpp +++ b/src/library/libraryview.cpp @@ -374,9 +374,28 @@ void LibraryView::AddToPlaylistEnqueue() { void LibraryView::OpenInNewPlaylist() { QMimeData* data = model()->mimeData(selectedIndexes()); - if (MimeData* mime_data = qobject_cast(data)) { - mime_data->name_for_new_playlist_ = LibraryView::GetNameForNewPlaylist(GetSelectedSongs()); + + // we look for the first smart playlist among selection because this + // is the one which will get into the new playlist eventually + QString first_smart_playlist_name; + foreach(const QModelIndex& index, selectedIndexes()) { + const int type = model()->data(index, LibraryModel::Role_Type).toInt(); + + if(type == LibraryItem::Type_SmartPlaylist) { + first_smart_playlist_name = model()->data(index).toString(); + break; + } } + + if (MimeData* mime_data = qobject_cast(data)) { + if(first_smart_playlist_name.isEmpty()) { + mime_data->name_for_new_playlist_ + = LibraryView::GetNameForNewPlaylist(GetSelectedSongs()); + } else { + mime_data->name_for_new_playlist_ = first_smart_playlist_name; + } + } + emit AddToPlaylistSignal(data); }