summaryrefslogtreecommitdiff
path: root/src/actions.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2015-05-24 17:04:21 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2015-05-24 17:04:21 +0200
commita5867405d212ffbb7c0c1d67f6eaa5d093034d79 (patch)
tree16426c921c1b0f041f49cbeae52247d222aa59f4 /src/actions.cpp
parent1b6cb65f3a371e40794e92176f013b1a720432e1 (diff)
actions: add support for selecting found items
Diffstat (limited to 'src/actions.cpp')
-rw-r--r--src/actions.cpp26
1 files changed, 26 insertions, 0 deletions
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<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());