mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #273, fixed missing JSON serialization
This commit is contained in:
@@ -5,10 +5,10 @@ using namespace BlackMisc;
|
|||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
CSimulatorInfo::CSimulatorInfo(const QString &shortname, const QString &fullname) : m_fullname(fullname), m_shortname(shortname)
|
CSimulatorInfo::CSimulatorInfo(const QString &shortname, const QString &fullname) : m_fullName(fullname), m_shortName(shortname)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CSimulatorInfo::CSimulatorInfo() : m_fullname("Unknown"), m_shortname("Unknown")
|
CSimulatorInfo::CSimulatorInfo() : m_fullName("Unknown"), m_shortName("Unknown")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
uint CSimulatorInfo::getValueHash() const
|
uint CSimulatorInfo::getValueHash() const
|
||||||
@@ -36,7 +36,7 @@ namespace BlackSim
|
|||||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
return QString(this->m_shortname).append(" (").append(this->m_fullname).append(")");
|
return QString(this->m_shortName).append(" (").append(this->m_fullName).append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSimulatorInfo::getMetaTypeId() const
|
int CSimulatorInfo::getMetaTypeId() const
|
||||||
@@ -71,6 +71,21 @@ namespace BlackSim
|
|||||||
argument >> TupleConverter<CSimulatorInfo>::toTuple(*this);
|
argument >> TupleConverter<CSimulatorInfo>::toTuple(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStringList &CSimulatorInfo::jsonMembers()
|
||||||
|
{
|
||||||
|
return TupleConverter<CSimulatorInfo>::jsonMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject CSimulatorInfo::toJson() const
|
||||||
|
{
|
||||||
|
return BlackMisc::serializeJson(CSimulatorInfo::jsonMembers(), TupleConverter<CSimulatorInfo>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorInfo::fromJson(const QJsonObject &json)
|
||||||
|
{
|
||||||
|
BlackMisc::deserializeJson(json, CSimulatorInfo::jsonMembers(), TupleConverter<CSimulatorInfo>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorInfo::registerMetadata()
|
void CSimulatorInfo::registerMetadata()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<CSimulatorInfo>();
|
qRegisterMetaType<CSimulatorInfo>();
|
||||||
|
|||||||
@@ -17,13 +17,10 @@ namespace BlackSim
|
|||||||
CSimulatorInfo(const QString &shortname, const QString &fullname);
|
CSimulatorInfo(const QString &shortname, const QString &fullname);
|
||||||
|
|
||||||
//! Unspecified simulator
|
//! Unspecified simulator
|
||||||
bool isUnspecified() const { return this->m_shortname.isEmpty() || this->m_shortname.startsWith("Unspecified", Qt::CaseInsensitive); }
|
bool isUnspecified() const { return this->m_shortName.isEmpty() || this->m_shortName.startsWith("Unspecified", Qt::CaseInsensitive); }
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
{
|
|
||||||
return QVariant::fromValue(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CSimulatorInfo &other) const;
|
bool operator ==(const CSimulatorInfo &other) const;
|
||||||
@@ -43,6 +40,24 @@ namespace BlackSim
|
|||||||
//! Set single settings
|
//! Set single settings
|
||||||
void setSimulatorSetup(const BlackMisc::CIndexVariantMap &setup);
|
void setSimulatorSetup(const BlackMisc::CIndexVariantMap &setup);
|
||||||
|
|
||||||
|
//! Short name
|
||||||
|
const QString &getShortName() const { return m_shortName; }
|
||||||
|
|
||||||
|
//! Short name
|
||||||
|
const QString &getFullName() const { return m_fullName; }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toJson
|
||||||
|
virtual QJsonObject toJson() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::fromJson
|
||||||
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
|
//! Members
|
||||||
|
static const QStringList &jsonMembers();
|
||||||
|
|
||||||
|
//! Register the metatypes
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
//! Simulator is FS9 - Microsoft Flight Simulator 2004
|
//! Simulator is FS9 - Microsoft Flight Simulator 2004
|
||||||
static const CSimulatorInfo &FS9()
|
static const CSimulatorInfo &FS9()
|
||||||
{
|
{
|
||||||
@@ -71,9 +86,6 @@ namespace BlackSim
|
|||||||
return sim;
|
return sim;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Register the metatypes
|
|
||||||
static void registerMetadata();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc CValueObject::convertToQString
|
//! \copydoc CValueObject::convertToQString
|
||||||
virtual QString convertToQString(bool i18n = false) const override;
|
virtual QString convertToQString(bool i18n = false) const override;
|
||||||
@@ -92,13 +104,13 @@ namespace BlackSim
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
|
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
|
||||||
QString m_fullname;
|
QString m_fullName;
|
||||||
QString m_shortname;
|
QString m_shortName;
|
||||||
BlackMisc::CIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side
|
BlackMisc::CIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorInfo, (o.m_fullname, o.m_shortname, o.m_simsetup))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorInfo, (o.m_fullName, o.m_shortName, o.m_simsetup))
|
||||||
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user