From f0cc1ac003969204a6f9fa1661daf81f42cd1972 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 18 Jan 2015 23:27:18 +0100 Subject: [PATCH] refs #368, updated components * clear when connection status changed * rowCount changed with filter parameter --- src/blackgui/components/aircraftcomponent.cpp | 23 +++++++++++++--- src/blackgui/components/aircraftcomponent.h | 5 +++- .../components/atcstationcomponent.cpp | 9 ++++--- src/blackgui/components/atcstationcomponent.h | 2 +- .../components/cockpitcomcomponent.cpp | 2 +- .../cockpittranspondermodeledscomponent.cpp | 2 +- .../components/simulatorcomponent.cpp | 4 +-- src/blackgui/components/usercomponent.cpp | 27 ++++++++++++++++--- src/blackgui/components/usercomponent.h | 9 ++++++- 9 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/blackgui/components/aircraftcomponent.cpp b/src/blackgui/components/aircraftcomponent.cpp index e75ec0314..d63862e21 100644 --- a/src/blackgui/components/aircraftcomponent.cpp +++ b/src/blackgui/components/aircraftcomponent.cpp @@ -13,9 +13,12 @@ #include "../guiutility.h" #include "blackcore/context_network.h" #include "blackcore/context_simulator.h" +#include "blackcore/network.h" using namespace BlackGui; using namespace BlackGui::Views; +using namespace BlackCore; + namespace BlackGui { @@ -31,8 +34,8 @@ namespace BlackGui this->ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce); m_updateTimer = new CUpdateTimer(SLOT(update()), this); - connect(this->ui->tvp_AircraftInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged); - connect(this->ui->tvp_AirportsInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged); + connect(this->ui->tvp_AircraftInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged); + connect(this->ui->tvp_AirportsInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged); } CAircraftComponent::~CAircraftComponent() @@ -76,7 +79,9 @@ namespace BlackGui void CAircraftComponent::runtimeHasBeenSet() { + Q_ASSERT(this->getIContextNetwork()); connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::ps_infoAreaTabBarChanged); + connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::ps_connectionStatusChanged); } void CAircraftComponent::ps_infoAreaTabBarChanged(int index) @@ -91,9 +96,10 @@ namespace BlackGui Q_UNUSED(index); } - void CAircraftComponent::ps_countChanged(int count) + void CAircraftComponent::ps_onRowCountChanged(int count, bool withFilter) { Q_UNUSED(count); + Q_UNUSED(withFilter); int ac = this->indexOf(this->ui->tb_AircraftInRange); int ap = this->indexOf(this->ui->tb_AirportsInRange); QString acs = this->tabBar()->tabText(ac); @@ -104,5 +110,16 @@ namespace BlackGui this->tabBar()->setTabText(ap, aps); } + void CAircraftComponent::ps_connectionStatusChanged(uint from, uint to) + { + INetwork::ConnectionStatus fromStatus = static_cast(from); + INetwork::ConnectionStatus toStatus = static_cast(to); + Q_UNUSED(fromStatus); + if (INetwork::isDisconnectedStatus(toStatus)) + { + this->ui->tvp_AircraftInRange->clear(); + } + } + } // namespace } // namespace diff --git a/src/blackgui/components/aircraftcomponent.h b/src/blackgui/components/aircraftcomponent.h index 7e5f20baa..01a93a455 100644 --- a/src/blackgui/components/aircraftcomponent.h +++ b/src/blackgui/components/aircraftcomponent.h @@ -71,7 +71,10 @@ namespace BlackGui void ps_infoAreaTabBarChanged(int index); //! Number of elements changed - void ps_countChanged(int count); + void ps_onRowCountChanged(int count, bool withFilter); + + //! Connection status has been changed + void ps_connectionStatusChanged(uint from, uint to); private: QScopedPointer ui; diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index f2a796c7f..e1d4c4016 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -57,12 +57,12 @@ namespace BlackGui connect(this->ui->tvp_AtcStationsOnline, &QTableView::clicked, this, &CAtcStationComponent::ps_onlineAtcStationSelected); connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::ps_testCreateDummyOnlineAtcStations); connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_requestOnlineStationsUpdate); - connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged); - connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged); + connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged); + connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged); connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::ps_setComFrequency); connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked); - connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged); + connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged); connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis); } @@ -231,9 +231,10 @@ namespace BlackGui Q_UNUSED(index); } - void CAtcStationComponent::ps_countChanged(int count) + void CAtcStationComponent::ps_onCountChanged(int count, bool withFilter) { Q_UNUSED(count); + Q_UNUSED(withFilter); int io = this->indexOf(this->ui->tb_AtcStationsOnline); int ib = this->indexOf(this->ui->tb_AtcStationsBooked); QString o = this->tabBar()->tabText(io); diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index f06c38164..98320e5e4 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -107,7 +107,7 @@ namespace BlackGui void ps_infoAreaTabBarChanged(int index); //! Count has been changed - void ps_countChanged(int count); + void ps_onCountChanged(int count, bool withFilter); //! Set COM frequency void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit); diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp index 484c4ec60..b75d12fdf 100644 --- a/src/blackgui/components/cockpitcomcomponent.cpp +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -246,7 +246,7 @@ namespace BlackGui bool CCockpitComComponent::updateOwnCockpitInContext(const CAircraft &ownAircraft) { - return this->getIContextOwnAircraft()->updateOwnCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator()); + return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator()); } void CCockpitComComponent::updateFrequencyDisplaysFromComSystems(const CComSystem &com1, const CComSystem &com2) diff --git a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp index 5bd7580e6..b4c5743a0 100644 --- a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp +++ b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp @@ -69,7 +69,7 @@ namespace BlackGui this->setMode(mode); CTransponder xpdr = ownAircraft.getTransponder(); xpdr.setTransponderMode(mode); - this->getIContextOwnAircraft()->updateOwnCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator()); + this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator()); } void CCockpitTransponderModeLedsComponent::init(bool horizontal) diff --git a/src/blackgui/components/simulatorcomponent.cpp b/src/blackgui/components/simulatorcomponent.cpp index 51f6804af..2a7158cb0 100644 --- a/src/blackgui/components/simulatorcomponent.cpp +++ b/src/blackgui/components/simulatorcomponent.cpp @@ -63,9 +63,9 @@ namespace BlackGui { if (!this->isVisibleWidget()) return; // no updates on invisible widgets if (!this->getIContextOwnAircraft()) return; - if (!this->getIContextSimulator()->isRunning()) + if (!this->getIContextSimulator()->isSimulating()) { - if (this->rowCount() == 1) return; + if (this->rowCount() == 1) { return; } this->clear(); this->addOrUpdateByName("info", "sim not running", CIcons::StandardIconWarning16); return; diff --git a/src/blackgui/components/usercomponent.cpp b/src/blackgui/components/usercomponent.cpp index 8cc0f1a88..d31e5645a 100644 --- a/src/blackgui/components/usercomponent.cpp +++ b/src/blackgui/components/usercomponent.cpp @@ -12,9 +12,11 @@ #include "../guiutility.h" #include "blackmisc/nwuserlist.h" #include "blackcore/context_network.h" +#include "blackcore/network.h" using namespace BlackGui; using namespace BlackGui::Views; +using namespace BlackCore; namespace BlackGui { @@ -30,8 +32,8 @@ namespace BlackGui this->tabBar()->setExpanding(false); this->m_updateTimer = new CUpdateTimer(SLOT(update()), this); - connect(this->ui->tvp_AllUsers, &CUserView::countChanged, this, &CUserComponent::ps_countChanged); - connect(this->ui->tvp_Clients, &CClientView::countChanged, this, &CUserComponent::ps_countChanged); + connect(this->ui->tvp_AllUsers, &CUserView::rowCountChanged, this, &CUserComponent::ps_onCountChanged); + connect(this->ui->tvp_Clients, &CClientView::rowCountChanged, this, &CUserComponent::ps_onCountChanged); } CUserComponent::~CUserComponent() @@ -70,9 +72,16 @@ namespace BlackGui } } - void CUserComponent::ps_countChanged(int count) + void CUserComponent::runtimeHasBeenSet() + { + Q_ASSERT(this->getIContextNetwork()); + this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CUserComponent::ps_connectionStatusChanged); + } + + void CUserComponent::ps_onCountChanged(int count, bool withFilter) { Q_UNUSED(count); + Q_UNUSED(withFilter); int iu = this->indexOf(this->ui->tb_AllUsers); int ic = this->indexOf(this->ui->tb_Clients); QString u = this->tabBar()->tabText(iu); @@ -83,5 +92,17 @@ namespace BlackGui this->tabBar()->setTabText(ic, c); } + void CUserComponent::ps_connectionStatusChanged(uint from, uint to) + { + INetwork::ConnectionStatus fromStatus = static_cast(from); + INetwork::ConnectionStatus toStatus = static_cast(to); + Q_UNUSED(fromStatus); + if (INetwork::isDisconnectedStatus(toStatus)) + { + this->ui->tvp_AllUsers->clear(); + this->ui->tvp_Clients->clear(); + } + } + } // namespace } // namespace diff --git a/src/blackgui/components/usercomponent.h b/src/blackgui/components/usercomponent.h index 9e1145dc5..da1b87a6b 100644 --- a/src/blackgui/components/usercomponent.h +++ b/src/blackgui/components/usercomponent.h @@ -63,9 +63,16 @@ namespace BlackGui //! \copydoc CTimerBasedComponent::stopTimer void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); } + protected: + //! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet + void runtimeHasBeenSet() override; + private slots: //! Number of elements changed - void ps_countChanged(int count); + void ps_onCountChanged(int count, bool withFilter); + + //! Connection status + void ps_connectionStatusChanged(uint from, uint to); private: QScopedPointer ui;