media library: fix adding songs with fetch delay enabled
This commit is contained in:
1
NEWS
1
NEWS
@@ -3,6 +3,7 @@ ncmpcpp-0.6.1 (????-??-??)
|
||||
* Comment tag is now properly written to mp3 files.
|
||||
* Only ID3v2.4 tags are now saved to mp3 files.
|
||||
* Mouse scrolling with newer ncurses API now works properly.
|
||||
* Adding songs from an album in media library now works properly with fetch delay.
|
||||
|
||||
ncmpcpp-0.6 (2014-10-25)
|
||||
|
||||
|
||||
@@ -58,6 +58,19 @@ size_t itsRightColStartX;
|
||||
|
||||
typedef MediaLibrary::AlbumEntry AlbumEntry;
|
||||
|
||||
template <typename FunT>
|
||||
void withSongsFromAlbum(const AlbumEntry &album, FunT &&f)
|
||||
{
|
||||
Mpd.StartSearch(true);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, album.entry().tag());
|
||||
if (!album.isAllTracksEntry())
|
||||
{
|
||||
Mpd.AddSearch(MPD_TAG_ALBUM, album.entry().album());
|
||||
Mpd.AddSearch(MPD_TAG_DATE, album.entry().date());
|
||||
}
|
||||
Mpd.CommitSearchSongs(std::forward<FunT>(f));
|
||||
}
|
||||
|
||||
std::string AlbumToString(const AlbumEntry &ae);
|
||||
std::string SongToString(const MPD::Song &s);
|
||||
|
||||
@@ -778,9 +791,9 @@ MPD::SongList MediaLibrary::getSelectedSongs()
|
||||
// if no item is selected, add songs from right column
|
||||
if (!any_selected && !Albums.empty())
|
||||
{
|
||||
withUnfilteredMenu(Songs, [this, &result]() {
|
||||
result.insert(result.end(), Songs.beginV(), Songs.endV());
|
||||
});
|
||||
size_t begin = result.size();
|
||||
withSongsFromAlbum(Albums.current().value().entry(), vectorMoveInserter(result));
|
||||
std::sort(result.begin()+begin, result.end(), SortSongs(false));
|
||||
}
|
||||
}
|
||||
else if (isActiveWindow(Songs))
|
||||
@@ -1059,10 +1072,9 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
||||
}
|
||||
else if (isActiveWindow(Albums))
|
||||
{
|
||||
bool success;
|
||||
withUnfilteredMenu(Songs, [&]() {
|
||||
success = addSongsToPlaylist(Songs.beginV(), Songs.endV(), add_n_play, -1);
|
||||
});
|
||||
MPD::SongList list;
|
||||
withSongsFromAlbum(Albums.current().value(), vectorMoveInserter(list));
|
||||
bool success = addSongsToPlaylist(list.begin(), list.end(), add_n_play, -1);
|
||||
Statusbar::printf("Songs from album \"%1%\" added%2%",
|
||||
Albums.current().value().entry().album(), withErrors(success)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user