Some fixes / tweaks / Doxygen:

* helper method to detect disconnected state
* clear ATC info if disconnected or not available
* unit test for "finders"
* added Doxygen file
* formatting frequency in text message tabs
This commit is contained in:
Klaus Basan
2014-06-25 18:59:21 +02:00
parent 378712592e
commit abd2d6d86d
11 changed files with 89 additions and 26 deletions

View File

@@ -125,6 +125,16 @@ namespace BlackCore
return status == Disconnecting || status == Connecting; 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. * Returns true if the current ConnectionStatus is a connected state.
*/ */

View File

@@ -35,9 +35,13 @@ namespace BlackGui
{ {
Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getIContextNetwork()); Q_ASSERT(this->getIContextNetwork());
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline); if (this->getIContextNetwork())
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked); {
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus); 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() void CAtcStationComponent::update()
@@ -62,6 +66,7 @@ namespace BlackGui
} }
else else
{ {
this->ui->tvp_AtcStationsOnline->clear();
this->ui->le_AtcStationsOnlineMetar->clear(); this->ui->le_AtcStationsOnlineMetar->clear();
} }
} }
@@ -87,10 +92,23 @@ namespace BlackGui
void CAtcStationComponent::changedAtcStationsOnline() void CAtcStationComponent::changedAtcStationsOnline()
{ {
// just update timestamp, data will be pulled by time // 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(); this->m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
} }
void CAtcStationComponent::connectionStatusChanged(uint from, uint to, const QString &message)
{
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(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) void CAtcStationComponent::changedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool added)
{ {
this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added); this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added);
@@ -103,14 +121,24 @@ namespace BlackGui
void CAtcStationComponent::getMetar(const QString &airportIcaoCode) 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(); QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
this->ui->le_AtcStationsOnlineMetar->setText(icao); this->ui->le_AtcStationsOnlineMetar->setText(icao);
if (icao.length() != 4) return; if (icao.length() != 4) return;
CInformationMessage metar = this->getIContextNetwork()->getMetar(icao); CInformationMessage metar = this->getIContextNetwork()->getMetar(icao);
if (metar.getType() != CInformationMessage::METAR) return; if (metar.getType() != CInformationMessage::METAR) return;
if (metar.isEmpty()) return; if (metar.isEmpty())
this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage()); {
this->ui->te_AtcStationsOnlineInfo->clear();
}
else
{
this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage());
}
} }
void CAtcStationComponent::onlineAtcStationSelected(QModelIndex index) void CAtcStationComponent::onlineAtcStationSelected(QModelIndex index)

View File

@@ -72,6 +72,9 @@ namespace BlackGui
//! Online stations changed //! Online stations changed
void changedAtcStationsOnline(); void changedAtcStationsOnline();
//! Connection status has been changed
void connectionStatusChanged(uint from, uint to, const QString &message);
private: private:
Ui::CAtcStationComponent *ui; Ui::CAtcStationComponent *ui;
CTimerBasedComponent *m_timerComponent; CTimerBasedComponent *m_timerComponent;

View File

@@ -175,8 +175,11 @@ namespace BlackGui
void CTextMessageComponent::showCurrentFrequenciesFromCockpit() void CTextMessageComponent::showCurrentFrequenciesFromCockpit()
{ {
const CAircraft ownAircraft = this->getOwnAircraft(); const CAircraft ownAircraft = this->getOwnAircraft();
const QString f1 = QString("COM1: %1").arg(ownAircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); QString f1n, f2n;
const QString f2 = QString("COM2: %1").arg(ownAircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); 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(f1);
this->ui->tb_TextMessagesCOM1->setToolTip(f2); this->ui->tb_TextMessagesCOM1->setToolTip(f2);
this->setTabText(this->indexOf(this->ui->tb_TextMessagesCOM1), f1); this->setTabText(this->indexOf(this->ui->tb_TextMessagesCOM1), f1);

View File

@@ -134,7 +134,9 @@ namespace BlackMisc
this->initNotificationFlags(); this->initNotificationFlags();
} }
/*
* Flags
*/
void CSettingsAudio::initNotificationFlags() void CSettingsAudio::initNotificationFlags()
{ {
// if we add flags in the future, we automatically extend ... // if we add flags in the future, we automatically extend ...

View File

@@ -15,7 +15,7 @@ namespace BlackMisc
public: public:
//! \brief Command validate //! Command validate
static const QString &CmdValidate() static const QString &CmdValidate()
{ {
static const QString cmd("validate"); static const QString cmd("validate");
@@ -57,31 +57,34 @@ namespace BlackMisc
return cmd; return cmd;
} }
//! \brief Wrong path message //! Wrong path message
static BlackMisc::CStatusMessage wrongPathMessage(const QString &path = ""); static BlackMisc::CStatusMessage wrongPathMessage(const QString &path = "");
//! \brief Wrong path messages //! Wrong path messages
static BlackMisc::CStatusMessageList wrongPathMessages(const QString &path = ""); static BlackMisc::CStatusMessageList wrongPathMessages(const QString &path = "");
//! \brief Value not changed message //! Value not changed message
static BlackMisc::CStatusMessage valueNotChangedMessage(const QString &valueName); 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); static BlackMisc::CStatusMessage valueChangedMessage(const QString &valueName);
//! \brief Remove leading path //! Remove leading path
static QString removeLeadingPath(const QString &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 = ""); 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(); static bool initSettingsDirectory();
//! \brief get the settings directory //! get the settings directory
static const QString &getSettingsDirectory(); static const QString &getSettingsDirectory();
//! \brief get the settings directory //! get the settings directory
static const QString &getSettingsFile(); static const QString &getSettingsFile();
}; };

View File

@@ -173,7 +173,7 @@ namespace BlackMisc
default: default:
static QString x("unknown type"); static QString x("unknown type");
qFatal("Unknown type"); qFatal("Unknown type");
return x; // just for compiler warning return x;
} }
} }

View File

@@ -7,7 +7,7 @@
#define BLACKSIM_FSCOMMON_AIRCRAFTMAPPING_H #define BLACKSIM_FSCOMMON_AIRCRAFTMAPPING_H
#include "aircraftcfgentries.h" #include "aircraftcfgentries.h"
#include "../simulatorinfo.h" #include "blacksim/simulatorinfo.h"
#include "blackmisc/valueobject.h" #include "blackmisc/valueobject.h"
#include <QVariant> #include <QVariant>
#include <QDateTime> #include <QDateTime>

View File

@@ -3,9 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*! //! \file
\file
*/
#ifndef BLACKSIM_SIMULATORINFOLIST_H #ifndef BLACKSIM_SIMULATORINFOLIST_H
#define BLACKSIM_SIMULATORINFOLIST_H #define BLACKSIM_SIMULATORINFOLIST_H

View File

@@ -4,8 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "testcontainers.h" #include "testcontainers.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/collection.h" #include "blackmisc/collection.h"
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/avcallsignlist.h"
#include <QList> #include <QList>
#include <QVector> #include <QVector>
#include <QSet> #include <QSet>
@@ -13,6 +15,7 @@
#include <set> #include <set>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation;
namespace BlackMiscTest namespace BlackMiscTest
{ {
@@ -109,4 +112,16 @@ namespace BlackMiscTest
QVERIFY2(c1 == c3, "Split collections"); QVERIFY2(c1 == c3, "Split collections");
} }
} //namespace BlackMiscTest void CTestContainers::findTests()
{
BlackMisc::registerMetadata();
CCallsignList callsigns;
CSequence<CCallsign> 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

View File

@@ -24,6 +24,7 @@ namespace BlackMiscTest
void collectionBasics(); void collectionBasics();
void sequenceBasics(); void sequenceBasics();
void joinAndSplit(); void joinAndSplit();
void findTests();
}; };
} //namespace BlackMiscTest } //namespace BlackMiscTest