From 758518b2486b20b221e343c3729e3cba880a679d Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 8 Jan 2019 23:53:31 +0000 Subject: [PATCH] Launcher: improve flight plan leg display --- src/GUI/FlightPlanController.cxx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/GUI/FlightPlanController.cxx b/src/GUI/FlightPlanController.cxx index c72cf655a..002db7e3d 100644 --- a/src/GUI/FlightPlanController.cxx +++ b/src/GUI/FlightPlanController.cxx @@ -52,9 +52,18 @@ public: if (!leg) return {}; + const auto wp = leg->waypoint(); + switch (role) { - case Qt::DisplayRole: + case Qt::DisplayRole: { + if (wp->type() == "via") { + // we want the end waypoint name + return QString::fromStdString(wp->source()->ident()); + } + return QString::fromStdString(leg->waypoint()->ident()); + } + case LegDistanceRole: return QVariant::fromValue(QuantityValue{Units::NauticalMiles, leg->distanceNm()}); case LegTrackRole: @@ -62,17 +71,15 @@ public: case LegAirwayIdentRole: { - const auto wp = leg->waypoint(); + AirwayRef awy; if (wp->type() == "via") { auto via = static_cast(leg->waypoint()); - return QString::fromStdString(via->airway()); + awy = via->airway(); + } else if (wp->flag(WPT_VIA)) { + awy = static_cast(wp->owner()); } - - if (wp->flag(WPT_VIA)) { - AirwayRef awy = static_cast(wp->owner()); - return QString::fromStdString(awy->ident()); - } - break; + + return awy ? QString::fromStdString(awy->ident()) : QVariant{}; } case LegTerminatorNavRole: