From 419965924f80c106654773466f84db4aa3b27c17 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 18 Sep 2012 20:41:35 +0200 Subject: [PATCH] menu: remove Menu::hasSelected --- src/actions.cpp | 4 ++-- src/menu.h | 12 ------------ src/sort_playlist.cpp | 3 ++- src/tag_editor.cpp | 3 ++- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 0d762fe3..f89e9798 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -797,7 +797,7 @@ void Delete::Run() return; std::string question; - if (myBrowser->main().hasSelected()) + if (hasSelected(myBrowser->main().begin(), myBrowser->main().end())) question = "Delete selected items?"; else { @@ -846,7 +846,7 @@ void Delete::Run() if (myScreen->isActiveWindow(myPlaylistEditor->Playlists)) { std::string question; - if (myPlaylistEditor->Playlists.hasSelected()) + if (hasSelected(myPlaylistEditor->Playlists.begin(), myPlaylistEditor->Playlists.end())) question = "Delete selected playlists?"; else { diff --git a/src/menu.h b/src/menu.h index 95bf7a92..5c088542 100644 --- a/src/menu.h +++ b/src/menu.h @@ -239,10 +239,6 @@ public: /// @return true if the position is reachable, false otherwise bool Goto(size_t y); - /// Checks whether list contains selected positions - /// @return true if it contains them, false otherwise - bool hasSelected() const; - /// Highlights given position /// @param pos position to be highlighted void highlight(size_t pos); @@ -774,14 +770,6 @@ template void Menu::clear() m_options_ptr = &m_options; } -template bool Menu::hasSelected() const -{ - for (auto it = begin(); it != end(); ++it) - if (it->isSelected()) - return true; - return false; -} - template void Menu::highlight(size_t pos) { assert(pos < m_options_ptr->size()); diff --git a/src/sort_playlist.cpp b/src/sort_playlist.cpp index ceb6d24f..60369517 100644 --- a/src/sort_playlist.cpp +++ b/src/sort_playlist.cpp @@ -20,6 +20,7 @@ #include "display.h" #include "global.h" +#include "helpers.h" #include "playlist.h" #include "settings.h" #include "sort_playlist.h" @@ -156,7 +157,7 @@ void SortPlaylistDialog::sort() const auto &pl = myPlaylist->main(); auto begin = pl.begin(), end = pl.end(); // if songs are selected, sort range from first selected to last selected - if (pl.hasSelected()) + if (hasSelected(pl.begin(), pl.end())) { while (!begin->isSelected()) ++begin; diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index c2fefa22..2e5b7cb6 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -451,7 +451,8 @@ void TagEditor::enterPressed() return; EditedSongs.clear(); - if (Tags->hasSelected()) // if there are selected songs, perform operations only on them + // if there are selected songs, perform operations only on them + if (hasSelected(Tags->begin(), Tags->end())) { for (auto it = Tags->begin(); it != Tags->end(); ++it) if (it->isSelected())