void TrafficListWidget::UpdateList() { assert(filter_widget != nullptr); items.clear(); last_update.Clear(); const TCHAR *callsign = filter_widget->GetValueString(CALLSIGN); if (!StringIsEmpty(callsign)) { FlarmId ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign(callsign, ids, 30); for (unsigned i = 0; i < count; ++i) AddItem(ids[i]); } else { /* if no filter was set, show a list of current traffic and known traffic */ /* add live FLARM traffic */ for (const auto &i : CommonInterface::Basic().flarm.traffic.list) { AddItem(i.id); } /* add FLARM peers that have a user-defined color */ for (const auto &i : traffic_databases->flarm_colors) { Item &item = AddItem(i.first); item.color = i.second; } /* add FLARM peers that have a user-defined name */ for (const auto &i : traffic_databases->flarm_names) { AddItem(i.id); } #ifdef HAVE_SKYLINES_TRACKING_HANDLER /* show SkyLines traffic unless this is a FLARM traffic picker dialog (from dlgTeamCode) */ if (action_listener == nullptr) { const auto &data = tracking->GetSkyLinesData(); const ScopeLock protect(data.mutex); for (const auto &i : data.traffic) { items.emplace_back(i.first, i.second.location); Item &item = items.back(); if (i.second.location.IsValid() && CommonInterface::Basic().location_available) item.vector = GeoVector(CommonInterface::Basic().location, i.second.location); } } #endif } GetList().SetLength(items.size()); UpdateVolatile(); UpdateButtons(); }
/** * Add a new item to the list, unless the given FLARM id already * exists. */ Item &AddItem(FlarmId id) { auto existing = FindItem(id); if (existing != items.end()) return *existing; items.emplace_back(id); return items.back(); }