new feature: add selected items to playlist at given position
This commit is contained in:
@@ -419,7 +419,7 @@ std::string Playlist::SongInColumnsToString(const MPD::Song &s, void *)
|
||||
return s.toString(result);
|
||||
}
|
||||
|
||||
bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play)
|
||||
bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play, int position)
|
||||
{
|
||||
BlockItemListUpdate = 1;
|
||||
if (Config.ncmpc_like_songs_adding && in_playlist)
|
||||
@@ -457,7 +457,7 @@ bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play)
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = Mpd.AddSong(s);
|
||||
int id = Mpd.AddSong(s, position);
|
||||
if (id >= 0)
|
||||
{
|
||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format_no_colors).c_str());
|
||||
@@ -470,7 +470,7 @@ bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play)
|
||||
}
|
||||
}
|
||||
|
||||
bool Playlist::Add(const MPD::SongList &l, bool play)
|
||||
bool Playlist::Add(const MPD::SongList &l, bool play, int position)
|
||||
{
|
||||
if (l.empty())
|
||||
return false;
|
||||
@@ -479,15 +479,25 @@ bool Playlist::Add(const MPD::SongList &l, bool play)
|
||||
|
||||
Mpd.StartCommandsList();
|
||||
MPD::SongList::const_iterator it = l.begin();
|
||||
for (; it != l.end(); ++it)
|
||||
if (Mpd.AddSong(**it) < 0)
|
||||
break;
|
||||
if (position < 0)
|
||||
{
|
||||
for (; it != l.end(); ++it)
|
||||
if (Mpd.AddSong(**it) < 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
MPD::SongList::const_reverse_iterator j = l.rbegin();
|
||||
for (; j != l.rend(); ++j)
|
||||
if (Mpd.AddSong(**j, position) < 0)
|
||||
break;
|
||||
}
|
||||
Mpd.CommitCommandsList();
|
||||
|
||||
if (play && old_playlist_size < Items->Size())
|
||||
Mpd.Play(old_playlist_size);
|
||||
|
||||
if (Items->Back().GetHash() != l.back()->GetHash())
|
||||
if (position < 0 && Items->Back().GetHash() != l.back()->GetHash())
|
||||
{
|
||||
if (it != l.begin())
|
||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
||||
|
||||
Reference in New Issue
Block a user