diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2015-05-17 18:10:42 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2015-05-17 21:51:15 +0200 |
commit | 2caf08aaa783cfabf54212bcb0197afc1db24440 (patch) | |
tree | 7d3f23002bbf502b2f0b804660616b7553ea1ae7 /src/playlist_editor.cpp | |
parent | c68631b2f080257108f979295fc6a5e2d58304d6 (diff) |
split PressSpace action into modular pieces
Diffstat (limited to 'src/playlist_editor.cpp')
-rw-r--r-- | src/playlist_editor.cpp | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index 6117093d..36fe3d5a 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -225,34 +225,9 @@ int PlaylistEditor::windowTimeout() return Screen<WindowType>::windowTimeout(); } -void PlaylistEditor::AddToPlaylist(bool add_n_play) -{ - if (isActiveWindow(Playlists) && !Playlists.empty()) - { - std::vector<MPD::Song> list( - std::make_move_iterator(Mpd.GetPlaylistContent(Playlists.current()->value().path())), - std::make_move_iterator(MPD::SongIterator()) - ); - bool success = addSongsToPlaylist(list.begin(), list.end(), add_n_play, -1); - Statusbar::printf("Playlist \"%1%\" loaded%2%", - Playlists.current()->value().path(), withErrors(success) - ); - } - else if (isActiveWindow(Content) && !Content.empty()) - addSongToPlaylist(Content.current()->value(), add_n_play); - - if (!add_n_play) - w->scroll(NC::Scroll::Down); -} - void PlaylistEditor::enterPressed() { - AddToPlaylist(true); -} - -void PlaylistEditor::spacePressed() -{ - AddToPlaylist(false); + addItemToPlaylist(true); } void PlaylistEditor::mouseButtonPressed(MEVENT me) @@ -270,12 +245,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me) { Playlists.Goto(me.y); if (me.bstate & BUTTON3_PRESSED) - { - size_t pos = Playlists.choice(); - spacePressed(); - if (pos < Playlists.size()-1) - Playlists.scroll(NC::Scroll::Up); - } + addItemToPlaylist(); } else Screen<WindowType>::mouseButtonPressed(me); @@ -294,12 +264,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me) { Content.Goto(me.y); if (me.bstate & BUTTON1_PRESSED) - { - size_t pos = Content.choice(); - spacePressed(); - if (pos < Content.size()-1) - Content.scroll(NC::Scroll::Up); - } + addItemToPlaylist(); else enterPressed(); } @@ -353,6 +318,11 @@ bool PlaylistEditor::find(SearchDirection direction, bool wrap, bool skip_curren /***********************************************************************/ +bool PlaylistEditor::addItemToPlaylist() +{ + return addItemToPlaylist(false); +} + std::vector<MPD::Song> PlaylistEditor::getSelectedSongs() { std::vector<MPD::Song> result; @@ -450,6 +420,25 @@ void PlaylistEditor::Locate(const MPD::Playlist &playlist) } } +bool PlaylistEditor::addItemToPlaylist(bool play) +{ + bool result = false; + if (isActiveWindow(Playlists) && !Playlists.empty()) + { + std::vector<MPD::Song> list( + std::make_move_iterator(Mpd.GetPlaylistContent(Playlists.current()->value().path())), + std::make_move_iterator(MPD::SongIterator()) + ); + result = addSongsToPlaylist(list.begin(), list.end(), play, -1); + Statusbar::printf("Playlist \"%1%\" loaded%2%", + Playlists.current()->value().path(), withErrors(result) + ); + } + else if (isActiveWindow(Content) && !Content.empty()) + result = addSongToPlaylist(Content.current()->value(), play); + return result; +} + namespace { std::string SongToString(const MPD::Song &s) |