From 9dd06c4c844188ee920b37c9e96e568d4a05442a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 11 Oct 2018 03:21:36 +0200 Subject: [PATCH] Ref T397, fixed "disable" for fast positions --- src/blackcore/airspacemonitor.cpp | 12 +++++++++++- src/blackcore/network.h | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 012ecb6ac..aef4c5ef1 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -125,7 +125,17 @@ namespace BlackCore QTimer::singleShot(0, m_network, [ = ] { if (!myself) { return; } - if (m_network) { m_network->addInterimPositionReceiver(callsign); } + if (m_network) + { + if (enableFastPositonUpdates) + { + m_network->addInterimPositionReceiver(callsign); + } + else + { + m_network->removeInterimPositionReceiver(callsign); + } + } }); } return r; diff --git a/src/blackcore/network.h b/src/blackcore/network.h index 77444f0e9..7d06a9779 100644 --- a/src/blackcore/network.h +++ b/src/blackcore/network.h @@ -357,20 +357,32 @@ namespace BlackCore */ virtual void setInterimPositionReceivers(const BlackMisc::Aviation::CCallsignSet &receiver) = 0; + /*! + * Get the group of callsigns receiving regular interim position updates. + */ + virtual const BlackMisc::Aviation::CCallsignSet &getInterimPositionReceivers() const = 0; + /*! * Add callsign receiving regular interim position updates. */ - virtual void addInterimPositionReceiver(const BlackMisc::Aviation::CCallsign &receiver) + void addInterimPositionReceiver(const BlackMisc::Aviation::CCallsign &receiver) { BlackMisc::Aviation::CCallsignSet set = this->getInterimPositionReceivers(); + if (set.contains(receiver)) { return; } // already in set set.push_back(receiver); this->setInterimPositionReceivers(set); } /*! - * Get the group of callsigns receiving regular interim position updates. + * Remove callsign receiving regular interim position updates. */ - virtual const BlackMisc::Aviation::CCallsignSet &getInterimPositionReceivers() const = 0; + void removeInterimPositionReceiver(const BlackMisc::Aviation::CCallsign &receiver) + { + BlackMisc::Aviation::CCallsignSet set = this->getInterimPositionReceivers(); + if (!set.contains(receiver)) { return; } // nothing to remove + set.remove(receiver); + this->setInterimPositionReceivers(set); + } //! @} ////////////////////////////////////////////////////////////////