From a4fc474d0930a4ce9ebe9bc30a57fac67b268f3b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 17 Sep 2018 20:03:20 +0200 Subject: [PATCH] Ref T345, directly update ATC stations when "in range" radio button changes - forced update - use component directly, no copy of settings --- src/blackgui/components/atcstationcomponent.cpp | 10 +++++++++- src/blackgui/components/atcstationcomponent.h | 4 +++- .../components/settingsatcstationsinlinecomponent.cpp | 8 ++++++-- .../components/settingsatcstationsinlinecomponent.h | 11 +++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index a99ac7719..69311f503 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -96,6 +96,8 @@ namespace BlackGui connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::setComFrequency); connect(ui->tvp_AtcStationsOnline, &CAtcStationView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget); + connect(ui->comp_AtcStationsSettings, &CSettingsAtcStationsInlineComponent::changed, this, &CAtcStationComponent::forceUpdate, Qt::QueuedConnection); + connect(ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::reloadAtcStationsBooked); connect(ui->tvp_AtcStationsBooked, &CAtcStationView::requestNewBackendData, this, &CAtcStationComponent::reloadAtcStationsBooked); connect(ui->tvp_AtcStationsBooked, &CAtcStationView::modelDataChangedDigest, this, &CAtcStationComponent::onCountChanged); @@ -152,6 +154,12 @@ namespace BlackGui return c && parentDockableWidget; } + void CAtcStationComponent::forceUpdate() + { + m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc(); + this->update(); + } + void CAtcStationComponent::update() { if (!this->canAccessContext()) { return; } @@ -180,7 +188,7 @@ namespace BlackGui // update if (m_timestampOnlineStationsChanged > m_timestampLastReadOnlineStations) { - const CAtcStationsSettings settings = m_settingsAtc.getThreadLocal(); + const CAtcStationsSettings settings = ui->comp_AtcStationsSettings->getSettings(); CAtcStationList onlineStations = sGui->getIContextNetwork()->getAtcStationsOnline(true).stationsWithValidFrequency(); // alternatively: stationsWithValidVoiceRoom() diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 9765a6710..492a3d9c7 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -88,6 +88,9 @@ namespace BlackGui void requestAudioWidget(); private: + //! Set timestampd and call update + void forceUpdate(); + //! \copydoc Models::CAtcStationListModel::changedAtcStationConnectionStatus void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added); @@ -155,7 +158,6 @@ namespace BlackGui QDateTime m_timestampLastReadBookedStations; //!< stations read QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed BlackMisc::CSettingReadOnly m_settingsView { this, &CAtcStationComponent::settingsChanged }; - BlackMisc::CSettingReadOnly m_settingsAtc { this, &CAtcStationComponent::settingsChanged }; }; } // namespace } // namespace diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp b/src/blackgui/components/settingsatcstationsinlinecomponent.cpp index bc6f0fd8e..cdb781aeb 100644 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp +++ b/src/blackgui/components/settingsatcstationsinlinecomponent.cpp @@ -27,7 +27,7 @@ namespace BlackGui CSettingsAtcStationsInlineComponent::~CSettingsAtcStationsInlineComponent() { } - void CSettingsAtcStationsInlineComponent::settingsChanged() + void CSettingsAtcStationsInlineComponent::onSettingsChanged() { const CAtcStationsSettings s = m_atcSettings.getThreadLocal(); ui->rb_InRange->setChecked(s.showOnlyInRange()); @@ -35,9 +35,13 @@ namespace BlackGui void CSettingsAtcStationsInlineComponent::changeSettings() { + const bool onlyInRange = ui->rb_InRange->isChecked(); CAtcStationsSettings s = m_atcSettings.getThreadLocal(); - s.setShowOnlyInRange(ui->rb_InRange->isChecked()); + if (s.showOnlyInRange() && onlyInRange) { return; } + s.setShowOnlyInRange(onlyInRange); m_atcSettings.setAndSave(s); + + emit this->changed(); } } // ns } // ns diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.h b/src/blackgui/components/settingsatcstationsinlinecomponent.h index af8225b81..86101b01d 100644 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.h +++ b/src/blackgui/components/settingsatcstationsinlinecomponent.h @@ -34,15 +34,22 @@ namespace BlackGui //! Destructor virtual ~CSettingsAtcStationsInlineComponent(); + //! Get the settings + Settings::CAtcStationsSettings getSettings() const { return m_atcSettings.get(); } + + signals: + //! Changed value + void changed(); + private: //! Settings have been changed - void settingsChanged(); + void onSettingsChanged(); //! Change the settings void changeSettings(); QScopedPointer ui; - BlackMisc::CSetting m_atcSettings { this, &CSettingsAtcStationsInlineComponent::settingsChanged }; + BlackMisc::CSetting m_atcSettings { this, &CSettingsAtcStationsInlineComponent::onSettingsChanged }; }; } // ns } // ns