void LibraryWindow::Edit() { if (CurrentLine() < library_.Size()) { Mpc::LibraryEntry * entry = library_.Get(CurrentLine()); if (entry->type_ != Mpc::SongType) { std::string title = library_.Get(CurrentLine())->album_; title = (title != "") ? title : library_.Get(CurrentLine())->artist_; SongWindow * window = screen_.CreateSongWindow("L:" + title); // Do not need to sort as this ensures it will be sorted in the same order as the library // Separated function out into variable as compile fails on g++ 4.7.2 // if passed directly to function using the lambda FUNCTION<void (Mpc::Song * song)> function = [&window] (Mpc::Song * song) { window->Add(song); }; Main::Library().ForEachChild(CurrentLine(), function); if (window->BufferSize() > 0) { screen_.SetActiveAndVisible(screen_.GetWindowFromName(window->Name())); } else { screen_.SetVisible(screen_.GetWindowFromName(window->Name()), false); } } else { screen_.CreateSongInfoWindow(entry->song_); } } }
void ListWindow::Edit() { if (lists_.Size() > 0) { Mpc::List const playlist(lists_.Get(CurrentLine())); SongWindow * window = screen_.CreateSongWindow("P:" + playlist.name_); client_.ForEachPlaylistSong(playlist.path_, window->Buffer(), static_cast<void (Main::Buffer<Mpc::Song *>::*)(Mpc::Song *)>(&Mpc::Browse::Add)); if (window->BufferSize() > 0) { screen_.SetActiveAndVisible(screen_.GetWindowFromName(window->Name())); } else { screen_.SetVisible(screen_.GetWindowFromName(window->Name()), false); ErrorString(ErrorNumber::PlaylistEmpty); } } }