change namespace Playlist into class
This commit is contained in:
@@ -11,5 +11,5 @@ INCLUDES= $(all_includes)
|
||||
ncmpcpp_LDFLAGS = $(all_libraries)
|
||||
noinst_HEADERS = browser.h charset.h clock.h display.h global.h help.h \
|
||||
helpers.h info.h lyrics.h media_library.h menu.h mpdpp.h playlist_editor.h \
|
||||
scrollpad.h search_engine.h settings.h song.h status_checker.h tag_editor.h \
|
||||
window.h
|
||||
screen.h scrollpad.h search_engine.h settings.h song.h status_checker.h \
|
||||
tag_editor.h window.h
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "settings.h"
|
||||
#include "status_checker.h"
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
@@ -94,9 +95,9 @@ void Browser::EnterPressed()
|
||||
{
|
||||
bool found = 0;
|
||||
long long hash = mBrowser->Current().song->GetHash();
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->Play(i);
|
||||
found = 1;
|
||||
@@ -125,7 +126,7 @@ void Browser::EnterPressed()
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Loading and playing playlist %s...", item.name.c_str());
|
||||
Song *s = &mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s->GetHash() == list[0]->GetHash())
|
||||
Mpd->PlayID(s->GetID());
|
||||
else
|
||||
@@ -164,7 +165,7 @@ void Browser::SpacePressed()
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Added folder: %s", item.name.c_str());
|
||||
Song &s = mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s.GetHash() != list[0]->GetHash())
|
||||
ShowMessage("%s", message_part_of_songs_added);
|
||||
}
|
||||
@@ -178,12 +179,12 @@ void Browser::SpacePressed()
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
long long hash = mBrowser->Current().song->GetHash();
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->QueueDeleteSong(i);
|
||||
mPlaylist->DeleteOption(i);
|
||||
myPlaylist->Main()->DeleteOption(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +211,7 @@ void Browser::SpacePressed()
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Loading playlist %s...", item.name.c_str());
|
||||
Song &s = mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s.GetHash() != list[0]->GetHash())
|
||||
ShowMessage("%s", message_part_of_songs_added);
|
||||
}
|
||||
@@ -288,9 +289,9 @@ void UpdateItemList(Menu<Item> *menu)
|
||||
{
|
||||
if (menu->at(i).type == itSong)
|
||||
{
|
||||
for (size_t j = 0; j < mPlaylist->Size(); j++)
|
||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||
{
|
||||
if (mPlaylist->at(j).GetHash() == menu->at(i).song->GetHash())
|
||||
if (myPlaylist->Main()->at(j).GetHash() == menu->at(i).song->GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
@@ -357,9 +358,9 @@ void GetDirectory(string dir, string subdir)
|
||||
case itSong:
|
||||
{
|
||||
bool bold = 0;
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == it->song->GetHash())
|
||||
if (myPlaylist->Main()->at(i).GetHash() == it->song->GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "playlist.h"
|
||||
#include "settings.h"
|
||||
#include "status_checker.h"
|
||||
|
||||
@@ -76,7 +77,7 @@ void Clock::Resize()
|
||||
wClock->MoveTo((COLS-width)/2, (LINES-height)/2);
|
||||
if (current_screen == csClock)
|
||||
{
|
||||
mPlaylist->Hide();
|
||||
myPlaylist->Main()->Hide();
|
||||
Prepare();
|
||||
wClock->Display();
|
||||
}
|
||||
@@ -165,7 +166,7 @@ void Clock::SwitchTo()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
wCurrent = wClock;
|
||||
mPlaylist->Hide();
|
||||
myPlaylist->Main()->Hide();
|
||||
current_screen = csClock;
|
||||
redraw_header = 1;
|
||||
Clock::Prepare();
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
|
||||
using Global::Config;
|
||||
using Global::mPlaylist;
|
||||
using MPD::Song;
|
||||
using std::string;
|
||||
|
||||
@@ -99,10 +99,10 @@ void Display::TotalPlaylistLength(Window &w)
|
||||
const int YEAR = 365*DAY;
|
||||
int length = 0;
|
||||
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
length += mPlaylist->at(i).GetTotalLength();
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
length += myPlaylist->Main()->at(i).GetTotalLength();
|
||||
|
||||
w << '(' << mPlaylist->Size() << (mPlaylist->Size() == 1 ? " item" : " items");
|
||||
w << '(' << myPlaylist->Main()->Size() << (myPlaylist->Main()->Size() == 1 ? " item" : " items");
|
||||
|
||||
if (length)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Global
|
||||
extern Window *wCurrent;
|
||||
extern Window *wPrev;
|
||||
|
||||
extern Menu<MPD::Song> *mPlaylist;
|
||||
// extern Menu<MPD::Song> *myPlaylist->Main();
|
||||
extern Menu<MPD::Item> *mBrowser;
|
||||
extern Menu< std::pair<Buffer *, MPD::Song *> > *mSearcher;
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include "charset.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using namespace MPD;
|
||||
using Global::Config;
|
||||
using Global::Mpd;
|
||||
using Global::mPlaylist;
|
||||
using Global::wFooter;
|
||||
using std::string;
|
||||
|
||||
@@ -225,9 +225,9 @@ void UpdateSongList(Menu<Song> *menu)
|
||||
bool bold = 0;
|
||||
for (size_t i = 0; i < menu->Size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < mPlaylist->Size(); j++)
|
||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||
{
|
||||
if (mPlaylist->at(j).GetHash() == menu->at(i).GetHash())
|
||||
if (myPlaylist->Main()->at(j).GetHash() == menu->at(i).GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "charset.h"
|
||||
#include "global.h"
|
||||
#include "media_library.h"
|
||||
#include "playlist.h"
|
||||
#include "playlist_editor.h"
|
||||
#include "status_checker.h"
|
||||
#include "tag_editor.h"
|
||||
@@ -92,7 +93,7 @@ void Info::GetSong()
|
||||
# endif // HAVE_TAGLIB_H
|
||||
}
|
||||
else if (
|
||||
(wCurrent == mPlaylist && !mPlaylist->Empty())
|
||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||
|| (wCurrent == mBrowser && mBrowser->Current().type == MPD::itSong)
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||
@@ -107,7 +108,7 @@ void Info::GetSong()
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &mPlaylist->at(id);
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
s = mBrowser->at(id).song;
|
||||
@@ -179,7 +180,7 @@ void Info::GetArtist()
|
||||
# endif // HAVE_TAGLIB_H
|
||||
}
|
||||
else if (
|
||||
(wCurrent == mPlaylist && !mPlaylist->Empty())
|
||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||
|| (wCurrent == mBrowser && mBrowser->Current().type == MPD::itSong)
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| (wCurrent == mLibArtists && !mLibArtists->Empty())
|
||||
@@ -201,7 +202,7 @@ void Info::GetArtist()
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
*artist = mPlaylist->at(id).GetArtist();
|
||||
*artist = myPlaylist->Main()->at(id).GetArtist();
|
||||
break;
|
||||
case csBrowser:
|
||||
*artist = mBrowser->at(id).song->GetArtist();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "helpers.h"
|
||||
#include "lyrics.h"
|
||||
#include "media_library.h"
|
||||
#include "playlist.h"
|
||||
#include "playlist_editor.h"
|
||||
#include "settings.h"
|
||||
#include "song.h"
|
||||
@@ -72,7 +73,7 @@ void Lyrics::Update()
|
||||
if (!reload_lyrics)
|
||||
return;
|
||||
|
||||
const MPD::Song &s = mPlaylist->at(now_playing);
|
||||
const MPD::Song &s = myPlaylist->Main()->at(now_playing);
|
||||
if (!s.GetArtist().empty() && !s.GetTitle().empty())
|
||||
Get();
|
||||
else
|
||||
@@ -105,7 +106,7 @@ void Lyrics::Get()
|
||||
}
|
||||
else if (
|
||||
reload_lyrics
|
||||
|| (wCurrent == mPlaylist && !mPlaylist->Empty())
|
||||
|| (wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||
|| (wCurrent == mBrowser && mBrowser->Current().type == MPD::itSong)
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||
@@ -129,7 +130,7 @@ void Lyrics::Get()
|
||||
if (reload_lyrics)
|
||||
{
|
||||
current_screen = csPlaylist;
|
||||
wCurrent = mPlaylist;
|
||||
wCurrent = myPlaylist->Main();
|
||||
reload_lyrics = 0;
|
||||
id = now_playing;
|
||||
}
|
||||
@@ -139,7 +140,7 @@ void Lyrics::Get()
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &mPlaylist->at(id);
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
s = mBrowser->at(id).song;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "global.h"
|
||||
#include "media_library.h"
|
||||
#include "mpdpp.h"
|
||||
#include "playlist.h"
|
||||
#include "status_checker.h"
|
||||
|
||||
using namespace MPD;
|
||||
@@ -116,7 +117,7 @@ void MediaLibrary::SwitchTo()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
mPlaylist->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
myPlaylist->Main()->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
@@ -231,9 +232,9 @@ void MediaLibrary::Update()
|
||||
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
for (size_t j = 0; j < mPlaylist->Size(); j++)
|
||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||
{
|
||||
if ((*it)->GetHash() == mPlaylist->at(j).GetHash())
|
||||
if ((*it)->GetHash() == myPlaylist->Main()->at(j).GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
@@ -264,7 +265,7 @@ void MediaLibrary::EnterPressed(bool add_n_play)
|
||||
string tag_type = IntoStr(Config.media_lib_primary_tag);
|
||||
ToLower(tag_type);
|
||||
ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), mLibArtists->Current().c_str());
|
||||
Song *s = &mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s->GetHash() == list[0]->GetHash())
|
||||
{
|
||||
if (add_n_play)
|
||||
@@ -281,7 +282,7 @@ void MediaLibrary::EnterPressed(bool add_n_play)
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Adding songs from album \"%s\"", mLibAlbums->Current().second.c_str());
|
||||
Song *s = &mPlaylist->at(mPlaylist->Size()-mLibSongs->Size());
|
||||
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-mLibSongs->Size());
|
||||
if (s->GetHash() == mLibSongs->at(0).GetHash())
|
||||
{
|
||||
if (add_n_play)
|
||||
@@ -301,9 +302,9 @@ void MediaLibrary::EnterPressed(bool add_n_play)
|
||||
long long hash = mLibSongs->Current().GetHash();
|
||||
if (add_n_play)
|
||||
{
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->Play(i);
|
||||
break;
|
||||
@@ -313,12 +314,12 @@ void MediaLibrary::EnterPressed(bool add_n_play)
|
||||
else
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->QueueDeleteSong(i);
|
||||
mPlaylist->DeleteOption(i);
|
||||
myPlaylist->Main()->DeleteOption(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
182
src/ncmpcpp.cpp
182
src/ncmpcpp.cpp
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
if (!Config.statusbar_visibility)
|
||||
main_height++;
|
||||
|
||||
Playlist::Init();
|
||||
myPlaylist->Init();
|
||||
Browser::Init();
|
||||
SearchEngine::Init();
|
||||
MediaLibrary::Init();
|
||||
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
|
||||
wFooter->SetGetStringHelper(TraceMpdStatus);
|
||||
wFooter->Display();
|
||||
|
||||
wCurrent = mPlaylist;
|
||||
wCurrent = myPlaylist->Main();
|
||||
current_screen = csPlaylist;
|
||||
|
||||
timer = time(NULL);
|
||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
screen_title = "Help";
|
||||
break;
|
||||
case csPlaylist:
|
||||
screen_title = "Playlist ";
|
||||
screen_title = myPlaylist->Title();
|
||||
break;
|
||||
case csBrowser:
|
||||
screen_title = "Browse: ";
|
||||
@@ -377,7 +377,7 @@ int main(int argc, char *argv[])
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
mPlaylist->Highlighting(1);
|
||||
myPlaylist->Main()->Highlighting(1);
|
||||
break;
|
||||
case csLibrary:
|
||||
case csPlaylistEditor:
|
||||
@@ -519,7 +519,7 @@ int main(int argc, char *argv[])
|
||||
main_height++;
|
||||
|
||||
Help::Resize();
|
||||
Playlist::Resize();
|
||||
myPlaylist->Resize();
|
||||
Browser::Resize();
|
||||
SearchEngine::Resize();
|
||||
MediaLibrary::Resize();
|
||||
@@ -582,8 +582,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
case csPlaylist:
|
||||
{
|
||||
if (!mPlaylist->Empty())
|
||||
Mpd->PlayID(mPlaylist->Current().GetID());
|
||||
if (!myPlaylist->Main()->Empty())
|
||||
Mpd->PlayID(myPlaylist->Main()->Current().GetID());
|
||||
break;
|
||||
}
|
||||
case csBrowser:
|
||||
@@ -627,13 +627,13 @@ int main(int argc, char *argv[])
|
||||
else if (Keypressed(input, Key.Space))
|
||||
{
|
||||
if (Config.space_selects
|
||||
|| wCurrent == mPlaylist
|
||||
|| wCurrent == myPlaylist->Main()
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| wCurrent == mEditorTags
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
if (wCurrent == mPlaylist
|
||||
if (wCurrent == myPlaylist->Main()
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| wCurrent == mEditorTags
|
||||
# endif // HAVE_TAGLIB_H
|
||||
@@ -801,17 +801,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.Delete))
|
||||
{
|
||||
if (!mPlaylist->Empty() && current_screen == csPlaylist)
|
||||
if (!myPlaylist->Main()->Empty() && current_screen == csPlaylist)
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
if (mPlaylist->hasSelected())
|
||||
if (myPlaylist->Main()->hasSelected())
|
||||
{
|
||||
vector<size_t> list;
|
||||
mPlaylist->GetSelected(list);
|
||||
myPlaylist->Main()->GetSelected(list);
|
||||
for (vector<size_t>::const_reverse_iterator it = list.rbegin(); it != ((const vector<size_t> &)list).rend(); it++)
|
||||
{
|
||||
Mpd->QueueDeleteSong(*it);
|
||||
mPlaylist->DeleteOption(*it);
|
||||
myPlaylist->Main()->DeleteOption(*it);
|
||||
}
|
||||
ShowMessage("Selected items deleted!");
|
||||
// redraw_screen = 1;
|
||||
@@ -819,20 +819,20 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
dont_change_now_playing = 1;
|
||||
mPlaylist->SetTimeout(50);
|
||||
while (!mPlaylist->Empty() && Keypressed(input, Key.Delete))
|
||||
myPlaylist->Main()->SetTimeout(50);
|
||||
while (!myPlaylist->Main()->Empty() && Keypressed(input, Key.Delete))
|
||||
{
|
||||
size_t id = mPlaylist->Choice();
|
||||
size_t id = myPlaylist->Main()->Choice();
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
if (size_t(now_playing) > id) // needed for keeping proper
|
||||
now_playing--; // position of now playing song.
|
||||
Mpd->QueueDeleteSong(id);
|
||||
mPlaylist->DeleteOption(id);
|
||||
mPlaylist->Refresh();
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->DeleteOption(id);
|
||||
myPlaylist->Main()->Refresh();
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
}
|
||||
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||
myPlaylist->Main()->SetTimeout(ncmpcpp_window_timeout);
|
||||
dont_change_now_playing = 0;
|
||||
}
|
||||
Mpd->CommitQueue();
|
||||
@@ -969,18 +969,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.MvSongUp))
|
||||
{
|
||||
if (current_screen == csPlaylist && !mPlaylist->Empty())
|
||||
if (current_screen == csPlaylist && !myPlaylist->Main()->Empty())
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
mPlaylist->SetTimeout(50);
|
||||
if (mPlaylist->hasSelected())
|
||||
myPlaylist->Main()->SetTimeout(50);
|
||||
if (myPlaylist->Main()->hasSelected())
|
||||
{
|
||||
vector<size_t> list;
|
||||
mPlaylist->GetSelected(list);
|
||||
myPlaylist->Main()->GetSelected(list);
|
||||
|
||||
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
||||
if (*it == size_t(now_playing) && list.front() > 0)
|
||||
mPlaylist->BoldOption(now_playing, 0);
|
||||
myPlaylist->Main()->BoldOption(now_playing, 0);
|
||||
|
||||
vector<size_t> origs(list);
|
||||
|
||||
@@ -991,11 +991,11 @@ int main(int argc, char *argv[])
|
||||
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
(*it)--;
|
||||
mPlaylist->Swap(*it, (*it)+1);
|
||||
myPlaylist->Main()->Swap(*it, (*it)+1);
|
||||
}
|
||||
mPlaylist->Highlight(list[(list.size()-1)/2]);
|
||||
mPlaylist->Refresh();
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->Highlight(list[(list.size()-1)/2]);
|
||||
myPlaylist->Main()->Refresh();
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
}
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
Mpd->QueueMove(origs[i], list[i]);
|
||||
@@ -1004,23 +1004,23 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
size_t from, to;
|
||||
from = to = mPlaylist->Choice();
|
||||
from = to = myPlaylist->Main()->Choice();
|
||||
// unbold now playing as if song changes during move, this won't be unbolded.
|
||||
if (to == size_t(now_playing) && to > 0)
|
||||
mPlaylist->BoldOption(now_playing, 0);
|
||||
myPlaylist->Main()->BoldOption(now_playing, 0);
|
||||
while (Keypressed(input, Key.MvSongUp) && to > 0)
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
to--;
|
||||
mPlaylist->Swap(to, to+1);
|
||||
mPlaylist->Scroll(wUp);
|
||||
mPlaylist->Refresh();
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->Swap(to, to+1);
|
||||
myPlaylist->Main()->Scroll(wUp);
|
||||
myPlaylist->Main()->Refresh();
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
}
|
||||
Mpd->Move(from, to);
|
||||
}
|
||||
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||
myPlaylist->Main()->SetTimeout(ncmpcpp_window_timeout);
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||
{
|
||||
@@ -1072,33 +1072,33 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.MvSongDown))
|
||||
{
|
||||
if (current_screen == csPlaylist && !mPlaylist->Empty())
|
||||
if (current_screen == csPlaylist && !myPlaylist->Main()->Empty())
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
mPlaylist->SetTimeout(50);
|
||||
if (mPlaylist->hasSelected())
|
||||
myPlaylist->Main()->SetTimeout(50);
|
||||
if (myPlaylist->Main()->hasSelected())
|
||||
{
|
||||
vector<size_t> list;
|
||||
mPlaylist->GetSelected(list);
|
||||
myPlaylist->Main()->GetSelected(list);
|
||||
|
||||
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
||||
if (*it == size_t(now_playing) && list.back() < mPlaylist->Size()-1)
|
||||
mPlaylist->BoldOption(now_playing, 0);
|
||||
if (*it == size_t(now_playing) && list.back() < myPlaylist->Main()->Size()-1)
|
||||
myPlaylist->Main()->BoldOption(now_playing, 0);
|
||||
|
||||
vector<size_t> origs(list);
|
||||
|
||||
while (Keypressed(input, Key.MvSongDown) && list.back() < mPlaylist->Size()-1)
|
||||
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1)
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
||||
{
|
||||
(*it)++;
|
||||
mPlaylist->Swap(*it, (*it)-1);
|
||||
myPlaylist->Main()->Swap(*it, (*it)-1);
|
||||
}
|
||||
mPlaylist->Highlight(list[(list.size()-1)/2]);
|
||||
mPlaylist->Refresh();
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->Highlight(list[(list.size()-1)/2]);
|
||||
myPlaylist->Main()->Refresh();
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
}
|
||||
for (int i = list.size()-1; i >= 0; i--)
|
||||
Mpd->QueueMove(origs[i], list[i]);
|
||||
@@ -1107,23 +1107,23 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
size_t from, to;
|
||||
from = to = mPlaylist->Choice();
|
||||
from = to = myPlaylist->Main()->Choice();
|
||||
// unbold now playing as if song changes during move, this won't be unbolded.
|
||||
if (to == size_t(now_playing) && to < mPlaylist->Size()-1)
|
||||
mPlaylist->BoldOption(now_playing, 0);
|
||||
while (Keypressed(input, Key.MvSongDown) && to < mPlaylist->Size()-1)
|
||||
if (to == size_t(now_playing) && to < myPlaylist->Main()->Size()-1)
|
||||
myPlaylist->Main()->BoldOption(now_playing, 0);
|
||||
while (Keypressed(input, Key.MvSongDown) && to < myPlaylist->Main()->Size()-1)
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
to++;
|
||||
mPlaylist->Swap(to, to-1);
|
||||
mPlaylist->Scroll(wDown);
|
||||
mPlaylist->Refresh();
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->Swap(to, to-1);
|
||||
myPlaylist->Main()->Scroll(wDown);
|
||||
myPlaylist->Main()->Refresh();
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
}
|
||||
Mpd->Move(from, to);
|
||||
}
|
||||
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||
myPlaylist->Main()->SetTimeout(ncmpcpp_window_timeout);
|
||||
|
||||
}
|
||||
else if (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||
@@ -1190,7 +1190,7 @@ int main(int argc, char *argv[])
|
||||
Mpd->QueueAddSong(**it);
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
Song &s = mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s.GetHash() != list[0]->GetHash())
|
||||
ShowMessage("%s", message_part_of_songs_added);
|
||||
}
|
||||
@@ -1204,7 +1204,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (now_playing < 0)
|
||||
continue;
|
||||
if (!mPlaylist->at(now_playing).GetTotalLength())
|
||||
if (!myPlaylist->Main()->at(now_playing).GetTotalLength())
|
||||
{
|
||||
ShowMessage("Unknown item length!");
|
||||
continue;
|
||||
@@ -1216,13 +1216,13 @@ int main(int argc, char *argv[])
|
||||
time_t t = time(NULL);
|
||||
|
||||
songpos = Mpd->GetElapsedTime();
|
||||
Song &s = mPlaylist->at(now_playing);
|
||||
Song &s = myPlaylist->Main()->at(now_playing);
|
||||
|
||||
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
mPlaylist->ReadKey(input);
|
||||
myPlaylist->Main()->ReadKey(input);
|
||||
|
||||
int howmuch = Config.incremental_seeking ? (timer-t)/2+Config.seek_time : Config.seek_time;
|
||||
|
||||
@@ -1258,13 +1258,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleDisplayMode))
|
||||
{
|
||||
if (wCurrent == mPlaylist)
|
||||
if (wCurrent == myPlaylist->Main())
|
||||
{
|
||||
Config.columns_in_playlist = !Config.columns_in_playlist;
|
||||
ShowMessage("Playlist display mode: %s", Config.columns_in_playlist ? "Columns" : "Classic");
|
||||
mPlaylist->SetItemDisplayer(Config.columns_in_playlist ? Display::SongsInColumns : Display::Songs);
|
||||
mPlaylist->SetItemDisplayerUserData(Config.columns_in_playlist ? &Config.song_columns_list_format : &Config.song_list_format);
|
||||
mPlaylist->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
||||
myPlaylist->Main()->SetItemDisplayer(Config.columns_in_playlist ? Display::SongsInColumns : Display::Songs);
|
||||
myPlaylist->Main()->SetItemDisplayerUserData(Config.columns_in_playlist ? &Config.song_columns_list_format : &Config.song_list_format);
|
||||
myPlaylist->Main()->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
||||
}
|
||||
else if (wCurrent == mBrowser)
|
||||
{
|
||||
@@ -1297,7 +1297,7 @@ int main(int argc, char *argv[])
|
||||
Config.autocenter_mode = !Config.autocenter_mode;
|
||||
ShowMessage("Auto center mode: %s", Config.autocenter_mode ? "On" : "Off");
|
||||
if (Config.autocenter_mode && now_playing >= 0)
|
||||
mPlaylist->Highlight(now_playing);
|
||||
myPlaylist->Main()->Highlight(now_playing);
|
||||
}
|
||||
else if (Keypressed(input, Key.UpdateDB))
|
||||
{
|
||||
@@ -1313,7 +1313,7 @@ int main(int argc, char *argv[])
|
||||
else if (Keypressed(input, Key.GoToNowPlaying))
|
||||
{
|
||||
if (current_screen == csPlaylist && now_playing >= 0)
|
||||
mPlaylist->Highlight(now_playing);
|
||||
myPlaylist->Main()->Highlight(now_playing);
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleRepeat))
|
||||
{
|
||||
@@ -1429,7 +1429,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(wCurrent == mPlaylist && !mPlaylist->Empty())
|
||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||
|| (wCurrent == mBrowser && mBrowser->Current().type == itSong)
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||
@@ -1441,7 +1441,7 @@ int main(int argc, char *argv[])
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
edited_song = mPlaylist->at(id);
|
||||
edited_song = myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
edited_song = *mBrowser->at(id).song;
|
||||
@@ -1554,7 +1554,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.GoToContainingDir))
|
||||
{
|
||||
if ((wCurrent == mPlaylist && !mPlaylist->Empty())
|
||||
if ((wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||
@@ -1568,7 +1568,7 @@ int main(int argc, char *argv[])
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &mPlaylist->at(id);
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csSearcher:
|
||||
s = mSearcher->at(id).second;
|
||||
@@ -1622,7 +1622,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (now_playing < 0)
|
||||
continue;
|
||||
if (!mPlaylist->at(now_playing).GetTotalLength())
|
||||
if (!myPlaylist->Main()->at(now_playing).GetTotalLength())
|
||||
{
|
||||
ShowMessage("Unknown item length!");
|
||||
continue;
|
||||
@@ -1632,12 +1632,12 @@ int main(int argc, char *argv[])
|
||||
string position = wFooter->GetString(3);
|
||||
int newpos = StrToInt(position);
|
||||
if (newpos > 0 && newpos < 100 && !position.empty())
|
||||
Mpd->Seek(mPlaylist->at(now_playing).GetTotalLength()*newpos/100.0);
|
||||
Mpd->Seek(myPlaylist->Main()->at(now_playing).GetTotalLength()*newpos/100.0);
|
||||
UnlockStatusbar();
|
||||
}
|
||||
else if (Keypressed(input, Key.ReverseSelection))
|
||||
{
|
||||
if (wCurrent == mPlaylist
|
||||
if (wCurrent == myPlaylist->Main()
|
||||
|| wCurrent == mBrowser
|
||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
||||
|| wCurrent == mLibSongs
|
||||
@@ -1662,7 +1662,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.DeselectAll))
|
||||
{
|
||||
if (wCurrent == mPlaylist
|
||||
if (wCurrent == myPlaylist->Main()
|
||||
|| wCurrent == mBrowser
|
||||
|| wCurrent == mSearcher
|
||||
|| wCurrent == mLibSongs
|
||||
@@ -1683,7 +1683,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.AddSelected))
|
||||
{
|
||||
if (wCurrent != mPlaylist
|
||||
if (wCurrent != myPlaylist->Main()
|
||||
&& wCurrent != mBrowser
|
||||
&& wCurrent != mSearcher
|
||||
&& wCurrent != mLibSongs
|
||||
@@ -1706,7 +1706,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
case csPlaylist:
|
||||
{
|
||||
Song *s = new Song(mPlaylist->at(*it));
|
||||
Song *s = new Song(myPlaylist->Main()->at(*it));
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
@@ -1829,7 +1829,7 @@ int main(int argc, char *argv[])
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Selected items added!");
|
||||
Song &s = mPlaylist->at(mPlaylist->Size()-result.size());
|
||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-result.size());
|
||||
if (s.GetHash() != result[0]->GetHash())
|
||||
ShowMessage("%s", message_part_of_songs_added);
|
||||
}
|
||||
@@ -1873,17 +1873,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.Crop))
|
||||
{
|
||||
if (mPlaylist->hasSelected())
|
||||
if (myPlaylist->Main()->hasSelected())
|
||||
{
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (!mPlaylist->isSelected(i) && i != size_t(now_playing))
|
||||
Mpd->QueueDeleteSongId(mPlaylist->at(i).GetID());
|
||||
if (!myPlaylist->Main()->isSelected(i) && i != size_t(now_playing))
|
||||
Mpd->QueueDeleteSongId(myPlaylist->Main()->at(i).GetID());
|
||||
}
|
||||
// if mpd deletes now playing song deletion will be sluggishly slow
|
||||
// then so we have to assure it will be deleted at the very end.
|
||||
if (now_playing >= 0 && !mPlaylist->isSelected(now_playing))
|
||||
Mpd->QueueDeleteSongId(mPlaylist->at(now_playing).GetID());
|
||||
if (now_playing >= 0 && !myPlaylist->Main()->isSelected(now_playing))
|
||||
Mpd->QueueDeleteSongId(myPlaylist->Main()->at(now_playing).GetID());
|
||||
|
||||
ShowMessage("Deleting all items but selected...");
|
||||
Mpd->CommitQueue();
|
||||
@@ -1897,9 +1897,9 @@ int main(int argc, char *argv[])
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < now_playing; i++)
|
||||
Mpd->QueueDeleteSongId(mPlaylist->at(i).GetID());
|
||||
for (size_t i = now_playing+1; i < mPlaylist->Size(); i++)
|
||||
Mpd->QueueDeleteSongId(mPlaylist->at(i).GetID());
|
||||
Mpd->QueueDeleteSongId(myPlaylist->Main()->at(i).GetID());
|
||||
for (size_t i = now_playing+1; i < myPlaylist->Main()->Size(); i++)
|
||||
Mpd->QueueDeleteSongId(myPlaylist->Main()->at(i).GetID());
|
||||
ShowMessage("Deleting all items except now playing one...");
|
||||
Mpd->CommitQueue();
|
||||
ShowMessage("Items deleted!");
|
||||
@@ -1945,7 +1945,7 @@ int main(int argc, char *argv[])
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
name = mPlaylist->at(i).toString(Config.song_list_format);
|
||||
name = myPlaylist->Main()->at(i).toString(Config.song_list_format);
|
||||
break;
|
||||
case csBrowser:
|
||||
switch (mBrowser->at(i).type)
|
||||
@@ -2060,10 +2060,10 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
mList->Highlight(vFoundPositions[found_pos < 0 ? 0 : found_pos]);
|
||||
if (wCurrent == mPlaylist)
|
||||
if (wCurrent == myPlaylist->Main())
|
||||
{
|
||||
timer = time(NULL);
|
||||
mPlaylist->Highlighting(1);
|
||||
myPlaylist->Main()->Highlighting(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2174,11 +2174,11 @@ int main(int argc, char *argv[])
|
||||
if (current_screen == csPlaylist)
|
||||
Browser::SwitchTo();
|
||||
else
|
||||
Playlist::SwitchTo();
|
||||
myPlaylist->SwitchTo();
|
||||
}
|
||||
else if (Keypressed(input, Key.Playlist))
|
||||
{
|
||||
Playlist::SwitchTo();
|
||||
myPlaylist->SwitchTo();
|
||||
}
|
||||
else if (Keypressed(input, Key.Browser))
|
||||
{
|
||||
|
||||
@@ -26,23 +26,17 @@
|
||||
|
||||
using namespace Global;
|
||||
|
||||
Menu<MPD::Song> *Global::mPlaylist;
|
||||
Playlist *myPlaylist = new Playlist;
|
||||
|
||||
void Playlist::Init()
|
||||
{
|
||||
mPlaylist = new Menu<MPD::Song>(0, main_start_y, COLS, main_height, Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "", Config.main_color, brNone);
|
||||
mPlaylist->SetTimeout(ncmpcpp_window_timeout);
|
||||
mPlaylist->HighlightColor(Config.main_highlight_color);
|
||||
mPlaylist->SetSelectPrefix(&Config.selected_item_prefix);
|
||||
mPlaylist->SetSelectSuffix(&Config.selected_item_suffix);
|
||||
mPlaylist->SetItemDisplayer(Config.columns_in_playlist ? Display::SongsInColumns : Display::Songs);
|
||||
mPlaylist->SetItemDisplayerUserData(Config.columns_in_playlist ? &Config.song_columns_list_format : &Config.song_list_format);
|
||||
}
|
||||
|
||||
void Playlist::Resize()
|
||||
{
|
||||
mPlaylist->Resize(COLS, main_height);
|
||||
mPlaylist->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
||||
w = new Menu<MPD::Song>(0, main_start_y, COLS, main_height, Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "", Config.main_color, brNone);
|
||||
w->SetTimeout(ncmpcpp_window_timeout);
|
||||
w->HighlightColor(Config.main_highlight_color);
|
||||
w->SetSelectPrefix(&Config.selected_item_prefix);
|
||||
w->SetSelectSuffix(&Config.selected_item_suffix);
|
||||
w->SetItemDisplayer(Config.columns_in_playlist ? Display::SongsInColumns : Display::Songs);
|
||||
w->SetItemDisplayerUserData(Config.columns_in_playlist ? &Config.song_columns_list_format : &Config.song_list_format);
|
||||
}
|
||||
|
||||
void Playlist::SwitchTo()
|
||||
@@ -54,7 +48,7 @@ void Playlist::SwitchTo()
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
wCurrent = mPlaylist;
|
||||
wCurrent = w;
|
||||
wCurrent->Hide();
|
||||
current_screen = csPlaylist;
|
||||
// redraw_screen = 1;
|
||||
@@ -62,3 +56,29 @@ void Playlist::SwitchTo()
|
||||
}
|
||||
}
|
||||
|
||||
void Playlist::Resize()
|
||||
{
|
||||
w->Resize(COLS, main_height);
|
||||
w->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
||||
}
|
||||
|
||||
const char *Playlist::Title()
|
||||
{
|
||||
return "Playlist ";
|
||||
}
|
||||
|
||||
void Playlist::SpacePressed()
|
||||
{
|
||||
if (w->Empty())
|
||||
return;
|
||||
size_t i = w->Choice();
|
||||
w->Select(i, !w->isSelected(i));
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
void Playlist::EnterPressed()
|
||||
{
|
||||
if (!w->Empty())
|
||||
Mpd->PlayID(w->Current().GetID());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,24 @@
|
||||
#ifndef _PLAYLIST_H
|
||||
#define _PLAYLIST_H
|
||||
|
||||
namespace Playlist
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
class Playlist : public Screen< Menu<MPD::Song> >
|
||||
{
|
||||
void Init();
|
||||
void Resize();
|
||||
void SwitchTo();
|
||||
}
|
||||
public:
|
||||
virtual void Init();
|
||||
virtual void SwitchTo();
|
||||
virtual void Resize();
|
||||
|
||||
virtual const char *Title();
|
||||
|
||||
virtual void EnterPressed();
|
||||
virtual void SpacePressed();
|
||||
};
|
||||
|
||||
extern Playlist *myPlaylist;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "playlist_editor.h"
|
||||
#include "mpdpp.h"
|
||||
#include "status_checker.h"
|
||||
@@ -94,7 +95,7 @@ void PlaylistEditor::SwitchTo()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
mPlaylist->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
myPlaylist->Main()->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
@@ -136,9 +137,9 @@ void PlaylistEditor::Update()
|
||||
bool bold = 0;
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
for (size_t j = 0; j < mPlaylist->Size(); j++)
|
||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||
{
|
||||
if ((*it)->GetHash() == mPlaylist->at(j).GetHash())
|
||||
if ((*it)->GetHash() == myPlaylist->Main()->at(j).GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
@@ -178,7 +179,7 @@ void PlaylistEditor::EnterPressed(bool add_n_play)
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
ShowMessage("Loading playlist %s...", mPlaylistList->Current().c_str());
|
||||
Song &s = mPlaylist->at(mPlaylist->Size()-list.size());
|
||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
|
||||
if (s.GetHash() == list[0]->GetHash())
|
||||
{
|
||||
if (add_n_play)
|
||||
@@ -198,9 +199,9 @@ void PlaylistEditor::EnterPressed(bool add_n_play)
|
||||
long long hash = mPlaylistEditor->Current().GetHash();
|
||||
if (add_n_play)
|
||||
{
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->Play(i);
|
||||
break;
|
||||
@@ -210,12 +211,12 @@ void PlaylistEditor::EnterPressed(bool add_n_play)
|
||||
else
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->QueueDeleteSong(i);
|
||||
mPlaylist->DeleteOption(i);
|
||||
myPlaylist->Main()->DeleteOption(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "search_engine.h"
|
||||
#include "settings.h"
|
||||
#include "status_checker.h"
|
||||
@@ -219,9 +220,9 @@ void SearchEngine::EnterPressed()
|
||||
if (Config.ncmpc_like_songs_adding && mSearcher->isBold())
|
||||
{
|
||||
long long hash = mSearcher->Current().second->GetHash();
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->Play(i);
|
||||
break;
|
||||
@@ -255,12 +256,12 @@ void SearchEngine::SpacePressed()
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
long long hash = mSearcher->Current().second->GetHash();
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (mPlaylist->at(i).GetHash() == hash)
|
||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||
{
|
||||
Mpd->QueueDeleteSong(i);
|
||||
mPlaylist->DeleteOption(i);
|
||||
myPlaylist->Main()->DeleteOption(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
@@ -284,9 +285,9 @@ void UpdateFoundList()
|
||||
bool bold = 0;
|
||||
for (size_t i = search_engine_static_options; i < mSearcher->Size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < mPlaylist->Size(); j++)
|
||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||
{
|
||||
if (mPlaylist->at(j).GetHash() == mSearcher->at(i).second->GetHash())
|
||||
if (myPlaylist->Main()->at(j).GetHash() == mSearcher->at(i).second->GetHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
@@ -360,9 +361,9 @@ void Search()
|
||||
Mpd->GetDirectoryRecursive("/", list);
|
||||
else
|
||||
{
|
||||
list.reserve(mPlaylist->Size());
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
list.push_back(&(*mPlaylist)[i]);
|
||||
list.reserve(myPlaylist->Main()->Size());
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
list.push_back(&(*myPlaylist->Main())[i]);
|
||||
}
|
||||
|
||||
bool any_found = 1;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "charset.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "search_engine.h"
|
||||
#include "settings.h"
|
||||
#include "status_checker.h"
|
||||
@@ -86,7 +87,7 @@ void TraceMpdStatus()
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (current_screen == csPlaylist && now == timer+Config.playlist_disable_highlight_delay)
|
||||
mPlaylist->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||
myPlaylist->Main()->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||
|
||||
if (lock_statusbar_delay > 0)
|
||||
{
|
||||
@@ -148,8 +149,8 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
now_playing = Mpd->GetCurrentSongPos();
|
||||
try
|
||||
{
|
||||
mPlaylist->BoldOption(old_playing, 0);
|
||||
mPlaylist->BoldOption(now_playing, 1);
|
||||
myPlaylist->Main()->BoldOption(old_playing, 0);
|
||||
myPlaylist->Main()->BoldOption(now_playing, 1);
|
||||
}
|
||||
catch (std::out_of_range) { }
|
||||
}
|
||||
@@ -160,51 +161,51 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
{
|
||||
SongList list;
|
||||
size_t playlist_length = Mpd->GetPlaylistLength();
|
||||
if (playlist_length != mPlaylist->Size())
|
||||
if (playlist_length != myPlaylist->Main()->Size())
|
||||
{
|
||||
if (playlist_length < mPlaylist->Size())
|
||||
if (playlist_length < myPlaylist->Main()->Size())
|
||||
{
|
||||
mPlaylist->Clear(playlist_length < mPlaylist->GetHeight() && current_screen == csPlaylist);
|
||||
myPlaylist->Main()->Clear(playlist_length < myPlaylist->Main()->GetHeight() && current_screen == csPlaylist);
|
||||
Mpd->GetPlaylistChanges(-1, list);
|
||||
}
|
||||
else
|
||||
Mpd->GetPlaylistChanges(Mpd->GetOldPlaylistID(), list);
|
||||
|
||||
mPlaylist->Reserve(playlist_length);
|
||||
myPlaylist->Main()->Reserve(playlist_length);
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
int pos = (*it)->GetPosition();
|
||||
if (pos < int(mPlaylist->Size()))
|
||||
if (pos < int(myPlaylist->Main()->Size()))
|
||||
{
|
||||
// if song's already in playlist, replace it with a new one
|
||||
mPlaylist->at(pos) = **it;
|
||||
myPlaylist->Main()->at(pos) = **it;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just add it to playlist
|
||||
mPlaylist->AddOption(**it, now_playing == pos);
|
||||
myPlaylist->Main()->AddOption(**it, now_playing == pos);
|
||||
}
|
||||
mPlaylist->at(pos).CopyPtr(0);
|
||||
myPlaylist->Main()->at(pos).CopyPtr(0);
|
||||
(*it)->NullMe();
|
||||
}
|
||||
|
||||
if (current_screen == csPlaylist)
|
||||
{
|
||||
if (!playlist_length || mPlaylist->Size() < mPlaylist->GetHeight())
|
||||
mPlaylist->Window::Clear();
|
||||
mPlaylist->Refresh();
|
||||
if (!playlist_length || myPlaylist->Main()->Size() < myPlaylist->Main()->GetHeight())
|
||||
myPlaylist->Main()->Window::Clear();
|
||||
myPlaylist->Main()->Refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Mpd->GetPlaylistChanges(-1, list);
|
||||
|
||||
for (size_t i = 0; i < mPlaylist->Size(); i++)
|
||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||
{
|
||||
if (*list[i] != mPlaylist->at(i))
|
||||
if (*list[i] != myPlaylist->Main()->at(i))
|
||||
{
|
||||
mPlaylist->at(i) = *list[i];
|
||||
mPlaylist->at(i).CopyPtr(0);
|
||||
myPlaylist->Main()->at(i) = *list[i];
|
||||
myPlaylist->Main()->at(i).CopyPtr(0);
|
||||
list[i]->NullMe();
|
||||
}
|
||||
}
|
||||
@@ -215,9 +216,9 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
if (current_screen == csPlaylist)
|
||||
redraw_header = 1;
|
||||
|
||||
if (mPlaylist->Empty())
|
||||
if (myPlaylist->Main()->Empty())
|
||||
{
|
||||
mPlaylist->Reset();
|
||||
myPlaylist->Main()->Reset();
|
||||
ShowMessage("Cleared playlist!");
|
||||
}
|
||||
|
||||
@@ -264,7 +265,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
case psPlay:
|
||||
{
|
||||
player_state = "Playing: ";
|
||||
mPlaylist->BoldOption(now_playing, 1);
|
||||
myPlaylist->Main()->BoldOption(now_playing, 1);
|
||||
changed.ElapsedTime = 1;
|
||||
break;
|
||||
}
|
||||
@@ -281,7 +282,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
wFooter->SetColor(Config.statusbar_color);
|
||||
try
|
||||
{
|
||||
mPlaylist->BoldOption(old_playing, 0);
|
||||
myPlaylist->Main()->BoldOption(old_playing, 0);
|
||||
}
|
||||
catch (std::out_of_range) { }
|
||||
now_playing = -1;
|
||||
@@ -294,7 +295,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
}
|
||||
if (changed.SongID)
|
||||
{
|
||||
if (!mPlaylist->Empty() && now_playing >= 0)
|
||||
if (!myPlaylist->Main()->Empty() && now_playing >= 0)
|
||||
{
|
||||
if (Config.repeat_one_mode && repeat_one_allowed)
|
||||
{
|
||||
@@ -303,12 +304,12 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
}
|
||||
try
|
||||
{
|
||||
mPlaylist->BoldOption(old_playing, 0);
|
||||
myPlaylist->Main()->BoldOption(old_playing, 0);
|
||||
}
|
||||
catch (std::out_of_range &) { }
|
||||
mPlaylist->BoldOption(now_playing, 1);
|
||||
myPlaylist->Main()->BoldOption(now_playing, 1);
|
||||
if (Config.autocenter_mode)
|
||||
mPlaylist->Highlight(now_playing);
|
||||
myPlaylist->Main()->Highlight(now_playing);
|
||||
repeat_one_allowed = 0;
|
||||
|
||||
if (!Mpd->GetElapsedTime())
|
||||
@@ -453,7 +454,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
wHeader->Refresh();
|
||||
}
|
||||
if (current_screen == csPlaylist)
|
||||
mPlaylist->Refresh();
|
||||
myPlaylist->Main()->Refresh();
|
||||
wFooter->Bold(0);
|
||||
wFooter->GotoXY(sx, sy);
|
||||
wFooter->Refresh();
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "media_library.h"
|
||||
#include "playlist.h"
|
||||
#include "playlist_editor.h"
|
||||
#include "status_checker.h"
|
||||
|
||||
@@ -163,8 +164,8 @@ void TinyTagEditor::EnterPressed(Song &s)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wPrev == mPlaylist)
|
||||
mPlaylist->Current() = s;
|
||||
if (wPrev == myPlaylist->Main())
|
||||
myPlaylist->Main()->Current() = s;
|
||||
else if (wPrev == mBrowser)
|
||||
*mBrowser->Current().song = s;
|
||||
}
|
||||
@@ -270,7 +271,7 @@ void TagEditor::SwitchTo()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
mPlaylist->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
myPlaylist->Main()->Hide(); // hack, should be wCurrent, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
@@ -957,17 +958,17 @@ bool WriteTags(Song &s)
|
||||
locale_to_utf(new_name);
|
||||
if (rename(path_to_file.c_str(), new_name.c_str()) == 0 && !file_is_from_db)
|
||||
{
|
||||
if (wPrev == mPlaylist)
|
||||
if (wPrev == myPlaylist->Main())
|
||||
{
|
||||
// if we rename local file, it won't get updated
|
||||
// so just remove it from playlist and add again
|
||||
size_t pos = mPlaylist->Choice();
|
||||
size_t pos = myPlaylist->Main()->Choice();
|
||||
Mpd->QueueDeleteSong(pos);
|
||||
Mpd->CommitQueue();
|
||||
int id = Mpd->AddSong("file://" + new_name);
|
||||
if (id >= 0)
|
||||
{
|
||||
s = mPlaylist->Back();
|
||||
s = myPlaylist->Main()->Back();
|
||||
Mpd->Move(s.GetPosition(), pos);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user