mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
refs #74 , class for mapping. Still open whether this will be FSX/9/P3D specific, or global.
This commit is contained in:
288
src/blacksim/fscommon/aircraftmapping.cpp
Normal file
288
src/blacksim/fscommon/aircraftmapping.cpp
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "aircraftmapping.h"
|
||||||
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace FsCommon
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CAircraftMapping::CAircraftMapping() :
|
||||||
|
m_mappingId(CAircraftMapping::InvalidId), m_proposalId(CAircraftMapping::InvalidId), m_fsAircraftKey(), m_icaoAircraftDesignator(), m_icaoAirlineDesignator(),
|
||||||
|
m_icaoAircraftType(), m_icaoWakeTurbulenceCategory(), m_painting(), m_lastChanged(-1), m_simulator(BlackSim::CSimulator::UnspecifiedSim())
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CAircraftMapping::CAircraftMapping(
|
||||||
|
qint32 mappingId, qint32 proposalId, const QString &fsAircraftKey, const QString &icaoAircraftDesignator,
|
||||||
|
const QString &icaoAirline, const QString &icaoAircraftType, const QString &icaoWakeTurbulenceCategory, const QString &painting,
|
||||||
|
const QString &lastChanged, BlackSim::CSimulator simulator) :
|
||||||
|
m_mappingId(mappingId), m_proposalId(proposalId), m_fsAircraftKey(fsAircraftKey), m_icaoAircraftDesignator(icaoAircraftDesignator),
|
||||||
|
m_icaoAirlineDesignator(icaoAirline), m_icaoAircraftType(icaoAircraftType), m_icaoWakeTurbulenceCategory(icaoWakeTurbulenceCategory), m_painting(painting),
|
||||||
|
m_lastChanged(lastChanged), m_simulator(simulator), m_changed(false)
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Operator ==
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::operator ==(const CAircraftMapping &otherMapping) const
|
||||||
|
{
|
||||||
|
if (this == &otherMapping) return true;
|
||||||
|
return
|
||||||
|
this->m_mappingId == otherMapping.m_mappingId &&
|
||||||
|
this->m_proposalId == otherMapping.m_proposalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Operator !=
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::operator !=(const CAircraftMapping &otherMapping) const
|
||||||
|
{
|
||||||
|
if (this == &otherMapping) return false;
|
||||||
|
return !((*this) == otherMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String for converter
|
||||||
|
*/
|
||||||
|
QString CAircraftMapping::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
QString s("{%1, %2, %3, %4, %5}");
|
||||||
|
s = s.arg(this->m_fsAircraftKey).
|
||||||
|
arg(this->m_mappingId).arg(this->m_proposalId).
|
||||||
|
arg(this->m_icaoAircraftDesignator).arg(this->m_simulator.toQString(i18n));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validate data
|
||||||
|
*/
|
||||||
|
QString CAircraftMapping::validate() const
|
||||||
|
{
|
||||||
|
QString msg;
|
||||||
|
|
||||||
|
if (this->m_fsAircraftKey.isEmpty())
|
||||||
|
msg.append("Missing sim key. ");
|
||||||
|
if (this->m_icaoAircraftDesignator.isEmpty())
|
||||||
|
msg.append("Missing designator. ");
|
||||||
|
if (this->m_simulator.isUnspecified())
|
||||||
|
msg.append("Unknown simulator. ");
|
||||||
|
|
||||||
|
if (this->m_icaoAircraftType.isEmpty())
|
||||||
|
msg.append("Missing type. ");
|
||||||
|
else if (this->m_icaoAircraftType.length() != 3)
|
||||||
|
msg.append("Wrong type length (req.3). ");
|
||||||
|
|
||||||
|
if (this->m_icaoWakeTurbulenceCategory.isEmpty() || this->m_icaoWakeTurbulenceCategory.length() != 1)
|
||||||
|
msg.append("Invalid WTC. ");
|
||||||
|
else if (this->m_icaoWakeTurbulenceCategory != "L" && this->m_icaoWakeTurbulenceCategory != "M" && this->m_icaoWakeTurbulenceCategory != "H")
|
||||||
|
msg.append("Invalid WTC code. ");
|
||||||
|
|
||||||
|
return msg.trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Last changed formatted
|
||||||
|
*/
|
||||||
|
QString CAircraftMapping::getLastChangedFormatted() const
|
||||||
|
{
|
||||||
|
QString ts = this->m_lastChanged;
|
||||||
|
QString f("%1-%2-%3 %4:%5:%6");
|
||||||
|
return f.arg(ts.left(4)).arg(ts.mid(4, 2)).arg(ts.mid(6, 2))
|
||||||
|
.arg(ts.mid(8, 2)).arg(ts.mid(10, 2)).arg(ts.right(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hash
|
||||||
|
*/
|
||||||
|
uint CAircraftMapping::getValueHash() const
|
||||||
|
{
|
||||||
|
QList<uint> hashs;
|
||||||
|
hashs << qHash(this->m_changed);
|
||||||
|
hashs << qHash(this->m_fsAircraftKey);
|
||||||
|
hashs << qHash(this->m_icaoAircraftDesignator);
|
||||||
|
hashs << qHash(this->m_icaoAircraftType);
|
||||||
|
hashs << qHash(this->m_icaoAirlineDesignator);
|
||||||
|
hashs << qHash(this->m_icaoWakeTurbulenceCategory);
|
||||||
|
hashs << qHash(this->m_lastChanged);
|
||||||
|
hashs << qHash(this->m_mappingId);
|
||||||
|
hashs << qHash(this->m_painting);
|
||||||
|
hashs << qHash(this->m_proposalId);
|
||||||
|
hashs << qHash(this->m_simulator);
|
||||||
|
return BlackMisc::calculateHash(hashs, "CAircraftMapping");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get column
|
||||||
|
*/
|
||||||
|
QVariant CAircraftMapping::propertyByIndex(int index) const
|
||||||
|
{
|
||||||
|
// non throwing implementation
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case IndexMappingId:
|
||||||
|
return this->m_mappingId;
|
||||||
|
case IndexProposalId:
|
||||||
|
return m_proposalId;
|
||||||
|
case IndexAircraftKey:
|
||||||
|
return m_fsAircraftKey;
|
||||||
|
case IndexIcaoAircraftDesignator:
|
||||||
|
return m_icaoAircraftDesignator;
|
||||||
|
case IndexIcaoAirlineDesignator:
|
||||||
|
return m_icaoAirlineDesignator;
|
||||||
|
case IndexAircraftType:
|
||||||
|
return m_icaoAircraftType;
|
||||||
|
case IndexWakeTurbulenceCategory:
|
||||||
|
return m_icaoWakeTurbulenceCategory;
|
||||||
|
case IndexPainting:
|
||||||
|
return this->m_painting;
|
||||||
|
case IndexLastChanged:
|
||||||
|
return this->getLastChangedFormatted();
|
||||||
|
case IndexSimulator:
|
||||||
|
return this->m_simulator.toQVariant();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT_X(false, "CAircraftMapping", "index unknown");
|
||||||
|
QString m = QString("no property, index ").append(QString::number(index));
|
||||||
|
return QVariant::fromValue(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set column's value
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::setPropertyByIndex(const QVariant &value, int index)
|
||||||
|
{
|
||||||
|
// non throwing implementation
|
||||||
|
bool changed;
|
||||||
|
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case IndexMappingId:
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
qint32 id = value.toInt(&ok);
|
||||||
|
this->m_mappingId = ok ? id : CAircraftMapping::InvalidId;
|
||||||
|
}
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexProposalId:
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
qint32 id = value.toInt(&ok);
|
||||||
|
this->m_proposalId = ok ? id : CAircraftMapping::InvalidId;
|
||||||
|
}
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexAircraftKey:
|
||||||
|
m_fsAircraftKey = value.toString();
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexIcaoAircraftDesignator:
|
||||||
|
this->setIcaoAircraftDesignator(value.toString());
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexIcaoAirlineDesignator:
|
||||||
|
this->setIcaoAirline(value.toString());
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexAircraftType:
|
||||||
|
this->setIcaoAircraftType(value.toString());
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexWakeTurbulenceCategory:
|
||||||
|
this->setIcaoWakeTurbulenceCategory(value.toString());
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
case IndexPainting:
|
||||||
|
this->m_painting = value.toString();
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
changed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (changed) this->setChanged(changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAircraftMapping::marshallToDbus(QDBusArgument &argument) const
|
||||||
|
{
|
||||||
|
argument << this->m_changed;
|
||||||
|
argument << this->m_fsAircraftKey;
|
||||||
|
argument << this->m_icaoAircraftDesignator;
|
||||||
|
argument << this->m_icaoAircraftType;
|
||||||
|
argument << this->m_icaoAirlineDesignator;
|
||||||
|
argument << this->m_icaoWakeTurbulenceCategory;
|
||||||
|
argument << this->m_lastChanged;
|
||||||
|
argument << this->m_mappingId;
|
||||||
|
argument << this->m_painting;
|
||||||
|
argument << this->m_proposalId;
|
||||||
|
argument << this->m_simulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unmarshall from DBus
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::unmarshallFromDbus(const QDBusArgument &argument)
|
||||||
|
{
|
||||||
|
argument >> this->m_changed;
|
||||||
|
argument >> this->m_fsAircraftKey;
|
||||||
|
argument >> this->m_icaoAircraftDesignator;
|
||||||
|
argument >> this->m_icaoAircraftType;
|
||||||
|
argument >> this->m_icaoAirlineDesignator;
|
||||||
|
argument >> this->m_icaoWakeTurbulenceCategory;
|
||||||
|
argument >> this->m_lastChanged;
|
||||||
|
argument >> this->m_mappingId;
|
||||||
|
argument >> this->m_painting;
|
||||||
|
argument >> this->m_proposalId;
|
||||||
|
argument >> this->m_simulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Metatype id
|
||||||
|
*/
|
||||||
|
int CAircraftMapping::getMetaTypeId() const
|
||||||
|
{
|
||||||
|
return qMetaTypeId<CAircraftCfgEntries>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare
|
||||||
|
*/
|
||||||
|
int CAircraftMapping::compareImpl(const CValueObject &otherBase) const
|
||||||
|
{
|
||||||
|
const CAircraftMapping &other = static_cast<const CAircraftMapping &>(otherBase);
|
||||||
|
int result;
|
||||||
|
if ((result = compare(this->m_simulator, other.m_simulator))) return result;
|
||||||
|
if ((result = this->m_icaoAircraftDesignator.compare(other.m_icaoAircraftDesignator, Qt::CaseInsensitive))) return result;
|
||||||
|
if ((result = this->m_icaoAirlineDesignator.compare(other.m_icaoAirlineDesignator, Qt::CaseInsensitive))) return result;
|
||||||
|
if ((result = this->m_icaoAircraftType.compare(other.m_icaoAircraftType, Qt::CaseInsensitive))) return result;;
|
||||||
|
if ((result = this->m_icaoWakeTurbulenceCategory.compare(other.m_icaoWakeTurbulenceCategory, Qt::CaseInsensitive))) return result;;
|
||||||
|
return this->m_fsAircraftKey.compare(other.m_fsAircraftKey, Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<CAircraftMapping>();
|
||||||
|
qDBusRegisterMetaType<CAircraftMapping>();
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
216
src/blacksim/fscommon/aircraftmapping.h
Normal file
216
src/blacksim/fscommon/aircraftmapping.h
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTMAPPING_H
|
||||||
|
#define BLACKSIM_FSCOMMON_AIRCRAFTMAPPING_H
|
||||||
|
|
||||||
|
#include "aircraftcfgentries.h"
|
||||||
|
#include "../simulator.h"
|
||||||
|
#include "blackmisc/valueobject.h"
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace FsCommon
|
||||||
|
{
|
||||||
|
|
||||||
|
//! \brief Aircraft mapping class, represents one particular mapping
|
||||||
|
class CAircraftMapping : public BlackMisc::CValueObject
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const qint32 InvalidId = -1; //!< Invalid mapping id
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc CValueObject::convertToQString
|
||||||
|
virtual QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::marshallToDbus
|
||||||
|
virtual void marshallToDbus(QDBusArgument &) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::unmarshallFromDbus
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &) override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getMetaTypeId()
|
||||||
|
int getMetaTypeId() const;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::compareImpl
|
||||||
|
int compareImpl(const CValueObject &otherBase) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint32 m_mappingId; //!< Kind of primary key for this particular mapping
|
||||||
|
qint32 m_proposalId; //!< If proposal id of the proposal
|
||||||
|
QString m_fsAircraftKey; //!< Id by which the simulator can create the aircraft
|
||||||
|
QString m_icaoAircraftDesignator; //!< Aircraft designator such as B737
|
||||||
|
QString m_icaoAirlineDesignator; //!< Airline designator such as DLH
|
||||||
|
QString m_icaoAircraftType; //!< Engine, type, number of engines L2J, L1P
|
||||||
|
QString m_icaoWakeTurbulenceCategory; //!< Wake turbulence category H, L, M
|
||||||
|
QString m_painting; //!< Aircrafts painting designator, could be same as airline or specific
|
||||||
|
QString m_lastChanged; //!< Simple timestamp as YYYYMMDDhhmmss
|
||||||
|
BlackSim::CSimulator m_simulator; //!< Mapping is for simulator
|
||||||
|
bool m_changed; //! Changed flag
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! \brief Columns
|
||||||
|
enum ColumnIndex
|
||||||
|
{
|
||||||
|
IndexMappingId = 0,
|
||||||
|
IndexProposalId,
|
||||||
|
IndexAircraftKey,
|
||||||
|
IndexIcaoAircraftDesignator,
|
||||||
|
IndexIcaoAirlineDesignator,
|
||||||
|
IndexAircraftType,
|
||||||
|
IndexWakeTurbulenceCategory,
|
||||||
|
IndexPainting,
|
||||||
|
IndexLastChanged,
|
||||||
|
IndexSimulator
|
||||||
|
};
|
||||||
|
|
||||||
|
//! \brief Default mapping
|
||||||
|
CAircraftMapping();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Complete constructor
|
||||||
|
* \param mappingId
|
||||||
|
* \param proposalId
|
||||||
|
* \param fsAircraftKey
|
||||||
|
* \param icaoAircraftDesignator
|
||||||
|
* \param icaoAirline
|
||||||
|
* \param icaoAircraftType
|
||||||
|
* \param icaoWakeTurbulenceCategory
|
||||||
|
* \param painting
|
||||||
|
* \param lastChanged
|
||||||
|
* \param simulator
|
||||||
|
*/
|
||||||
|
CAircraftMapping(qint32 mappingId, qint32 proposalId, const QString &fsAircraftKey, const QString &icaoAircraftDesignator, const QString &icaoAirline, const QString &icaoAircraftType, const QString &icaoWakeTurbulenceCategory, const QString &painting, const QString &lastChanged, CSimulator simulator);
|
||||||
|
|
||||||
|
//! \brief Virtual destructor
|
||||||
|
virtual ~CAircraftMapping()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! \brief operator ==
|
||||||
|
bool operator ==(const CAircraftMapping &otherMapping) const;
|
||||||
|
|
||||||
|
//! \brief operator !=
|
||||||
|
bool operator !=(const CAircraftMapping &otherMapping) const;
|
||||||
|
|
||||||
|
//! \brief Mapping id
|
||||||
|
qint32 getMappingId() const { return this->m_mappingId; }
|
||||||
|
|
||||||
|
//! \brief Proposal id (if proposal, otherwise <0)
|
||||||
|
qint32 getProposalId() const { return this->m_proposalId; }
|
||||||
|
|
||||||
|
//! \brief Aircraft key
|
||||||
|
QString getFsAircraftKey() const { return this->m_fsAircraftKey; }
|
||||||
|
|
||||||
|
//! \brief ICAO designator (B737)
|
||||||
|
QString getIcaoAircraftDesignator() const { return this->m_icaoAircraftDesignator; }
|
||||||
|
|
||||||
|
//! \brief ICAO airline (DLH)
|
||||||
|
QString getIcaoAirline() const { return this->m_icaoAirlineDesignator; }
|
||||||
|
|
||||||
|
//! \brief ICAO aircraft type (L2J)
|
||||||
|
QString getIcaoAircraftType() const { return this->m_icaoAircraftType; }
|
||||||
|
|
||||||
|
//! \brief ICAO wake turbulence category
|
||||||
|
QString getIcaoWakeTurbulenceCategory() const { return this->m_icaoWakeTurbulenceCategory; }
|
||||||
|
|
||||||
|
//! \brief Painting, basically the airline code for GA planes
|
||||||
|
QString getPainting() const { return this->m_painting; }
|
||||||
|
|
||||||
|
//! \brief Last changed timestamp YYYYMMDDhhmmss
|
||||||
|
QString getLastChanged() const { return this->m_lastChanged; }
|
||||||
|
|
||||||
|
//! \brief Last changed timestamp YYYYMMDDhhmmss
|
||||||
|
QString getLastChangedFormatted() const;
|
||||||
|
|
||||||
|
//! \brief Simulator
|
||||||
|
BlackSim::CSimulator getSimulator() const { return this->m_simulator; }
|
||||||
|
|
||||||
|
//! \brief Simulator
|
||||||
|
QString getSimulatorText() const;
|
||||||
|
|
||||||
|
//! \brief Get changed flag
|
||||||
|
bool isChanged() const { return this->m_changed; }
|
||||||
|
|
||||||
|
//! \brief Valid data?
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
QString v = this->validate();
|
||||||
|
return v.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Validate and return error messages, empty string means all OK.
|
||||||
|
QString validate() const;
|
||||||
|
|
||||||
|
//! \brief Set mapping id
|
||||||
|
void setMappingId(qint32 mappingId) { this->m_mappingId = mappingId; }
|
||||||
|
|
||||||
|
//! \brief Proposal id
|
||||||
|
void setProposalId(qint32 proposalId) { this->m_proposalId = proposalId; }
|
||||||
|
|
||||||
|
//! \brief Aircraft key
|
||||||
|
void setFsAircraftKey(const QString &aircraftKey) { this->m_fsAircraftKey = aircraftKey; }
|
||||||
|
|
||||||
|
//! \brief ICAO designator (B737)
|
||||||
|
void setIcaoAircraftDesignator(const QString &icaoDesignator) { this->m_icaoAircraftDesignator = icaoDesignator.toUpper(); }
|
||||||
|
|
||||||
|
//! \brief ICAO airline (DLH)
|
||||||
|
void setIcaoAirline(const QString &airline) { this->m_icaoAirlineDesignator = airline.toUpper(); }
|
||||||
|
|
||||||
|
//! \brief ICAO aircraft type (L2J)
|
||||||
|
void setIcaoAircraftType(const QString &aircraftType) { this->m_icaoAircraftType = aircraftType.toUpper(); }
|
||||||
|
|
||||||
|
//! \brief ICAO wake turbulence category
|
||||||
|
void setIcaoWakeTurbulenceCategory(const QString &wtc) { this->m_icaoWakeTurbulenceCategory = wtc.toUpper(); }
|
||||||
|
|
||||||
|
//! \brief Painting, basically the airline code for GA planes
|
||||||
|
void setPainting(const QString &painting) { this->m_painting = painting; }
|
||||||
|
|
||||||
|
//! \brief Last changed timestamp YYYYMMDDhhmmss
|
||||||
|
void setLastChanged(qint32 lastChanged) { this->m_lastChanged = lastChanged; }
|
||||||
|
|
||||||
|
//! \brief Simulator
|
||||||
|
void setSimulator(BlackSim::CSimulator simulator) { this->m_simulator = simulator; }
|
||||||
|
|
||||||
|
//! \brief Set simulator text
|
||||||
|
void setSimulatorText(const QString &simulator);
|
||||||
|
|
||||||
|
//! \brief Set changed flag
|
||||||
|
void setChanged(bool changed) { this->m_changed = changed; }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::propertyByIndex
|
||||||
|
QVariant propertyByIndex(int index) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::setPropertyByIndex()
|
||||||
|
void setPropertyByIndex(const QVariant &value, int index) override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toQVariant()
|
||||||
|
virtual QVariant toQVariant() const override
|
||||||
|
{
|
||||||
|
return QVariant::fromValue(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getValueHash()
|
||||||
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
|
//! \brief Current UTC timestamp
|
||||||
|
static QString currentUtcTimestamp()
|
||||||
|
{
|
||||||
|
QDateTime dateTime = QDateTime::currentDateTimeUtc();
|
||||||
|
QString dateTimeString = dateTime.toString("yyyyMMddhhmmss");
|
||||||
|
return dateTimeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Register metadata
|
||||||
|
static void registerMetadata();
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftMapping)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
20
src/blacksim/fscommon/aircraftmappinglist.cpp
Normal file
20
src/blacksim/fscommon/aircraftmappinglist.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "aircraftmappinglist.h"
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace FsCommon
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
void CAircraftMappingList::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<BlackMisc::CSequence<CAircraftMapping>>();
|
||||||
|
qDBusRegisterMetaType<BlackMisc::CSequence<CAircraftMapping>>();
|
||||||
|
qRegisterMetaType<BlackMisc::CCollection<CAircraftMapping>>();
|
||||||
|
qDBusRegisterMetaType<BlackMisc::CCollection<CAircraftMapping>>();
|
||||||
|
qRegisterMetaType<CAircraftMappingList>();
|
||||||
|
qDBusRegisterMetaType<CAircraftMappingList>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
49
src/blacksim/fscommon/aircraftmappinglist.h
Normal file
49
src/blacksim/fscommon/aircraftmappinglist.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTMAPPINGS_H
|
||||||
|
#define BLACKSIM_FSCOMMON_AIRCRAFTMAPPINGS_H
|
||||||
|
|
||||||
|
#include "aircraftmapping.h"
|
||||||
|
#include "aircraftcfgentrieslist.h"
|
||||||
|
#include "blackmisc/sequence.h"
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace FsCommon
|
||||||
|
{
|
||||||
|
//! \brief Aircraft mappings
|
||||||
|
class CAircraftMappingList : public BlackMisc::CSequence<CAircraftMapping>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! \brief Default constructor
|
||||||
|
CAircraftMappingList() {}
|
||||||
|
|
||||||
|
//! \brief Virtual destructor
|
||||||
|
virtual ~CAircraftMappingList() {}
|
||||||
|
|
||||||
|
//! \brief Unknown mapping
|
||||||
|
static const CAircraftMapping &UnknownMapping()
|
||||||
|
{
|
||||||
|
static CAircraftMapping mapping;
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Register metadata
|
||||||
|
static void registerMetadata();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftMappingList)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackSim::FsCommon::CAircraftMapping>)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackSim::FsCommon::CAircraftMapping>)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user