summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2012-09-14 16:16:35 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2012-09-14 16:16:35 +0200
commit9c29082afeec8751c53be7037b83e250133abf19 (patch)
tree97d8c22495d6c095db048c09f52b00e571f0e6ed /src
parent4d6ea660bcbf8c5f4e61ad51d6f6bb739b4cb3a7 (diff)
playlist: define main screen as non-pointer
Diffstat (limited to 'src')
-rw-r--r--src/actions.cpp54
-rw-r--r--src/browser.cpp4
-rw-r--r--src/display.cpp2
-rw-r--r--src/menu.h1
-rw-r--r--src/ncmpcpp.cpp2
-rw-r--r--src/playlist.cpp120
-rw-r--r--src/playlist.h2
-rw-r--r--src/search_engine.cpp4
-rw-r--r--src/sel_items_adder.cpp6
-rw-r--r--src/sort_playlist.cpp6
-rw-r--r--src/status.cpp30
-rw-r--r--src/tags.cpp4
-rw-r--r--src/tiny_tag_editor.cpp2
13 files changed, 119 insertions, 118 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index b297d98f..0166ba83 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -783,11 +783,11 @@ void VolumeDown::Run()
void Delete::Run()
{
- if (myScreen == myPlaylist && !myPlaylist->main()->empty())
+ if (myScreen == myPlaylist && !myPlaylist->main().empty())
{
Statusbar::msg("Deleting items...");
auto delete_fun = std::bind(&MPD::Connection::Delete, _1, _2);
- if (deleteSelectedSongs(*myPlaylist->main(), delete_fun))
+ if (deleteSelectedSongs(myPlaylist->main(), delete_fun))
Statusbar::msg("Item(s) deleted");
}
# ifndef WIN32
@@ -914,11 +914,11 @@ void SavePlaylist::Run()
}
if (!playlist_name.empty())
{
- if (myPlaylist->main()->isFiltered())
+ if (myPlaylist->main().isFiltered())
{
Mpd.StartCommandsList();
- for (size_t i = 0; i < myPlaylist->main()->size(); ++i)
- Mpd.AddToPlaylist(playlist_name, (*myPlaylist->main())[i].value());
+ for (size_t i = 0; i < myPlaylist->main().size(); ++i)
+ Mpd.AddToPlaylist(playlist_name, myPlaylist->main()[i].value());
Mpd.CommitCommandsList();
if (Mpd.GetErrorMessage().empty())
Statusbar::msg("Filtered items added to playlist \"%s\"", playlist_name.c_str());
@@ -979,8 +979,8 @@ void MoveSortOrderDown::Run()
bool MoveSelectedItemsUp::canBeRun() const
{
- return ((myScreen->activeWindow() == myPlaylist->main()
- && !myPlaylist->main()->empty()
+ return ((myScreen == myPlaylist
+ && !myPlaylist->main().empty()
&& !myPlaylist->isFiltered())
|| (myScreen->activeWindow() == myPlaylistEditor->Content
&& !myPlaylistEditor->Content->empty()
@@ -991,7 +991,7 @@ void MoveSelectedItemsUp::Run()
{
if (myScreen == myPlaylist)
{
- moveSelectedItemsUp(*myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
+ moveSelectedItemsUp(myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
}
else if (myScreen == myPlaylistEditor)
{
@@ -1004,8 +1004,8 @@ void MoveSelectedItemsUp::Run()
bool MoveSelectedItemsDown::canBeRun() const
{
- return ((myScreen->activeWindow() == myPlaylist->main()
- && !myPlaylist->main()->empty()
+ return ((myScreen == myPlaylist
+ && !myPlaylist->main().empty()
&& !myPlaylist->isFiltered())
|| (myScreen->activeWindow() == myPlaylistEditor->Content
&& !myPlaylistEditor->Content->empty()
@@ -1016,7 +1016,7 @@ void MoveSelectedItemsDown::Run()
{
if (myScreen == myPlaylist)
{
- moveSelectedItemsDown(*myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
+ moveSelectedItemsDown(myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
}
else if (myScreen == myPlaylistEditor)
{
@@ -1029,14 +1029,14 @@ void MoveSelectedItemsDown::Run()
bool MoveSelectedItemsTo::canBeRun() const
{
- return myScreen->activeWindow() == myPlaylist->main()
+ return myScreen == myPlaylist
|| myScreen->activeWindow() == myPlaylistEditor->Content;
}
void MoveSelectedItemsTo::Run()
{
if (myScreen == myPlaylist)
- moveSelectedItemsTo(*myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
+ moveSelectedItemsTo(myPlaylist->main(), std::bind(&MPD::Connection::Move, _1, _2, _3));
else
{
assert(!myPlaylistEditor->Playlists->empty());
@@ -1119,16 +1119,16 @@ void ToggleDisplayMode::Run()
if (Config.columns_in_playlist)
{
- myPlaylist->main()->setItemDisplayer(std::bind(Display::SongsInColumns, _1, myPlaylist));
+ myPlaylist->main().setItemDisplayer(std::bind(Display::SongsInColumns, _1, myPlaylist));
if (Config.titles_visibility)
- myPlaylist->main()->setTitle(Display::Columns(myPlaylist->main()->getWidth()));
+ myPlaylist->main().setTitle(Display::Columns(myPlaylist->main().getWidth()));
else
- myPlaylist->main()->setTitle("");
+ myPlaylist->main().setTitle("");
}
else
{
- myPlaylist->main()->setItemDisplayer(std::bind(Display::Songs, _1, myPlaylist, Config.song_list_format));
- myPlaylist->main()->setTitle("");
+ myPlaylist->main().setItemDisplayer(std::bind(Display::Songs, _1, myPlaylist, Config.song_list_format));
+ myPlaylist->main().setTitle("");
}
}
else if (myScreen == myBrowser)
@@ -1199,8 +1199,8 @@ void TogglePlayingSongCentering::Run()
{
Config.autocenter_mode = !Config.autocenter_mode;
Statusbar::msg("Centering playing song: %s", Config.autocenter_mode ? "On" : "Off");
- if (Config.autocenter_mode && Mpd.isPlaying() && !myPlaylist->main()->isFiltered())
- myPlaylist->main()->highlight(Mpd.GetCurrentlyPlayingSongPos());
+ if (Config.autocenter_mode && Mpd.isPlaying() && !myPlaylist->main().isFiltered())
+ myPlaylist->main().highlight(Mpd.GetCurrentlyPlayingSongPos());
}
void UpdateDatabase::Run()
@@ -1226,7 +1226,7 @@ bool JumpToPlayingSong::canBeRun() const
void JumpToPlayingSong::Run()
{
if (myScreen == myPlaylist)
- myPlaylist->main()->highlight(Mpd.GetCurrentlyPlayingSongPos());
+ myPlaylist->main().highlight(Mpd.GetCurrentlyPlayingSongPos());
else if (myScreen == myBrowser)
{
myBrowser->LocateSong(myPlaylist->nowPlayingSong());
@@ -1782,7 +1782,7 @@ void CropMainPlaylist::Run()
if (yes)
{
Statusbar::msg("Cropping playlist...");
- if (cropPlaylist(*myPlaylist->main(), std::bind(&MPD::Connection::Delete, _1, _2)))
+ if (cropPlaylist(myPlaylist->main(), std::bind(&MPD::Connection::Delete, _1, _2)))
Statusbar::msg("Cropping playlist...");
}
}
@@ -1818,7 +1818,7 @@ void ClearMainPlaylist::Run()
auto delete_fun = std::bind(&MPD::Connection::Delete, _1, _2);
auto clear_fun = std::bind(&MPD::Connection::ClearMainPlaylist, _1);
Statusbar::msg("Deleting items...");
- if (clearPlaylist(*myPlaylist->main(), delete_fun, clear_fun))
+ if (clearPlaylist(myPlaylist->main(), delete_fun, clear_fun))
Statusbar::msg("Items deleted");
}
}
@@ -1888,7 +1888,7 @@ void ApplyFilter::Run()
filter = f->currentFilter();
if (filter.empty())
{
- myPlaylist->main()->clearFilterResults();
+ myPlaylist->main().clearFilterResults();
Statusbar::msg("Filtering disabled");
}
else
@@ -2176,7 +2176,7 @@ bool SetSelectedItemsPriority::canBeRun() const
Statusbar::msg("Priorities are supported in MPD >= 0.17.0");
return false;
}
- return myScreen == myPlaylist && !myPlaylist->main()->empty();
+ return myScreen == myPlaylist && !myPlaylist->main().empty();
}
void SetSelectedItemsPriority::Run()
@@ -2200,7 +2200,7 @@ void SetSelectedItemsPriority::Run()
bool FilterPlaylistOnPriorities::canBeRun() const
{
- return myScreen->activeWindow() == myPlaylist->main();
+ return myScreen == myPlaylist;
}
void FilterPlaylistOnPriorities::Run()
@@ -2214,7 +2214,7 @@ void FilterPlaylistOnPriorities::Run()
if (!isInteger(strprio.c_str(), false))
return;
unsigned prio = stringToInt(strprio);
- myPlaylist->main()->filter(myPlaylist->main()->begin(), myPlaylist->main()->end(),
+ myPlaylist->main().filter(myPlaylist->main().begin(), myPlaylist->main().end(),
[prio](const NC::Menu<MPD::Song>::Item &s) {
return s.value().getPrio() > prio;
});
diff --git a/src/browser.cpp b/src/browser.cpp
index 37014750..f4b372e3 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -436,9 +436,9 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
case itSong:
{
bool bold = 0;
- for (size_t i = 0; i < myPlaylist->main()->size(); ++i)
+ for (size_t i = 0; i < myPlaylist->main().size(); ++i)
{
- if (myPlaylist->main()->at(i).value().getHash() == it->song->getHash())
+ if (myPlaylist->main().at(i).value().getHash() == it->song->getHash())
{
bold = 1;
break;
diff --git a/src/display.cpp b/src/display.cpp
index 49fec4a5..c9624f88 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -96,7 +96,7 @@ void setProperties(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen, bool
discard_colors = Config.discard_colors_if_item_is_selected && is_selected;
int song_pos = menu.isFiltered() ? s.getPosition() : drawn_pos;
- is_now_playing = static_cast<void *>(&menu) == myPlaylist->main()
+ is_now_playing = &menu == myPlaylist->activeWindow()
&& song_pos == Mpd.GetCurrentlyPlayingSongPos();
if (is_now_playing)
menu << Config.now_playing_prefix;
diff --git a/src/menu.h b/src/menu.h
index 6aaef247..ac7f968d 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -523,6 +523,7 @@ template <typename T> Menu<T>::Menu(Menu &&rhs)
template <typename T> Menu<T> &Menu<T>::operator=(Menu rhs)
{
+ std::swap(static_cast<Window &>(*this), static_cast<Window &>(rhs));
std::swap(m_item_displayer, rhs.m_item_displayer);
std::swap(m_filter, rhs.m_filter);
std::swap(m_searcher, rhs.m_searcher);
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp
index 4c29c6e4..9e8d7f30 100644
--- a/src/ncmpcpp.cpp
+++ b/src/ncmpcpp.cpp
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
Status::trace();
int curr_pos = Mpd.GetCurrentSongPos();
if (curr_pos >= 0)
- myPlaylist->main()->highlight(curr_pos);
+ myPlaylist->main().highlight(curr_pos);
}
# ifndef WIN32
diff --git a/src/playlist.cpp b/src/playlist.cpp
index e4044585..cbf74dcc 100644
--- a/src/playlist.cpp
+++ b/src/playlist.cpp
@@ -52,16 +52,16 @@ bool playlistEntryMatcher(const Regex &rx, const MPD::Song &s);
Playlist::Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0)
{
- w = new NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
- w->cyclicScrolling(Config.use_cyclic_scrolling);
- w->centeredCursor(Config.centered_cursor);
- w->setHighlightColor(Config.main_highlight_color);
- w->setSelectedPrefix(Config.selected_item_prefix);
- w->setSelectedSuffix(Config.selected_item_suffix);
+ w = NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
+ w.cyclicScrolling(Config.use_cyclic_scrolling);
+ w.centeredCursor(Config.centered_cursor);
+ w.setHighlightColor(Config.main_highlight_color);
+ w.setSelectedPrefix(Config.selected_item_prefix);
+ w.setSelectedSuffix(Config.selected_item_suffix);
if (Config.columns_in_playlist)
- w->setItemDisplayer(std::bind(Display::SongsInColumns, _1, this));
+ w.setItemDisplayer(std::bind(Display::SongsInColumns, _1, this));
else
- w->setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_list_format));
+ w.setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_list_format));
}
void Playlist::switchTo()
@@ -92,13 +92,13 @@ void Playlist::resize()
{
size_t x_offset, width;
getWindowResizeParams(x_offset, width);
- w->resize(width, MainHeight);
- w->moveTo(x_offset, MainStartY);
+ w.resize(width, MainHeight);
+ w.moveTo(x_offset, MainStartY);
if (Config.columns_in_playlist && Config.titles_visibility)
- w->setTitle(Display::Columns(w->getWidth()));
+ w.setTitle(Display::Columns(w.getWidth()));
else
- w->setTitle("");
+ w.setTitle("");
hasToBeResized = 0;
}
@@ -114,26 +114,26 @@ std::wstring Playlist::title()
void Playlist::enterPressed()
{
- if (!w->empty())
- Mpd.PlayID(w->current().value().getID());
+ if (!w.empty())
+ Mpd.PlayID(w.current().value().getID());
}
void Playlist::spacePressed()
{
- if (!w->empty())
+ if (!w.empty())
{
- w->current().setSelected(!w->current().isSelected());
- w->scroll(NC::wDown);
+ w.current().setSelected(!w.current().isSelected());
+ w.scroll(NC::wDown);
}
}
void Playlist::mouseButtonPressed(MEVENT me)
{
- if (!w->empty() && w->hasCoords(me.x, me.y))
+ if (!w.empty() && w.hasCoords(me.x, me.y))
{
- if (size_t(me.y) < w->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
+ if (size_t(me.y) < w.size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
- w->Goto(me.y);
+ w.Goto(me.y);
if (me.bstate & BUTTON3_PRESSED)
enterPressed();
}
@@ -151,14 +151,14 @@ bool Playlist::allowsFiltering()
std::string Playlist::currentFilter()
{
- return RegexFilter<MPD::Song>::currentFilter(*w);
+ return RegexFilter<MPD::Song>::currentFilter(w);
}
void Playlist::applyFilter(const std::string &filter)
{
- w->showAll();
+ w.showAll();
auto rx = RegexFilter<MPD::Song>(filter, Config.regex_type, playlistEntryMatcher);
- w->filter(w->begin(), w->end(), rx);
+ w.filter(w.begin(), w.end(), rx);
}
/***********************************************************************/
@@ -171,24 +171,24 @@ bool Playlist::allowsSearching()
bool Playlist::search(const std::string &constraint)
{
auto rx = RegexFilter<MPD::Song>(constraint, Config.regex_type, playlistEntryMatcher);
- return w->search(w->begin(), w->end(), rx);
+ return w.search(w.begin(), w.end(), rx);
}
void Playlist::nextFound(bool wrap)
{
- w->nextFound(wrap);
+ w.nextFound(wrap);
}
void Playlist::prevFound(bool wrap)
{
- w->prevFound(wrap);
+ w.prevFound(wrap);
}
/***********************************************************************/
std::shared_ptr<ProxySongList> Playlist::getProxySongList()
{
- return mkProxySongList(*w, [](NC::Menu<MPD::Song>::Item &item) {
+ return mkProxySongList(w, [](NC::Menu<MPD::Song>::Item &item) {
return &item.value();
});
}
@@ -200,17 +200,17 @@ bool Playlist::allowsSelection()
void Playlist::reverseSelection()
{
- reverseSelectionHelper(w->begin(), w->end());
+ reverseSelectionHelper(w.begin(), w.end());
}
MPD::SongList Playlist::getSelectedSongs()
{
MPD::SongList result;
- for (auto it = w->begin(); it != w->end(); ++it)
+ for (auto it = w.begin(); it != w.end(); ++it)
if (it->isSelected())
result.push_back(it->value());
- if (result.empty() && !w->empty())
- result.push_back(w->current().value());
+ if (result.empty() && !w.empty())
+ result.push_back(w.current().value());
return result;
}
@@ -220,15 +220,15 @@ MPD::Song Playlist::nowPlayingSong()
{
MPD::Song s;
if (Mpd.isPlaying())
- withUnfilteredMenu(*w, [this, &s]() {
- s = w->at(Mpd.GetCurrentSongPos()).value();
+ withUnfilteredMenu(w, [this, &s]() {
+ s = w.at(Mpd.GetCurrentSongPos()).value();
});
return s;
}
bool Playlist::isFiltered()
{
- if (w->isFiltered())
+ if (w.isFiltered())
{
Statusbar::msg("Function currently unavailable due to filtered playlist");
return true;
@@ -242,9 +242,9 @@ void Playlist::Reverse()
return;
Statusbar::msg("Reversing playlist order...");
size_t beginning = -1, end = -1;
- for (size_t i = 0; i < w->size(); ++i)
+ for (size_t i = 0; i < w.size(); ++i)
{
- if (w->at(i).isSelected())
+ if (w.at(i).isSelected())
{
if (beginning == size_t(-1))
beginning = i;
@@ -254,7 +254,7 @@ void Playlist::Reverse()
if (beginning == size_t(-1)) // no selected items
{
beginning = 0;
- end = w->size();
+ end = w.size();
}
Mpd.StartCommandsList();
for (size_t i = beginning, j = end-1; i < (beginning+end)/2; ++i, --j)
@@ -265,7 +265,7 @@ void Playlist::Reverse()
void Playlist::EnableHighlighting()
{
- w->setHighlighting(true);
+ w.setHighlighting(true);
UpdateTimer();
}
@@ -281,26 +281,26 @@ std::string Playlist::TotalLength()
if (ReloadTotalLength)
{
itsTotalLength = 0;
- for (size_t i = 0; i < w->size(); ++i)
- itsTotalLength += (*w)[i].value().getDuration();
+ for (size_t i = 0; i < w.size(); ++i)
+ itsTotalLength += w[i].value().getDuration();
ReloadTotalLength = 0;
}
- if (Config.playlist_show_remaining_time && ReloadRemaining && !w->isFiltered())
+ if (Config.playlist_show_remaining_time && ReloadRemaining && !w.isFiltered())
{
itsRemainingTime = 0;
- for (size_t i = Mpd.GetCurrentlyPlayingSongPos(); i < w->size(); ++i)
- itsRemainingTime += (*w)[i].value().getDuration();
+ for (size_t i = Mpd.GetCurrentlyPlayingSongPos(); i < w.size(); ++i)
+ itsRemainingTime += w[i].value().getDuration();
ReloadRemaining = false;
}
- result << '(' << w->size() << (w->size() == 1 ? " item" : " items");
+ result << '(' << w.size() << (w.size() == 1 ? " item" : " items");
- if (w->isFiltered())
+ if (w.isFiltered())
{
- w->showAll();
- size_t real_size = w->size();
- w->showFiltered();
- if (w->size() != real_size)
+ w.showAll();
+ size_t real_size = w.size();
+ w.showFiltered();
+ if (w.size() != real_size)
result << " (out of " << Mpd.GetPlaylistLength() << ")";
}
@@ -309,7 +309,7 @@ std::string Playlist::TotalLength()
result << ", length: ";
ShowTime(result, itsTotalLength, Config.playlist_shorten_total_times);
}
- if (Config.playlist_show_remaining_time && itsRemainingTime && !w->isFiltered() && w->size() > 1)
+ if (Config.playlist_show_remaining_time && itsRemainingTime && !w.isFiltered() && w.size() > 1)
{
result << " :: remaining: ";
ShowTime(result, itsRemainingTime, Config.playlist_shorten_total_times);
@@ -325,9 +325,9 @@ bool Playlist::Add(const MPD::Song &s, bool play, int position)
size_t hash = s.getHash();
if (play)
{
- for (size_t i = 0; i < w->size(); ++i)
+ for (size_t i = 0; i < w.size(); ++i)
{
- if (w->at(i).value().getHash() == hash)
+ if (w.at(i).value().getHash() == hash)
{
Mpd.Play(i);
break;
@@ -338,8 +338,8 @@ bool Playlist::Add(const MPD::Song &s, bool play, int position)
else
{
Mpd.StartCommandsList();
- for (size_t i = 0; i < w->size(); ++i)
- if ((*w)[i].value().getHash() == hash)
+ for (size_t i = 0; i < w.size(); ++i)
+ if (w[i].value().getHash() == hash)
Mpd.Delete(i);
Mpd.CommitCommandsList();
return false;
@@ -387,19 +387,19 @@ bool Playlist::Add(const MPD::SongList &l, bool play, int position)
void Playlist::PlayNewlyAddedSongs()
{
- bool is_filtered = w->isFiltered();
- w->showAll();
- size_t old_size = w->size();
+ bool is_filtered = w.isFiltered();
+ w.showAll();
+ size_t old_size = w.size();
Mpd.UpdateStatus();
- if (old_size < w->size())
+ if (old_size < w.size())
Mpd.Play(old_size);
if (is_filtered)
- w->showFiltered();
+ w.showFiltered();
}
void Playlist::SetSelectedItemsPriority(int prio)
{
- auto list = getSelectedOrCurrent(w->begin(), w->end(), w->currentI());
+ auto list = getSelectedOrCurrent(w.begin(), w.end(), w.currentI());
Mpd.StartCommandsList();
for (auto it = list.begin(); it != list.end(); ++it)
Mpd.SetPriority((*it)->value(), prio);
diff --git a/src/playlist.h b/src/playlist.h
index 579705ca..79bf2a09 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -27,7 +27,7 @@
#include "screen.h"
#include "song.h"
-struct Playlist : public Screen<NC::Menu<MPD::Song> *>, public Filterable, public HasSongs, public Searchable
+struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public HasSongs, public Searchable
{
Playlist();
diff --git a/src/search_engine.cpp b/src/search_engine.cpp
index 512b6c34..5d8f627c 100644
--- a/src/search_engine.cpp
+++ b/src/search_engine.cpp
@@ -438,8 +438,8 @@ void SearchEngine::Search()
list = Mpd.GetDirectoryRecursive("/");
else
{
- list.reserve(myPlaylist->main()->size());
- for (auto s = myPlaylist->main()->beginV(); s != myPlaylist->main()->endV(); ++s)
+ list.reserve(myPlaylist->main().size());
+ for (auto s = myPlaylist->main().beginV(); s != myPlaylist->main().endV(); ++s)
list.push_back(*s);
}
diff --git a/src/sel_items_adder.cpp b/src/sel_items_adder.cpp
index 85c4f7b3..a3a8c310 100644
--- a/src/sel_items_adder.cpp
+++ b/src/sel_items_adder.cpp
@@ -212,14 +212,14 @@ void SelectedItemsAdder::enterPressed()
{
std::string album = myPlaylist->nowPlayingSong().getAlbum();
int i;
- for (i = Mpd.GetCurrentlyPlayingSongPos()+1; i < int(myPlaylist->main()->size()); ++i)
- if ((*myPlaylist->main())[i].value().getAlbum() != album)
+ for (i = Mpd.GetCurrentlyPlayingSongPos()+1; i < int(myPlaylist->main().size()); ++i)
+ if (myPlaylist->main()[i].value().getAlbum() != album)
break;
successful_operation = myPlaylist->Add(list, 0, i);
}
else if (pos == 4) // after highlighted item
{
- successful_operation = myPlaylist->Add(list, 0, std::min(myPlaylist->main()->choice()+1, myPlaylist->main()->size()));
+ successful_operation = myPlaylist->Add(list, 0, std::min(myPlaylist->main().choice()+1, myPlaylist->main().size()));
}
else
{
diff --git a/src/sort_playlist.cpp b/src/sort_playlist.cpp
index 10ff88d7..2e67ca01 100644
--- a/src/sort_playlist.cpp
+++ b/src/sort_playlist.cpp
@@ -98,9 +98,9 @@ void SortPlaylistDialog::enterPressed()
auto option = w->currentVI();
if (*option == m_sort_entry)
{
- auto begin = myPlaylist->main()->begin(), end = myPlaylist->main()->end();
+ auto begin = myPlaylist->main().begin(), end = myPlaylist->main().end();
// if songs are selected, sort range from first selected to last selected
- if (myPlaylist->main()->hasSelected())
+ if (myPlaylist->main().hasSelected())
{
while (!begin->isSelected())
++begin;
@@ -108,7 +108,7 @@ void SortPlaylistDialog::enterPressed()
--end;
}
- size_t start_pos = begin - myPlaylist->main()->begin();
+ size_t start_pos = begin - myPlaylist->main().begin();
MPD::SongList playlist;
playlist.reserve(end - begin);
for (; begin != end; ++begin)
diff --git a/src/status.cpp b/src/status.cpp
index 8e810d8c..91de9803 100644
--- a/src/status.cpp
+++ b/src/status.cpp
@@ -92,13 +92,13 @@ void Status::trace()
applyToVisibleWindows(&BasicScreen::update);
- if (isVisible(myPlaylist) && myPlaylist->activeWindow() == myPlaylist->main()
+ if (isVisible(myPlaylist)
&& Timer.tv_sec == myPlaylist->Timer().tv_sec+Config.playlist_disable_highlight_delay
- && myPlaylist->main()->isHighlighted()
+ && myPlaylist->main().isHighlighted()
&& Config.playlist_disable_highlight_delay)
{
- myPlaylist->main()->setHighlighting(false);
- myPlaylist->main()->refresh();
+ myPlaylist->main().setHighlighting(false);
+ myPlaylist->main().refresh();
}
Statusbar::tryRedraw();
@@ -129,31 +129,31 @@ void Status::handleError(MPD::Connection * , int errorid, const char *msg, void
void Status::Changes::playlist()
{
- myPlaylist->main()->clearSearchResults();
- withUnfilteredMenuReapplyFilter(*myPlaylist->main(), []() {
+ myPlaylist->main().clearSearchResults();
+ withUnfilteredMenuReapplyFilter(myPlaylist->main(), []() {
size_t playlist_length = Mpd.GetPlaylistLength();
- if (playlist_length < myPlaylist->main()->size())
+ if (playlist_length < myPlaylist->main().size())
{
- auto it = myPlaylist->main()->begin()+playlist_length;
- auto end = myPlaylist->main()->end();
+ auto it = myPlaylist->main().begin()+playlist_length;
+ auto end = myPlaylist->main().end();
for (; it != end; ++it)
myPlaylist->unregisterHash(it->value().getHash());
- myPlaylist->main()->resizeList(playlist_length);
+ myPlaylist->main().resizeList(playlist_length);
}
auto songs = Mpd.GetPlaylistChanges(Mpd.GetOldPlaylistID());
for (auto s = songs.begin(); s != songs.end(); ++s)
{
size_t pos = s->getPosition();
- if (pos < myPlaylist->main()->size())
+ if (pos < myPlaylist->main().size())
{
// if song's already in playlist, replace it with a new one
- MPD::Song &old_s = (*myPlaylist->main())[pos].value();
+ MPD::Song &old_s = myPlaylist->main()[pos].value();
myPlaylist->unregisterHash(old_s.getHash());
old_s = *s;
}
else // otherwise just add it to playlist
- myPlaylist->main()->addItem(*s);
+ myPlaylist->main().addItem(*s);
myPlaylist->registerHash(s->getHash());
}
});
@@ -287,8 +287,8 @@ void Status::Changes::songID()
drawTitle(myPlaylist->nowPlayingSong());
- if (Config.autocenter_mode && !myPlaylist->main()->isFiltered())
- myPlaylist->main()->highlight(Mpd.GetCurrentlyPlayingSongPos());
+ if (Config.autocenter_mode && !myPlaylist->main().isFiltered())
+ myPlaylist->main().highlight(Mpd.GetCurrentlyPlayingSongPos());
if (Config.now_playing_lyrics && isVisible(myLyrics) && Global::myOldScreen == myPlaylist)
myLyrics->ReloadNP = 1;
diff --git a/src/tags.cpp b/src/tags.cpp
index 5e6cc943..501c0d7a 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -257,13 +257,13 @@ bool write(MPD::MutableSong &s)
{
// if we rename local file, it won't get updated
// so just remove it from playlist and add again
- size_t pos = myPlaylist->main()->choice();
+ size_t pos = myPlaylist->main().choice();
Mpd.StartCommandsList();
Mpd.Delete(pos);
int id = Mpd.AddSong("file://" + new_name);
if (id >= 0)
{
- s = myPlaylist->main()->back().value();
+ s = myPlaylist->main().back().value();
Mpd.Move(s.getPosition(), pos);
}
Mpd.CommitCommandsList();
diff --git a/src/tiny_tag_editor.cpp b/src/tiny_tag_editor.cpp
index 3de58f22..5a4d293d 100644
--- a/src/tiny_tag_editor.cpp
+++ b/src/tiny_tag_editor.cpp
@@ -140,7 +140,7 @@ void TinyTagEditor::enterPressed()
else
{
if (myOldScreen == myPlaylist)
- myPlaylist->main()->current().value() = itsEdited;
+ myPlaylist->main().current().value() = itsEdited;
else if (myOldScreen == myBrowser)
myBrowser->GetDirectory(myBrowser->CurrentDir());
}