Minor fixes: Formatting, string generation

This commit is contained in:
Klaus Basan
2017-01-05 02:12:19 +01:00
committed by Mathew Sutcliffe
parent 7e95d4a550
commit 5f18707c9c
10 changed files with 28 additions and 38 deletions

View File

@@ -739,7 +739,7 @@ namespace BlackCore
/********************************** shimlib callbacks ************************************/ /********************************** shimlib callbacks ************************************/
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/ /********************************** * * * * * * * * * * * * * * * * * * * ************************************/
//! Cast void* to a pointer of CNetworkVatlib // Cast void* to a pointer of CNetworkVatlib
CNetworkVatlib *cbvar_cast(void *cbvar) CNetworkVatlib *cbvar_cast(void *cbvar)
{ {
return static_cast<CNetworkVatlib *>(cbvar); return static_cast<CNetworkVatlib *>(cbvar);

View File

@@ -86,7 +86,6 @@ namespace BlackCore
virtual void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data) override; virtual void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data) override;
virtual void sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void sendCustomFsinnReponse(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendCustomFsinnReponse(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void broadcastAircraftConfig(const QJsonObject &config) override; virtual void broadcastAircraftConfig(const QJsonObject &config) override;
virtual void sendAircraftConfigQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendAircraftConfigQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
//! @} //! @}

View File

@@ -25,7 +25,6 @@ class QModelIndex;
class QObject; class QObject;
namespace BlackMisc { namespace Simulation { class CAircraftModel; } } namespace BlackMisc { namespace Simulation { class CAircraftModel; } }
namespace BlackGui namespace BlackGui
{ {
namespace Models namespace Models

View File

@@ -10,7 +10,6 @@
#include "blackgui/models/serverlistmodel.h" #include "blackgui/models/serverlistmodel.h"
#include "blackgui/views/serverview.h" #include "blackgui/views/serverview.h"
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackGui::Models; using namespace BlackGui::Models;

View File

@@ -9,8 +9,8 @@
//! \file //! \file
#ifndef BLACKGUI_SERVERVIEW_H #ifndef BLACKGUI_VIEWS_SERVERVIEW_H
#define BLACKGUI_SERVERVIEW_H #define BLACKGUI_VIEWS_SERVERVIEW_H
#include "blackgui/blackguiexport.h" #include "blackgui/blackguiexport.h"
#include "blackgui/models/serverlistmodel.h" #include "blackgui/models/serverlistmodel.h"
@@ -20,7 +20,6 @@
class QWidget; class QWidget;
namespace BlackMisc { namespace Network { class CServer; } } namespace BlackMisc { namespace Network { class CServer; } }
namespace BlackGui namespace BlackGui
{ {
namespace Views namespace Views
@@ -28,12 +27,10 @@ namespace BlackGui
//! Network servers //! Network servers
class BLACKGUI_EXPORT CServerView : public CViewBase<Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer> class BLACKGUI_EXPORT CServerView : public CViewBase<Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>
{ {
public: public:
//! Constructor //! Constructor
explicit CServerView(QWidget *parent = nullptr); explicit CServerView(QWidget *parent = nullptr);
}; };
} }
} } // ns
#endif // guard #endif // guard

View File

@@ -17,7 +17,6 @@ namespace BlackMisc
{ {
namespace Aviation namespace Aviation
{ {
CAircraftEngine::CAircraftEngine(int number, bool on) : m_number(number), m_on(on) CAircraftEngine::CAircraftEngine(int number, bool on) : m_number(number), m_on(on)
{ {
Q_ASSERT_X(number > 0, "CAircraftEngine", "Engine number have to be > 1"); Q_ASSERT_X(number > 0, "CAircraftEngine", "Engine number have to be > 1");
@@ -32,11 +31,8 @@ namespace BlackMisc
QString CAircraftEngine::convertToQString(bool i18n) const QString CAircraftEngine::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n);
QString s = QString::number(m_number); static const QString s("%1 on: %2");
s += " "; return s.arg(m_number).arg(BlackMisc::boolToOnOff(m_on));
s += BlackMisc::boolToOnOff(m_on);
return s;
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -18,21 +18,21 @@ namespace BlackMisc
{ {
namespace Aviation namespace Aviation
{ {
QString CHeading::convertToQString(bool i18n) const QString CHeading::convertToQString(bool i18n) const
{ {
QString s = CAngle::convertToQString(i18n).append(" "); static const QString s("%1 %2");
if (i18n) if (i18n)
{ {
return s.append(this->isMagneticHeading() ? return s.arg(CAngle::convertToQString(i18n),
this->isMagneticHeading() ?
QCoreApplication::translate("Aviation", "magnetic") : QCoreApplication::translate("Aviation", "magnetic") :
QCoreApplication::translate("Aviation", "true")); QCoreApplication::translate("Aviation", "true"));
} }
else else
{ {
return s.append(this->isMagneticHeading() ? "magnetic" : "true"); return s.arg(CAngle::convertToQString(i18n),
this->isMagneticHeading() ? "magnetic" : "true");
} }
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -35,19 +35,18 @@ namespace BlackMisc
QString CFsdSetup::convertToQString(bool i18n) const QString CFsdSetup::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n);
QString s("Codec: "); static const QString s("Codec: '%1' details: '%2'");
s.append(" ").append(this->m_textCodec); s.arg(this->getTextCodec(), CFsdSetup::sendReceiveDetailsToString(this->getSendReceiveDetails()));
s.append(" details:").append(sendReceiveDetailsToString(this->getSendReceiveDetails()));
return s; return s;
} }
QString CFsdSetup::sendReceiveDetailsToString(SendReceiveDetails details) QString CFsdSetup::sendReceiveDetailsToString(SendReceiveDetails details)
{ {
QString ds("Send parts; %1 interim: %2 Receive parts: %3 interim: %4"); static const QString ds("Send parts; %1 interim: %2 Receive parts: %3 interim: %4");
return ds.arg(boolToYesNo(details.testFlag(SendAircraftParts))). return ds.arg(boolToYesNo(details.testFlag(SendAircraftParts)),
arg(boolToYesNo(details.testFlag(SendIterimPositions))). boolToYesNo(details.testFlag(SendIterimPositions)),
arg(boolToYesNo(details.testFlag(ReceiveAircraftParts))). boolToYesNo(details.testFlag(ReceiveAircraftParts)),
arg(boolToYesNo(details.testFlag(ReceiveInterimPositions))); boolToYesNo(details.testFlag(ReceiveInterimPositions)));
} }
void CFsdSetup::setSendReceiveDetails(bool partsSend, bool partsReceive, bool interimSend, bool interimReceive) void CFsdSetup::setSendReceiveDetails(bool partsSend, bool partsReceive, bool interimSend, bool interimReceive)

View File

@@ -58,7 +58,7 @@ namespace BlackMisc
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::propertyByIndex(index); } if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::propertyByIndex(index); }
if (IOrderable::canHandleIndex(index)) { return IOrderable::propertyByIndex(index); } if (IOrderable::canHandleIndex(index)) { return IOrderable::propertyByIndex(index); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAlias1: return CVariant::from(this->m_alias1); case IndexAlias1: return CVariant::from(this->m_alias1);
@@ -76,7 +76,7 @@ namespace BlackMisc
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { IDatastoreObjectWithStringKey::setPropertyByIndex(index, variant); return; } if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { IDatastoreObjectWithStringKey::setPropertyByIndex(index, variant); return; }
if (IOrderable::canHandleIndex(index)) { IOrderable::setPropertyByIndex(index, variant); return; } if (IOrderable::canHandleIndex(index)) { IOrderable::setPropertyByIndex(index, variant); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAlias1: case IndexAlias1:
@@ -101,7 +101,8 @@ namespace BlackMisc
{ {
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::comparePropertyByIndex(index, compareValue); } if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::comparePropertyByIndex(index, compareValue); }
if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue); } if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAlias1: return this->m_alias1.compare(compareValue.m_alias1, Qt::CaseInsensitive); case IndexAlias1: return this->m_alias1.compare(compareValue.m_alias1, Qt::CaseInsensitive);
@@ -118,7 +119,7 @@ namespace BlackMisc
QString CDistributor::convertToQString(bool i18n) const QString CDistributor::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n);
QString s = QString("Id: %1").arg(m_dbKey); QString s = QString("Id: '%1'").arg(m_dbKey);
if (this->hasAlias1()) { s.append(" ").append(m_alias1); } if (this->hasAlias1()) { s.append(" ").append(m_alias1); }
if (this->hasAlias2()) { s.append(" ").append(m_alias2); } if (this->hasAlias2()) { s.append(" ").append(m_alias2); }
return s; return s;

View File

@@ -12,12 +12,12 @@
#ifndef BLACKMISC_SIMULATION_DISTRIBUTORLIST_H #ifndef BLACKMISC_SIMULATION_DISTRIBUTORLIST_H
#define BLACKMISC_SIMULATION_DISTRIBUTORLIST_H #define BLACKMISC_SIMULATION_DISTRIBUTORLIST_H
#include "blackmisc/db/datastoreobjectlist.h"
#include "blackmisc/simulation/distributor.h"
#include "blackmisc/blackmiscexport.h" #include "blackmisc/blackmiscexport.h"
#include "blackmisc/collection.h" #include "blackmisc/collection.h"
#include "blackmisc/db/datastoreobjectlist.h"
#include "blackmisc/orderablelist.h" #include "blackmisc/orderablelist.h"
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/simulation/distributor.h"
#include "blackmisc/variant.h" #include "blackmisc/variant.h"
#include <QMetaType> #include <QMetaType>