]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/AirportList.cxx
Expose vertical speed for MP planes
[flightgear.git] / src / GUI / AirportList.cxx
index 2cdbd58a3e240b5841ebc4effa1ca6e74a6c8a67..bcbe06e09c90dea778a4430228f2d208d93f4313 100644 (file)
@@ -1,50 +1,45 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include <Main/globals.hxx>
 #include <Airports/simple.hxx>
 
 #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<char> &ct = std::use_facet<std::ctype<char> >(std::locale());
+    ct.toupper((char *)filter.data(), (char *)filter.data() + filter.size());
+
     if (filter != _filter) {
         _filter = filter;
         create_list();
     }
 }
 
-// end of AirportList.cxx