Add the default tutorial airport to the launcher
This commit is contained in:
parent
d4cd82b521
commit
607cef530a
1 changed files with 17 additions and 11 deletions
|
@ -1114,21 +1114,27 @@ void LocationWidget::addToRecent(FGPositionedRef pos)
|
||||||
settings.setValue("recent-locations", savePositionList(m_recentLocations));
|
settings.setValue("recent-locations", savePositionList(m_recentLocations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prependLocation(FGPositionedList& locs, const std::string& airportIdent)
|
||||||
|
{
|
||||||
|
auto it = std::find_if(locs.begin(), locs.end(), [airportIdent](FGPositionedRef pos) {
|
||||||
|
return pos->ident() == airportIdent;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it == locs.end()) {
|
||||||
|
FGAirportRef apt = FGAirport::findByIdent(airportIdent);
|
||||||
|
locs.insert(locs.begin(), apt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LocationWidget::onShowHistory()
|
void LocationWidget::onShowHistory()
|
||||||
{
|
{
|
||||||
// prepend the default location
|
|
||||||
FGPositionedList locs = m_recentLocations;
|
FGPositionedList locs = m_recentLocations;
|
||||||
const std::string defaultICAO = flightgear::defaultAirportICAO();
|
|
||||||
|
// prepend the C172P tutorial airport
|
||||||
auto it = std::find_if(locs.begin(), locs.end(), [defaultICAO](FGPositionedRef pos) {
|
prependLocation(locs, "PHTO");
|
||||||
return pos->ident() == defaultICAO;
|
|
||||||
});
|
// and then prepend our default airport
|
||||||
|
prependLocation(locs, flightgear::defaultAirportICAO());
|
||||||
if (it == locs.end()) {
|
|
||||||
FGAirportRef apt = FGAirport::findByIdent(defaultICAO);
|
|
||||||
locs.insert(locs.begin(), apt);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_searchModel->setItems(locs);
|
m_searchModel->setItems(locs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue