Formatting, comments, typos, or minor tweaks

* Aircraft ICAO class: hasXX methods (hasAircraftCombinedType(), ..)
* Index Variant map, contains(index)
* Deleted context_network_textmessages.cpp and moved it into impl.cpp (this was only 1 method)
* Fixed bug refs#228
This commit is contained in:
Klaus Basan
2014-05-06 12:55:29 +02:00
parent 841ea97421
commit 580ec3d8c8
14 changed files with 77 additions and 120 deletions

View File

@@ -56,8 +56,6 @@ namespace BlackCore
*/
void CContextNetwork::psFsdAircraftUpdateReceived(const CCallsign &callsign, const CAircraftSituation &situation, const CTransponder &transponder)
{
// this->log(Q_FUNC_INFO, callsign.toQString(), situation.toQString(), transponder.toQString());
CAircraftList list = this->m_aircraftsInRange.findByCallsign(callsign);
if (list.isEmpty())
{
@@ -99,8 +97,8 @@ namespace BlackCore
*/
void CContextNetwork::psFsdPilotDisconnected(const CCallsign &callsign)
{
// this->log(Q_FUNC_INFO, callsign.toQString());
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);
this->m_otherClients.removeIf(&CClient::getCallsign, callsign);
}
/*
@@ -108,8 +106,6 @@ namespace BlackCore
*/
void CContextNetwork::psFsdFrequencyReceived(const CCallsign &callsign, const CFrequency &frequency)
{
// this->log(Q_FUNC_INFO, callsign.toQString(), frequency.toQString());
// update
CIndexVariantMap vm(CAircraft::IndexFrequencyCom1, frequency.toQVariant());
this->m_aircraftsInRange.applyIf(BlackMisc::Predicates::MemberEqual<CAircraft>(&CAircraft::getCallsign, callsign), vm);

View File

@@ -271,7 +271,6 @@ namespace BlackCore
*/
void CContextNetwork::psFsdAtcControllerDisconnected(const CCallsign &callsign)
{
// this->log(Q_FUNC_INFO, callsign.toQString());
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
emit this->changedAtcStationsOnline();
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false)));

View File

@@ -328,4 +328,13 @@ namespace BlackCore
if (this->m_vatsimDataFileReader->interval() < interval) this->m_vatsimDataFileReader->setInterval(interval);
}
/*
* Radio text message received
*/
void CContextNetwork::psFsdTextMessageReceived(const CTextMessageList &messages)
{
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, messages.toQString());
this->textMessagesReceived(messages); // relay
}
} // namespace

View File

@@ -23,7 +23,7 @@ namespace BlackCore
class CVatsimBookingReader;
class CVatsimDataFileReader;
//! \brief Network context implementation
//! Network context implementation
class CContextNetwork : public IContextNetwork
{
Q_OBJECT
@@ -136,28 +136,28 @@ namespace BlackCore
CVatsimDataFileReader *m_vatsimDataFileReader;
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
//! \brief Replace value by new values
//! Replace value by new values
void setAtcStationsBooked(const BlackMisc::Aviation::CAtcStationList &newStations);
//! \brief Replace value by new values
//! Replace value by new values
void setAtcStationsOnline(const BlackMisc::Aviation::CAtcStationList &newStations);
//! \brief The "central" ATC list with online ATC controllers
//! The "central" ATC list with online ATC controllers
BlackMisc::Aviation::CAtcStationList &atcStationsOnline()
{
return m_atcStationsOnline;
}
//! \brief ATC list, with booked controllers
//! ATC list, with booked controllers
BlackMisc::Aviation::CAtcStationList &atcStationsBooked()
{
return m_atcStationsBooked;
}
//! \brief Init my very onw aircraft
//! Init my very own aircraft
void initOwnAircraft();
//! \brief Get network settings
//! Get network settings
BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const
{
Q_ASSERT(this->getRuntime());
@@ -166,10 +166,10 @@ namespace BlackCore
}
private slots:
//! \brief ATC bookings received
//! ATC bookings received
void psReceivedBookings(BlackMisc::Aviation::CAtcStationList bookedStations);
//! \brief Data file has been read
//! Data file has been read
void psDataFileRead();
/*!
@@ -179,7 +179,7 @@ namespace BlackCore
*/
void psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message);
//! \brief ATC position update
//! ATC position update
void psFsdAtcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range);
/*!
@@ -188,7 +188,7 @@ namespace BlackCore
*/
void psFsdAtcControllerDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
//! \brief ATIS received
//! ATIS received
void psFsdAtisQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atisMessage);
/*!
@@ -205,25 +205,25 @@ namespace BlackCore
*/
void psFsdAtisLogoffTimeQueryReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime);
//! \brief METAR received
//! METAR received
void psFsdMetarReceived(const QString &metarMessage);
//! \brief Realname recevied
//! Realname recevied
void psFsdRealNameReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &realname);
//! \brief Plane ICAO codes received
//! Plane ICAO codes received
void psFsdIcaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftIcao &icaoData);
//! \brief Aircraft position update received
//! Aircraft position update received
void psFsdAircraftUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
//! \brief Pilot disconnected
//! Pilot disconnected
void psFsdPilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
//! \brief Frequency received
//! Frequency received
void psFsdFrequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
//! \brief Radio text messages received
//! Radio text messages received
void psFsdTextMessageReceived(const BlackMisc::Network::CTextMessageList &messages);
};
}

View File

@@ -1,27 +0,0 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#include "context_network_impl.h"
#include "context_runtime.h"
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
using namespace BlackMisc::Geo;
namespace BlackCore
{
/*
* Radio text message received
*/
void CContextNetwork::psFsdTextMessageReceived(const CTextMessageList &messages)
{
if (messages.isEmpty()) return;
// this->log(Q_FUNC_INFO, messages.toQString());
this->textMessagesReceived(messages); // relay
}
} // namespace

View File

@@ -910,13 +910,13 @@ namespace BlackCore
quint32 flags = 0;
while (*keysValues)
{
const char *key = keysValues[0];
const QString key(keysValues[0]);
const char *value = keysValues[1];
if (*value == '1')
{
if (key == net->capability_AtcInfo) { flags |= AcceptsAtisResponses; }
if (key == net->capability_AtcInfo) { flags |= AcceptsAtisResponses; }
else if (key == net->capability_InterimPos) { flags |= SupportsInterimPosUpdates; }
else if (key == net->capability_ModelDesc) { flags |= SupportsModelDescriptions; }
else if (key == net->capability_ModelDesc) { flags |= SupportsModelDescriptions; }
}
keysValues += 2;
}

View File

@@ -2,7 +2,6 @@
#define BLACKGUI_USERLISTMODEL_H
#include <QAbstractItemModel>
#include <QDBusConnection>
#include "blackmisc/nwuserlist.h"
#include "blackgui/listmodelbase.h"

View File

@@ -22,7 +22,7 @@ namespace BlackMisc
class CAircraftIcao : public BlackMisc::CValueObject
{
public:
//! \brief Default constructor.
//! Default constructor.
CAircraftIcao() {}
/*!
@@ -49,40 +49,49 @@ namespace BlackMisc
//! Set ICAO designator, e.g. "B737"
void setAircraftDesignator(const QString &icaoDesignator) { this->m_aircraftDesignator = icaoDesignator.trimmed().toUpper(); }
//! \brief Get airline, e.g. "DLH"
//! Aircraft designator?
bool hasAircraftDesignator() const { return !this->m_aircraftDesignator.isEmpty(); }
//! Get airline, e.g. "DLH"
const QString &getAirlineDesignator() const { return this->m_airlineDesignator; }
//! \brief Set airline, e.g. "DLH"
//! Set airline, e.g. "DLH"
void setAirlineDesignator(const QString &icaoDesignator) { this->m_airlineDesignator = icaoDesignator.trimmed().toUpper(); }
//! \brief Airline available?
//! Airline available?
bool hasAirlineDesignator() const { return !this->m_airlineDesignator.isEmpty(); }
//! \brief Get livery
//! Airline and Aircraft designator?
bool hasAircraftAndAirlineDsignator() const { return this->hasAirlineDesignator() && this->hasAircraftDesignator(); }
//! Get livery
const QString &getLivery() const { return this->m_livery; }
//! \brief Set livery
//! Set livery
void setLivery(const QString &livery) { this->m_livery = livery.trimmed().toUpper(); }
//! \brief has livery?
//! has livery?
bool hasLivery() const { return !this->m_livery.isEmpty(); }
//! \brief Get livery or color
//! Get livery or color
const QString &getLiveryOrColor() const { return this->hasLivery() ? this->m_livery : this->m_aircraftColor; }
//! \brief Get color (RGB hex)
//! Get color (RGB hex)
const QString &getAircraftColor() const { return this->m_aircraftColor; }
//! \brief Set color (RGB hex)
//! Set color (RGB hex)
void setAircraftColor(const QString &color) { this->m_aircraftColor = color.trimmed().toUpper(); }
//! \brief Color available?
//! Color available?
bool hasAircraftColor() const { return !this->m_aircraftColor.isEmpty(); }
//! \brief Get type, e.g. "L2J"
//! Get type, e.g. "L2J"
const QString &getAircraftCombinedType() const { return this->m_aircraftCombinedType; }
//! \brief Get engine type, e.g. "J"
//! Combined type available?
bool hasAircraftCombinedType() const { return this->getAircraftCombinedType().length() == 3; }
//! Get engine type, e.g. "J"
QString getEngineType() const
{
if (this->m_aircraftCombinedType.length() != 3) return "";
@@ -95,16 +104,16 @@ namespace BlackMisc
*/
QString asString() const;
//! \brief Set type
//! Set type
void setAircraftCombinedType(const QString &type) { this->m_aircraftCombinedType = type.trimmed().toUpper(); }
//! \brief Equal operator ==
//! Equal operator ==
bool operator ==(const CAircraftIcao &other) const;
//! \brief Unequal operator !=
//! Unequal operator !=
bool operator !=(const CAircraftIcao &other) const;
//! \brief Value hash
//! Value hash
virtual uint getValueHash() const override;
//! \copydoc CValueObject::toJson
@@ -113,10 +122,10 @@ namespace BlackMisc
//! \copydoc CValueObject::fromJson
virtual void fromJson(const QJsonObject &json) override;
//! \brief Register metadata
//! Register metadata
static void registerMetadata();
//! \brief Members
//! Members
static const QStringList &jsonMembers();
/*!

View File

@@ -3,10 +3,6 @@
* 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
*/
#ifndef BLACKMISC_SELCAL_H
#define BLACKMISC_SELCAL_H
#include "blackmisc/pqfrequency.h"

View File

@@ -55,6 +55,9 @@ namespace BlackMisc
//! Indexes
QList<int> indexes() const { return this->m_values.keys(); }
//! Contains index?
bool contains(int index) const { return this->m_values.contains(index); }
//! values
QList<QVariant> values() const { return this->m_values.values(); }

View File

@@ -3,10 +3,6 @@
* 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
*/
#ifndef BLACKMISC_SERVER_H
#define BLACKMISC_SERVER_H
#include "nwuser.h"

View File

@@ -3,10 +3,6 @@
* 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
*/
#ifndef BLACKMISC_USER_H
#define BLACKMISC_USER_H
@@ -38,15 +34,18 @@ namespace BlackMisc
IndexCallsignIcon
};
//! \brief Default constructor.
//! Default constructor.
CUser() {}
//! \brief Constructor.
//! Constructor by callsign
CUser(const BlackMisc::Aviation::CCallsign &callsign) : m_callsign(callsign) {}
//! Constructor.
CUser(const QString &id, const QString &realname, const BlackMisc::Aviation::CCallsign &callsign)
: m_id(id), m_realname(realname), m_callsign(callsign)
{}
//! \brief Constructor.
//! Constructor.
CUser(const QString &id, const QString &realname, const QString &email = "", const QString &password = "", const BlackMisc::Aviation::CCallsign &callsign = BlackMisc::Aviation::CCallsign())
: m_id(id), m_realname(realname), m_email(email), m_password(password), m_callsign(callsign)
{}
@@ -100,16 +99,13 @@ namespace BlackMisc
void setId(const QString &id) { m_id = id.trimmed(); }
//! \brief Get associated callsign.
BlackMisc::Aviation::CCallsign getCallsign() const { return m_callsign; }
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_callsign; }
//! \brief Set associated callsign
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { m_callsign = callsign; }
//! \copydoc CValueObject::toIcon()
virtual const QPixmap &toIcon() const override
{
return this->getCallsign().toIcon();
}
virtual const QPixmap &toIcon() const override { return this->getCallsign().toIcon(); }
//! \brief Equal operator ==
bool operator ==(const CUser &other) const;

View File

@@ -3,10 +3,6 @@
* 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
*/
#ifndef BLACKMISC_USERLIST_H
#define BLACKMISC_USERLIST_H
@@ -21,35 +17,20 @@ namespace BlackMisc
{
namespace Network
{
/*!
* Value object encapsulating a list of voice rooms.
*/
//! Value object encapsulating a list of voice rooms.
class CUserList : public CSequence<CUser>
{
public:
/*!
* \brief Default constructor.
*/
//! \brief Default constructor.
CUserList();
/*!
* \brief Construct from a base class object.
* \param other
*/
//! Construct from a base class object.
CUserList(const CSequence &other);
/*!
* \brief QVariant, required for DBus QVariant lists
* \return
*/
virtual QVariant asQVariant() const
{
return QVariant::fromValue(*this);
}
//! QVariant, required for DBus QVariant lists
virtual QVariant asQVariant() const { return QVariant::fromValue(*this); }
/*!
* \brief Register metadata
*/
//! Register metadata
static void registerMetadata();
};

View File

@@ -16,7 +16,7 @@
namespace BlackSim
{
//! \brief Value object encapsulating a list of SimulatorInfos.
//! \brief Value object encapsulating a list of SimulatorInfo.
class CSimulatorInfoList : public BlackMisc::CSequence<CSimulatorInfo>
{
public: