From a0c8f3778b2d5a6debc1289acbbb812939d7de18 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 17 Jan 2019 12:48:34 +0100 Subject: [PATCH] Ref T515, context menus for re-matching * added re-matching for single aircraft * re-ordered --- .../context/contextsimulatorimpl.cpp | 2 +- src/blackgui/components/aircraftcomponent.cpp | 2 +- src/blackgui/components/mappingcomponent.cpp | 4 +- src/blackgui/menus/menuaction.cpp | 2 +- src/blackgui/views/simulatedaircraftview.cpp | 51 +++++++++++++++---- src/blackgui/views/simulatedaircraftview.h | 9 +++- 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index a572d7f82..3f7d941f0 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -953,7 +953,7 @@ namespace BlackCore resetAircraft.resetToNetworkModel(); this->xCtxAddedRemoteAircraftReadyForModelMatching(resetAircraft); }); - return false; + return true; } void CContextSimulator::onSimulatorStarted(const CSimulatorPluginInfo &info) diff --git a/src/blackgui/components/aircraftcomponent.cpp b/src/blackgui/components/aircraftcomponent.cpp index 886ce5955..dae88ab84 100644 --- a/src/blackgui/components/aircraftcomponent.cpp +++ b/src/blackgui/components/aircraftcomponent.cpp @@ -57,7 +57,7 @@ namespace BlackGui this->tabBar()->setUsesScrollButtons(true); ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce); ui->tvp_AircraftInRange->setAircraftMode(CSimulatedAircraftListModel::NetworkMode); - ui->tvp_AircraftInRange->configureMenu(true, false, true, true); + ui->tvp_AircraftInRange->configureMenu(true, true, false, true, true); connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged); connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestTextMessageWidget, this, &CAircraftComponent::requestTextMessageWidget); diff --git a/src/blackgui/components/mappingcomponent.cpp b/src/blackgui/components/mappingcomponent.cpp index 00ed08a11..c3ac5b7ba 100644 --- a/src/blackgui/components/mappingcomponent.cpp +++ b/src/blackgui/components/mappingcomponent.cpp @@ -315,8 +315,8 @@ namespace BlackGui void CMappingComponent::doMatchingsAgain() { if (!sGui || !sGui->getIContextSimulator() || !sGui->getISimulator() || !sGui->getISimulator()->isConnected()) { return; } - const int reMatchedNo = sGui->getIContextSimulator()->doMatchingsAgain(); - CLogMessage(this).info(u"Triggered re-apping of %1 aircraft") << reMatchedNo; + const int rematchedNumber = sGui->getIContextSimulator()->doMatchingsAgain(); + CLogMessage(this).info(u"Triggered re-matching of %1 aircraft") << rematchedNumber; } void CMappingComponent::onSaveAircraft() diff --git a/src/blackgui/menus/menuaction.cpp b/src/blackgui/menus/menuaction.cpp index 2ca1a5035..476d969a4 100644 --- a/src/blackgui/menus/menuaction.cpp +++ b/src/blackgui/menus/menuaction.cpp @@ -103,7 +103,7 @@ namespace BlackGui const CMenuAction &CMenuAction::subMenuDisplayModels() { - static const CMenuAction subdir(CIcons::appAircraft16(), "Display models", CMenuAction::pathClientSimulationDisplay()); + static const CMenuAction subdir(CIcons::appAircraft16(), "Display and render models", CMenuAction::pathClientSimulationDisplay()); return subdir; } diff --git a/src/blackgui/views/simulatedaircraftview.cpp b/src/blackgui/views/simulatedaircraftview.cpp index bbcdd6360..fb87a9d80 100644 --- a/src/blackgui/views/simulatedaircraftview.cpp +++ b/src/blackgui/views/simulatedaircraftview.cpp @@ -23,6 +23,7 @@ using namespace BlackConfig; using namespace BlackMisc; +using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; using namespace BlackCore::Context; using namespace BlackGui::Models; @@ -45,12 +46,13 @@ namespace BlackGui this->setSortIndicator(); } - void CSimulatedAircraftView::configureMenu(bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag) + void CSimulatedAircraftView::configureMenu(bool menuRecalculate, bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag) { - m_withMenuEnableAircraft = menuEnableAircraft; - m_withMenuFastPosition = menuFastPositionUpdates; + m_withRecalculate = menuRecalculate; + m_withMenuEnableAircraft = menuEnableAircraft; + m_withMenuFastPosition = menuFastPositionUpdates; m_withMenuHighlightAndFollow = menuHighlightAndFollow; - m_withMenuEnableGndFlag = menuGndFlag; + m_withMenuEnableGndFlag = menuGndFlag; } void CSimulatedAircraftView::configureMenuFastPositionUpdates(bool menuFastPositionUpdates) @@ -65,17 +67,26 @@ namespace BlackGui menuActions.addMenuDisplayModels(); menuActions.addMenuDataTransfer(); - menuActions.addAction(CIcons::appInterpolation16(), "Recalculate all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::recalculateAllAircraft }); + if (m_menus.testFlag(MenuDisableModelsTemp) && this->hasSelection()) + { + menuActions.addAction(CIcons::delete16(), "Temp.disable model from set", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::requestTempDisable }); + } + + if (m_withRecalculate) + { + menuActions.addAction(CIcons::appInterpolation16(), "Re-calculate all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::recalculateAllAircraft }); + menuActions.addAction(CIcons::appInterpolation16(), "Re-matching all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::doMatchingsAgain }); + if (this->hasSelection()) + { + menuActions.addAction(CIcons::appInterpolation16(), "Re-matching selected", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::doMatchingsAgainForSelected }); + } + } if (m_withMenuEnableAircraft && !this->isEmpty()) { menuActions.addAction(CIcons::appAircraft16(), "Enable all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::enableAllDisabledAircraft }); - menuActions.addAction(CIcons::appAircraft16(), "Disable all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::disableAllEnabledAircraft }); menuActions.addAction(CIcons::appAircraft16(), "Re-enable unrendered aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::reEnableAllUnrenderedAircraft }); - if (m_menus.testFlag(MenuDisableModelsTemp) && this->hasSelection()) - { - menuActions.addAction(CIcons::delete16(), "Temp.disable model", CMenuAction::pathModel(), { this, &CSimulatedAircraftView::requestTempDisable }); - } + menuActions.addAction(CIcons::appAircraft16(), "Disable all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::disableAllEnabledAircraft }); } if (this->hasSelection()) @@ -241,6 +252,26 @@ namespace BlackGui simContext->recalculateAllAircraft(); } + void CSimulatedAircraftView::doMatchingsAgain() + { + IContextSimulator *simContext = simulatorContext(); + if (!simContext) { return; } + const int rematchedNumber = simContext->doMatchingsAgain(); + CLogMessage(this).info(u"Triggered re-matching of %1 aircraft") << rematchedNumber; + } + + void CSimulatedAircraftView::doMatchingsAgainForSelected() + { + IContextSimulator *simContext = simulatorContext(); + if (!simContext) { return; } + if (!this->hasSelection()) { return; } + const CCallsign cs = this->selectedObject().getCallsign(); + if (simContext->doMatchingAgain(cs)) + { + CLogMessage(this).info(u"Triggered re-matching of '%1'") << cs.asString(); + } + } + void CSimulatedAircraftView::enableFastPositionUpdates(const CSimulatedAircraft &aircraft) { IContextNetwork *nwContext = networkContext(); diff --git a/src/blackgui/views/simulatedaircraftview.h b/src/blackgui/views/simulatedaircraftview.h index 410c52ef2..3cb6b3b25 100644 --- a/src/blackgui/views/simulatedaircraftview.h +++ b/src/blackgui/views/simulatedaircraftview.h @@ -51,7 +51,7 @@ namespace BlackGui void setAircraftMode(Models::CSimulatedAircraftListModel::AircraftMode mode); //! Configure the menu - void configureMenu(bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag); + void configureMenu(bool menuRecalculate, bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag); //! Configure fast position updates menu void configureMenuFastPositionUpdates(bool menuFastPositionUpdates); @@ -113,6 +113,12 @@ namespace BlackGui //! Fully recalculate all aircraft void recalculateAllAircraft(); + //! Match all aircraft again + void doMatchingsAgain(); + + //! Match all aircraft again + void doMatchingsAgainForSelected(); + //! Enable fast position updates void enableFastPositionUpdates(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); @@ -128,6 +134,7 @@ namespace BlackGui //! Network context static BlackCore::Context::IContextNetwork *networkContext(); + bool m_withRecalculate = true; bool m_withMenuHighlightAndFollow = true; bool m_withMenuEnableAircraft = true; bool m_withMenuEnableGndFlag = true;