From dc1d14effe156f90d537ef579c4e15063228491f Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 30 Oct 2026 18:32:02 +0000 Subject: [PATCH] Fix warnings. Select on find. --- plugins/feature/aircraft/aircraftgui.cpp | 14 ++++-- plugins/feature/aircraft/aircrafttracker.cpp | 7 ++- plugins/feature/map/map/map3d.html | 51 ++++++++++++-------- plugins/feature/map/mapgui.cpp | 12 +++-- plugins/feature/map/mapitem.h | 1 + plugins/feature/map/mapmodel.cpp | 24 ++++++--- plugins/feature/map/mapmodel.h | 29 +++++++++++ 7 files changed, 100 insertions(+), 38 deletions(-) diff --git a/plugins/feature/aircraft/aircraftgui.cpp b/plugins/feature/aircraft/aircraftgui.cpp index 85ebe0f3c..c884fdb20 100644 --- a/plugins/feature/aircraft/aircraftgui.cpp +++ b/plugins/feature/aircraft/aircraftgui.cpp @@ -533,8 +533,11 @@ AircraftGUI::AircraftGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Featu }); // Context menus: copy cell contents or find the aircraft on the Map - for (auto pair : { qMakePair((QTableView *) ui->aircraft, true), qMakePair((QTableView *) ui->oldAircraft, true), - qMakePair((QTableView *) ui->flights, false), qMakePair((QTableView *) ui->oldFlights, false) }) + const QPair contextMenuViews[] = { + { ui->aircraft, true }, { ui->oldAircraft, true }, + { ui->flights, false }, { ui->oldFlights, false } + }; + for (const auto& pair : contextMenuViews) { QTableView *view = pair.first; bool isAircraft = pair.second; @@ -940,8 +943,11 @@ void AircraftGUI::setDefaultColumnWidths() set(ui->flights, FlightTableModel::COL_ROUTE_SOURCE, "Message <>DB"); // The archive views show the same columns, so give them the same widths - for (auto pair : { qMakePair((QTableView *) ui->aircraft, (QTableView *) ui->oldAircraft), - qMakePair((QTableView *) ui->flights, (QTableView *) ui->oldFlights) }) + const QPair archiveViews[] = { + { ui->aircraft, ui->oldAircraft }, + { ui->flights, ui->oldFlights } + }; + for (const auto& pair : archiveViews) { for (int col = 0; col < pair.first->model()->columnCount(); col++) { pair.second->setColumnWidth(col, pair.first->columnWidth(col)); diff --git a/plugins/feature/aircraft/aircrafttracker.cpp b/plugins/feature/aircraft/aircrafttracker.cpp index 8246cc161..2cb9b0597 100644 --- a/plugins/feature/aircraft/aircrafttracker.cpp +++ b/plugins/feature/aircraft/aircrafttracker.cpp @@ -2204,8 +2204,11 @@ void AircraftTracker::mergeFlightInto(TrackedAircraft *item, TrackedFlight *dst, // stays on the Map with nothing left that knows how to take it off. Where dst has one // of its own, src's drawing is removed rather than kept: two flights have become one, // and only one route can be current. - for (auto pair : { qMakePair(&src->m_flightPlan, &dst->m_flightPlan), - qMakePair(&src->m_clearance, &dst->m_clearance) }) + const QPair routes[] = { + { &src->m_flightPlan, &dst->m_flightPlan }, + { &src->m_clearance, &dst->m_clearance } + }; + for (const auto& pair : routes) { TrackedFlight::FiledRoute *from = pair.first; TrackedFlight::FiledRoute *to = pair.second; diff --git a/plugins/feature/map/map/map3d.html b/plugins/feature/map/map/map3d.html index b6eb82d7a..af60f4501 100644 --- a/plugins/feature/map/map/map3d.html +++ b/plugins/feature/map/map/map3d.html @@ -1004,23 +1004,29 @@ viewer.selectedEntity = pickEntityPrioritized(e); } + // Follow an entity with the camera, in the current camera mode. Something with no + // position to follow - a polygon or polyline - is zoomed to instead + function followEntity(entity) { + withFullDetail(entity, function () { + if (cameraMode === cameraModeFirstPerson) { + setFirstPersonView(entity); + } else if (cameraMode === cameraModeFlyBy) { + setFlyByView(entity); + } else { + if (Cesium.Property.getValueOrUndefined(entity.position, viewer.clock.currentTime)) { + setThirdPersonView(entity); + } else { + clearFarAmbient(entity); + viewer.zoomTo(entity); + } + } + }); + } + function pickAndTrack(e) { const entity = pickEntityPrioritized(e); if (Cesium.defined(entity)) { - withFullDetail(entity, function () { - if (cameraMode === cameraModeFirstPerson) { - setFirstPersonView(entity); - } else if (cameraMode === cameraModeFlyBy) { - setFlyByView(entity); - } else { - if (Cesium.Property.getValueOrUndefined(entity.position, viewer.clock.currentTime)) { - setThirdPersonView(entity); - } else { - clearFarAmbient(entity); - viewer.zoomTo(entity); - } - } - }); + followEntity(entity); } else if (Cesium.defined(viewer.trackedEntity)) { //viewer.trackedEntity = undefined; lodPendingFocus = undefined; @@ -3619,11 +3625,15 @@ const command = JSON.parse(event.data); if (command.command == "trackId") { - // Track an entity with the given ID + // Select and track an entity with the given ID, as a click then a double + // click on it would. Setting trackedEntity alone left a first person or + // fly-by camera on whatever it was following before. An ID that isn't on + // the map leaves the selection and camera be const entity = czmlStream.entities.getById(command.id); - withFullDetail(entity, function () { - viewer.trackedEntity = entity; - }); + if (Cesium.defined(entity)) { + viewer.selectedEntity = entity; + followEntity(entity); + } } else if (command.command == "setHomeView") { // Set the viewing rectangle used when the home button is pressed Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees( @@ -3635,7 +3645,10 @@ Cesium.Camera.DEFAULT_VIEW_FACTOR = 0.0; viewer.camera.flyHome(0); } else if (command.command == "setView") { - // Set the camera view + // Set the camera view. Only sent for a search, so stop following whatever + // was being tracked, or the camera would stay with it + lodPendingFocus = undefined; + setThirdPersonView(undefined); viewer.scene.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(command.longitude, command.latitude, command.altitude), orientation: { diff --git a/plugins/feature/map/mapgui.cpp b/plugins/feature/map/mapgui.cpp index 246d01b2e..7e3c1af99 100644 --- a/plugins/feature/map/mapgui.cpp +++ b/plugins/feature/map/mapgui.cpp @@ -3713,14 +3713,16 @@ void MapGUI::find(const QString& target) } else { + // The names match case-insensitively, but the 3D map's IDs don't, so + // track by the item's own name, not what was typed ObjectMapItem *mapItem = (ObjectMapItem *)m_objectMapModel.findMapItem(target); if (mapItem != nullptr) { map->setProperty("center", QVariant::fromValue(mapItem->getCoordinates())); if (m_cesium) { - m_cesium->track(target); + m_cesium->track(mapItem->getName()); } - m_objectMapModel.moveToFront(m_objectMapModel.findMapItemIndex(target).row()); + m_objectMapModel.moveToFront(mapItem->m_row); return; } @@ -3729,18 +3731,18 @@ void MapGUI::find(const QString& target) { map->setProperty("center", QVariant::fromValue(polylineMapItem->getCoordinates())); if (m_cesium) { - m_cesium->track(target); + m_cesium->track(polylineMapItem->getName()); } //m_polylineMapModel.moveToFront(m_polylineMapModel.findMapItemIndex(target).row()); return; } - PolygonMapItem *polygonMapItem = (PolygonMapItem *)m_polylineMapModel.findMapItem(target); + PolygonMapItem *polygonMapItem = (PolygonMapItem *)m_polygonMapModel.findMapItem(target); if (polygonMapItem != nullptr) { map->setProperty("center", QVariant::fromValue(polygonMapItem->getCoordinates())); if (m_cesium) { - m_cesium->track(target); + m_cesium->track(polygonMapItem->getName()); } //m_polylineMapModel.moveToFront(m_polylineMapModel.findMapItemIndex(target).row()); return; diff --git a/plugins/feature/map/mapitem.h b/plugins/feature/map/mapitem.h index 1cba223b8..40ffd2448 100644 --- a/plugins/feature/map/mapitem.h +++ b/plugins/feature/map/mapitem.h @@ -73,6 +73,7 @@ public: int m_row = -1; virtual void update(SWGSDRangel::SWGMapItem *mapItem); QGeoCoordinate getCoordinates(); + const QString& getName() const { return m_name; } protected: diff --git a/plugins/feature/map/mapmodel.cpp b/plugins/feature/map/mapmodel.cpp index 48dad47a6..75c47ebd8 100644 --- a/plugins/feature/map/mapmodel.cpp +++ b/plugins/feature/map/mapmodel.cpp @@ -1877,6 +1877,7 @@ bool ObjectMapFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP void ObjectMapFilter::viewChanged(double topLeftLongitude, double topLeftLatitude, double bottomRightLongitude, double bottomRightLatitude, double zoomLevel) { PROFILER_START() + beginFilterChange(); m_zoomLevel = zoomLevel; if (!std::isnan(topLeftLongitude)) { @@ -1885,7 +1886,7 @@ void ObjectMapFilter::viewChanged(double topLeftLongitude, double topLeftLatitud m_bottomRightLongitude = bottomRightLongitude; m_bottomRightLatitude = bottomRightLatitude; } - invalidateFilter(); + endFilterChange(); PROFILER_STOP("Map filter objects") } @@ -1927,11 +1928,12 @@ bool PolygonFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePar void PolygonFilter::viewChanged(double topLeftLongitude, double topLeftLatitude, double bottomRightLongitude, double bottomRightLatitude, double zoomLevel) { PROFILER_START() + beginFilterChange(); m_zoomLevel = zoomLevel; if (!std::isnan(topLeftLongitude)) { m_view = QGeoRectangle(QGeoCoordinate(topLeftLatitude, topLeftLongitude), QGeoCoordinate(bottomRightLatitude, bottomRightLongitude)); } - invalidateFilter(); + endFilterChange(); PROFILER_STOP("Map filter polygons") } @@ -1972,11 +1974,12 @@ bool PolylineFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePa void PolylineFilter::viewChanged(double topLeftLongitude, double topLeftLatitude, double bottomRightLongitude, double bottomRightLatitude, double zoomLevel) { PROFILER_START() + beginFilterChange(); m_zoomLevel = zoomLevel; if (!std::isnan(topLeftLongitude)) { m_view = QGeoRectangle(QGeoCoordinate(topLeftLatitude, topLeftLongitude), QGeoCoordinate(bottomRightLatitude, bottomRightLongitude)); } - invalidateFilter(); + endFilterChange(); PROFILER_STOP("Map filter polylines") } @@ -2021,11 +2024,12 @@ bool ImageFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen void ImageFilter::viewChanged(double topLeftLongitude, double topLeftLatitude, double bottomRightLongitude, double bottomRightLatitude, double zoomLevel) { PROFILER_START() + beginFilterChange(); m_zoomLevel = zoomLevel; if (!std::isnan(topLeftLongitude)) { m_view = QGeoRectangle(QGeoCoordinate(topLeftLatitude, topLeftLongitude), QGeoCoordinate(bottomRightLatitude, bottomRightLongitude)); } - invalidateFilter(); + endFilterChange(); PROFILER_STOP("Map filter images") } @@ -2037,24 +2041,28 @@ Q_INVOKABLE int ImageFilter::mapRowToSource(int row) void PolygonFilter::setPosition(const QGeoCoordinate& position) { + beginFilterChange(); m_position = position; - invalidateFilter(); + endFilterChange(); } void PolylineFilter::setPosition(const QGeoCoordinate& position) { + beginFilterChange(); m_position = position; - invalidateFilter(); + endFilterChange(); } void ObjectMapFilter::setPosition(const QGeoCoordinate& position) { + beginFilterChange(); m_position = position; - invalidateFilter(); + endFilterChange(); } void ImageFilter::setPosition(const QGeoCoordinate& position) { + beginFilterChange(); m_position = position; - invalidateFilter(); + endFilterChange(); } diff --git a/plugins/feature/map/mapmodel.h b/plugins/feature/map/mapmodel.h index e25666c00..91fef4421 100644 --- a/plugins/feature/map/mapmodel.h +++ b/plugins/feature/map/mapmodel.h @@ -454,6 +454,14 @@ public: Q_INVOKABLE int mapRowToSource(int row); void setPosition(const QGeoCoordinate& position); +protected: + // Qt 6.10 brought these, deprecating invalidateFilter() in their favour. On anything + // older they stand in for it, as in AcarsMessageFilter +#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) + void beginFilterChange() {} + void endFilterChange() { invalidateFilter(); } +#endif + private: QGeoRectangle m_view; double m_zoomLevel; @@ -476,6 +484,13 @@ public: Q_INVOKABLE int mapRowToSource(int row); void setPosition(const QGeoCoordinate& position); +protected: + // As in PolygonFilter +#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) + void beginFilterChange() {} + void endFilterChange() { invalidateFilter(); } +#endif + private: QGeoRectangle m_view; double m_zoomLevel; @@ -503,6 +518,13 @@ public: Q_INVOKABLE int mapRowToSource(int row); void setPosition(const QGeoCoordinate& position); +protected: + // As in PolygonFilter +#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) + void beginFilterChange() {} + void endFilterChange() { invalidateFilter(); } +#endif + private: double m_topLeftLongitude; double m_topLeftLatitude; @@ -528,6 +550,13 @@ public: Q_INVOKABLE int mapRowToSource(int row); void setPosition(const QGeoCoordinate& position); +protected: + // As in PolygonFilter +#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0) + void beginFilterChange() {} + void endFilterChange() { invalidateFilter(); } +#endif + private: QGeoRectangle m_view; double m_zoomLevel;