mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T709, based on the Qt free base class, added swift compliant settings class
This commit is contained in:
committed by
Mat Sutcliffe
parent
a809679b34
commit
81c832457e
@@ -11,9 +11,14 @@
|
||||
#ifndef BLACKMISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
|
||||
#define BLACKMISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
|
||||
|
||||
#include <QString>
|
||||
#include "xswiftbussettingsqtfree.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -21,10 +26,71 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! XSwiftBus settings
|
||||
class BLACKMISC_EXPORT CXSwiftBusSettings :
|
||||
public CValueObject<CXSwiftBusSettings>,
|
||||
public CXSwiftBusSettingsQtFree,
|
||||
public ITimestampBased
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexDBusServerAddress = CPropertyIndex::GlobalIndexCXSwiftBusSettings,
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexMaxDrawingDistance
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CXSwiftBusSettings();
|
||||
|
||||
//! From JSON constructor
|
||||
CXSwiftBusSettings(const QString &json);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getDBusServerAddress
|
||||
QString getDBusServerAddressQt() const { return QString::fromStdString(this->getDBusServerAddress()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setDBusServerAddress
|
||||
void setDBusServerAddressQt(const QString &dBusAddress) { this->setDBusServerAddress(dBusAddress.toStdString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::toXSwiftBusJsonString
|
||||
QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::parseXSwiftBusString
|
||||
void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
|
||||
|
||||
//! Valid settings?
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Default value for settings
|
||||
static const CXSwiftBusSettings &defaultValue();
|
||||
|
||||
private:
|
||||
BLACK_METACLASS(
|
||||
CXSwiftBusSettings,
|
||||
BLACK_METAMEMBER(dBusServerAddress),
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
* @deprecated will be changed to JSON Settings
|
||||
*/
|
||||
struct TXSwiftBusServer : public BlackMisc::TSettingTrait<QString>
|
||||
struct TXSwiftBusServer : public TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "xswiftbus/server"; }
|
||||
@@ -38,8 +104,33 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const QString &dBusAddress, QString &) { return BlackMisc::CDBusServer::isSessionOrSystemAddress(dBusAddress) || BlackMisc::CDBusServer::isQtDBusAddress(dBusAddress); }
|
||||
};
|
||||
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
*/
|
||||
struct TXSwiftBusSettings : public TSettingTrait<CXSwiftBusSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "xswiftbus/settings"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("XSwiftBus"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static CXSwiftBusSettings defaultValue() { return CXSwiftBusSettings::defaultValue(); }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const CXSwiftBusSettings &settings, QString &reason)
|
||||
{
|
||||
const CStatusMessageList msgs = settings.validate();
|
||||
reason = msgs.toQString(true);
|
||||
return msgs.isSuccess();
|
||||
}
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CXSwiftBusSettings)
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user