From 99254938b1df8fbeb3013eda08e6e8ddbef7dc73 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 30 Dec 2016 01:52:13 +0100 Subject: [PATCH] refs #844, avoid pending load indicator * Renamed to settingsChanged * update bookings even if not connected --- .../components/atcstationcomponent.cpp | 23 ++++++++++++------- src/blackgui/components/atcstationcomponent.h | 10 ++++---- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index f1e6acaae..ec5b8d58a 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -109,8 +109,8 @@ namespace BlackGui this->ps_airportsRead(); } - // settings have - this->ps_settingsChanged(); + // init settings + this->settingsChanged(); } CAtcStationComponent::~CAtcStationComponent() @@ -142,10 +142,12 @@ namespace BlackGui Q_ASSERT(ui->tvp_AtcStationsOnline); // check if component is visible, if we have already data then skip udpate - bool hasData = this->countBookedStations() > 0 || this->countOnlineStations() > 0; + const bool hasData = this->countBookedStations() > 0 || this->countOnlineStations() > 0; if (hasData && !this->isVisibleWidget()) { // Update skipped, as not visible + ui->tvp_AtcStationsBooked->hideLoadIndicator(); + ui->tvp_AtcStationsOnline->hideLoadIndicator(); return; } @@ -161,10 +163,10 @@ namespace BlackGui // update if (this->m_timestampOnlineStationsChanged > this->m_timestampLastReadOnlineStations) { - // sGui->getIContextNetwork()->getAtcStationsOnline().stationsWithValidVoiceRoom() const CAtcStationsSettings settings = m_settingsAtc.getThreadLocal(); CAtcStationList onlineStations = - sGui->getIContextNetwork()->getAtcStationsOnline().stationsWithValidFrequency(); + sGui->getIContextNetwork()->getAtcStationsOnline().stationsWithValidFrequency(); // alternatively: stationsWithValidVoiceRoom() + if (settings.showOnlyInRange()) { onlineStations.removeIfOutsideRange(); @@ -179,6 +181,7 @@ namespace BlackGui else { ui->tvp_AtcStationsOnline->clear(); + ui->tvp_AtcStationsOnline->hideLoadIndicator(); this->updateTreeView(); } } @@ -196,7 +199,7 @@ namespace BlackGui void CAtcStationComponent::getMetar(const QString &airportIcaoCode) { - QString icao(airportIcaoCode.isEmpty() ? ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper()); + const QString icao(airportIcaoCode.isEmpty() ? ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper()); ui->le_AtcStationsOnlineMetar->setText(icao); if (icao.length() != 4) { return; } CMetar metar(sGui->getIContextNetwork()->getMetarForAirport(icao)); @@ -224,7 +227,7 @@ namespace BlackGui { // trigger new read, which takes some time. A signal will be received when this is done CLogMessage(this).info("Requested new bookings"); - sGui->getIContextNetwork()->readAtcBookingsFromSource(); + sGui->getIContextNetwork()->requestAtcBookingsUpdate(); } else { @@ -246,7 +249,11 @@ namespace BlackGui // a single value is updated (e.g. online status) // just update timestamp, data will be pulled by timer // the timestamp will tell if there are any newer data + // unlike online stations, this can happen if we are not connected to a FSD server + this->m_timestampBookedStationsChanged = QDateTime::currentDateTimeUtc(); + if (this->m_updateTimer.isActive()) { return; } // update by timer + this->update(); } void CAtcStationComponent::ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to) @@ -310,7 +317,7 @@ namespace BlackGui sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier()); } - void CAtcStationComponent::ps_settingsChanged() + void CAtcStationComponent::settingsChanged() { const CViewUpdateSettings settings = this->m_settingsView.get(); const int ms = settings.getAtcUpdateTime().toMs(); diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 89c736e4c..d07bf21b3 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -118,9 +118,6 @@ namespace BlackGui //! Set COM frequency void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit); - //! Settings have been changed - void ps_settingsChanged(); - //! Airports read from web readers void ps_airportsRead(); @@ -131,14 +128,17 @@ namespace BlackGui //! Init the completers void initCompleters(); + //! Settings have been changed + void settingsChanged(); + QScopedPointer ui; QTimer m_updateTimer { this }; QDateTime m_timestampLastReadOnlineStations; //!< stations read QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed QDateTime m_timestampLastReadBookedStations; //!< stations read QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed - BlackMisc::CSettingReadOnly m_settingsView { this, &CAtcStationComponent::ps_settingsChanged }; - BlackMisc::CSettingReadOnly m_settingsAtc { this, &CAtcStationComponent::ps_settingsChanged }; + BlackMisc::CSettingReadOnly m_settingsView { this, &CAtcStationComponent::settingsChanged }; + BlackMisc::CSettingReadOnly m_settingsAtc { this, &CAtcStationComponent::settingsChanged }; }; } // namespace } // namespace