diff --git a/src/GUI/AirportList.cxx b/src/GUI/AirportList.cxx index 9fff82310..1b62f0aff 100644 --- a/src/GUI/AirportList.cxx +++ b/src/GUI/AirportList.cxx @@ -1,37 +1,45 @@ - +#include #include
#include #include "AirportList.hxx" -AirportList::AirportList (int x, int y, int width, int height) - : puaList(x, y, width, height), - GUI_ID(FGCLASS_AIRPORTLIST), - _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), + _airports(globals->get_airports()), + _content(0) { create_list(); } -AirportList::~AirportList () + +AirportList::~AirportList() { destroy_list(); } + void -AirportList::create_list () +AirportList::create_list() { + const std::ctype &ct = std::use_facet >(std::locale()); int num_apt = _airports->size(); char **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() + ')'); + std::string entry(' ' + apt->getName() + " (" + apt->getId() + ')'); - if (!_filter.empty() && entry.find(_filter) == STD::string::npos) - continue; + if (!_filter.empty()) { + std::string upper(entry.data()); + ct.toupper((char *)upper.data(), (char *)upper.data() + upper.size()); + + if (upper.find(_filter) == std::string::npos) + continue; + } content[n] = new char[entry.size() + 1]; strcpy(content[n], entry.c_str()); @@ -47,8 +55,9 @@ AirportList::create_list () _content = content; } + void -AirportList::destroy_list () +AirportList::destroy_list() { for (char **c = _content; *c; c++) { delete *c; @@ -57,15 +66,18 @@ AirportList::destroy_list () delete [] _content; } + 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 diff --git a/src/GUI/AirportList.hxx b/src/GUI/AirportList.hxx index 1fe4673af..dabd69778 100644 --- a/src/GUI/AirportList.hxx +++ b/src/GUI/AirportList.hxx @@ -4,31 +4,24 @@ #define __AIRPORTLIST_HXX #include -#include STL_STRING - #include #include "dialog.hxx" - - -SG_USING_STD(string); - class FGAirportList; -class AirportList : public puaList, public GUI_ID -{ - public: - AirportList (int x, int y, int width, int height); - virtual ~AirportList (); +class AirportList : public puaList, public GUI_ID { +public: + AirportList(int x, int y, int width, int height); + virtual ~AirportList(); virtual void create_list(); virtual void destroy_list(); - virtual void setValue (const char *); + virtual void setValue(const char *); - private: - FGAirportList * _airports; - char ** _content; - STD::string _filter; +private: + FGAirportList *_airports; + char **_content; + std::string _filter; }; #endif // __AIRPORTLIST_HXX