From a5867405d212ffbb7c0c1d67f6eaa5d093034d79 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 24 May 2015 17:04:21 +0200 Subject: actions: add support for selecting found items --- src/actions.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/actions.cpp') diff --git a/src/actions.cpp b/src/actions.cpp index 6c26f226..7decf335 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1755,6 +1755,31 @@ void SelectAlbum::run() Statusbar::print("Album around cursor position selected"); } +bool SelectFoundItems::canBeRun() +{ + m_list = dynamic_cast(myScreen->activeWindow()); + if (m_list == nullptr || m_list->empty()) + return false; + m_searchable = dynamic_cast(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()); -- cgit v1.2.3