From 20b4044d29e443a218b831c4bfb725faca726357 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 20 Nov 2016 23:03:06 +0100 Subject: [PATCH] Minor UI and style fixes * completer for airports in ATC component * log messages * style fixes --- .../context/contextownaircraftimpl.cpp | 2 +- .../components/atcstationcomponent.cpp | 42 +++++++++++++++++-- src/blackgui/components/atcstationcomponent.h | 10 ++++- src/blackmisc/interpolatorlinear.cpp | 8 ++-- src/plugins/simulator/fsx/simulatorfsx.cpp | 4 +- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/blackcore/context/contextownaircraftimpl.cpp b/src/blackcore/context/contextownaircraftimpl.cpp index a30e00578..6e6375dfa 100644 --- a/src/blackcore/context/contextownaircraftimpl.cpp +++ b/src/blackcore/context/contextownaircraftimpl.cpp @@ -325,7 +325,7 @@ namespace BlackCore void CContextOwnAircraft::ps_allSwiftWebDataRead() { - // we should already receive a reverse lookup model + // we should already have received a reverse lookup model // from the driver } diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index 26768abd8..01fd375bb 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -9,10 +9,12 @@ #include "blackcore/context/contextnetwork.h" #include "blackcore/context/contextownaircraft.h" +#include "blackcore/webdataservices.h" #include "blackgui/components/atcstationcomponent.h" #include "blackgui/guiapplication.h" #include "blackgui/guiutility.h" #include "blackgui/infoarea.h" +#include "blackgui/uppercasevalidator.h" #include "blackgui/models/atcstationlistmodel.h" #include "blackgui/views/atcstationview.h" #include "blackgui/views/viewbase.h" @@ -34,6 +36,7 @@ #include #include #include +#include using namespace BlackGui; using namespace BlackGui::Models; @@ -58,6 +61,8 @@ namespace BlackGui ui->setupUi(this); this->tabBar()->setExpanding(false); this->tabBar()->setUsesScrollButtons(true); + CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar); + ui->le_AtcStationsOnlineMetar->setValidator(ucv); // some icons ui->pb_AtcStationsAtisReload->setIcon(CIcons::atis()); @@ -93,10 +98,17 @@ namespace BlackGui connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update); // runtime based connects - this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::ps_changedAtcStationsOnline); - this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::ps_changedAtcStationsBooked); - this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus); - this->connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::ps_connectionStatusChanged); + connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::ps_changedAtcStationsOnline); + connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::ps_changedAtcStationsBooked); + connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus); + connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::ps_connectionStatusChanged); + + // web readers + if (sGui->hasWebDataServices()) + { + connect(sGui->getWebDataServices(), &CWebDataServices::swiftDbAirportsRead, this, &CAtcStationComponent::ps_airportsRead); + this->ps_airportsRead(); + } // settings have this->ps_settingsChanged(); @@ -174,6 +186,11 @@ namespace BlackGui ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added); } + void CAtcStationComponent::ps_getMetarAsEntered() + { + this->getMetar(""); + } + void CAtcStationComponent::getMetar(const QString &airportIcaoCode) { QString icao(airportIcaoCode.isEmpty() ? ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper()); @@ -296,6 +313,11 @@ namespace BlackGui this->m_updateTimer.setInterval(settings.getAtcUpdateTime().toMs()); } + void CAtcStationComponent::ps_airportsRead() + { + this->initCompleters(); + } + void CAtcStationComponent::updateTreeView() { //! \fixme EXPERIMENTAL CODE: change model so we can directly use hierarchies @@ -313,6 +335,18 @@ namespace BlackGui } } + void CAtcStationComponent::initCompleters() + { + if (!sGui || !sGui->getWebDataServices()) { return; } + const QStringList airports = sGui->getWebDataServices()->getAirports().allIcaoCodes(true); + if (!airports.isEmpty()) + { + QCompleter *airportCompleter = new QCompleter(airports, this); + airportCompleter->popup()->setMinimumWidth(75); + ui->le_AtcStationsOnlineMetar->setCompleter(airportCompleter); + } + } + void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index) { ui->te_AtcStationsOnlineInfo->setText(""); // reset diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 6cf9d4145..28525cf41 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -79,7 +79,7 @@ namespace BlackGui private slots: //! Get all METARs - void ps_getMetarAsEntered() { this->getMetar(""); } + void ps_getMetarAsEntered(); //! Request new ATIS void ps_requestAtis(); @@ -120,8 +120,16 @@ namespace BlackGui //! Settings have been changed void ps_settingsChanged(); + //! Airports read from web readers + void ps_airportsRead(); + private: + //! Build a tree view for ATC stations void updateTreeView(); + + //! Init the completers + void initCompleters(); + QScopedPointer ui; QTimer m_updateTimer { this }; QDateTime m_timestampLastReadOnlineStations; //!< stations read diff --git a/src/blackmisc/interpolatorlinear.cpp b/src/blackmisc/interpolatorlinear.cpp index fab85c648..91ab25ab3 100644 --- a/src/blackmisc/interpolatorlinear.cpp +++ b/src/blackmisc/interpolatorlinear.cpp @@ -104,7 +104,7 @@ namespace BlackMisc // 1) values > 1 mean extrapolation // 2) values > 2 mean no new situations coming in double distanceToSplitTime = newSituation.getAdjustedMSecsSinceEpoch() - currentTimeMsSinceEpoc; - double simulationTimeFraction = 1 - (distanceToSplitTime / deltaTime); + double simulationTimeFraction = 1.0 - (distanceToSplitTime / deltaTime); if (simulationTimeFraction > 2.0) { if (setup.showInterpolatorDebugMessages()) @@ -164,9 +164,9 @@ namespace BlackMisc currentSituation.setPitch(pitch); // Interpolate bank: Bank = (BankB - BankA) * t + BankA - CAngle bankBegin = oldSituation.getBank(); - CAngle bankEnd = newSituation.getBank(); - CAngle bank = (bankEnd - bankBegin) * simulationTimeFraction + bankBegin; + const CAngle bankBegin = oldSituation.getBank(); + const CAngle bankEnd = newSituation.getBank(); + const CAngle bank = (bankEnd - bankBegin) * simulationTimeFraction + bankBegin; currentSituation.setBank(bank); currentSituation.setGroundSpeed((newSituation.getGroundSpeed() - oldSituation.getGroundSpeed()) diff --git a/src/plugins/simulator/fsx/simulatorfsx.cpp b/src/plugins/simulator/fsx/simulatorfsx.cpp index 4a4dd36bc..5c209dc55 100644 --- a/src/plugins/simulator/fsx/simulatorfsx.cpp +++ b/src/plugins/simulator/fsx/simulatorfsx.cpp @@ -589,7 +589,7 @@ namespace BlackSimPlugin if (!simObject.getAircraftModelString().isEmpty()) { this->m_outOfRealityBubble.push_back(simObject.getAircraft()); - CLogMessage(this).info("Aircraft '%1' '%2' '%3' out of reality bubble") << callsign.toQString() << simObject.getAircraftModelString() << objectID; + CLogMessage(this).info("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble") << callsign.toQString() << simObject.getAircraftModelString() << objectID; } else { @@ -600,8 +600,6 @@ namespace BlackSimPlugin // in all cases we remove const int c = m_simConnectObjects.remove(callsign); ok = c > 0; - CLogMessage(this).info("FSX: Removed aircraft '%1'") << simObject.getCallsign().toQString(); - const bool updated = this->updateAircraftRendered(simObject.getCallsign(), false); if (updated) {