mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T709, display settings as string/QString (for logging)
This commit is contained in:
committed by
Mat Sutcliffe
parent
6a2f08b49f
commit
d1db1943ae
@@ -55,7 +55,7 @@ namespace BlackMisc
|
|||||||
QString CXSwiftBusSettings::convertToQString(bool i18n) const
|
QString CXSwiftBusSettings::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
return "";
|
return QString::fromStdString(CXSwiftBusSettingsQtFree::convertToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList CXSwiftBusSettings::validate() const
|
CStatusMessageList CXSwiftBusSettings::validate() const
|
||||||
|
|||||||
@@ -7,12 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xswiftbussettingsqtfree.h"
|
#include "xswiftbussettingsqtfree.h"
|
||||||
|
#include "blackmisc/simulation/xplane/qtfreeutils.h"
|
||||||
|
|
||||||
#include "rapidjson/document.h" // rapidjson's DOM-style API
|
#include "rapidjson/document.h" // rapidjson's DOM-style API
|
||||||
#include "rapidjson/prettywriter.h" // for stringify JSON
|
#include "rapidjson/prettywriter.h" // for stringify JSON
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace rapidjson;
|
|
||||||
using namespace BlackMisc::Simulation::Settings;
|
using namespace BlackMisc::Simulation::Settings;
|
||||||
|
using namespace BlackMisc::Simulation::XPlane;
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
//! @cond SWIFT_INTERNAL
|
//! @cond SWIFT_INTERNAL
|
||||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDBusServerAddress[];
|
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDBusServerAddress[];
|
||||||
@@ -85,6 +89,14 @@ namespace BlackMisc
|
|||||||
const std::string json = sb.GetString();
|
const std::string json = sb.GetString();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CXSwiftBusSettingsQtFree::convertToString() const
|
||||||
|
{
|
||||||
|
return "DBusServer: " + m_dBusServerAddress +
|
||||||
|
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||||
|
", max planes: " + std::to_string(m_maxPlanes) +
|
||||||
|
", max distance NM: " + std::to_string(m_maxDrawDistanceNM);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ namespace BlackMisc
|
|||||||
//! As JSON string
|
//! As JSON string
|
||||||
std::string toXSwiftBusJsonString() const;
|
std::string toXSwiftBusJsonString() const;
|
||||||
|
|
||||||
|
//! Convert to string
|
||||||
|
std::string convertToString() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! The JSON members @{
|
//! The JSON members @{
|
||||||
static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
|
static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
|
||||||
|
|||||||
@@ -139,6 +139,22 @@ namespace BlackMisc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Yes/no from bool
|
||||||
|
inline const std::string &boolToYesNo(bool t)
|
||||||
|
{
|
||||||
|
static const std::string y("yes");
|
||||||
|
static const std::string n("no");
|
||||||
|
return t ? y : n;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! True/false from bool
|
||||||
|
inline const std::string &boolTotrueFalse(bool t)
|
||||||
|
{
|
||||||
|
static const std::string tr("true");
|
||||||
|
static const std::string fa("false");
|
||||||
|
return t ? tr : fa;
|
||||||
|
}
|
||||||
|
|
||||||
//! Trim whitespace from the beginning and end, and replace sequences of whitespace with single space characters
|
//! Trim whitespace from the beginning and end, and replace sequences of whitespace with single space characters
|
||||||
inline std::string simplifyWhitespace(const std::string &s)
|
inline std::string simplifyWhitespace(const std::string &s)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user