menu: make current() return an iterator

This commit is contained in:
Andrzej Rybczak
2014-11-04 22:33:16 +01:00
parent 12772c47f9
commit efdac2058e
13 changed files with 103 additions and 109 deletions

View File

@@ -657,7 +657,7 @@ void DeletePlaylistItems::run()
}
else if (myScreen->isActiveWindow(myPlaylistEditor->Content))
{
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
auto delete_fun = boost::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
Statusbar::print("Deleting items...");
deleteSelectedSongs(myPlaylistEditor->Content, delete_fun);
@@ -706,7 +706,7 @@ void DeleteBrowserItems::run()
question = boost::format("Delete selected items?");
else
{
const auto &item = myBrowser->main().current().value();
const auto &item = myBrowser->main().current()->value();
// parent directories are not accepted (and they
// can't be selected, so in other cases it's fine).
if (myBrowser->isParentDirectory(item))
@@ -721,7 +721,7 @@ void DeleteBrowserItems::run()
auto items = getSelectedOrCurrent(
myBrowser->main().begin(),
myBrowser->main().end(),
myBrowser->main().currentI()
myBrowser->main().current()
);
for (const auto &item : items)
{
@@ -753,12 +753,12 @@ void DeleteStoredPlaylist::run()
question = boost::format("Delete selected playlists?");
else
question = boost::format("Delete playlist \"%1%\"?")
% wideShorten(myPlaylistEditor->Playlists.current().value().path(), COLS-question.size()-10);
% wideShorten(myPlaylistEditor->Playlists.current()->value().path(), COLS-question.size()-10);
confirmAction(question);
auto list = getSelectedOrCurrent(
myPlaylistEditor->Playlists.begin(),
myPlaylistEditor->Playlists.end(),
myPlaylistEditor->Playlists.currentI()
myPlaylistEditor->Playlists.current()
);
for (const auto &item : list)
Mpd.DeletePlaylist(item->value().path());
@@ -903,7 +903,7 @@ void MoveSelectedItemsUp::run()
else if (myScreen == myPlaylistEditor)
{
assert(!myPlaylistEditor->Playlists.empty());
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
auto move_fun = boost::bind(&MPD::Connection::PlaylistMove, _1, playlist, _2, _3);
moveSelectedItemsUp(myPlaylistEditor->Content, move_fun);
}
@@ -928,7 +928,7 @@ void MoveSelectedItemsDown::run()
else if (myScreen == myPlaylistEditor)
{
assert(!myPlaylistEditor->Playlists.empty());
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
auto move_fun = boost::bind(&MPD::Connection::PlaylistMove, _1, playlist, _2, _3);
moveSelectedItemsDown(myPlaylistEditor->Content, move_fun);
}
@@ -950,7 +950,7 @@ void MoveSelectedItemsTo::run()
else
{
assert(!myPlaylistEditor->Playlists.empty());
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
auto move_fun = boost::bind(&MPD::Connection::PlaylistMove, _1, playlist, _2, _3);
moveSelectedItemsTo(myPlaylistEditor->Content, move_fun);
}
@@ -976,7 +976,7 @@ void Add::run()
Statusbar::put() << "Adding...";
wFooter->refresh();
if (myScreen == myPlaylistEditor)
Mpd.AddToPlaylist(myPlaylistEditor->Playlists.current().value().path(), path);
Mpd.AddToPlaylist(myPlaylistEditor->Playlists.current()->value().path(), path);
else
{
const char lastfm_url[] = "lastfm://";
@@ -1336,13 +1336,13 @@ void EditLibraryTag::run()
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << tagTypeToString(Config.media_lib_primary_tag) << NC::Format::NoBold << ": ";
new_tag = wFooter->prompt(myLibrary->Tags.current().value().tag());
new_tag = wFooter->prompt(myLibrary->Tags.current()->value().tag());
}
if (!new_tag.empty() && new_tag != myLibrary->Tags.current().value().tag())
if (!new_tag.empty() && new_tag != myLibrary->Tags.current()->value().tag())
{
Statusbar::print("Updating tags...");
Mpd.StartSearch(true);
Mpd.AddSearch(Config.media_lib_primary_tag, myLibrary->Tags.current().value().tag());
Mpd.AddSearch(Config.media_lib_primary_tag, myLibrary->Tags.current()->value().tag());
MPD::MutableSong::SetFunction set = tagTypeToSetFunction(Config.media_lib_primary_tag);
assert(set);
bool success = true;
@@ -1395,9 +1395,9 @@ void EditLibraryAlbum::run()
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << "Album: " << NC::Format::NoBold;
new_album = wFooter->prompt(myLibrary->Albums.current().value().entry().album());
new_album = wFooter->prompt(myLibrary->Albums.current()->value().entry().album());
}
if (!new_album.empty() && new_album != myLibrary->Albums.current().value().entry().album())
if (!new_album.empty() && new_album != myLibrary->Albums.current()->value().entry().album())
{
bool success = 1;
Statusbar::print("Updating tags...");
@@ -1435,7 +1435,7 @@ bool EditDirectoryName::canBeRun() const
{
return ((myScreen == myBrowser
&& !myBrowser->main().empty()
&& myBrowser->main().current().value().type() == MPD::Item::Type::Directory)
&& myBrowser->main().current()->value().type() == MPD::Item::Type::Directory)
# ifdef HAVE_TAGLIB_H
|| (myScreen->activeWindow() == myTagEditor->Dirs
&& !myTagEditor->Dirs->empty()
@@ -1450,7 +1450,7 @@ void EditDirectoryName::run()
// FIXME: use boost::filesystem and better error reporting
if (myScreen == myBrowser)
{
std::string old_dir = myBrowser->main().current().value().directory().path(), new_dir;
std::string old_dir = myBrowser->main().current()->value().directory().path(), new_dir;
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << "Directory: " << NC::Format::NoBold;
@@ -1485,7 +1485,7 @@ void EditDirectoryName::run()
# ifdef HAVE_TAGLIB_H
else if (myScreen->activeWindow() == myTagEditor->Dirs)
{
std::string old_dir = myTagEditor->Dirs->current().value().first, new_dir;
std::string old_dir = myTagEditor->Dirs->current()->value().first, new_dir;
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << "Directory: " << NC::Format::NoBold;
@@ -1517,7 +1517,7 @@ bool EditPlaylistName::canBeRun() const
&& !myPlaylistEditor->Playlists.empty())
|| (myScreen == myBrowser
&& !myBrowser->main().empty()
&& myBrowser->main().current().value().type() == MPD::Item::Type::Playlist);
&& myBrowser->main().current()->value().type() == MPD::Item::Type::Playlist);
}
void EditPlaylistName::run()
@@ -1525,9 +1525,9 @@ void EditPlaylistName::run()
using Global::wFooter;
std::string old_name, new_name;
if (myScreen->isActiveWindow(myPlaylistEditor->Playlists))
old_name = myPlaylistEditor->Playlists.current().value().path();
old_name = myPlaylistEditor->Playlists.current()->value().path();
else
old_name = myBrowser->main().current().value().playlist().path();
old_name = myBrowser->main().current()->value().playlist().path();
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << "Playlist: " << NC::Format::NoBold;
@@ -1576,12 +1576,12 @@ void JumpToMediaLibrary::run()
bool JumpToPlaylistEditor::canBeRun() const
{
return myScreen == myBrowser
&& myBrowser->main().current().value().type() == MPD::Item::Type::Playlist;
&& myBrowser->main().current()->value().type() == MPD::Item::Type::Playlist;
}
void JumpToPlaylistEditor::run()
{
myPlaylistEditor->Locate(myBrowser->main().current().value().playlist());
myPlaylistEditor->Locate(myBrowser->main().current()->value().playlist());
}
void ToggleScreenLock::run()
@@ -1778,7 +1778,7 @@ void CropPlaylist::run()
if (w.size() <= 1)
return;
assert(!myPlaylistEditor->Playlists.empty());
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
if (Config.ask_before_clearing_playlists)
confirmAction(boost::format("Do you really want to crop playlist \"%1%\"?") % playlist);
selectCurrentIfNoneSelected(w);
@@ -1808,7 +1808,7 @@ void ClearPlaylist::run()
{
if (myPlaylistEditor->Playlists.empty())
return;
std::string playlist = myPlaylistEditor->Playlists.current().value().path();
std::string playlist = myPlaylistEditor->Playlists.current()->value().path();
if (Config.ask_before_clearing_playlists)
confirmAction(boost::format("Do you really want to clear playlist \"%1%\"?") % playlist);
auto delete_fun = boost::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
@@ -2312,7 +2312,7 @@ void ShowArtistInfo::run()
{
assert(!myLibrary->Tags.empty());
assert(Config.media_lib_primary_tag == MPD_TAG_ARTIST);
artist = myLibrary->Tags.current().value().tag();
artist = myLibrary->Tags.current()->value().tag();
}
else
{

View File

@@ -127,7 +127,7 @@ void Browser::enterPressed()
if (w.empty())
return;
const MPD::Item &item = w.current().value();
const MPD::Item &item = w.current()->value();
switch (item.type())
{
case MPD::Item::Type::Directory:
@@ -170,7 +170,7 @@ void Browser::spacePressed()
return;
}
const MPD::Item &item = w.current().value();
const MPD::Item &item = w.current()->value();
// ignore parent directory
if (isParentDirectory(item))
return;
@@ -212,12 +212,12 @@ void Browser::mouseButtonPressed(MEVENT me)
if (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED))
{
w.Goto(me.y);
switch (w.current().value().type())
switch (w.current()->value().type())
{
case MPD::Item::Type::Directory:
if (me.bstate & BUTTON1_PRESSED)
{
getDirectory(w.current().value().directory().path());
getDirectory(w.current()->value().directory().path());
drawHeader();
}
else
@@ -369,7 +369,7 @@ std::vector<MPD::Song> Browser::getSelectedSongs()
item_handler(item.value());
// if no item is selected, add current one
if (songs.empty() && !w.empty())
item_handler(w.current().value());
item_handler(w.current()->value());
return songs;
}

View File

@@ -49,7 +49,7 @@ void searchForward(NC::Menu<ItemT> &m, const PredicateT &pred, bool wrap)
{
if (!pred.defined())
return;
auto it = wrappedSearch(m.begin(), m.currentI(), m.end(), pred, wrap);
auto it = wrappedSearch(m.begin(), m.current(), m.end(), pred, wrap);
if (it != m.end())
m.highlight(it-m.begin());
}
@@ -59,7 +59,7 @@ void searchBackward(NC::Menu<ItemT> &m, const PredicateT &pred, bool wrap)
{
if (!pred.defined())
return;
auto it = wrappedSearch(m.rbegin(), m.currentRI(), m.rend(), pred, wrap);
auto it = wrappedSearch(m.rbegin(), m.rcurrent(), m.rend(), pred, wrap);
if (it != m.rend())
m.highlight(m.size()-1-(it-m.rbegin()));
}
@@ -130,7 +130,7 @@ template <typename T>
void selectCurrentIfNoneSelected(NC::Menu<T> &m)
{
if (!hasSelected(m.begin(), m.end()))
m.current().setSelected(true);
m.current()->setSelected(true);
}
template <typename Iterator>
@@ -264,7 +264,7 @@ void moveSelectedItemsDown(NC::Menu<MPD::Song> &m, F swap_fun)
template <typename F>
void moveSelectedItemsTo(NC::Menu<MPD::Song> &m, F move_fun)
{
auto cur_ptr = &m.current().value();
auto cur_ptr = &m.current()->value();
withUnfilteredMenu(m, [&]() {
// this is kinda shitty, but there is no other way to know
// what position current item has in unfiltered menu.

View File

@@ -344,7 +344,7 @@ void MediaLibrary::update()
)
{
m_albums_update_request = false;
auto &primary_tag = Tags.current().value().tag();
auto &primary_tag = Tags.current()->value().tag();
Mpd.StartSearch(true);
Mpd.AddSearch(Config.media_lib_primary_tag, primary_tag);
std::map<std::tuple<std::string, std::string>, time_t> albums;
@@ -392,7 +392,7 @@ void MediaLibrary::update()
)
{
m_songs_update_request = false;
auto &album = Albums.current().value();
auto &album = Albums.current()->value();
Mpd.StartSearch(true);
Mpd.AddSearch(Config.media_lib_primary_tag, album.entry().tag());
if (!album.isAllTracksEntry())
@@ -448,7 +448,7 @@ void MediaLibrary::spacePressed()
}
else if (isActiveWindow(Albums))
{
if (!Albums.current().value().isAllTracksEntry())
if (!Albums.current()->value().isAllTracksEntry())
{
size_t idx = Albums.choice();
Albums[idx].setSelected(!Albums[idx].isSelected());
@@ -750,7 +750,7 @@ std::vector<MPD::Song> MediaLibrary::getSelectedSongs()
}
// if no item is selected, add current one
if (!any_selected && !Tags.empty())
tag_handler(Tags.current().value().tag());
tag_handler(Tags.current()->value().tag());
}
else if (isActiveWindow(Albums))
{
@@ -766,7 +766,7 @@ std::vector<MPD::Song> MediaLibrary::getSelectedSongs()
Mpd.AddSearch(Config.media_lib_primary_tag, sc.entry().tag());
else
Mpd.AddSearch(Config.media_lib_primary_tag,
Tags.current().value().tag());
Tags.current()->value().tag());
Mpd.AddSearch(MPD_TAG_ALBUM, sc.entry().album());
Mpd.AddSearch(MPD_TAG_DATE, sc.entry().date());
size_t begin = result.size();
@@ -793,7 +793,7 @@ std::vector<MPD::Song> MediaLibrary::getSelectedSongs()
result.push_back(it->value());
// if no item is selected, add current one
if (result.empty() && !Songs.empty())
result.push_back(Songs.current().value());
result.push_back(Songs.current()->value());
}
return result;
}
@@ -979,7 +979,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
Tags.showAll();
if (Tags.empty())
update();
if (primary_tag != Tags.current().value().tag())
if (primary_tag != Tags.current()->value().tag())
{
for (size_t i = 0; i < Tags.size(); ++i)
{
@@ -1000,9 +1000,9 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
std::string album = s.getAlbum();
std::string date = s.getDate();
if ((hasTwoColumns && Albums.current().value().entry().tag() != primary_tag)
|| album != Albums.current().value().entry().album()
|| date != Albums.current().value().entry().date())
if ((hasTwoColumns && Albums.current()->value().entry().tag() != primary_tag)
|| album != Albums.current()->value().entry().album()
|| date != Albums.current()->value().entry().date())
{
for (size_t i = 0; i < Albums.size(); ++i)
{
@@ -1021,7 +1021,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
if (Songs.empty())
update();
if (s != Songs.current().value())
if (s != Songs.current()->value())
{
for (size_t i = 0; i < Songs.size(); ++i)
{
@@ -1043,14 +1043,14 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
void MediaLibrary::AddToPlaylist(bool add_n_play)
{
if (isActiveWindow(Songs) && !Songs.empty())
addSongToPlaylist(Songs.current().value(), add_n_play);
addSongToPlaylist(Songs.current()->value(), add_n_play);
else
{
if ((!Tags.empty() && isActiveWindow(Tags))
|| (isActiveWindow(Albums) && Albums.current().value().isAllTracksEntry()))
|| (isActiveWindow(Albums) && Albums.current()->value().isAllTracksEntry()))
{
Mpd.StartSearch(true);
Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current().value().tag());
Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current()->value().tag());
std::vector<MPD::Song> list(
std::make_move_iterator(Mpd.CommitSearchSongs()),
std::make_move_iterator(MPD::SongIterator())
@@ -1059,7 +1059,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
std::string tag_type = boost::locale::to_lower(
tagTypeToString(Config.media_lib_primary_tag));
Statusbar::printf("Songs with %1% \"%2%\" added%3%",
tag_type, Tags.current().value().tag(), withErrors(success)
tag_type, Tags.current()->value().tag(), withErrors(success)
);
}
else if (isActiveWindow(Albums))
@@ -1069,7 +1069,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
success = addSongsToPlaylist(Songs.beginV(), Songs.endV(), add_n_play, -1);
});
Statusbar::printf("Songs from album \"%1%\" added%2%",
Albums.current().value().entry().album(), withErrors(success)
Albums.current()->value().entry().album(), withErrors(success)
);
}
}

View File

@@ -265,12 +265,6 @@ public:
/// @throw List::InvalidItem if requested item is separator
const Menu<ItemT>::Item &back() const { return *m_options_ptr->back(); }
/// @return reference to curently highlighted object
Menu<ItemT>::Item &current() { return *(*m_options_ptr)[m_highlight]; }
/// @return const reference to curently highlighted object
const Menu<ItemT>::Item &current() const { return *(*m_options_ptr)[m_highlight]; }
/// @param pos requested position
/// @return reference to item at given position
/// @throw std::out_of_range if given position is out of range
@@ -289,15 +283,15 @@ public:
/// @return const reference to item at given position
Menu<ItemT>::Item &operator[](size_t pos) { return *(*m_options_ptr)[pos]; }
Iterator currentI() { return Iterator(m_options_ptr->begin() + m_highlight); }
ConstIterator currentI() const { return ConstIterator(m_options_ptr->begin() + m_highlight); }
ReverseIterator currentRI() { return ReverseIterator(++currentI()); }
ConstReverseIterator currentRI() const { return ReverseIterator(++currentI()); }
Iterator current() { return Iterator(m_options_ptr->begin() + m_highlight); }
ConstIterator current() const { return ConstIterator(m_options_ptr->begin() + m_highlight); }
ReverseIterator rcurrent() { return ReverseIterator(++current()); }
ConstReverseIterator rcurrent() const { return ReverseIterator(++current()); }
ValueIterator currentVI() { return ValueIterator(m_options_ptr->begin() + m_highlight); }
ConstValueIterator currentVI() const { return ConstValueIterator(m_options_ptr->begin() + m_highlight); }
ReverseValueIterator currentRVI() { return ReverseValueIterator(++currentVI()); }
ConstReverseValueIterator currentRVI() const { return ConstReverseValueIterator(++currentVI()); }
ValueIterator currentV() { return ValueIterator(m_options_ptr->begin() + m_highlight); }
ConstValueIterator currentV() const { return ConstValueIterator(m_options_ptr->begin() + m_highlight); }
ReverseValueIterator rcurrentV() { return ReverseValueIterator(++currentV()); }
ConstReverseValueIterator rcurrentV() const { return ConstReverseValueIterator(++currentV()); }
Iterator begin() { return Iterator(m_options_ptr->begin()); }
ConstIterator begin() const { return ConstIterator(m_options_ptr->begin()); }

View File

@@ -70,15 +70,15 @@ std::wstring Outputs::title()
void Outputs::enterPressed()
{
if (w.current().value().enabled())
if (w.current()->value().enabled())
{
Mpd.DisableOutput(w.choice());
Statusbar::printf("Output \"%s\" disabled", w.current().value().name());
Statusbar::printf("Output \"%s\" disabled", w.current()->value().name());
}
else
{
Mpd.EnableOutput(w.choice());
Statusbar::printf("Output \"%s\" enabled", w.current().value().name());
Statusbar::printf("Output \"%s\" enabled", w.current()->value().name());
}
}

View File

@@ -119,14 +119,14 @@ void Playlist::update()
void Playlist::enterPressed()
{
if (!w.empty())
Mpd.PlayID(w.current().value().getID());
Mpd.PlayID(w.current()->value().getID());
}
void Playlist::spacePressed()
{
if (!w.empty())
{
w.current().setSelected(!w.current().isSelected());
w.current()->setSelected(!w.current()->isSelected());
w.scroll(NC::Scroll::Down);
}
}
@@ -235,7 +235,7 @@ std::vector<MPD::Song> Playlist::getSelectedSongs()
if (it->isSelected())
result.push_back(it->value());
if (result.empty() && !w.empty())
result.push_back(w.current().value());
result.push_back(w.current()->value());
return result;
}
@@ -327,7 +327,7 @@ std::string Playlist::getTotalLength()
void Playlist::SetSelectedItemsPriority(int prio)
{
auto list = getSelectedOrCurrent(w.begin(), w.end(), w.currentI());
auto list = getSelectedOrCurrent(w.begin(), w.end(), w.current());
Mpd.StartCommandsList();
for (auto it = list.begin(); it != list.end(); ++it)
Mpd.SetPriority((*it)->value(), prio);

View File

@@ -164,7 +164,7 @@ void PlaylistEditor::update()
{
withUnfilteredMenuReapplyFilter(Content, [this]() {
size_t idx = 0;
MPD::SongIterator s = Mpd.GetPlaylistContent(Playlists.current().value().path()), end;
MPD::SongIterator s = Mpd.GetPlaylistContent(Playlists.current()->value().path()), end;
for (; s != end; ++s, ++idx)
{
bool is_bold = myPlaylist->checkForSong(*s);
@@ -247,11 +247,11 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
success = addSongsToPlaylist(Content.beginV(), Content.endV(), add_n_play, -1);
});
Statusbar::printf("Playlist \"%1%\" loaded%2%",
Playlists.current().value().path(), withErrors(success)
Playlists.current()->value().path(), withErrors(success)
);
}
else if (isActiveWindow(Content) && !Content.empty())
addSongToPlaylist(Content.current().value(), add_n_play);
addSongToPlaylist(Content.current()->value(), add_n_play);
if (!add_n_play)
w->scroll(NC::Scroll::Down);
@@ -270,7 +270,7 @@ void PlaylistEditor::spacePressed()
{
if (!Playlists.empty())
{
Playlists.current().setSelected(!Playlists.current().isSelected());
Playlists.current()->setSelected(!Playlists.current()->isSelected());
Playlists.scroll(NC::Scroll::Down);
}
}
@@ -278,7 +278,7 @@ void PlaylistEditor::spacePressed()
{
if (!Content.empty())
{
Content.current().setSelected(!Content.current().isSelected());
Content.current()->setSelected(!Content.current()->isSelected());
Content.scroll(NC::Scroll::Down);
}
}
@@ -502,7 +502,7 @@ std::vector<MPD::Song> PlaylistEditor::getSelectedSongs()
result.push_back(e.value());
// if no item is selected, add current one
if (result.empty() && !Content.empty())
result.push_back(Content.current().value());
result.push_back(Content.current()->value());
}
return result;
}

View File

@@ -150,7 +150,7 @@ void SearchEngine::enterPressed()
{
size_t option = w.choice();
if (option > ConstraintsNumber && option < SearchButton)
w.current().value().buffer().clear();
w.current()->value().buffer().clear();
if (option < ConstraintsNumber)
{
@@ -158,21 +158,21 @@ void SearchEngine::enterPressed()
std::string constraint = ConstraintsNames[option];
Statusbar::put() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
itsConstraints[option] = Global::wFooter->prompt(itsConstraints[option]);
w.current().value().buffer().clear();
w.current()->value().buffer().clear();
constraint.resize(13, ' ');
w.current().value().buffer() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
ShowTag(w.current().value().buffer(), itsConstraints[option]);
w.current()->value().buffer() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
ShowTag(w.current()->value().buffer(), itsConstraints[option]);
}
else if (option == ConstraintsNumber+1)
{
Config.search_in_db = !Config.search_in_db;
w.current().value().buffer() << NC::Format::Bold << "Search in:" << NC::Format::NoBold << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
w.current()->value().buffer() << NC::Format::Bold << "Search in:" << NC::Format::NoBold << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
}
else if (option == ConstraintsNumber+2)
{
if (!*++SearchMode)
SearchMode = &SearchModes[0];
w.current().value().buffer() << NC::Format::Bold << "Search mode:" << NC::Format::NoBold << ' ' << *SearchMode;
w.current()->value().buffer() << NC::Format::Bold << "Search mode:" << NC::Format::NoBold << ' ' << *SearchMode;
}
else if (option == SearchButton)
{
@@ -207,22 +207,22 @@ void SearchEngine::enterPressed()
reset();
}
else
addSongToPlaylist(w.current().value().song(), true);
addSongToPlaylist(w.current()->value().song(), true);
}
void SearchEngine::spacePressed()
{
if (!w.current().value().isSong())
if (!w.current()->value().isSong())
return;
if (Config.space_selects)
{
w.current().setSelected(!w.current().isSelected());
w.current()->setSelected(!w.current()->isSelected());
w.scroll(NC::Scroll::Down);
return;
}
addSongToPlaylist(w.current().value().song(), false);
addSongToPlaylist(w.current()->value().song(), false);
w.scroll(NC::Scroll::Down);
}
@@ -333,7 +333,7 @@ ProxySongList SearchEngine::proxySongList()
bool SearchEngine::allowsSelection()
{
return w.current().value().isSong();
return w.current()->value().isSong();
}
void SearchEngine::reverseSelection()
@@ -355,8 +355,8 @@ std::vector<MPD::Song> SearchEngine::getSelectedSongs()
// if no item is selected, add current one
if (result.empty() && !w.empty())
{
assert(w.current().value().isSong());
result.push_back(w.current().value().song());
assert(w.current()->value().isSong());
result.push_back(w.current()->value().song());
}
return result;
}

View File

@@ -163,7 +163,7 @@ std::wstring SelectedItemsAdder::title()
void SelectedItemsAdder::enterPressed()
{
w->current().value().run();
w->current()->value().run();
}
void SelectedItemsAdder::mouseButtonPressed(MEVENT me)
@@ -282,7 +282,7 @@ void SelectedItemsAdder::addAfterCurrentAlbum() const
void SelectedItemsAdder::addAfterHighlightedSong() const
{
size_t pos = myPlaylist->main().current().value().getPosition();
size_t pos = myPlaylist->main().current()->value().getPosition();
++pos;
bool success = addSongsToPlaylist(m_selected_items.begin(), m_selected_items.end(), false, pos);
exitSuccessfully(success);

View File

@@ -110,7 +110,7 @@ std::wstring SortPlaylistDialog::title()
void SortPlaylistDialog::enterPressed()
{
w.current().value().run();
w.current()->value().run();
}
void SortPlaylistDialog::mouseButtonPressed(MEVENT me)
@@ -130,7 +130,7 @@ void SortPlaylistDialog::mouseButtonPressed(MEVENT me)
void SortPlaylistDialog::moveSortOrderDown()
{
auto cur = w.currentVI();
auto cur = w.currentV();
if ((cur+1)->item().second)
{
std::iter_swap(cur, cur+1);
@@ -140,7 +140,7 @@ void SortPlaylistDialog::moveSortOrderDown()
void SortPlaylistDialog::moveSortOrderUp()
{
auto cur = w.currentVI();
auto cur = w.currentV();
if (cur > w.beginV() && cur->item().second)
{
std::iter_swap(cur, cur-1);

View File

@@ -254,7 +254,7 @@ void TagEditor::update()
if (Tags->reallyEmpty())
{
Tags->reset();
MPD::SongIterator s = Mpd.GetSongs(Dirs->current().value().second), end;
MPD::SongIterator s = Mpd.GetSongs(Dirs->current()->value().second), end;
for (; s != end; ++s)
Tags->addItem(std::move(*s));
std::sort(Tags->beginV(), Tags->endV(),
@@ -279,13 +279,13 @@ void TagEditor::enterPressed()
if (w == Dirs)
{
MPD::DirectoryIterator directory = Mpd.GetDirectories(Dirs->current().value().second), end;
MPD::DirectoryIterator directory = Mpd.GetDirectories(Dirs->current()->value().second), end;
bool has_subdirs = directory != end;
directory.finish();
if (has_subdirs)
{
itsHighlightedDir = itsBrowsedDir;
itsBrowsedDir = Dirs->current().value().second;
itsBrowsedDir = Dirs->current()->value().second;
Dirs->clear();
Dirs->reset();
}
@@ -435,7 +435,7 @@ void TagEditor::enterPressed()
}
else // list of patterns
{
Config.pattern = FParser->current().value();
Config.pattern = FParser->current()->value();
FParser->at(0).value() = "Pattern: " + Config.pattern;
}
@@ -489,18 +489,18 @@ void TagEditor::enterPressed()
if (id > 0 && w == TagTypes)
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << TagTypes->current().value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->prompt(Tags->current().value().getTags(get, Config.tags_separator));
Statusbar::put() << NC::Format::Bold << TagTypes->current()->value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->prompt(Tags->current()->value().getTags(get, Config.tags_separator));
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
(*it)->setTags(set, new_tag, Config.tags_separator);
}
else if (w == Tags)
{
Statusbar::ScopedLock slock;
Statusbar::put() << NC::Format::Bold << TagTypes->current().value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->prompt(Tags->current().value().getTags(get, Config.tags_separator));
if (new_tag != Tags->current().value().getTags(get, Config.tags_separator))
Tags->current().value().setTags(set, new_tag, Config.tags_separator);
Statusbar::put() << NC::Format::Bold << TagTypes->current()->value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->prompt(Tags->current()->value().getTags(get, Config.tags_separator));
if (new_tag != Tags->current()->value().getTags(get, Config.tags_separator))
Tags->current()->value().setTags(set, new_tag, Config.tags_separator);
Tags->scroll(NC::Scroll::Down);
}
}
@@ -516,7 +516,7 @@ void TagEditor::enterPressed()
else if (w == Tags)
{
Statusbar::ScopedLock slock;
MPD::MutableSong &s = Tags->current().value();
MPD::MutableSong &s = Tags->current()->value();
std::string old_name = s.getNewName().empty() ? s.getName() : s.getNewName();
size_t last_dot = old_name.rfind(".");
std::string extension = old_name.substr(last_dot);
@@ -583,7 +583,7 @@ void TagEditor::spacePressed()
{
if (w == Tags && !Tags->empty())
{
Tags->current().setSelected(!Tags->current().isSelected());
Tags->current()->setSelected(!Tags->current()->isSelected());
w->scroll(NC::Scroll::Down);
}
}
@@ -854,7 +854,7 @@ std::vector<MPD::Song> TagEditor::getSelectedSongs()
result.push_back(it->value());
// if no song was selected, add current one
if (result.empty() && !Tags->empty())
result.push_back(Tags->current().value());
result.push_back(Tags->current()->value());
}
return result;
}

View File

@@ -140,7 +140,7 @@ void TinyTagEditor::enterPressed()
else
{
if (m_previous_screen == myPlaylist)
myPlaylist->main().current().value() = itsEdited;
myPlaylist->main().current()->value() = itsEdited;
else if (m_previous_screen == myBrowser)
myBrowser->getDirectory(myBrowser->currentDirectory());
}