From 2d1226fefc2f21e504418a9e2b08f2d781562d15 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 14 Sep 2014 00:13:19 +0200 Subject: [PATCH] refs #325, reduced loading in ATC stations component --- .../components/atcstationcomponent.cpp | 18 ++++++++++++++++++ src/blackgui/components/atcstationcomponent.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index bb6ece28b..ca439a23b 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -55,6 +55,16 @@ namespace BlackGui delete ui; } + int CAtcStationComponent::countBookedStations() const + { + return ui->tvp_AtcStationsBooked->rowCount(); + } + + int CAtcStationComponent::countOnlineStations() const + { + return ui->tvp_AtcStationsOnline->rowCount(); + } + void CAtcStationComponent::runtimeHasBeenSet() { Q_ASSERT(this->getRuntime()); @@ -74,6 +84,14 @@ namespace BlackGui Q_ASSERT(this->ui->tvp_AtcStationsOnline); Q_ASSERT(this->getIContextNetwork()); + // check if component is visible, if we have already data then skip udpate + bool hasData = this->countBookedStations() > 0 || this->countOnlineStations() > 0; + if (hasData && !this->isVisibleWidget()) + { + qDebug() << this->objectName() << "Skipping update, not visible"; + return; + } + // bookings if (this->m_timestampBookedStationsChanged > this->m_timestampLastReadBookedStations) { diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index f09f13e83..800a2d6ad 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -47,6 +47,12 @@ namespace BlackGui //! Timer for updating CTimerBasedComponent *getTimerComponent() { return this->m_timerComponent; } + //! Number of booked stations + int countBookedStations() const; + + //! Number of online stations + int countOnlineStations() const; + public slots: //! Update stations void update();