get rid of this awful casting to List *
This commit is contained in:
@@ -42,9 +42,10 @@ class Browser : public Screen< Menu<MPD::Item> >
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return true; }
|
virtual bool allowsSelection() { return true; }
|
||||||
virtual void ReverseSelection();
|
virtual void ReverseSelection();
|
||||||
virtual bool Deselect() { return w->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList() { return w; }
|
||||||
|
|
||||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||||
|
|
||||||
void GetDirectory(std::string, std::string = "/");
|
void GetDirectory(std::string, std::string = "/");
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ class Clock : public Screen<Window>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return false; }
|
virtual bool allowsSelection() { return false; }
|
||||||
|
|
||||||
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void Prepare();
|
static void Prepare();
|
||||||
static void Set(int, int);
|
static void Set(int, int);
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class Help : public Screen<Scrollpad>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return false; }
|
virtual bool allowsSelection() { return false; }
|
||||||
|
|
||||||
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string DisplayKeys(int *, int = 2);
|
std::string DisplayKeys(int *, int = 2);
|
||||||
void GetKeybindings();
|
void GetKeybindings();
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class Info : public Screen<Scrollpad>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return false; }
|
virtual bool allowsSelection() { return false; }
|
||||||
|
|
||||||
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
void GetSong();
|
void GetSong();
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
void GetArtist();
|
void GetArtist();
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return false; }
|
virtual bool allowsSelection() { return false; }
|
||||||
|
|
||||||
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
static bool Reload;
|
static bool Reload;
|
||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
|
|||||||
@@ -256,6 +256,18 @@ MPD::Song *MediaLibrary::CurrentSong()
|
|||||||
return w == Songs && !Songs->Empty() ? &Songs->Current() : 0;
|
return w == Songs && !Songs->Empty() ? &Songs->Current() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List *MediaLibrary::GetList()
|
||||||
|
{
|
||||||
|
if (w == Artists)
|
||||||
|
return Artists;
|
||||||
|
else if (w == Albums)
|
||||||
|
return Albums;
|
||||||
|
else if (w == Songs)
|
||||||
|
return Songs;
|
||||||
|
else // silence compiler
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MediaLibrary::GetSelectedSongs(MPD::SongList &v)
|
void MediaLibrary::GetSelectedSongs(MPD::SongList &v)
|
||||||
{
|
{
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ class MediaLibrary : public Screen<Window>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return w == Songs; }
|
virtual bool allowsSelection() { return w == Songs; }
|
||||||
virtual void ReverseSelection() { Songs->ReverseSelection(); }
|
virtual void ReverseSelection() { Songs->ReverseSelection(); }
|
||||||
virtual bool Deselect() { return Songs->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList();
|
||||||
|
|
||||||
void NextColumn();
|
void NextColumn();
|
||||||
void PrevColumn();
|
void PrevColumn();
|
||||||
|
|
||||||
|
|||||||
106
src/ncmpcpp.cpp
106
src/ncmpcpp.cpp
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
myLibrary->Songs->Clear(0);
|
myLibrary->Songs->Clear(0);
|
||||||
}
|
}
|
||||||
else if (myScreen->Cmp() == myPlaylistEditor->List)
|
else if (myScreen->Cmp() == myPlaylistEditor->Playlists)
|
||||||
{
|
{
|
||||||
myPlaylistEditor->Content->Clear(0);
|
myPlaylistEditor->Content->Clear(0);
|
||||||
}
|
}
|
||||||
@@ -468,10 +468,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
}
|
}
|
||||||
else if (myScreen == myBrowser || myScreen->Cmp() == myPlaylistEditor->List)
|
else if (myScreen == myBrowser || myScreen->Cmp() == myPlaylistEditor->Playlists)
|
||||||
{
|
{
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
string name = myScreen == myBrowser ? myBrowser->Main()->Current().name : myPlaylistEditor->List->Current();
|
string name = myScreen == myBrowser ? myBrowser->Main()->Current().name : myPlaylistEditor->Playlists->Current();
|
||||||
if (myScreen != myBrowser || myBrowser->Main()->Current().type == itPlaylist)
|
if (myScreen != myBrowser || myBrowser->Main()->Current().type == itPlaylist)
|
||||||
{
|
{
|
||||||
Statusbar() << "Delete playlist " << name << " ? [y/n] ";
|
Statusbar() << "Delete playlist " << name << " ? [y/n] ";
|
||||||
@@ -493,7 +493,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
ShowMessage("Aborted!");
|
ShowMessage("Aborted!");
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
myPlaylistEditor->List->Clear(0); // make playlists list update itself
|
myPlaylistEditor->Playlists->Clear(0); // make playlists list update itself
|
||||||
}
|
}
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
}
|
}
|
||||||
@@ -503,29 +503,29 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
vector<size_t> list;
|
vector<size_t> list;
|
||||||
myPlaylistEditor->Content->GetSelected(list);
|
myPlaylistEditor->Content->GetSelected(list);
|
||||||
locale_to_utf(myPlaylistEditor->List->Current());
|
locale_to_utf(myPlaylistEditor->Playlists->Current());
|
||||||
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->QueueDeleteFromPlaylist(myPlaylistEditor->List->Current(), *it);
|
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->Playlists->Current(), *it);
|
||||||
myPlaylistEditor->Content->DeleteOption(*it);
|
myPlaylistEditor->Content->DeleteOption(*it);
|
||||||
}
|
}
|
||||||
utf_to_locale(myPlaylistEditor->List->Current());
|
utf_to_locale(myPlaylistEditor->Playlists->Current());
|
||||||
ShowMessage("Selected items deleted from playlist '%s'!", myPlaylistEditor->List->Current().c_str());
|
ShowMessage("Selected items deleted from playlist '%s'!", myPlaylistEditor->Playlists->Current().c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myPlaylistEditor->Content->SetTimeout(50);
|
myPlaylistEditor->Content->SetTimeout(50);
|
||||||
locale_to_utf(myPlaylistEditor->List->Current());
|
locale_to_utf(myPlaylistEditor->Playlists->Current());
|
||||||
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
|
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
timer = time(NULL);
|
timer = time(NULL);
|
||||||
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->List->Current(), myPlaylistEditor->Content->Choice());
|
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice());
|
||||||
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
|
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
|
||||||
myPlaylistEditor->Content->Refresh();
|
myPlaylistEditor->Content->Refresh();
|
||||||
myPlaylistEditor->Content->ReadKey(input);
|
myPlaylistEditor->Content->ReadKey(input);
|
||||||
}
|
}
|
||||||
utf_to_locale(myPlaylistEditor->List->Current());
|
utf_to_locale(myPlaylistEditor->Playlists->Current());
|
||||||
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
@@ -561,7 +561,7 @@ int main(int argc, char *argv[])
|
|||||||
if (Mpd->SavePlaylist(real_playlist_name))
|
if (Mpd->SavePlaylist(real_playlist_name))
|
||||||
{
|
{
|
||||||
ShowMessage("Playlist saved as: %s", playlist_name.c_str());
|
ShowMessage("Playlist saved as: %s", playlist_name.c_str());
|
||||||
myPlaylistEditor->List->Clear(0); // make playlist's list update itself
|
myPlaylistEditor->Playlists->Clear(0); // make playlist's list update itself
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -586,7 +586,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
ShowMessage("Aborted!");
|
ShowMessage("Aborted!");
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
myPlaylistEditor->List->Clear(0); // make playlist's list update itself
|
myPlaylistEditor->Playlists->Clear(0); // make playlist's list update itself
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,7 +677,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i < list.size(); i++)
|
for (size_t i = 0; i < list.size(); i++)
|
||||||
if (origs[i] != list[i])
|
if (origs[i] != list[i])
|
||||||
Mpd->QueueMove(myPlaylistEditor->List->Current(), origs[i], list[i]);
|
Mpd->QueueMove(myPlaylistEditor->Playlists->Current(), origs[i], list[i]);
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
|
|||||||
myPlaylistEditor->Content->ReadKey(input);
|
myPlaylistEditor->Content->ReadKey(input);
|
||||||
}
|
}
|
||||||
if (from != to)
|
if (from != to)
|
||||||
Mpd->Move(myPlaylistEditor->List->Current(), from, to);
|
Mpd->Move(myPlaylistEditor->Playlists->Current(), from, to);
|
||||||
}
|
}
|
||||||
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
@@ -781,7 +781,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
for (int i = list.size()-1; i >= 0; i--)
|
for (int i = list.size()-1; i >= 0; i--)
|
||||||
if (origs[i] != list[i])
|
if (origs[i] != list[i])
|
||||||
Mpd->QueueMove(myPlaylistEditor->List->Current(), origs[i], list[i]);
|
Mpd->QueueMove(myPlaylistEditor->Playlists->Current(), origs[i], list[i]);
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -799,7 +799,7 @@ int main(int argc, char *argv[])
|
|||||||
myPlaylistEditor->Content->ReadKey(input);
|
myPlaylistEditor->Content->ReadKey(input);
|
||||||
}
|
}
|
||||||
if (from != to)
|
if (from != to)
|
||||||
Mpd->Move(myPlaylistEditor->List->Current(), from, to);
|
Mpd->Move(myPlaylistEditor->Playlists->Current(), from, to);
|
||||||
}
|
}
|
||||||
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
@@ -1113,9 +1113,9 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("Cannot rename '%s' to '%s'!", old_dir.c_str(), new_dir.c_str());
|
ShowMessage("Cannot rename '%s' to '%s'!", old_dir.c_str(), new_dir.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (myScreen->Cmp() == myPlaylistEditor->List || (myScreen == myBrowser && myBrowser->Main()->Current().type == itPlaylist))
|
else if (myScreen->Cmp() == myPlaylistEditor->Playlists || (myScreen == myBrowser && myBrowser->Main()->Current().type == itPlaylist))
|
||||||
{
|
{
|
||||||
string old_name = myScreen->Cmp() == myPlaylistEditor->List ? myPlaylistEditor->List->Current() : myBrowser->Main()->Current().name;
|
string old_name = myScreen->Cmp() == myPlaylistEditor->Playlists ? myPlaylistEditor->Playlists->Current() : myBrowser->Main()->Current().name;
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
Statusbar() << fmtBold << "Playlist: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Playlist: " << fmtBoldEnd;
|
||||||
string new_name = wFooter->GetString(old_name);
|
string new_name = wFooter->GetString(old_name);
|
||||||
@@ -1126,7 +1126,7 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("Playlist '%s' renamed to '%s'", old_name.c_str(), new_name.c_str());
|
ShowMessage("Playlist '%s' renamed to '%s'", old_name.c_str(), new_name.c_str());
|
||||||
if (!Config.local_browser)
|
if (!Config.local_browser)
|
||||||
myBrowser->GetDirectory("/");
|
myBrowser->GetDirectory("/");
|
||||||
myPlaylistEditor->List->Clear(0);
|
myPlaylistEditor->Playlists->Clear(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1192,7 +1192,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (myScreen->allowsSelection())
|
if (myScreen->allowsSelection())
|
||||||
{
|
{
|
||||||
if (myScreen->Deselect())
|
if (myScreen->GetList()->Deselect())
|
||||||
{
|
{
|
||||||
ShowMessage("Items deselected!");
|
ShowMessage("Items deselected!");
|
||||||
}
|
}
|
||||||
@@ -1313,7 +1313,7 @@ int main(int argc, char *argv[])
|
|||||||
// refresh playlist's lists
|
// refresh playlist's lists
|
||||||
if (!Config.local_browser && myBrowser->CurrentDir() == "/")
|
if (!Config.local_browser && myBrowser->CurrentDir() == "/")
|
||||||
myBrowser->GetDirectory("/");
|
myBrowser->GetDirectory("/");
|
||||||
myPlaylistEditor->List->Clear(0); // make playlist editor update itself
|
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
|
||||||
}
|
}
|
||||||
timer = time(NULL);
|
timer = time(NULL);
|
||||||
delete mDialog;
|
delete mDialog;
|
||||||
@@ -1360,16 +1360,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward))
|
else if (Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward))
|
||||||
{
|
{
|
||||||
if ((myScreen == myHelp
|
List *mList = myScreen->GetList();
|
||||||
|| myScreen == mySearcher
|
|
||||||
# ifdef HAVE_TAGLIB_H
|
if (!mList)
|
||||||
|| myScreen == myTinyTagEditor
|
|
||||||
|| myScreen->Cmp() == myTagEditor->TagTypes
|
|
||||||
# endif // HAVE_TAGLIB_H
|
|
||||||
)
|
|
||||||
&& (myScreen != mySearcher
|
|
||||||
|| mySearcher->Main()->Current().first)
|
|
||||||
)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string how = Keypressed(input, Key.FindForward) ? "forward" : "backward";
|
string how = Keypressed(input, Key.FindForward) ? "forward" : "backward";
|
||||||
@@ -1385,7 +1378,6 @@ int main(int argc, char *argv[])
|
|||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
|
|
||||||
ShowMessage("Searching...");
|
ShowMessage("Searching...");
|
||||||
List *mList = reinterpret_cast<Menu<Song> *>(myWindow->Main());
|
|
||||||
for (size_t i = (myScreen == mySearcher ? SearchEngine::StaticOptions : 0); i < mList->Size(); i++)
|
for (size_t i = (myScreen == mySearcher ? SearchEngine::StaticOptions : 0); i < mList->Size(); i++)
|
||||||
{
|
{
|
||||||
string name;
|
string name;
|
||||||
@@ -1424,8 +1416,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (myScreen == myPlaylistEditor)
|
else if (myScreen == myPlaylistEditor)
|
||||||
{
|
{
|
||||||
if (myScreen->Cmp() == myPlaylistEditor->List)
|
if (myScreen->Cmp() == myPlaylistEditor->Playlists)
|
||||||
name = myPlaylistEditor->List->at(i);
|
name = myPlaylistEditor->Playlists->at(i);
|
||||||
else
|
else
|
||||||
name = myPlaylistEditor->Content->at(i).toString(Config.song_list_format);
|
name = myPlaylistEditor->Content->at(i).toString(Config.song_list_format);
|
||||||
}
|
}
|
||||||
@@ -1517,32 +1509,34 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
|
else if (Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
|
||||||
{
|
{
|
||||||
if (!vFoundPositions.empty())
|
List *mList = myScreen->GetList();
|
||||||
|
|
||||||
|
if (!mList || vFoundPositions.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool next = Keypressed(input, Key.NextFoundPosition);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List *mList = reinterpret_cast<Menu<Song> *>(myWindow->Main());
|
mList->Highlight(vFoundPositions.at(next ? ++found_pos : --found_pos));
|
||||||
try
|
}
|
||||||
|
catch (std::out_of_range)
|
||||||
|
{
|
||||||
|
if (Config.wrapped_search)
|
||||||
{
|
{
|
||||||
mList->Highlight(vFoundPositions.at(Keypressed(input, Key.NextFoundPosition) ? ++found_pos : --found_pos));
|
if (next)
|
||||||
}
|
|
||||||
catch (std::out_of_range)
|
|
||||||
{
|
|
||||||
if (Config.wrapped_search)
|
|
||||||
{
|
{
|
||||||
|
mList->Highlight(vFoundPositions.front());
|
||||||
if (Keypressed(input, Key.NextFoundPosition))
|
found_pos = 0;
|
||||||
{
|
}
|
||||||
mList->Highlight(vFoundPositions.front());
|
else // prev
|
||||||
found_pos = 0;
|
{
|
||||||
}
|
mList->Highlight(vFoundPositions.back());
|
||||||
else
|
found_pos = vFoundPositions.size()-1;
|
||||||
{
|
|
||||||
mList->Highlight(vFoundPositions.back());
|
|
||||||
found_pos = vFoundPositions.size()-1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
found_pos = Keypressed(input, Key.NextFoundPosition) ? vFoundPositions.size()-1 : 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
found_pos = next ? vFoundPositions.size()-1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.ToggleFindMode))
|
else if (Keypressed(input, Key.ToggleFindMode))
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ class Playlist : public Screen< Menu<MPD::Song> >
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return true; }
|
virtual bool allowsSelection() { return true; }
|
||||||
virtual void ReverseSelection() { w->ReverseSelection(); }
|
virtual void ReverseSelection() { w->ReverseSelection(); }
|
||||||
virtual bool Deselect() { return w->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList() { return w; }
|
||||||
|
|
||||||
bool isPlaying() { return NowPlaying >= 0 && !w->Empty(); }
|
bool isPlaying() { return NowPlaying >= 0 && !w->Empty(); }
|
||||||
const MPD::Song &NowPlayingSong();
|
const MPD::Song &NowPlayingSong();
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ void PlaylistEditor::Init()
|
|||||||
RightColumnStartX = LeftColumnWidth+1;
|
RightColumnStartX = LeftColumnWidth+1;
|
||||||
RightColumnWidth = COLS-LeftColumnWidth-1;
|
RightColumnWidth = COLS-LeftColumnWidth-1;
|
||||||
|
|
||||||
List = new Menu<string>(0, main_start_y, LeftColumnWidth, main_height, "Playlists", Config.main_color, brNone);
|
Playlists = new Menu<string>(0, main_start_y, LeftColumnWidth, main_height, "Playlists", Config.main_color, brNone);
|
||||||
List->HighlightColor(Config.active_column_color);
|
Playlists->HighlightColor(Config.active_column_color);
|
||||||
List->SetTimeout(ncmpcpp_window_timeout);
|
Playlists->SetTimeout(ncmpcpp_window_timeout);
|
||||||
List->SetItemDisplayer(Display::Generic);
|
Playlists->SetItemDisplayer(Display::Generic);
|
||||||
|
|
||||||
Content = new Menu<Song>(RightColumnStartX, main_start_y, RightColumnWidth, main_height, "Playlist's content", Config.main_color, brNone);
|
Content = new Menu<Song>(RightColumnStartX, main_start_y, RightColumnWidth, main_height, "Playlist's content", Config.main_color, brNone);
|
||||||
Content->HighlightColor(Config.main_highlight_color);
|
Content->HighlightColor(Config.main_highlight_color);
|
||||||
@@ -59,7 +59,7 @@ void PlaylistEditor::Init()
|
|||||||
Content->SetItemDisplayer(Display::Songs);
|
Content->SetItemDisplayer(Display::Songs);
|
||||||
Content->SetItemDisplayerUserData(&Config.song_list_format);
|
Content->SetItemDisplayerUserData(&Config.song_list_format);
|
||||||
|
|
||||||
w = List;
|
w = Playlists;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistEditor::Resize()
|
void PlaylistEditor::Resize()
|
||||||
@@ -68,7 +68,7 @@ void PlaylistEditor::Resize()
|
|||||||
RightColumnStartX = LeftColumnWidth+1;
|
RightColumnStartX = LeftColumnWidth+1;
|
||||||
RightColumnWidth = COLS-LeftColumnWidth-1;
|
RightColumnWidth = COLS-LeftColumnWidth-1;
|
||||||
|
|
||||||
List->Resize(LeftColumnWidth, main_height);
|
Playlists->Resize(LeftColumnWidth, main_height);
|
||||||
Content->Resize(RightColumnWidth, main_height);
|
Content->Resize(RightColumnWidth, main_height);
|
||||||
|
|
||||||
Content->MoveTo(RightColumnStartX, main_start_y);
|
Content->MoveTo(RightColumnStartX, main_start_y);
|
||||||
@@ -83,7 +83,7 @@ std::string PlaylistEditor::Title()
|
|||||||
|
|
||||||
void PlaylistEditor::Refresh()
|
void PlaylistEditor::Refresh()
|
||||||
{
|
{
|
||||||
List->Display();
|
Playlists->Display();
|
||||||
mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
|
mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
|
||||||
Content->Display();
|
Content->Display();
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ void PlaylistEditor::SwitchTo()
|
|||||||
|
|
||||||
void PlaylistEditor::Update()
|
void PlaylistEditor::Update()
|
||||||
{
|
{
|
||||||
if (List->Empty())
|
if (Playlists->Empty())
|
||||||
{
|
{
|
||||||
Content->Clear(0);
|
Content->Clear(0);
|
||||||
TagList list;
|
TagList list;
|
||||||
@@ -114,17 +114,17 @@ void PlaylistEditor::Update()
|
|||||||
for (TagList::iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
utf_to_locale(*it);
|
utf_to_locale(*it);
|
||||||
List->AddOption(*it);
|
Playlists->AddOption(*it);
|
||||||
}
|
}
|
||||||
List->Window::Clear();
|
Playlists->Window::Clear();
|
||||||
List->Refresh();
|
Playlists->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!List->Empty() && Content->Empty())
|
if (!Playlists->Empty() && Content->Empty())
|
||||||
{
|
{
|
||||||
Content->Reset();
|
Content->Reset();
|
||||||
SongList list;
|
SongList list;
|
||||||
Mpd->GetPlaylistContent(locale_to_utf_cpy(List->Current()), list);
|
Mpd->GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list);
|
||||||
if (!list.empty())
|
if (!list.empty())
|
||||||
Content->SetTitle("Playlist's content (" + IntoStr(list.size()) + " item" + (list.size() == 1 ? ")" : "s)"));
|
Content->SetTitle("Playlist's content (" + IntoStr(list.size()) + " item" + (list.size() == 1 ? ")" : "s)"));
|
||||||
else
|
else
|
||||||
@@ -151,8 +151,8 @@ void PlaylistEditor::Update()
|
|||||||
if (w == Content && Content->Empty())
|
if (w == Content && Content->Empty())
|
||||||
{
|
{
|
||||||
Content->HighlightColor(Config.main_highlight_color);
|
Content->HighlightColor(Config.main_highlight_color);
|
||||||
List->HighlightColor(Config.active_column_color);
|
Playlists->HighlightColor(Config.active_column_color);
|
||||||
w = List;
|
w = Playlists;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Content->Empty())
|
if (Content->Empty())
|
||||||
@@ -163,10 +163,10 @@ void PlaylistEditor::Update()
|
|||||||
|
|
||||||
void PlaylistEditor::NextColumn()
|
void PlaylistEditor::NextColumn()
|
||||||
{
|
{
|
||||||
if (w == List)
|
if (w == Playlists)
|
||||||
{
|
{
|
||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
List->HighlightColor(Config.main_highlight_color);
|
Playlists->HighlightColor(Config.main_highlight_color);
|
||||||
w->Refresh();
|
w->Refresh();
|
||||||
w = Content;
|
w = Content;
|
||||||
Content->HighlightColor(Config.active_column_color);
|
Content->HighlightColor(Config.active_column_color);
|
||||||
@@ -180,8 +180,8 @@ void PlaylistEditor::PrevColumn()
|
|||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
Content->HighlightColor(Config.main_highlight_color);
|
Content->HighlightColor(Config.main_highlight_color);
|
||||||
w->Refresh();
|
w->Refresh();
|
||||||
w = List;
|
w = Playlists;
|
||||||
List->HighlightColor(Config.active_column_color);
|
Playlists->HighlightColor(Config.active_column_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,14 +189,14 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
|||||||
{
|
{
|
||||||
SongList list;
|
SongList list;
|
||||||
|
|
||||||
if (w == List && !List->Empty())
|
if (w == Playlists && !Playlists->Empty())
|
||||||
{
|
{
|
||||||
Mpd->GetPlaylistContent(locale_to_utf_cpy(List->Current()), list);
|
Mpd->GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list);
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
Mpd->QueueAddSong(**it);
|
Mpd->QueueAddSong(**it);
|
||||||
if (Mpd->CommitQueue())
|
if (Mpd->CommitQueue())
|
||||||
{
|
{
|
||||||
ShowMessage("Loading playlist %s...", List->Current().c_str());
|
ShowMessage("Loading playlist %s...", Playlists->Current().c_str());
|
||||||
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->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())
|
||||||
{
|
{
|
||||||
@@ -287,3 +287,13 @@ void PlaylistEditor::GetSelectedSongs(MPD::SongList &v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List *PlaylistEditor::GetList()
|
||||||
|
{
|
||||||
|
if (w == Playlists)
|
||||||
|
return Playlists;
|
||||||
|
else if (w == Content)
|
||||||
|
return Content;
|
||||||
|
else // silence compiler
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,14 @@ class PlaylistEditor : public Screen<Window>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return w == Content; }
|
virtual bool allowsSelection() { return w == Content; }
|
||||||
virtual void ReverseSelection() { Content->ReverseSelection(); }
|
virtual void ReverseSelection() { Content->ReverseSelection(); }
|
||||||
virtual bool Deselect() { return Content->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList();
|
||||||
|
|
||||||
void NextColumn();
|
void NextColumn();
|
||||||
void PrevColumn();
|
void PrevColumn();
|
||||||
|
|
||||||
Menu<std::string> *List;
|
Menu<std::string> *Playlists;
|
||||||
Menu<MPD::Song> *Content;
|
Menu<MPD::Song> *Content;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ class BasicScreen
|
|||||||
|
|
||||||
virtual bool allowsSelection() = 0;
|
virtual bool allowsSelection() = 0;
|
||||||
virtual void ReverseSelection() { }
|
virtual void ReverseSelection() { }
|
||||||
virtual bool Deselect() { return false; }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &) { }
|
virtual void GetSelectedSongs(MPD::SongList &) { }
|
||||||
|
|
||||||
|
virtual List *GetList() = 0;
|
||||||
|
|
||||||
bool hasToBeResized;
|
bool hasToBeResized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,10 @@ class SearchEngine : public Screen< Menu< std::pair<Buffer *, MPD::Song *> > >
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return w->Choice() >= StaticOptions; }
|
virtual bool allowsSelection() { return w->Choice() >= StaticOptions; }
|
||||||
virtual void ReverseSelection() { w->ReverseSelection(StaticOptions); }
|
virtual void ReverseSelection() { w->ReverseSelection(StaticOptions); }
|
||||||
virtual bool Deselect() { return w->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList() { return w; }
|
||||||
|
|
||||||
void UpdateFoundList();
|
void UpdateFoundList();
|
||||||
|
|
||||||
static size_t StaticOptions;
|
static size_t StaticOptions;
|
||||||
|
|||||||
@@ -734,6 +734,16 @@ void TagEditor::GetSelectedSongs(MPD::SongList &v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List *TagEditor::GetList()
|
||||||
|
{
|
||||||
|
if (w == LeftColumn)
|
||||||
|
return LeftColumn;
|
||||||
|
else if (w == Tags)
|
||||||
|
return Tags;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void TagEditor::NextColumn()
|
void TagEditor::NextColumn()
|
||||||
{
|
{
|
||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class TinyTagEditor : public Screen< Menu<Buffer> >
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return false; }
|
virtual bool allowsSelection() { return false; }
|
||||||
|
|
||||||
|
virtual List *GetList() { return w; }
|
||||||
|
|
||||||
bool SetEdited(MPD::Song *);
|
bool SetEdited(MPD::Song *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -74,9 +76,10 @@ class TagEditor : public Screen<Window>
|
|||||||
|
|
||||||
virtual bool allowsSelection() { return w == Tags; }
|
virtual bool allowsSelection() { return w == Tags; }
|
||||||
virtual void ReverseSelection() { Tags->ReverseSelection(); }
|
virtual void ReverseSelection() { Tags->ReverseSelection(); }
|
||||||
virtual bool Deselect() { return Tags->Deselect(); }
|
|
||||||
virtual void GetSelectedSongs(MPD::SongList &);
|
virtual void GetSelectedSongs(MPD::SongList &);
|
||||||
|
|
||||||
|
virtual List *GetList();
|
||||||
|
|
||||||
void NextColumn();
|
void NextColumn();
|
||||||
void PrevColumn();
|
void PrevColumn();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user