diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2016-11-13 00:21:25 +0100 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2016-11-13 01:15:07 +0100 |
commit | 29b1813c6d44ff74f939fd469251f998a31b072c (patch) | |
tree | 14bf896c8b61171163049b0ab7c66f3787e2a76f /src/status.cpp | |
parent | 60e66b47b6748c48f9ee36e9ef80bc4b5d1a09e1 (diff) |
Resurrect filtering of lists (playlist only for now)
Diffstat (limited to 'src/status.cpp')
-rw-r--r-- | src/status.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/status.cpp b/src/status.cpp index 522373b7..19472cc6 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -408,29 +408,33 @@ int Status::State::volume() void Status::Changes::playlist(unsigned previous_version) { - if (m_playlist_length < myPlaylist->main().size()) { - auto it = myPlaylist->main().begin()+m_playlist_length; - auto end = myPlaylist->main().end(); - for (; it != end; ++it) - myPlaylist->unregisterSong(it->value()); - myPlaylist->main().resizeList(m_playlist_length); - } + ScopedUnfilteredMenu<MPD::Song, ReapplyFilter::Yes> sunfilter(myPlaylist->main()); - MPD::SongIterator s = Mpd.GetPlaylistChanges(previous_version), end; - for (; s != end; ++s) - { - size_t pos = s->getPosition(); - myPlaylist->registerSong(*s); - if (pos < myPlaylist->main().size()) + if (m_playlist_length < myPlaylist->main().size()) { - // if song's already in playlist, replace it with a new one - MPD::Song &old_s = myPlaylist->main()[pos].value(); - myPlaylist->unregisterSong(old_s); - old_s = std::move(*s); + auto it = myPlaylist->main().begin()+m_playlist_length; + auto end = myPlaylist->main().end(); + for (; it != end; ++it) + myPlaylist->unregisterSong(it->value()); + myPlaylist->main().resizeList(m_playlist_length); + } + + MPD::SongIterator s = Mpd.GetPlaylistChanges(previous_version), end; + for (; s != end; ++s) + { + size_t pos = s->getPosition(); + myPlaylist->registerSong(*s); + if (pos < myPlaylist->main().size()) + { + // if song's already in playlist, replace it with a new one + MPD::Song &old_s = myPlaylist->main()[pos].value(); + myPlaylist->unregisterSong(old_s); + old_s = std::move(*s); + } + else // otherwise just add it to playlist + myPlaylist->main().addItem(std::move(*s)); } - else // otherwise just add it to playlist - myPlaylist->main().addItem(std::move(*s)); } myPlaylist->reloadTotalLength(); @@ -576,7 +580,7 @@ void Status::Changes::songID(int song_id) drawTitle(s); if (Config.autocenter_mode) - pl.highlight(Status::State::currentSongPosition()); + myPlaylist->moveToSong(s); if (Config.now_playing_lyrics && isVisible(myLyrics) && myLyrics->previousScreen() == myPlaylist) { |