use common interface for adding item(s) to playlist
this also removes a few code duplications.
This commit is contained in:
121
src/browser.cpp
121
src/browser.cpp
@@ -107,53 +107,15 @@ void Browser::EnterPressed()
|
|||||||
}
|
}
|
||||||
case itSong:
|
case itSong:
|
||||||
{
|
{
|
||||||
BlockItemListUpdate = 1;
|
w->BoldOption(w->Choice(), myPlaylist->Add(*item.song, w->isBold(), 1));
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
|
||||||
{
|
|
||||||
bool found = 0;
|
|
||||||
unsigned hash = w->Current().song->GetHash();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Play(i);
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Song &s = *item.song;
|
|
||||||
int id = Mpd.AddSong(s);
|
|
||||||
if (id >= 0)
|
|
||||||
{
|
|
||||||
Mpd.PlayID(id);
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
w->BoldOption(w->Choice(), 1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
SongList list;
|
SongList list;
|
||||||
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
|
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
|
||||||
Mpd.StartCommandsList();
|
if (myPlaylist->Add(list, 1))
|
||||||
SongList::const_iterator it = list.begin();
|
|
||||||
for (; it != list.end(); ++it)
|
|
||||||
if (Mpd.AddSong(**it) < 0)
|
|
||||||
break;
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
|
|
||||||
if (it != list.begin())
|
|
||||||
{
|
|
||||||
ShowMessage("Loading and playing playlist %s...", item.name.c_str());
|
ShowMessage("Loading and playing playlist %s...", item.name.c_str());
|
||||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
|
||||||
if (s->GetHash() == list[0]->GetHash())
|
|
||||||
Mpd.PlayID(s->GetID());
|
|
||||||
else
|
|
||||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
|
||||||
}
|
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -180,95 +142,36 @@ void Browser::SpacePressed()
|
|||||||
if (itsBrowsedDir != "/" && !w->Choice())
|
if (itsBrowsedDir != "/" && !w->Choice())
|
||||||
break; // do not let add parent dir.
|
break; // do not let add parent dir.
|
||||||
|
|
||||||
bool everything_was_added = 1;
|
SongList list;
|
||||||
if (Config.local_browser)
|
if (Config.local_browser)
|
||||||
{
|
{
|
||||||
ItemList list;
|
ItemList items;
|
||||||
|
|
||||||
ShowMessage("Scanning \"%s\"...", item.name.c_str());
|
ShowMessage("Scanning \"%s\"...", item.name.c_str());
|
||||||
myBrowser->GetLocalDirectory(list, item.name, 1);
|
myBrowser->GetLocalDirectory(items, item.name, 1);
|
||||||
|
list.reserve(items.size());
|
||||||
Mpd.StartCommandsList();
|
for (MPD::ItemList::const_iterator it = items.begin(); it != items.end(); ++it)
|
||||||
for (ItemList::const_iterator it = list.begin(); it != list.end(); ++it)
|
list.push_back(it->song);
|
||||||
{
|
|
||||||
if (everything_was_added && Mpd.AddSong(*it->song) < 0)
|
|
||||||
everything_was_added = 0;
|
|
||||||
delete it->song;
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
SongList list;
|
|
||||||
Mpd.GetDirectoryRecursive(locale_to_utf_cpy(item.name), list);
|
Mpd.GetDirectoryRecursive(locale_to_utf_cpy(item.name), list);
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); ++it)
|
|
||||||
{
|
|
||||||
if (Mpd.AddSong(**it) < 0)
|
|
||||||
{
|
|
||||||
everything_was_added = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
FreeSongList(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (everything_was_added)
|
if (myPlaylist->Add(list, 0))
|
||||||
ShowMessage("Added folder: %s", item.name.c_str());
|
ShowMessage("Added folder: %s", item.name.c_str());
|
||||||
|
|
||||||
|
FreeSongList(list);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itSong:
|
case itSong:
|
||||||
{
|
{
|
||||||
BlockItemListUpdate = 1;
|
w->BoldOption(w->Choice(), myPlaylist->Add(*item.song, w->isBold(), 0));
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
|
||||||
{
|
|
||||||
Playlist::BlockUpdate = 1;
|
|
||||||
unsigned hash = w->Current().song->GetHash();
|
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Delete(i);
|
|
||||||
myPlaylist->Main()->DeleteOption(i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
w->BoldOption(w->Choice(), 0);
|
|
||||||
Playlist::BlockUpdate = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Song &s = *item.song;
|
|
||||||
if (Mpd.AddSong(s) != -1)
|
|
||||||
{
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
w->BoldOption(w->Choice(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
SongList list;
|
SongList list;
|
||||||
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
|
Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list);
|
||||||
Mpd.StartCommandsList();
|
if (myPlaylist->Add(list, 0))
|
||||||
SongList::const_iterator it = list.begin();
|
|
||||||
for (; it != list.end(); ++it)
|
|
||||||
if (Mpd.AddSong(**it) < 0)
|
|
||||||
break;
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
|
|
||||||
if (it != list.begin())
|
|
||||||
{
|
|
||||||
ShowMessage("Loading playlist %s...", item.name.c_str());
|
ShowMessage("Loading playlist %s...", item.name.c_str());
|
||||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
|
||||||
if (s.GetHash() != list[0]->GetHash())
|
|
||||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
|
||||||
}
|
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,101 +482,26 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|||||||
Mpd.StartSearch(1);
|
Mpd.StartSearch(1);
|
||||||
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(Artists->Current()));
|
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(Artists->Current()));
|
||||||
Mpd.CommitSearch(list);
|
Mpd.CommitSearch(list);
|
||||||
Mpd.StartCommandsList();
|
|
||||||
SongList::const_iterator it = list.begin();
|
|
||||||
for (; it != list.end(); ++it)
|
|
||||||
if (Mpd.AddSong(**it) < 0)
|
|
||||||
break;
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
|
|
||||||
if (it != list.begin())
|
if (myPlaylist->Add(list, add_n_play))
|
||||||
{
|
{
|
||||||
std::string tag_type = IntoStr(Config.media_lib_primary_tag);
|
std::string tag_type = IntoStr(Config.media_lib_primary_tag);
|
||||||
ToLower(tag_type);
|
ToLower(tag_type);
|
||||||
ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), Artists->Current().c_str());
|
ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), Artists->Current().c_str());
|
||||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
|
||||||
if (s->GetHash() == list[0]->GetHash())
|
|
||||||
{
|
|
||||||
if (add_n_play)
|
|
||||||
Mpd.PlayID(s->GetID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (w == Albums)
|
else if (w == Albums)
|
||||||
{
|
{
|
||||||
Mpd.StartCommandsList();
|
MPD::SongList l;
|
||||||
size_t i = 0;
|
l.reserve(Songs->Size());
|
||||||
for (; i < Songs->Size(); ++i)
|
for (size_t i = 0; i < Songs->Size(); ++i)
|
||||||
if (Mpd.AddSong(Songs->at(i)) < 0)
|
l.push_back(&(*Songs)[i]);
|
||||||
break;
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
|
|
||||||
if (i)
|
if (myPlaylist->Add(l, add_n_play))
|
||||||
{
|
|
||||||
ShowMessage("Adding songs from album \"%s\"", Albums->Current().second.Album.c_str());
|
ShowMessage("Adding songs from album \"%s\"", Albums->Current().second.Album.c_str());
|
||||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-Songs->Size());
|
|
||||||
if (s->GetHash() == Songs->at(0).GetHash())
|
|
||||||
{
|
|
||||||
if (add_n_play)
|
|
||||||
Mpd.PlayID(s->GetID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (w == Songs)
|
|
||||||
{
|
|
||||||
if (!Songs->Empty())
|
|
||||||
{
|
|
||||||
BlockItemListUpdate = 1;
|
|
||||||
if (Config.ncmpc_like_songs_adding && Songs->isBold())
|
|
||||||
{
|
|
||||||
unsigned hash = Songs->Current().GetHash();
|
|
||||||
if (add_n_play)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Play(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Playlist::BlockUpdate = 1;
|
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Delete(i);
|
|
||||||
myPlaylist->Main()->DeleteOption(i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
Songs->BoldOption(Songs->Choice(), 0);
|
|
||||||
Playlist::BlockUpdate = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Song &s = Songs->Current();
|
|
||||||
int id = Mpd.AddSong(s);
|
|
||||||
if (id >= 0)
|
|
||||||
{
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
if (add_n_play)
|
|
||||||
Mpd.PlayID(id);
|
|
||||||
Songs->BoldOption(Songs->Choice(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (w == Songs && !Songs->Empty())
|
||||||
|
Songs->BoldOption(Songs->Choice(), myPlaylist->Add(Songs->Current(), Songs->isBold(), add_n_play));
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
if (!add_n_play)
|
if (!add_n_play)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -467,3 +467,81 @@ std::string Playlist::SongInColumnsToString(const MPD::Song &s, void *)
|
|||||||
return s.toString(result);
|
return s.toString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Playlist::Add(const MPD::Song &s, bool in_playlist, bool play)
|
||||||
|
{
|
||||||
|
BlockItemListUpdate = 1;
|
||||||
|
if (Config.ncmpc_like_songs_adding && in_playlist)
|
||||||
|
{
|
||||||
|
unsigned hash = s.GetHash();
|
||||||
|
if (play)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < w->Size(); ++i)
|
||||||
|
{
|
||||||
|
if (w->at(i).GetHash() == hash)
|
||||||
|
{
|
||||||
|
Mpd.Play(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Playlist::BlockUpdate = 1;
|
||||||
|
Mpd.StartCommandsList();
|
||||||
|
for (size_t i = 0; i < w->Size(); ++i)
|
||||||
|
{
|
||||||
|
if ((*w)[i].GetHash() == hash)
|
||||||
|
{
|
||||||
|
Mpd.Delete(i);
|
||||||
|
w->DeleteOption(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mpd.CommitCommandsList();
|
||||||
|
Playlist::BlockUpdate = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int id = Mpd.AddSong(s);
|
||||||
|
if (id >= 0)
|
||||||
|
{
|
||||||
|
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
||||||
|
if (play)
|
||||||
|
Mpd.PlayID(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Playlist::Add(const MPD::SongList &l, bool play)
|
||||||
|
{
|
||||||
|
if (l.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t old_playlist_size = w->Size();
|
||||||
|
|
||||||
|
Mpd.StartCommandsList();
|
||||||
|
MPD::SongList::const_iterator it = l.begin();
|
||||||
|
for (; it != l.end(); ++it)
|
||||||
|
if (Mpd.AddSong(**it) < 0)
|
||||||
|
break;
|
||||||
|
Mpd.CommitCommandsList();
|
||||||
|
|
||||||
|
if (play && old_playlist_size < w->Size())
|
||||||
|
Mpd.Play(old_playlist_size);
|
||||||
|
|
||||||
|
if (w->Back().GetHash() != l.back()->GetHash())
|
||||||
|
{
|
||||||
|
if (it != l.begin())
|
||||||
|
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ class Playlist : public Screen< Menu<MPD::Song> >
|
|||||||
void UpdateTimer() { time(&itsTimer); }
|
void UpdateTimer() { time(&itsTimer); }
|
||||||
time_t Timer() const { return itsTimer; }
|
time_t Timer() const { return itsTimer; }
|
||||||
|
|
||||||
|
bool Add(const MPD::Song &s, bool in_playlist, bool play);
|
||||||
|
bool Add(const MPD::SongList &l, bool play);
|
||||||
|
|
||||||
static std::string SongToString(const MPD::Song &, void *);
|
static std::string SongToString(const MPD::Song &, void *);
|
||||||
static std::string SongInColumnsToString(const MPD::Song &, void *);
|
static std::string SongInColumnsToString(const MPD::Song &, void *);
|
||||||
|
|
||||||
|
|||||||
@@ -197,77 +197,12 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
|||||||
if (w == Playlists && !Playlists->Empty())
|
if (w == Playlists && !Playlists->Empty())
|
||||||
{
|
{
|
||||||
Mpd.GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list);
|
Mpd.GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list);
|
||||||
Mpd.StartCommandsList();
|
if (myPlaylist->Add(list, add_n_play))
|
||||||
SongList::const_iterator it = list.begin();
|
|
||||||
for (; it != list.end(); ++it)
|
|
||||||
if (Mpd.AddSong(**it) < 0)
|
|
||||||
break;
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
|
|
||||||
if (it != list.begin())
|
|
||||||
{
|
|
||||||
ShowMessage("Loading playlist %s...", Playlists->Current().c_str());
|
ShowMessage("Loading playlist %s...", Playlists->Current().c_str());
|
||||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
|
||||||
if (s.GetHash() == list[0]->GetHash())
|
|
||||||
{
|
|
||||||
if (add_n_play)
|
|
||||||
Mpd.PlayID(s.GetID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (w == Content)
|
|
||||||
{
|
|
||||||
if (!Content->Empty())
|
|
||||||
{
|
|
||||||
BlockItemListUpdate = 1;
|
|
||||||
if (Config.ncmpc_like_songs_adding && Content->isBold())
|
|
||||||
{
|
|
||||||
unsigned hash = Content->Current().GetHash();
|
|
||||||
if (add_n_play)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Play(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Playlist::BlockUpdate = 1;
|
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Delete(i);
|
|
||||||
myPlaylist->Main()->DeleteOption(i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
Content->BoldOption(Content->Choice(), 0);
|
|
||||||
Playlist::BlockUpdate = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const Song &s = Content->Current();
|
|
||||||
int id = Mpd.AddSong(s);
|
|
||||||
if (id >= 0)
|
|
||||||
{
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
if (add_n_play)
|
|
||||||
Mpd.PlayID(id);
|
|
||||||
Content->BoldOption(Content->Choice(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (w == Content && !Content->Empty())
|
||||||
|
Content->BoldOption(Content->Choice(), myPlaylist->Add(Content->Current(), Content->isBold(), add_n_play));
|
||||||
|
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
if (!add_n_play)
|
if (!add_n_play)
|
||||||
w->Scroll(wDown);
|
w->Scroll(wDown);
|
||||||
|
|||||||
@@ -225,30 +225,7 @@ void SearchEngine::EnterPressed()
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
BlockItemListUpdate = 1;
|
w->BoldOption(w->Choice(), myPlaylist->Add(*w->Current().second, w->isBold(), 1));
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
|
||||||
{
|
|
||||||
unsigned hash = w->Current().second->GetHash();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Play(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const Song &s = *w->Current().second;
|
|
||||||
int id = Mpd.AddSong(s);
|
|
||||||
if (id >= 0)
|
|
||||||
{
|
|
||||||
Mpd.PlayID(id);
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
w->BoldOption(w->Choice(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,34 +245,7 @@ void SearchEngine::SpacePressed()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockItemListUpdate = 1;
|
w->BoldOption(w->Choice(), myPlaylist->Add(*w->Current().second, w->isBold(), 0));
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
|
||||||
{
|
|
||||||
Playlist::BlockUpdate = 1;
|
|
||||||
unsigned hash = w->Current().second->GetHash();
|
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); ++i)
|
|
||||||
{
|
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
|
||||||
{
|
|
||||||
Mpd.Delete(i);
|
|
||||||
myPlaylist->Main()->DeleteOption(i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
w->BoldOption(w->Choice(), 0);
|
|
||||||
Playlist::BlockUpdate = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const Song &s = *w->Current().second;
|
|
||||||
if (Mpd.AddSong(s) != -1)
|
|
||||||
{
|
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
|
||||||
w->BoldOption(w->Choice(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w->Scroll(wDown);
|
w->Scroll(wDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user