diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index 732d42fd4..74ca59639 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -143,6 +143,9 @@ namespace BlackCore //! Read for model matching void readyForModelMatching(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft); + //! An ATIS has been received + void atisReceived(const BlackMisc::Aviation::CCallsign &callsign); + private: //! Used to temporary store FsInn data struct FsInnPacket diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index bcbeed103..9a2ed0f58 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -88,6 +88,7 @@ namespace BlackCore connect(m_airspace, &CAirspaceMonitor::removedAircraft, this, &IContextNetwork::removedAircraft); // DBus connect(m_airspace, &CAirspaceMonitor::readyForModelMatching, this, &CContextNetwork::readyForModelMatching); connect(m_airspace, &CAirspaceMonitor::addedAircraft, this, &CContextNetwork::addedAircraft); + connect(m_airspace, &CAirspaceMonitor::atisReceived, this, &CContextNetwork::onAtisReceived); } CContextNetwork *CContextNetwork::registerWithDBus(BlackMisc::CDBusServer *server) @@ -489,6 +490,12 @@ namespace BlackCore CLogMessage(this).info("%1 METARs updated") << metars.size(); } + void CContextNetwork::onAtisReceived(const CCallsign &callsign) + { + Q_UNUSED(callsign); + m_dsAtcStationsOnlineChanged.inputSignal(); // the ATIS data are stored in the station object + } + void CContextNetwork::checkForSupervisiorTextMessage(const CTextMessageList &messages) { if (messages.containsPrivateMessages()) diff --git a/src/blackcore/context/contextnetworkimpl.h b/src/blackcore/context/contextnetworkimpl.h index 0dbb04f9a..0857e5b83 100644 --- a/src/blackcore/context/contextnetworkimpl.h +++ b/src/blackcore/context/contextnetworkimpl.h @@ -231,9 +231,9 @@ namespace BlackCore QTimer *m_networkDataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates() // Digest signals, only sending after some time - BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 }; - BlackMisc::CDigestSignal m_dsAtcStationsOnlineChanged { this, &IContextNetwork::changedAtcStationsOnline, &IContextNetwork::changedAtcStationsOnlineDigest, 750, 4 }; - BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftInRange, &IContextNetwork::changedAircraftInRangeDigest, 750, 4 }; + BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 1000, 2 }; + BlackMisc::CDigestSignal m_dsAtcStationsOnlineChanged { this, &IContextNetwork::changedAtcStationsOnline, &IContextNetwork::changedAtcStationsOnlineDigest, 1000, 4 }; + BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftInRange, &IContextNetwork::changedAircraftInRangeDigest, 1000, 4 }; //! Own aircraft from \sa CContextOwnAircraft const BlackMisc::Simulation::CSimulatedAircraft ownAircraft() const; @@ -241,6 +241,9 @@ namespace BlackCore //! Update METAR collection void updateMetars(const BlackMisc::Weather::CMetarList &metars); + //! An ATIS has been received + void onAtisReceived(const BlackMisc::Aviation::CCallsign &callsign); + //! Check if a supervisor message was received void checkForSupervisiorTextMessage(const BlackMisc::Network::CTextMessageList &messages); diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index d6918d477..96fbcd2b0 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -38,8 +38,8 @@ #include #include #include +#include -using namespace BlackGui; using namespace BlackGui::Models; using namespace BlackGui::Views; using namespace BlackGui::Settings; @@ -292,7 +292,12 @@ namespace BlackGui if (this->isParentDockWidgetFloating()) { return; } // here I know I am the selected widget, update, but keep GUI responsive (-> timer) - QTimer::singleShot(1000, this, &CAtcStationComponent::update); + const QPointer myself(this); + QTimer::singleShot(1000, this, [ = ] + { + if (myself.isNull()) { return; } + this->update(); + }); Q_UNUSED(index); } diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index e08f64d86..51f4763d4 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -61,6 +61,12 @@ namespace BlackGui //! Number of online stations int countOnlineStations() const; + //! Update stations + void update(); + + //! Get METAR for given ICAO airport code + void getMetar(const QString &airportIcaoCode); + //! \copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override; @@ -68,17 +74,10 @@ namespace BlackGui //! Request a text message void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign); - public slots: - //! Update stations - void update(); - - //! Get METAR for given ICAO airport code - void getMetar(const QString &airportIcaoCode); - + private: //! \copydoc Models::CAtcStationListModel::changedAtcStationConnectionStatus void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added); - private: //! Get all METARs void getMetarAsEntered();