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