actions: add support for selecting found items

master
Andrzej Rybczak 11 years ago
parent 1b6cb65f3a
commit a5867405d2
  1. 1
      NEWS
  2. 3
      doc/bindings
  3. 26
      src/actions.cpp
  4. 18
      src/actions.h
  5. 2
      src/bindings.cpp
  6. 1
      src/help.cpp

@ -27,6 +27,7 @@ ncmpcpp-0.7 (????-??-??)
* Monolithic 'press_space' action was split into 'add_item_to_playlist', 'toggle_lyrics_update_on_song_change' and 'toggle_visualization_type'.
* Sorting actions were rebound to Ctrl-S.
* Support for range selection was added (bound to Ctrl-V by default). In addition, sorting, reversing and shuffling items in playlist now works on ranges.
* Support for selecting found items was added (bound to Ctrl-_ by default).
ncmpcpp-0.6.4 (2015-05-02)

@ -364,6 +364,9 @@
#def_key "ctrl_r"
# reverse_playlist
#
#def_key "ctrl__"
# select_found_items
#
#def_key "/"
# find
#

@ -1755,6 +1755,31 @@ void SelectAlbum::run()
Statusbar::print("Album around cursor position selected");
}
bool SelectFoundItems::canBeRun()
{
m_list = dynamic_cast<NC::List *>(myScreen->activeWindow());
if (m_list == nullptr || m_list->empty())
return false;
m_searchable = dynamic_cast<Searchable *>(myScreen);
return m_searchable != nullptr && m_searchable->allowsSearching();
}
void SelectFoundItems::run()
{
auto current_pos = m_list->choice();
myScreen->activeWindow()->scroll(NC::Scroll::Home);
bool found = m_searchable->find(SearchDirection::Forward, false, false);
if (found)
{
Statusbar::print("Searching for items...");
m_list->currentP()->setSelected(true);
while (m_searchable->find(SearchDirection::Forward, false, true))
m_list->currentP()->setSelected(true);
Statusbar::print("Found items selected");
}
m_list->highlight(current_pos);
}
bool AddSelectedItems::canBeRun()
{
return myScreen != mySelectedItemsAdder;
@ -2617,6 +2642,7 @@ void populateActions()
insert_action(new Actions::ReverseSelection());
insert_action(new Actions::RemoveSelection());
insert_action(new Actions::SelectAlbum());
insert_action(new Actions::SelectFoundItems());
insert_action(new Actions::AddSelectedItems());
insert_action(new Actions::CropMainPlaylist());
insert_action(new Actions::CropPlaylist());

@ -49,9 +49,9 @@ enum class Type
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
SelectItem, SelectRange, ReverseSelection, RemoveSelection, SelectAlbum, AddSelectedItems,
CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist, SortPlaylist,
ReversePlaylist, Find, FindItemForward, FindItemBackward,
SelectItem, SelectRange, ReverseSelection, RemoveSelection, SelectAlbum, SelectFoundItems,
AddSelectedItems, CropMainPlaylist, CropPlaylist, ClearMainPlaylist, ClearPlaylist,
SortPlaylist, ReversePlaylist, Find, FindItemForward, FindItemBackward,
NextFoundItem, PreviousFoundItem, ToggleFindMode, ToggleReplayGainMode,
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
@ -827,6 +827,18 @@ private:
SongList *m_songs;
};
struct SelectFoundItems: BaseAction
{
SelectFoundItems(): BaseAction(Type::SelectFoundItems, "select_found_items") { }
private:
virtual bool canBeRun() OVERRIDE;
virtual void run() OVERRIDE;
NC::List *m_list;
Searchable *m_searchable;
};
struct AddSelectedItems: BaseAction
{
AddSelectedItems(): BaseAction(Type::AddSelectedItems, "add_selected_items") { }

@ -597,6 +597,8 @@ void BindingsConfiguration::generateDefaults()
}
if (notBound(k = stringToKey("ctrl_r")))
bind(k, Actions::Type::ReversePlaylist);
if (notBound(k = stringToKey("ctrl__")))
bind(k, Actions::Type::SelectFoundItems);
if (notBound(k = stringToKey("/")))
{
bind(k, Actions::Type::Find);

@ -182,6 +182,7 @@ void write_bindings(NC::Scrollpad &w)
key(w, Type::ReverseSelection, "Reverse selection");
key(w, Type::RemoveSelection, "Remove selection");
key(w, Type::SelectItem, "Select current item");
key(w, Type::SelectFoundItems, "Select found items");
key(w, Type::SelectAlbum, "Select songs of album around the cursor");
key(w, Type::AddSelectedItems, "Add selected items to playlist");
key(w, Type::AddRandomItems, "Add random items to playlist");

Loading…
Cancel
Save