From d37f774c507ee118f6d6032e784a64ee276dcc92 Mon Sep 17 00:00:00 2001 From: Alexander Barthel Date: Tue, 11 May 2021 14:04:13 +0200 Subject: [PATCH] Added transponder code to user and AI aircraft. Now showing in tooltips, information and map. Fetching transponder code for all simulators now. Increased data version to 11 to force incompatibility. Added transponder code option to aircraft labels. Aircraft label settings are now reset back to default. albar965/littlenavmap#525 --- src/common/constants.h | 3 +- src/common/htmlinfobuilder.cpp | 19 +++----- src/connect/connectclient.cpp | 1 + src/mappainter/mappainter.h | 12 +++-- src/mappainter/mappainteraircraft.cpp | 2 +- src/mappainter/mappaintervehicle.cpp | 68 +++++++++++++++------------ src/mappainter/mappaintervehicle.h | 2 +- src/mappainter/mappaintlayer.cpp | 3 +- src/options/optiondata.h | 54 ++++++++++++++------- src/options/optionsdialog.cpp | 68 +++++++++++++++------------ src/options/optionsdialog.h | 3 +- 11 files changed, 137 insertions(+), 98 deletions(-) diff --git a/src/common/constants.h b/src/common/constants.h index f7ae5b63e..eef38c4dd 100644 --- a/src/common/constants.h +++ b/src/common/constants.h @@ -253,7 +253,8 @@ const QLatin1Literal OPTIONS_DIALOG_FLIGHTPLAN_PROCEDURE_COLOR("OptionsDialog/Fl const QLatin1Literal OPTIONS_DIALOG_FLIGHTPLAN_ACTIVE_COLOR("OptionsDialog/FlightplanActiveColor"); const QLatin1Literal OPTIONS_DIALOG_FLIGHTPLAN_PASSED_COLOR("OptionsDialog/FlightplanPassedColor"); const QLatin1Literal OPTIONS_DIALOG_TRAIL_COLOR("OptionsDialog/TrailColor"); -const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS("OptionsDialog/DisplayOptions"); +const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS_USER_AIRCRAFT("OptionsDialog/DisplayOptionsuserAircraft"); +const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS_AI_AIRCRAFT("OptionsDialog/DisplayOptionsAiAircraft"); const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS_AIRPORT("OptionsDialog/DisplayOptionsAirport"); const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS_COMPASS_ROSE("OptionsDialog/DisplayOptionsCompassRose"); const QLatin1Literal OPTIONS_DIALOG_DISPLAY_OPTIONS_MEASUREMENT("OptionsDialog/DisplayOptionsMeasurement"); diff --git a/src/common/htmlinfobuilder.cpp b/src/common/htmlinfobuilder.cpp index 88d2d4bfa..cbaf43fda 100644 --- a/src/common/htmlinfobuilder.cpp +++ b/src/common/htmlinfobuilder.cpp @@ -3041,21 +3041,18 @@ void HtmlInfoBuilder::aircraftText(const atools::fs::sc::SimConnectAircraft& air else html.row2(tr("Number:"), locale.toString(aircraft.getObjectId() + 1)); - if(!aircraft.getAirplaneAirline().isEmpty()) - html.row2(tr("Airline:"), aircraft.getAirplaneAirline()); + html.row2If(tr("Airline:"), aircraft.getAirplaneAirline()); - if(!aircraft.getAirplaneFlightnumber().isEmpty()) - html.row2(tr("Flight Number:"), aircraft.getAirplaneFlightnumber()); + html.row2If(tr("Flight Number:"), aircraft.getAirplaneFlightnumber()); - if(!aircraft.getAirplaneModel().isEmpty()) - html.row2(tr("Type:"), aircraft.getAirplaneModel()); // BE58 + html.row2If(tr("Transponder Code:"), aircraft.getTransponderCodeStr()); + + html.row2If(tr("Type:"), aircraft.getAirplaneModel()); // BE58 - if(!aircraft.getAirplaneRegistration().isEmpty()) - html.row2(tr("Registration:"), aircraft.getAirplaneRegistration()); // ASXGS + html.row2If(tr("Registration:"), aircraft.getAirplaneRegistration()); // ASXGS QString model = map::aircraftType(aircraft); - if(!model.isEmpty()) - html.row2(tr("Model:"), model); // Beechcraft + html.row2If(tr("Model:"), model); // Beechcraft if(aircraft.isAnyBoat()) { @@ -3153,8 +3150,6 @@ void HtmlInfoBuilder::aircraftOnlineText(const atools::fs::sc::SimConnectAircraf else html.row2If(tr("Cruising Level:"), alt); - html.row2If(tr("Transponder Code:"), onlineRec.valueStr("transponder_code")); - float range = onlineRec.valueFloat("visual_range"); if(range > 0.f && range < map::INVALID_ALTITUDE_VALUE) html.row2If(tr("Visual Range:"), Unit::distNm(range)); diff --git a/src/connect/connectclient.cpp b/src/connect/connectclient.cpp index f385a3499..e6281e88f 100644 --- a/src/connect/connectclient.cpp +++ b/src/connect/connectclient.cpp @@ -235,6 +235,7 @@ void ConnectClient::disconnectedFromSimulatorDirect() /* Posts data received directly from simconnect or the socket and caches any metar reports */ void ConnectClient::postSimConnectData(atools::fs::sc::SimConnectData dataPacket) { + // AI list does not include user aircraft atools::fs::sc::SimConnectUserAircraft& userAircraft = dataPacket.getUserAircraft(); // Workaround for MSFS sending wrong positions around 0/0 while in menu diff --git a/src/mappainter/mappainter.h b/src/mappainter/mappainter.h index 36f806842..43f40d9ba 100644 --- a/src/mappainter/mappainter.h +++ b/src/mappainter/mappainter.h @@ -90,7 +90,8 @@ struct PaintContext // Same for procedure preview QSet routeProcIdMap; - optsd::DisplayOptions dispOpts; + optsac::DisplayOptionsUserAircraft dispOptsUser; + optsac::DisplayOptionsAiAircraft dispOptsAi; optsd::DisplayOptionsAirport dispOptsAirport; optsd::DisplayOptionsRose dispOptsRose; optsd::DisplayOptionsMeasurement dispOptsMeasurement; @@ -153,9 +154,14 @@ struct PaintContext return queryOverflow; } - bool dOpt(optsd::DisplayOption opts) const + bool dOptUserAc(optsac::DisplayOptionUserAircraft opts) const { - return dispOpts.testFlag(opts); + return dispOptsUser.testFlag(opts); + } + + bool dOptAiAc(optsac::DisplayOptionAiAircraft opts) const + { + return dispOptsAi.testFlag(opts); } bool dOptAp(optsd::DisplayOptionAirport opts) const diff --git a/src/mappainter/mappainteraircraft.cpp b/src/mappainter/mappainteraircraft.cpp index 2e3cfad99..2a7d970ff 100644 --- a/src/mappainter/mappainteraircraft.cpp +++ b/src/mappainter/mappainteraircraft.cpp @@ -128,7 +128,7 @@ void MapPainterAircraft::render() paintUserAircraft(userAircraft, x, y); } - if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_WIND_POINTER)) + if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_WIND_POINTER)) paintWindPointer(userAircraft, context->painter->device()->width() / 2, 0); } } diff --git a/src/mappainter/mappaintervehicle.cpp b/src/mappainter/mappaintervehicle.cpp index 7b30108cd..a54b46aa6 100644 --- a/src/mappainter/mappaintervehicle.cpp +++ b/src/mappainter/mappaintervehicle.cpp @@ -113,7 +113,7 @@ void MapPainterVehicle::paintUserAircraft(const SimConnectUserAircraft& userAirc context->szFont(context->textSizeAircraftUser); int offset = -(size / 2); - if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_TRACK_LINE) && + if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_TRACK_LINE) && userAircraft.getGroundSpeedKts() > 30 && userAircraft.getTrackDegTrue() < atools::fs::sc::SC_INVALID_FLOAT) { @@ -176,18 +176,19 @@ void MapPainterVehicle::paintTextLabelAi(float x, float y, int size, (aircraft.isOnline() && context->mapLayer->isOnlineAircraftText()) || // All online forceLabel) // Force label for nearby aircraft { - appendAtcText(texts, aircraft, context->dOpt(optsd::ITEM_AI_AIRCRAFT_REGISTRATION), - context->dOpt(optsd::ITEM_AI_AIRCRAFT_TYPE), - context->dOpt(optsd::ITEM_AI_AIRCRAFT_AIRLINE), - context->dOpt(optsd::ITEM_AI_AIRCRAFT_FLIGHT_NUMBER)); + appendAtcText(texts, aircraft, context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_REGISTRATION), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_TYPE), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_AIRLINE), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_FLIGHT_NUMBER), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_TRANSPONDER_CODE)); if(aircraft.getGroundSpeedKts() > 30) appendSpeedText(texts, aircraft, - context->dOpt(optsd::ITEM_AI_AIRCRAFT_IAS), - context->dOpt(optsd::ITEM_AI_AIRCRAFT_GS), - context->dOpt(optsd::ITEM_AI_AIRCRAFT_TAS)); + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_IAS), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_GS), + context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_TAS)); - if(context->dOpt(optsd::ITEM_AI_AIRCRAFT_DEP_DEST) && + if(context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_DEP_DEST) && (!aircraft.getFromIdent().isEmpty() || !aircraft.getToIdent().isEmpty())) { texts.append(tr("%1 to %2"). @@ -197,7 +198,7 @@ void MapPainterVehicle::paintTextLabelAi(float x, float y, int size, if(!aircraft.isOnGround()) { - if(context->dOpt(optsd::ITEM_AI_AIRCRAFT_HEADING)) + if(context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_HEADING)) { float heading = atools::fs::sc::SC_INVALID_FLOAT; if(aircraft.getHeadingDegMag() < atools::fs::sc::SC_INVALID_FLOAT) @@ -210,13 +211,13 @@ void MapPainterVehicle::paintTextLabelAi(float x, float y, int size, texts.append(tr("HDG %3°M").arg(QString::number(heading, 'f', 0))); } - if(context->dOpt(optsd::ITEM_AI_AIRCRAFT_CLIMB_SINK)) + if(context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_CLIMB_SINK)) appendClimbSinkText(texts, aircraft); - if(context->dOpt(optsd::ITEM_AI_AIRCRAFT_ALTITUDE)) + if(context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_ALTITUDE)) { QString upDown; - if(!context->dOpt(optsd::ITEM_AI_AIRCRAFT_CLIMB_SINK)) + if(!context->dOptAiAc(optsac::ITEM_AI_AIRCRAFT_CLIMB_SINK)) climbSinkPointer(upDown, aircraft); texts.append(tr("ALT %1%2").arg(Unit::altFeet(aircraft.getPosition().getAltitude())).arg(upDown)); } @@ -235,42 +236,45 @@ void MapPainterVehicle::paintTextLabelUser(float x, float y, int size, { QStringList texts; - appendAtcText(texts, aircraft, context->dOpt(optsd::ITEM_USER_AIRCRAFT_REGISTRATION), - context->dOpt(optsd::ITEM_USER_AIRCRAFT_TYPE), - context->dOpt(optsd::ITEM_USER_AIRCRAFT_AIRLINE), - context->dOpt(optsd::ITEM_USER_AIRCRAFT_FLIGHT_NUMBER)); + appendAtcText(texts, aircraft, context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_REGISTRATION), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_TYPE), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_AIRLINE), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_FLIGHT_NUMBER), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_TRANSPONDER_CODE)); if(aircraft.getGroundSpeedKts() > 30) { appendSpeedText(texts, aircraft, - context->dOpt(optsd::ITEM_USER_AIRCRAFT_IAS), - context->dOpt(optsd::ITEM_USER_AIRCRAFT_GS), - context->dOpt(optsd::ITEM_USER_AIRCRAFT_TAS)); + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_IAS), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_GS), + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_TAS)); } - if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_HEADING) && aircraft.getHeadingDegMag() < atools::fs::sc::SC_INVALID_FLOAT) + if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_HEADING) && + aircraft.getHeadingDegMag() < atools::fs::sc::SC_INVALID_FLOAT) texts.append(tr("HDG %3°M").arg(QString::number(aircraft.getHeadingDegMag(), 'f', 0))); - if(!aircraft.isOnGround() && context->dOpt(optsd::ITEM_USER_AIRCRAFT_CLIMB_SINK)) + if(!aircraft.isOnGround() && context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_CLIMB_SINK)) appendClimbSinkText(texts, aircraft); - if(!aircraft.isOnGround() && (context->dOpt(optsd::ITEM_USER_AIRCRAFT_ALTITUDE) || - context->dOpt(optsd::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE))) + if(!aircraft.isOnGround() && (context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_ALTITUDE) || + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE))) { QString upDown; - if(!context->dOpt(optsd::ITEM_USER_AIRCRAFT_CLIMB_SINK)) + if(!context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_CLIMB_SINK)) climbSinkPointer(upDown, aircraft); - if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_ALTITUDE) && context->dOpt(optsd::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE)) + if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_ALTITUDE) && + context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE)) { texts.append(tr("ALT %1, IND %2%3"). arg(Unit::altFeet(aircraft.getPosition().getAltitude())). arg(Unit::altFeet(aircraft.getIndicatedAltitudeFt())). arg(upDown)); } - else if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_ALTITUDE)) + else if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_ALTITUDE)) texts.append(tr("%1%2").arg(Unit::altFeet(aircraft.getPosition().getAltitude())).arg(upDown)); - else if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE)) + else if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE)) texts.append(tr("%1%2").arg(Unit::altFeet(aircraft.getIndicatedAltitudeFt())).arg(upDown)); } @@ -308,7 +312,8 @@ void MapPainterVehicle::appendClimbSinkText(QStringList& texts, const SimConnect } void MapPainterVehicle::appendAtcText(QStringList& texts, const SimConnectAircraft& aircraft, - bool registration, bool type, bool airline, bool flightnumber) + bool registration, bool type, bool airline, bool flightnumber, + bool transponderCode) { QStringList line; if(registration) @@ -334,6 +339,9 @@ void MapPainterVehicle::appendAtcText(QStringList& texts, const SimConnectAircra if(!line.isEmpty()) texts.append(line.join(tr(" / "))); + + if(transponderCode && aircraft.isTransponderCodeValid()) + texts.append(tr("TCAS %1").arg(aircraft.getTransponderCodeStr())); } void MapPainterVehicle::appendSpeedText(QStringList& texts, const SimConnectAircraft& aircraft, @@ -375,7 +383,7 @@ void MapPainterVehicle::paintTextLabelWind(int x, int y, int size, textatt::TextAttributes atts = textatt::ROUTE_BG_COLOR; if(aircraft.getWindSpeedKts() >= 1.f) { - if(context->dOpt(optsd::ITEM_USER_AIRCRAFT_WIND)) + if(context->dOptUserAc(optsac::ITEM_USER_AIRCRAFT_WIND)) { texts.append(tr("%1 °M").arg(QString::number(atools::geo::normalizeCourse( aircraft.getWindDirectionDegT() - aircraft.getMagVarDeg()), diff --git a/src/mappainter/mappaintervehicle.h b/src/mappainter/mappaintervehicle.h index 0ad7a29a4..e7304a429 100644 --- a/src/mappainter/mappaintervehicle.h +++ b/src/mappainter/mappaintervehicle.h @@ -64,7 +64,7 @@ class MapPainterVehicle : bool forceLabel); void appendClimbSinkText(QStringList& texts, const atools::fs::sc::SimConnectAircraft& aircraft); void appendAtcText(QStringList& texts, const atools::fs::sc::SimConnectAircraft& aircraft, - bool registration, bool type, bool airline, bool flightnumber); + bool registration, bool type, bool airline, bool flightnumber, bool transponderCode); void appendSpeedText(QStringList& texts, const atools::fs::sc::SimConnectAircraft& aircraft, bool ias, bool gs, bool tas); void climbSinkPointer(QString& upDown, const atools::fs::sc::SimConnectAircraft& aircraft); diff --git a/src/mappainter/mappaintlayer.cpp b/src/mappainter/mappaintlayer.cpp index 727a2bf0a..97af84f5a 100644 --- a/src/mappainter/mappaintlayer.cpp +++ b/src/mappainter/mappaintlayer.cpp @@ -567,7 +567,8 @@ bool MapPaintLayer::render(GeoPainter *painter, ViewportParams *viewport, const context.thicknessCompassRose = od.getDisplayThicknessCompassRose() / 100.f; context.thicknessAirway = od.getDisplayThicknessAirway() / 100.f; - context.dispOpts = od.getDisplayOptions(); + context.dispOptsUser = od.getDisplayOptionsUserAircraft(); + context.dispOptsAi = od.getDisplayOptionsAiAircraft(); context.dispOptsAirport = od.getDisplayOptionsAirport(); context.dispOptsRose = od.getDisplayOptionsRose(); context.dispOptsMeasurement = od.getDisplayOptionsMeasurement(); diff --git a/src/options/optiondata.h b/src/options/optiondata.h index c6e9d65ad..dc30e75c0 100644 --- a/src/options/optiondata.h +++ b/src/options/optiondata.h @@ -401,16 +401,16 @@ Q_DECLARE_FLAGS(FlagsWeather, FlagWeather); Q_DECLARE_OPERATORS_FOR_FLAGS(optsw::FlagsWeather); } // namespace opts2 -namespace optsd { +namespace optsac { /* Changing these option values will also change the saved values thus invalidating user settings */ -enum DisplayOption +enum DisplayOptionUserAircraft { - ITEM_NONE = 0, - + ITEM_USER_AIRCRAFT_NONE = 0, ITEM_USER_AIRCRAFT_REGISTRATION = 1 << 8, ITEM_USER_AIRCRAFT_TYPE = 1 << 9, ITEM_USER_AIRCRAFT_AIRLINE = 1 << 10, ITEM_USER_AIRCRAFT_FLIGHT_NUMBER = 1 << 11, + ITEM_USER_AIRCRAFT_TRANSPONDER_CODE = 1 << 21, ITEM_USER_AIRCRAFT_IAS = 1 << 12, ITEM_USER_AIRCRAFT_GS = 1 << 13, ITEM_USER_AIRCRAFT_CLIMB_SINK = 1 << 14, @@ -421,12 +421,20 @@ enum DisplayOption ITEM_USER_AIRCRAFT_TRACK_LINE = 1 << 18, ITEM_USER_AIRCRAFT_WIND_POINTER = 1 << 19, ITEM_USER_AIRCRAFT_TAS = 1 << 20, +}; + +Q_DECLARE_FLAGS(DisplayOptionsUserAircraft, DisplayOptionUserAircraft); +Q_DECLARE_OPERATORS_FOR_FLAGS(optsac::DisplayOptionsUserAircraft); +enum DisplayOptionAiAircraft +{ + ITEM_AI_AIRCRAFT_NONE = 0, ITEM_AI_AIRCRAFT_DEP_DEST = 1 << 21, ITEM_AI_AIRCRAFT_REGISTRATION = 1 << 22, ITEM_AI_AIRCRAFT_TYPE = 1 << 23, ITEM_AI_AIRCRAFT_AIRLINE = 1 << 24, ITEM_AI_AIRCRAFT_FLIGHT_NUMBER = 1 << 25, + ITEM_AI_AIRCRAFT_TRANSPONDER_CODE = 1 << 20, ITEM_AI_AIRCRAFT_IAS = 1 << 26, ITEM_AI_AIRCRAFT_GS = 1 << 27, ITEM_AI_AIRCRAFT_CLIMB_SINK = 1 << 28, @@ -435,8 +443,11 @@ enum DisplayOption ITEM_AI_AIRCRAFT_TAS = 1 << 31 }; -Q_DECLARE_FLAGS(DisplayOptions, DisplayOption); -Q_DECLARE_OPERATORS_FOR_FLAGS(optsd::DisplayOptions); +Q_DECLARE_FLAGS(DisplayOptionsAiAircraft, DisplayOptionAiAircraft); +Q_DECLARE_OPERATORS_FOR_FLAGS(optsac::DisplayOptionsAiAircraft); +} + +namespace optsd { /* Changing these option values will also change the saved values thus invalidating user settings */ enum DisplayOptionAirport @@ -873,11 +884,6 @@ class OptionData return trailColor; } - const optsd::DisplayOptions& getDisplayOptions() const - { - return displayOptions; - } - const optsd::DisplayOptionsAirport& getDisplayOptionsAirport() const { return displayOptionsAirport; @@ -1126,6 +1132,16 @@ class OptionData return onlineVatsimTransceiverReload; } + const optsac::DisplayOptionsUserAircraft& getDisplayOptionsUserAircraft() const + { + return displayOptionsUserAircraft; + } + + const optsac::DisplayOptionsAiAircraft& getDisplayOptionsAiAircraft() const + { + return displayOptionsAiAircraft; + } + private: friend class OptionsDialog; @@ -1369,13 +1385,15 @@ class OptionData opts::DisplayTrailType displayTrailType = opts::DASHED; /* Default values are set by widget states - these are needed for the reset button */ - optsd::DisplayOptions displayOptions = - optsd::ITEM_USER_AIRCRAFT_GS | optsd::ITEM_USER_AIRCRAFT_ALTITUDE | - optsd::ITEM_USER_AIRCRAFT_WIND | optsd::ITEM_USER_AIRCRAFT_TRACK_LINE | - optsd::ITEM_USER_AIRCRAFT_WIND_POINTER | - optsd::ITEM_AI_AIRCRAFT_REGISTRATION | optsd::ITEM_AI_AIRCRAFT_TYPE | - optsd::ITEM_AI_AIRCRAFT_AIRLINE | optsd::ITEM_AI_AIRCRAFT_GS | - optsd::ITEM_AI_AIRCRAFT_ALTITUDE | optsd::ITEM_AI_AIRCRAFT_DEP_DEST; + optsac::DisplayOptionsUserAircraft displayOptionsUserAircraft = + optsac::ITEM_USER_AIRCRAFT_GS | optsac::ITEM_USER_AIRCRAFT_ALTITUDE | + optsac::ITEM_USER_AIRCRAFT_WIND | optsac::ITEM_USER_AIRCRAFT_TRACK_LINE | + optsac::ITEM_USER_AIRCRAFT_WIND_POINTER; + + optsac::DisplayOptionsAiAircraft displayOptionsAiAircraft = + optsac::ITEM_AI_AIRCRAFT_REGISTRATION | optsac::ITEM_AI_AIRCRAFT_TYPE | + optsac::ITEM_AI_AIRCRAFT_AIRLINE | optsac::ITEM_AI_AIRCRAFT_GS | + optsac::ITEM_AI_AIRCRAFT_ALTITUDE | optsac::ITEM_AI_AIRCRAFT_DEP_DEST; optsd::DisplayOptionsAirport displayOptionsAirport = optsd::ITEM_AIRPORT_NAME | optsd::ITEM_AIRPORT_TOWER | optsd::ITEM_AIRPORT_ATIS | diff --git a/src/options/optionsdialog.cpp b/src/options/optionsdialog.cpp index 891e83e4c..a3d218915 100644 --- a/src/options/optionsdialog.cpp +++ b/src/options/optionsdialog.cpp @@ -189,8 +189,8 @@ OptionsDialog::OptionsDialog(QMainWindow *parentWindow) QTreeWidgetItem *root = ui->treeWidgetOptionsDisplayTextOptions->invisibleRootItem(); QTreeWidgetItem *topOfMap = addTopItem(root, tr("Top of Map"), tr("Select information that is displayed on top of the map.")); - addItem(topOfMap, displayOptItemIndex, tr("Wind Direction and Speed"), tr("Show wind direction and speed on the top center of the map."), optsd::ITEM_USER_AIRCRAFT_WIND, true); - addItem(topOfMap, displayOptItemIndex, tr("Wind Pointer"), tr("Show wind direction pointer on the top center of the map."), optsd::ITEM_USER_AIRCRAFT_WIND_POINTER, true); + addItem(topOfMap, displayOptItemIndexUser, tr("Wind Direction and Speed"), tr("Show wind direction and speed on the top center of the map."), optsac::ITEM_USER_AIRCRAFT_WIND, true); + addItem(topOfMap, displayOptItemIndexUser, tr("Wind Pointer"), tr("Show wind direction pointer on the top center of the map."), optsac::ITEM_USER_AIRCRAFT_WIND_POINTER, true); QTreeWidgetItem *navAids = addTopItem(root, tr("Map Navigation Aids"), QString()); addItem(navAids , displayOptItemIndexNavAid, tr("Center Cross"), tr("Shows the map center. Useful if \"Click map to center position\" on page \"Map Navigation\" is enabled."), optsd::NAVAIDS_CENTER_CROSS); @@ -219,31 +219,33 @@ OptionsDialog::OptionsDialog(QMainWindow *parentWindow) addItem(route, displayOptItemIndexRoute, tr("True great circle course"), tr("Show true great circle start course at flight plan leg."), optsd::ROUTE_TRUE_COURSE_GC); QTreeWidgetItem *userAircraft = addTopItem(root, tr("User Aircraft"), tr("Select text labels and other options for the user aircraft.")); - addItem(userAircraft, displayOptItemIndex, tr("Registration"), QString(), optsd::ITEM_USER_AIRCRAFT_REGISTRATION); - addItem(userAircraft, displayOptItemIndex, tr("Type"), tr("Show the aircraft type, like B738, B350 or M20T."), optsd::ITEM_USER_AIRCRAFT_TYPE); - addItem(userAircraft, displayOptItemIndex, tr("Airline"), QString(), optsd::ITEM_USER_AIRCRAFT_AIRLINE); - addItem(userAircraft, displayOptItemIndex, tr("Flight Number"), QString(), optsd::ITEM_USER_AIRCRAFT_FLIGHT_NUMBER); - addItem(userAircraft, displayOptItemIndex, tr("Indicated Airspeed"), tr("Value prefixed with \"IAS\" on the map"), optsd::ITEM_USER_AIRCRAFT_IAS); - addItem(userAircraft, displayOptItemIndex, tr("Ground Speed"), tr("Value prefixed with \"GS\" on the map"), optsd::ITEM_USER_AIRCRAFT_GS, true); - addItem(userAircraft, displayOptItemIndex, tr("True Airspeed"), tr("Value prefixed with \"TAS\" on the map"), optsd::ITEM_USER_AIRCRAFT_TAS); - addItem(userAircraft, displayOptItemIndex, tr("Climb- and Sinkrate"), QString(), optsd::ITEM_USER_AIRCRAFT_CLIMB_SINK); - addItem(userAircraft, displayOptItemIndex, tr("Heading"), tr("Aircraft heading prefixed with \"HDG\" on the map"), optsd::ITEM_USER_AIRCRAFT_HEADING); - addItem(userAircraft, displayOptItemIndex, tr("Actual Altitude"), tr("Real aircraft altitude prefixed with \"ALT\" on the map"), optsd::ITEM_USER_AIRCRAFT_ALTITUDE, false); - addItem(userAircraft, displayOptItemIndex, tr("Indicated Altitude"), tr("Indicated aircraft altitude prefixed with \"IND\" on the map"), optsd::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE, true); - addItem(userAircraft, displayOptItemIndex, tr("Track Line"), tr("Show the aircraft track as a black needle protruding from the aircraft nose."), optsd::ITEM_USER_AIRCRAFT_TRACK_LINE, true); + addItem(userAircraft, displayOptItemIndexUser, tr("Registration"), QString(), optsac::ITEM_USER_AIRCRAFT_REGISTRATION); + addItem(userAircraft, displayOptItemIndexUser, tr("Type"), tr("Show the aircraft type, like B738, B350 or M20T."), optsac::ITEM_USER_AIRCRAFT_TYPE); + addItem(userAircraft, displayOptItemIndexUser, tr("Airline"), QString(), optsac::ITEM_USER_AIRCRAFT_AIRLINE); + addItem(userAircraft, displayOptItemIndexUser, tr("Flight Number"), QString(), optsac::ITEM_USER_AIRCRAFT_FLIGHT_NUMBER); + addItem(userAircraft, displayOptItemIndexUser, tr("Transponder Code"), QString(), optsac::ITEM_USER_AIRCRAFT_TRANSPONDER_CODE); + addItem(userAircraft, displayOptItemIndexUser, tr("Indicated Airspeed"), tr("Value prefixed with \"IAS\" on the map"), optsac::ITEM_USER_AIRCRAFT_IAS); + addItem(userAircraft, displayOptItemIndexUser, tr("Ground Speed"), tr("Value prefixed with \"GS\" on the map"), optsac::ITEM_USER_AIRCRAFT_GS, true); + addItem(userAircraft, displayOptItemIndexUser, tr("True Airspeed"), tr("Value prefixed with \"TAS\" on the map"), optsac::ITEM_USER_AIRCRAFT_TAS); + addItem(userAircraft, displayOptItemIndexUser, tr("Climb- and Sinkrate"), QString(), optsac::ITEM_USER_AIRCRAFT_CLIMB_SINK); + addItem(userAircraft, displayOptItemIndexUser, tr("Heading"), tr("Aircraft heading prefixed with \"HDG\" on the map"), optsac::ITEM_USER_AIRCRAFT_HEADING); + addItem(userAircraft, displayOptItemIndexUser, tr("Actual Altitude"), tr("Real aircraft altitude prefixed with \"ALT\" on the map"), optsac::ITEM_USER_AIRCRAFT_ALTITUDE, false); + addItem(userAircraft, displayOptItemIndexUser, tr("Indicated Altitude"), tr("Indicated aircraft altitude prefixed with \"IND\" on the map"), optsac::ITEM_USER_AIRCRAFT_INDICATED_ALTITUDE, true); + addItem(userAircraft, displayOptItemIndexUser, tr("Track Line"), tr("Show the aircraft track as a black needle protruding from the aircraft nose."), optsac::ITEM_USER_AIRCRAFT_TRACK_LINE, true); QTreeWidgetItem *aiAircraft = addTopItem(root, tr("AI, Multiplayer and Online Client Aircraft"), tr("Select text labels for the AI, multiplayer and online client aircraft.")); - addItem(aiAircraft, displayOptItemIndex, tr("Registration, Number or Callsign"), QString(), optsd::ITEM_AI_AIRCRAFT_REGISTRATION, true); - addItem(aiAircraft, displayOptItemIndex, tr("Type"), QString(), optsd::ITEM_AI_AIRCRAFT_TYPE, true); - addItem(aiAircraft, displayOptItemIndex, tr("Airline"), QString(), optsd::ITEM_AI_AIRCRAFT_AIRLINE, true); - addItem(aiAircraft, displayOptItemIndex, tr("Flight Number"), QString(), optsd::ITEM_AI_AIRCRAFT_FLIGHT_NUMBER); - addItem(aiAircraft, displayOptItemIndex, tr("Indicated Airspeed"), QString(), optsd::ITEM_AI_AIRCRAFT_IAS); - addItem(aiAircraft, displayOptItemIndex, tr("Ground Speed"), QString(), optsd::ITEM_AI_AIRCRAFT_GS, true); - addItem(aiAircraft, displayOptItemIndex, tr("True Airspeed"), QString(), optsd::ITEM_AI_AIRCRAFT_TAS); - addItem(aiAircraft, displayOptItemIndex, tr("Climb- and Sinkrate"), QString(), optsd::ITEM_AI_AIRCRAFT_CLIMB_SINK); - addItem(aiAircraft, displayOptItemIndex, tr("Heading"), QString(), optsd::ITEM_AI_AIRCRAFT_HEADING); - addItem(aiAircraft, displayOptItemIndex, tr("Altitude"), QString(), optsd::ITEM_AI_AIRCRAFT_ALTITUDE, true); - addItem(aiAircraft, displayOptItemIndex, tr("Departure and Destination"), QString(), optsd::ITEM_AI_AIRCRAFT_DEP_DEST, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("Registration, Number or Callsign"), QString(), optsac::ITEM_AI_AIRCRAFT_REGISTRATION, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("Type"), QString(), optsac::ITEM_AI_AIRCRAFT_TYPE, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("Airline"), QString(), optsac::ITEM_AI_AIRCRAFT_AIRLINE, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("Flight Number"), QString(), optsac::ITEM_AI_AIRCRAFT_FLIGHT_NUMBER); + addItem(aiAircraft, displayOptItemIndexAi, tr("Transponder Code"), QString(), optsac::ITEM_AI_AIRCRAFT_TRANSPONDER_CODE); + addItem(aiAircraft, displayOptItemIndexAi, tr("Indicated Airspeed"), QString(), optsac::ITEM_AI_AIRCRAFT_IAS); + addItem(aiAircraft, displayOptItemIndexAi, tr("Ground Speed"), QString(), optsac::ITEM_AI_AIRCRAFT_GS, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("True Airspeed"), QString(), optsac::ITEM_AI_AIRCRAFT_TAS); + addItem(aiAircraft, displayOptItemIndexAi, tr("Climb- and Sinkrate"), QString(), optsac::ITEM_AI_AIRCRAFT_CLIMB_SINK); + addItem(aiAircraft, displayOptItemIndexAi, tr("Heading"), QString(), optsac::ITEM_AI_AIRCRAFT_HEADING); + addItem(aiAircraft, displayOptItemIndexAi, tr("Altitude"), QString(), optsac::ITEM_AI_AIRCRAFT_ALTITUDE, true); + addItem(aiAircraft, displayOptItemIndexAi, tr("Departure and Destination"), QString(), optsac::ITEM_AI_AIRCRAFT_DEP_DEST, true); QTreeWidgetItem *compassRose = addTopItem(root, tr("Compass Rose"), tr("Select display options for the compass rose.")); addItem(compassRose, displayOptItemIndexRose, tr("Direction Labels"), tr("Show N, S, E and W labels."), optsd::ROSE_DIR_LABLES, true); @@ -986,7 +988,8 @@ void OptionsDialog::saveState() state.save(widgets); state.save(this); - saveDisplayOptItemStates(displayOptItemIndex, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS); + saveDisplayOptItemStates(displayOptItemIndexUser, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_USER_AIRCRAFT); + saveDisplayOptItemStates(displayOptItemIndexAi, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_AI_AIRCRAFT); saveDisplayOptItemStates(displayOptItemIndexAirport, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_AIRPORT); saveDisplayOptItemStates(displayOptItemIndexRose, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_COMPASS_ROSE); saveDisplayOptItemStates(displayOptItemIndexMeasurement, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_MEASUREMENT); @@ -1057,7 +1060,8 @@ void OptionsDialog::restoreState() state.restore(this); state.restore(widgets); - restoreOptionItemStates(displayOptItemIndex, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS); + restoreOptionItemStates(displayOptItemIndexUser, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_USER_AIRCRAFT); + restoreOptionItemStates(displayOptItemIndexAi, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_AI_AIRCRAFT); restoreOptionItemStates(displayOptItemIndexAirport, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_AIRPORT); restoreOptionItemStates(displayOptItemIndexRose, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_COMPASS_ROSE); restoreOptionItemStates(displayOptItemIndexMeasurement, lnm::OPTIONS_DIALOG_DISPLAY_OPTIONS_MEASUREMENT); @@ -1519,8 +1523,11 @@ void OptionsDialog::widgetsToOptionData() data.flightplanPassedColor = flightplanPassedColor; data.trailColor = trailColor; - data.displayOptions = optsd::ITEM_NONE; - displayOptWidgetToOptionData(data.displayOptions, displayOptItemIndex); + data.displayOptionsUserAircraft = optsac::ITEM_USER_AIRCRAFT_NONE; + displayOptWidgetToOptionData(data.displayOptionsUserAircraft, displayOptItemIndexUser); + + data.displayOptionsAiAircraft = optsac::ITEM_AI_AIRCRAFT_NONE; + displayOptWidgetToOptionData(data.displayOptionsAiAircraft, displayOptItemIndexAi); data.displayOptionsAirport = optsd::AIRPORT_NONE; displayOptWidgetToOptionData(data.displayOptionsAirport, displayOptItemIndexAirport); @@ -1786,7 +1793,8 @@ void OptionsDialog::optionDataToWidgets(const OptionData& data) flightplanPassedColor = data.flightplanPassedColor; trailColor = data.trailColor; - displayOptDataToWidget(data.displayOptions, displayOptItemIndex); + displayOptDataToWidget(data.displayOptionsUserAircraft, displayOptItemIndexUser); + displayOptDataToWidget(data.displayOptionsAiAircraft, displayOptItemIndexAi); displayOptDataToWidget(data.displayOptionsAirport, displayOptItemIndexAirport); displayOptDataToWidget(data.displayOptionsRose, displayOptItemIndexRose); displayOptDataToWidget(data.displayOptionsMeasurement, displayOptItemIndexMeasurement); diff --git a/src/options/optionsdialog.h b/src/options/optionsdialog.h index 1bd0b6c52..0688b8266 100644 --- a/src/options/optionsdialog.h +++ b/src/options/optionsdialog.h @@ -234,7 +234,8 @@ class OptionsDialog : RangeRingValidator *rangeRingValidator; // Maps options flags to items in the tree widget - QHash displayOptItemIndex; + QHash displayOptItemIndexUser; + QHash displayOptItemIndexAi; QHash displayOptItemIndexAirport; QHash displayOptItemIndexNavAid; QHash displayOptItemIndexRose;