From 580ec3d8c8076abb3cddffef7eb9294e159d30df Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 6 May 2014 12:55:29 +0200 Subject: [PATCH] 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 --- src/blackcore/context_network_aircraft.cpp | 6 +-- src/blackcore/context_network_atc.cpp | 1 - src/blackcore/context_network_impl.cpp | 9 ++++ src/blackcore/context_network_impl.h | 36 +++++++------- .../context_network_textmessages.cpp | 27 ----------- src/blackcore/network_vatlib.cpp | 6 +-- src/blackgui/userlistmodel.h | 1 - src/blackmisc/avaircrafticao.h | 47 +++++++++++-------- src/blackmisc/avselcal.h | 4 -- src/blackmisc/indexvariantmap.h | 3 ++ src/blackmisc/nwserver.h | 4 -- src/blackmisc/nwuser.h | 20 ++++---- src/blackmisc/nwuserlist.h | 31 +++--------- src/blacksim/simulatorinfolist.h | 2 +- 14 files changed, 77 insertions(+), 120 deletions(-) delete mode 100644 src/blackcore/context_network_textmessages.cpp diff --git a/src/blackcore/context_network_aircraft.cpp b/src/blackcore/context_network_aircraft.cpp index 5c6b4ef2e..18d053c0c 100644 --- a/src/blackcore/context_network_aircraft.cpp +++ b/src/blackcore/context_network_aircraft.cpp @@ -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::getCallsign, callsign), vm); diff --git a/src/blackcore/context_network_atc.cpp b/src/blackcore/context_network_atc.cpp index c344b1adf..6b7277f27 100644 --- a/src/blackcore/context_network_atc.cpp +++ b/src/blackcore/context_network_atc.cpp @@ -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))); diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index d37f217df..abe0672b7 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -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 diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index 31cfd8bf2..a6a3c0186 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -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); }; } diff --git a/src/blackcore/context_network_textmessages.cpp b/src/blackcore/context_network_textmessages.cpp deleted file mode 100644 index 52c89f17e..000000000 --- a/src/blackcore/context_network_textmessages.cpp +++ /dev/null @@ -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 diff --git a/src/blackcore/network_vatlib.cpp b/src/blackcore/network_vatlib.cpp index b0a3cbab7..de4aad553 100644 --- a/src/blackcore/network_vatlib.cpp +++ b/src/blackcore/network_vatlib.cpp @@ -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; } diff --git a/src/blackgui/userlistmodel.h b/src/blackgui/userlistmodel.h index e349c1c9e..c1139fb7c 100644 --- a/src/blackgui/userlistmodel.h +++ b/src/blackgui/userlistmodel.h @@ -2,7 +2,6 @@ #define BLACKGUI_USERLISTMODEL_H #include -#include #include "blackmisc/nwuserlist.h" #include "blackgui/listmodelbase.h" diff --git a/src/blackmisc/avaircrafticao.h b/src/blackmisc/avaircrafticao.h index 799a425dc..fb59a24b4 100644 --- a/src/blackmisc/avaircrafticao.h +++ b/src/blackmisc/avaircrafticao.h @@ -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(); /*! diff --git a/src/blackmisc/avselcal.h b/src/blackmisc/avselcal.h index cf57f1822..c7e15b632 100644 --- a/src/blackmisc/avselcal.h +++ b/src/blackmisc/avselcal.h @@ -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" diff --git a/src/blackmisc/indexvariantmap.h b/src/blackmisc/indexvariantmap.h index 087c6a6d4..e95585949 100644 --- a/src/blackmisc/indexvariantmap.h +++ b/src/blackmisc/indexvariantmap.h @@ -55,6 +55,9 @@ namespace BlackMisc //! Indexes QList indexes() const { return this->m_values.keys(); } + //! Contains index? + bool contains(int index) const { return this->m_values.contains(index); } + //! values QList values() const { return this->m_values.values(); } diff --git a/src/blackmisc/nwserver.h b/src/blackmisc/nwserver.h index 4567fb6ad..850fe7d55 100644 --- a/src/blackmisc/nwserver.h +++ b/src/blackmisc/nwserver.h @@ -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" diff --git a/src/blackmisc/nwuser.h b/src/blackmisc/nwuser.h index 378c4d22d..d9a44019b 100644 --- a/src/blackmisc/nwuser.h +++ b/src/blackmisc/nwuser.h @@ -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; diff --git a/src/blackmisc/nwuserlist.h b/src/blackmisc/nwuserlist.h index 4afdec165..436069454 100644 --- a/src/blackmisc/nwuserlist.h +++ b/src/blackmisc/nwuserlist.h @@ -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 { 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(); }; diff --git a/src/blacksim/simulatorinfolist.h b/src/blacksim/simulatorinfolist.h index d402c676a..ff54f679c 100644 --- a/src/blacksim/simulatorinfolist.h +++ b/src/blacksim/simulatorinfolist.h @@ -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 { public: