diff --git a/src/blackcore/network.h b/src/blackcore/network.h index 3e1a075fe..53924d8df 100644 --- a/src/blackcore/network.h +++ b/src/blackcore/network.h @@ -125,6 +125,16 @@ namespace BlackCore return status == Disconnecting || status == Connecting; } + /*! + * Returns true if the given ConnectionStatus represents a disconnected state. + */ + static bool isDisconnectedStatus(ConnectionStatus status) + { + return status == Disconnected || status == DisconnectedError || + status == DisconnectedFailed || status == DisconnectedLost; + } + + /*! * Returns true if the current ConnectionStatus is a connected state. */ diff --git a/src/blackgui/atcstationcomponent.cpp b/src/blackgui/atcstationcomponent.cpp index 53e0297d9..9763734eb 100644 --- a/src/blackgui/atcstationcomponent.cpp +++ b/src/blackgui/atcstationcomponent.cpp @@ -35,9 +35,13 @@ namespace BlackGui { Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getIContextNetwork()); - this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline); - this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked); - this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus); + if (this->getIContextNetwork()) + { + this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline); + this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked); + this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus); + this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::connectionStatusChanged); + } } void CAtcStationComponent::update() @@ -62,6 +66,7 @@ namespace BlackGui } else { + this->ui->tvp_AtcStationsOnline->clear(); this->ui->le_AtcStationsOnlineMetar->clear(); } } @@ -87,10 +92,23 @@ namespace BlackGui void CAtcStationComponent::changedAtcStationsOnline() { // just update timestamp, data will be pulled by time - // the timestamp will tell if there are newer data + // the timestamp will tell if there are any newer data this->m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc(); } + void CAtcStationComponent::connectionStatusChanged(uint from, uint to, const QString &message) + { + INetwork::ConnectionStatus fromStatus = static_cast(from); + INetwork::ConnectionStatus toStatus = static_cast(to); + Q_UNUSED(fromStatus); + Q_UNUSED(message); + if (INetwork::isDisconnectedStatus(toStatus)) + { + this->ui->tvp_AtcStationsOnline->clear(); + this->ui->le_AtcStationsOnlineMetar->clear(); + } + } + void CAtcStationComponent::changedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool added) { this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added); @@ -103,14 +121,24 @@ namespace BlackGui void CAtcStationComponent::getMetar(const QString &airportIcaoCode) { - if (!this->getIContextNetwork()->isConnected()) return; + if (!this->getIContextNetwork()->isConnected()) + { + this->ui->te_AtcStationsOnlineInfo->clear(); + return; + } QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper(); this->ui->le_AtcStationsOnlineMetar->setText(icao); if (icao.length() != 4) return; CInformationMessage metar = this->getIContextNetwork()->getMetar(icao); if (metar.getType() != CInformationMessage::METAR) return; - if (metar.isEmpty()) return; - this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage()); + if (metar.isEmpty()) + { + this->ui->te_AtcStationsOnlineInfo->clear(); + } + else + { + this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage()); + } } void CAtcStationComponent::onlineAtcStationSelected(QModelIndex index) diff --git a/src/blackgui/atcstationcomponent.h b/src/blackgui/atcstationcomponent.h index 59382e263..fd8c16ac8 100644 --- a/src/blackgui/atcstationcomponent.h +++ b/src/blackgui/atcstationcomponent.h @@ -72,6 +72,9 @@ namespace BlackGui //! Online stations changed void changedAtcStationsOnline(); + //! Connection status has been changed + void connectionStatusChanged(uint from, uint to, const QString &message); + private: Ui::CAtcStationComponent *ui; CTimerBasedComponent *m_timerComponent; diff --git a/src/blackgui/textmessagecomponent.cpp b/src/blackgui/textmessagecomponent.cpp index 4c5cca444..4eae4e7cb 100644 --- a/src/blackgui/textmessagecomponent.cpp +++ b/src/blackgui/textmessagecomponent.cpp @@ -175,8 +175,11 @@ namespace BlackGui void CTextMessageComponent::showCurrentFrequenciesFromCockpit() { const CAircraft ownAircraft = this->getOwnAircraft(); - const QString f1 = QString("COM1: %1").arg(ownAircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); - const QString f2 = QString("COM2: %1").arg(ownAircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); + QString f1n, f2n; + f1n.sprintf("%03.3f", ownAircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); + f2n.sprintf("%03.3f", ownAircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); + const QString f1 = QString("COM1: %1").arg(f1n); + const QString f2 = QString("COM2: %1").arg(f2n); this->ui->tb_TextMessagesCOM1->setToolTip(f1); this->ui->tb_TextMessagesCOM1->setToolTip(f2); this->setTabText(this->indexOf(this->ui->tb_TextMessagesCOM1), f1); diff --git a/src/blackmisc/setaudio.cpp b/src/blackmisc/setaudio.cpp index 6ec4a88f4..3b7f4105e 100644 --- a/src/blackmisc/setaudio.cpp +++ b/src/blackmisc/setaudio.cpp @@ -134,7 +134,9 @@ namespace BlackMisc this->initNotificationFlags(); } - + /* + * Flags + */ void CSettingsAudio::initNotificationFlags() { // if we add flags in the future, we automatically extend ... diff --git a/src/blackmisc/settingutilities.h b/src/blackmisc/settingutilities.h index c06cbafd0..2b8b8c1a0 100644 --- a/src/blackmisc/settingutilities.h +++ b/src/blackmisc/settingutilities.h @@ -15,7 +15,7 @@ namespace BlackMisc public: - //! \brief Command validate + //! Command validate static const QString &CmdValidate() { static const QString cmd("validate"); @@ -57,31 +57,34 @@ namespace BlackMisc return cmd; } - //! \brief Wrong path message + //! Wrong path message static BlackMisc::CStatusMessage wrongPathMessage(const QString &path = ""); - //! \brief Wrong path messages + //! Wrong path messages static BlackMisc::CStatusMessageList wrongPathMessages(const QString &path = ""); - //! \brief Value not changed message + //! Value not changed message static BlackMisc::CStatusMessage valueNotChangedMessage(const QString &valueName); - //! \brief Value changed message + //! Value changed message with flag + static CStatusMessage valueChangedMessage(bool changed, const QString &valueName); + + //! Value changed message static BlackMisc::CStatusMessage valueChangedMessage(const QString &valueName); - //! \brief Remove leading path + //! Remove leading path static QString removeLeadingPath(const QString &path); - //! \brief Append setting paths + //! Append setting paths static QString appendPaths(const QString &part1, const QString &part2, const QString &part3 = ""); - //! \brief prepare the settings directory, if required create it + //! prepare the settings directory, if required create it static bool initSettingsDirectory(); - //! \brief get the settings directory + //! get the settings directory static const QString &getSettingsDirectory(); - //! \brief get the settings directory + //! get the settings directory static const QString &getSettingsFile(); }; diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index 82bcdfd8d..2586591c9 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -173,7 +173,7 @@ namespace BlackMisc default: static QString x("unknown type"); qFatal("Unknown type"); - return x; // just for compiler warning + return x; } } diff --git a/src/blacksim/fscommon/aircraftmapping.h b/src/blacksim/fscommon/aircraftmapping.h index 8db8005a5..b954e0342 100644 --- a/src/blacksim/fscommon/aircraftmapping.h +++ b/src/blacksim/fscommon/aircraftmapping.h @@ -7,7 +7,7 @@ #define BLACKSIM_FSCOMMON_AIRCRAFTMAPPING_H #include "aircraftcfgentries.h" -#include "../simulatorinfo.h" +#include "blacksim/simulatorinfo.h" #include "blackmisc/valueobject.h" #include #include diff --git a/src/blacksim/simulatorinfolist.h b/src/blacksim/simulatorinfolist.h index ff54f679c..391f265c1 100644 --- a/src/blacksim/simulatorinfolist.h +++ b/src/blacksim/simulatorinfolist.h @@ -3,9 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/*! - \file -*/ +//! \file #ifndef BLACKSIM_SIMULATORINFOLIST_H #define BLACKSIM_SIMULATORINFOLIST_H diff --git a/tests/blackmisc/testcontainers.cpp b/tests/blackmisc/testcontainers.cpp index 8d2bad3c9..c0068b013 100644 --- a/tests/blackmisc/testcontainers.cpp +++ b/tests/blackmisc/testcontainers.cpp @@ -4,8 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "testcontainers.h" +#include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/collection.h" #include "blackmisc/sequence.h" +#include "blackmisc/avcallsignlist.h" #include #include #include @@ -13,6 +15,7 @@ #include using namespace BlackMisc; +using namespace BlackMisc::Aviation; namespace BlackMiscTest { @@ -109,4 +112,16 @@ namespace BlackMiscTest QVERIFY2(c1 == c3, "Split collections"); } -} //namespace BlackMiscTest \ No newline at end of file + void CTestContainers::findTests() + { + BlackMisc::registerMetadata(); + CCallsignList callsigns; + CSequence found = callsigns.findBy(&CCallsign::asString, "Foo"); + QVERIFY2(found.isEmpty(), "Empty found"); + callsigns.push_back(CCallsign("EDDM_TWR")); + callsigns.push_back(CCallsign("KLAX_TWR")); + found = callsigns.findBy(&CCallsign::asString, "KLAXTWR"); + QVERIFY2(found.size() == 1, "found"); + } + +} //namespace BlackMiscTest diff --git a/tests/blackmisc/testcontainers.h b/tests/blackmisc/testcontainers.h index 64b9e504f..12b51794b 100644 --- a/tests/blackmisc/testcontainers.h +++ b/tests/blackmisc/testcontainers.h @@ -24,6 +24,7 @@ namespace BlackMiscTest void collectionBasics(); void sequenceBasics(); void joinAndSplit(); + void findTests(); }; } //namespace BlackMiscTest