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;
}
/*!
* 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.
*/

View File

@@ -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<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)
{
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)

View File

@@ -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;

View File

@@ -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);

View File

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

View File

@@ -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();
};

View File

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

View File

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

View File

@@ -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