1
0
Fork 0

Ensure the C172P tutorial airport (PHTO) is always listed

Adjust the location history so the default and tutorial airports always appear at
history locations 0 and 1.
This commit is contained in:
James Turner 2018-07-01 09:55:37 +01:00
parent 33ed13f889
commit b7e98caecf

View file

@ -603,18 +603,26 @@ QObjectList LocationController::airportParkings() const
void LocationController::showHistoryInSearchModel() void LocationController::showHistoryInSearchModel()
{ {
// prepend the default location // prepend the default location and tutorial airport
FGPositionedList locs = m_recentLocations; FGPositionedList locs = m_recentLocations;
const std::string defaultICAO = flightgear::defaultAirportICAO(); const std::string defaultICAO = flightgear::defaultAirportICAO();
const std::string tutorialICAO = "PHTO"; // C172P tutorial aiurport
auto it = std::find_if(locs.begin(), locs.end(), [defaultICAO](FGPositionedRef pos) { // remove them from the recent locations
return pos->ident() == defaultICAO; auto it = std::remove_if(locs.begin(), locs.end(),
[defaultICAO, tutorialICAO](FGPositionedRef pos)
{
return (pos->ident() == defaultICAO) || (pos->ident() == tutorialICAO);
}); });
locs.erase(it, locs.end());
if (it == locs.end()) { // prepend them
FGAirportRef apt = FGAirport::findByIdent(defaultICAO); FGAirportRef apt = FGAirport::findByIdent(tutorialICAO);
locs.insert(locs.begin(), apt);
apt = FGAirport::findByIdent(defaultICAO);
locs.insert(locs.begin(), apt); locs.insert(locs.begin(), apt);
}
m_searchModel->setItems(locs); m_searchModel->setItems(locs);
} }