X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2FAirportList.cxx;h=bcbe06e09c90dea778a4430228f2d208d93f4313;hb=0f7f7fce6bd57bea6c93f5d40c89f1b741edff45;hp=2cdbd58a3e240b5841ebc4effa1ca6e74a6c8a67;hpb=2e7cab820b7ea40e667fc3b2181ade0f6451e666;p=flightgear.git diff --git a/src/GUI/AirportList.cxx b/src/GUI/AirportList.cxx index 2cdbd58a3..bcbe06e09 100644 --- a/src/GUI/AirportList.cxx +++ b/src/GUI/AirportList.cxx @@ -1,50 +1,45 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include
#include #include "AirportList.hxx" - -AirportList::AirportList (int x, int y, int width, int height) - : puList(x, y, width, height), - _airports(globals->get_airports()), - _content(0) +AirportList::AirportList(int x, int y, int width, int height) : + puaList(x, y, width, height), + GUI_ID(FGCLASS_AIRPORTLIST), + _content(0) { create_list(); } -AirportList::~AirportList () + +AirportList::~AirportList() { destroy_list(); } + void -AirportList::create_list () +AirportList::create_list() { + char **content = FGAirport::searchNamesAndIdents(_filter); + int n = (content[0] != NULL) ? 1 : 0; + + // work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up + newList(n > 0 ? content : 0); + if (_content) destroy_list(); - int num_apt = _airports->size(); - _content = new char *[num_apt + 1]; - - int n = 0; - for (int i = 0; i < num_apt; i++) { - const FGAirport *apt = _airports->getAirport(i); - STD::string entry(apt->getName() + " (" + apt->getId() + ')'); - - if (!_filter.empty() && entry.find(_filter) == STD::string::npos) - continue; - - _content[n] = new char[entry.size() + 1]; - strcpy(_content[n], entry.c_str()); - n++; - } - _content[n] = 0; - newList(_content); + _content = content; } + void -AirportList::destroy_list () +AirportList::destroy_list() { for (char **c = _content; *c; c++) { delete *c; @@ -53,22 +48,18 @@ AirportList::destroy_list () delete [] _content; } -char * -AirportList::getListStringValue () -{ - int i = getListIntegerValue(); - return i < 0 ? 0 : _content[i]; -} void -AirportList::setValue (const char *s) +AirportList::setValue(const char *s) { - STD::string filter(s); + std::string filter(s); + const std::ctype &ct = std::use_facet >(std::locale()); + ct.toupper((char *)filter.data(), (char *)filter.data() + filter.size()); + if (filter != _filter) { _filter = filter; create_list(); } } -// end of AirportList.cxx