void DirectoryWindow::ScrollToCurrent() { int32_t currentSongId = clientState_.GetCurrentSongPos(); Mpc::Song * currentSong = NULL; if ((currentSongId >= 0) && (currentSongId < static_cast<int32_t>(Main::Playlist().Size()))) { currentSong = Main::Playlist().Get(currentSongId); } if ((currentSong != NULL) && (currentSong->Entry() != NULL) && (currentSong->URI() != "")) { std::string Directory = currentSong->URI(); if (Directory.find("/") != std::string::npos) { Directory = Directory.substr(0, Directory.find_last_of("/")); } else { Directory = ""; } directory_.ChangeDirectory(Directory); } }
int32_t SongWindow::DetermineColour(uint32_t line) const { uint32_t printLine = line + FirstLine(); Mpc::Song * song = (printLine < BufferSize()) ? Buffer().Get(printLine) : NULL; int32_t colour = Colour::Song; if (song != NULL) { if ((song->URI() == client_.GetCurrentSongURI())) { colour = Colour::CurrentSong; } else if (client_.SongIsInQueue(*song)) { colour = Colour::FullAdd; } else if ((search_.LastSearchString() != "") && (settings_.Get(Setting::HighlightSearch) == true) && (search_.HighlightSearch() == true)) { pcrecpp::RE const expression(".*" + search_.LastSearchString() + ".*", search_.LastSearchOptions()); if (expression.FullMatch(song->FormatString(settings_.Get(Setting::SongFormat)))) { colour = Colour::SongMatch; } } } return colour; }
uint32_t Client::Add(Mpc::Song & song) { ClearCommand(); if (Connected() == true) { mpd_send_add(connection_, song.URI().c_str()); UpdateStatus(true); } else { ErrorString(ErrorNumber::ClientNoConnection); } return TotalNumberOfSongs() - 1; }
uint32_t Client::Add(Mpc::Song & song, uint32_t position) { ClearCommand(); if (Connected() == true) { mpd_send_add_id_to(connection_, song.URI().c_str(), position); if ((currentSongId_ > -1) && (position <= static_cast<uint32_t>(currentSongId_))) { ++currentSongId_; } UpdateStatus(true); } else { ErrorString(ErrorNumber::ClientNoConnection); } return TotalNumberOfSongs() - 1; }