From a8c7575d9da7a2da9cc97d1ef2e2156e4731f2db Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 18 Oct 2019 01:01:32 +0200 Subject: [PATCH] Style --- samples/afvclient/afvclientbridge.h | 3 + src/blackcore/afv/audio/input.cpp | 3 +- src/blackcore/afv/clients/afvclient.h | 3 + src/blackcore/airspacemonitor.cpp | 5 +- src/blackcore/fsd/fsdclient.cpp | 62 +++++++++---------- .../components/audiovolumecomponent.h | 2 +- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/samples/afvclient/afvclientbridge.h b/samples/afvclient/afvclientbridge.h index 8e426b7af..7187164e1 100644 --- a/samples/afvclient/afvclientbridge.h +++ b/samples/afvclient/afvclientbridge.h @@ -18,11 +18,14 @@ class CAfvClientBridge : public QObject { Q_OBJECT + + //! Bridge properties @{ Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU) Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU) Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged) Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged) + //! @} public: //! Ctor diff --git a/src/blackcore/afv/audio/input.cpp b/src/blackcore/afv/audio/input.cpp index afe38a920..4433deef2 100644 --- a/src/blackcore/afv/audio/input.cpp +++ b/src/blackcore/afv/audio/input.cpp @@ -9,8 +9,9 @@ //! \file #include "input.h" -#include "blackmisc/logmessage.h" #include "blacksound/audioutilities.h" +#include "blackmisc/logmessage.h" +#include "blackmisc/verify.h" #include #include diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index b11431f83..b1485f62f 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -48,11 +48,14 @@ namespace BlackCore class BLACKCORE_EXPORT CAfvClient final : public BlackMisc::CContinuousWorker { Q_OBJECT + + //! AFV client properties @{ Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU) Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU) Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged) Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged) Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged) + //! @} public: //! Categories diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 04d1ec8be..f417ab2d3 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -827,8 +827,7 @@ namespace BlackCore { Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread"); if (!this->isConnectedAndNotShuttingDown()) { return; } - - BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); + if (CBuildConfig::isLocalDeveloperDebugBuild()) { BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); } if (!callsign.isValid()) { return; } const ReverseLookupLogging reverseLookupEnabled = this->isReverseLookupMessagesEnabled(); CStatusMessageList reverseLookupMessages; @@ -1204,7 +1203,7 @@ namespace BlackCore void CAirspaceMonitor::onConnectionStatusChanged(CConnectionStatus oldStatus, CConnectionStatus newStatus) { - Q_UNUSED(oldStatus); + Q_UNUSED(oldStatus) if (newStatus.isDisconnected()) { clear(); } } diff --git a/src/blackcore/fsd/fsdclient.cpp b/src/blackcore/fsd/fsdclient.cpp index beb00ffd1..1a5453f13 100644 --- a/src/blackcore/fsd/fsdclient.cpp +++ b/src/blackcore/fsd/fsdclient.cpp @@ -507,7 +507,7 @@ namespace BlackCore QStringList receivers; for (const int &frequency : frequencies) { - receivers.push_back(QString("@%1").arg(frequency - 100000)); + receivers.push_back(QStringLiteral("@%1").arg(frequency - 100000)); } TextMessage radioMessage(m_ownCallsign.asString(), receivers.join('&'), message); @@ -562,7 +562,7 @@ namespace BlackCore this->increaseStatisticsValue(QStringLiteral("sendFlightPlan")); } - void CFSDClient::sendPlaneInfoRequest(const BlackMisc::Aviation::CCallsign &receiver) + void CFSDClient::sendPlaneInfoRequest(const CCallsign &receiver) { PlaneInfoRequest planeInfoRequest(m_ownCallsign.asString(), receiver.toQString()); sendMessage(planeInfoRequest); @@ -1010,8 +1010,8 @@ namespace BlackCore CAltitude cruiseAlt; cruiseAlt.parseFromString(cruiseAltString, CPqString::SeparatorBestGuess); - const QString depTimePlanned = QString("0000").append(QString::number(fp.m_estimatedDepTime)).right(4); - const QString depTimeActual = QString("0000").append(QString::number(fp.m_actualDepTime)).right(4); + const QString depTimePlanned = QStringLiteral("0000").append(QString::number(fp.m_estimatedDepTime)).right(4); + const QString depTimeActual = QStringLiteral("0000").append(QString::number(fp.m_actualDepTime)).right(4); const CCallsign callsign(fp.sender(), CCallsign::Aircraft); const CFlightPlan flightPlan( @@ -1231,22 +1231,22 @@ namespace BlackCore ServerError serverError = ServerError::fromTokens(tokens); switch (serverError.m_errorNumber) { - case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break; - case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break; - case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break; - case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break; - case ServerErrorCode::RequestedLevelTooHigh: CLogMessage(this).error(u"You are not authorized to use the requested pilot rating"); break; - case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break; - case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break; - case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break; - case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break; + case ServerErrorCode::CallsignInUse: CLogMessage(this).error(u"The requested callsign is already taken"); break; + case ServerErrorCode::InvalidCallsign: CLogMessage(this).error(u"The requested callsign is not valid"); break; + case ServerErrorCode::InvalidCidPassword: CLogMessage(this).error(u"Wrong user ID or password, inactive account"); break; + case ServerErrorCode::InvalidRevision: CLogMessage(this).error(u"This server does not support our protocol version"); break; + case ServerErrorCode::RequestedLevelTooHigh: CLogMessage(this).error(u"You are not authorized to use the requested pilot rating"); break; + case ServerErrorCode::ServerFull: CLogMessage(this).error(u"The server is full"); break; + case ServerErrorCode::CidSuspended: CLogMessage(this).error(u"Your user account is suspended"); break; + case ServerErrorCode::RatingTooLow: CLogMessage(this).error(u"You are not authorized to use the requested rating"); break; + case ServerErrorCode::InvalidClient: CLogMessage(this).error(u"This software is not authorized for use on this network"); break; - case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break; - case ServerErrorCode::SyntaxError: CLogMessage(this).info(u"Malformed packet: Syntax error: %1") << serverError.m_causingParameter; break; - case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break; - case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.m_causingParameter << serverError.m_description; break; - case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break; - case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break; + case ServerErrorCode::NoError: CLogMessage(this).info(u"OK"); break; + case ServerErrorCode::SyntaxError: CLogMessage(this).info(u"Malformed packet: Syntax error: %1") << serverError.m_causingParameter; break; + case ServerErrorCode::InvalidSrcCallsign: CLogMessage(this).info(u"FSD message was using an invalid callsign: %1 (%2)") << serverError.m_causingParameter << serverError.m_description; break; + case ServerErrorCode::NoSuchCallsign: CLogMessage(this).info(u"FSD Server: no such callsign: %1 %2") << serverError.m_causingParameter << serverError.m_description; break; + case ServerErrorCode::NoFlightPlan: CLogMessage(this).info(u"FSD Server: no flight plan"); break; + case ServerErrorCode::NoWeatherProfile: CLogMessage(this).info(u"FSD Server: requested weather profile does not exist"); break; // we have no idea what these mean case ServerErrorCode::AlreadyRegistered: CLogMessage(this).info(u"Server says already registered: %1") << serverError.m_description; break; @@ -1543,8 +1543,7 @@ namespace BlackCore if (reLogoff.match(message).hasMatch()) { emit atisLogoffTimeReplyReceived(sender, message); - CInformationMessage atisMessage; - atisMessage.setType(CInformationMessage::ATIS); + CInformationMessage atisMessage(CInformationMessage::ATIS); for (const auto &line : as_const(pendingQuery.m_atisMessage)) { if (!atisMessage.isEmpty()) atisMessage.appendMessage("\n"); @@ -1565,13 +1564,13 @@ namespace BlackCore if (setting.getFileWriteMode() == CRawFsdMessageSettings::None || setting.getFileDir().isEmpty()) { return; } if (setting.getFileWriteMode() == CRawFsdMessageSettings::Truncate) { - QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); + const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly); } else if (setting.getFileWriteMode() == CRawFsdMessageSettings::Append) { - QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); + const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log"); m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Append); } @@ -1581,7 +1580,7 @@ namespace BlackCore filename += QLatin1String("_"); filename += QDateTime::currentDateTime().toString(QStringLiteral("yyMMddhhmmss")); filename += QLatin1String(".log"); - QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), filename); + const QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), filename); m_rawFsdMessageLogFile.setFileName(filePath); m_rawFsdMessageLogFile.open(QIODevice::Text | QIODevice::WriteOnly); } @@ -1672,8 +1671,8 @@ namespace BlackCore { while (m_socket.canReadLine()) { - QByteArray dataEncoded = m_socket.readLine(); - QString data = m_fsdTextCodec->toUnicode(dataEncoded); + const QByteArray dataEncoded = m_socket.readLine(); + const QString data = m_fsdTextCodec->toUnicode(dataEncoded); parseMessage(data); } } @@ -1699,13 +1698,12 @@ namespace BlackCore if (messageType != MessageType::Unknown) { // Cutoff the cmd from the beginning - QString payload = line.mid(cmd.size()).trimmed(); + const QString payload = line.mid(cmd.size()).trimmed(); // We expected a payload, but there is nothing if (payload.length() == 0) return; - QStringList tokens = payload.split(':'); - + const QStringList tokens = payload.split(':'); switch (messageType) { case MessageType::AddAtc: /* ignore */ return; @@ -1746,7 +1744,7 @@ namespace BlackCore } } - QString prefix = isSent ? "FSD Sent=>" : "FSD Recv=>"; + const QString prefix = isSent ? "FSD Sent=>" : "FSD Recv=>"; CRawFsdMessage rawMessage(prefix + fsdMessageFiltered); rawMessage.setCurrentUtcTime(); if (m_rawFsdMessageLogFile.isOpen()) @@ -1813,9 +1811,7 @@ namespace BlackCore // emit atisVoiceRoomReplyReceived(cs, m_mapAtisMessages[callsign].voiceRoom); emit atisLogoffTimeReplyReceived(cs, m_mapAtisMessages[callsign].zuluLogoff); - CInformationMessage atisMessage; - atisMessage.setType(CInformationMessage::ATIS); - + CInformationMessage atisMessage(CInformationMessage::ATIS); for (const QString &tm : m_mapAtisMessages[callsign].textLines) { const QString fixed = tm.trimmed(); diff --git a/src/blackgui/components/audiovolumecomponent.h b/src/blackgui/components/audiovolumecomponent.h index b1b4c32cf..1cb929b97 100644 --- a/src/blackgui/components/audiovolumecomponent.h +++ b/src/blackgui/components/audiovolumecomponent.h @@ -32,7 +32,7 @@ namespace BlackGui explicit CAudioVolumeComponent(QWidget *parent = nullptr); //! Destructor - virtual ~CAudioVolumeComponent(); + virtual ~CAudioVolumeComponent() override; private: //! Mute toggleBlackGui::Components::CHotkeyDialog