mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T658, renamed and extended matching script objects
This commit is contained in:
committed by
Mat Sutcliffe
parent
ab5fc6f0ee
commit
a58204ad9e
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "matchingscript.h"
|
||||
#include "stringutils.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
@@ -14,126 +15,268 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
MSSwiftValues::MSSwiftValues(
|
||||
MSInOutValues::MSInOutValues(
|
||||
const QString &cs,
|
||||
const CAircraftIcaoCode aircraftIcao,
|
||||
const CAirlineIcaoCode airlineIcao,
|
||||
const QString &livery, int liveryId) :
|
||||
MSSwiftValues(cs,
|
||||
aircraftIcao.getDesignator(), aircraftIcao.getDbKey(),
|
||||
airlineIcao.getDesignator(), airlineIcao.getVDesignator(), airlineIcao.getDbKey(),
|
||||
MSInOutValues(cs,
|
||||
aircraftIcao.getDesignator(), aircraftIcao.getCombinedType(), aircraftIcao.getDbKey(),
|
||||
airlineIcao.getDesignator(), airlineIcao.getVDesignator(), airlineIcao.getDbKey(),
|
||||
livery, liveryId)
|
||||
{ }
|
||||
|
||||
MSSwiftValues::MSSwiftValues(
|
||||
MSInOutValues::MSInOutValues(
|
||||
const QString &cs,
|
||||
const CAircraftIcaoCode aircraftIcao,
|
||||
const CLivery livery) :
|
||||
MSSwiftValues(cs,
|
||||
MSInOutValues(cs,
|
||||
aircraftIcao,
|
||||
livery.getAirlineIcaoCode(),
|
||||
livery.getCombinedCode(), livery.getDbKey())
|
||||
{ }
|
||||
|
||||
MSSwiftValues::MSSwiftValues(const MSSwiftValues &sv) :
|
||||
MSSwiftValues(sv.m_callsign,
|
||||
sv.getAircraftIcao(), sv.getDbAircraftIcaoId(),
|
||||
MSInOutValues::MSInOutValues(const CAircraftModel &model) :
|
||||
MSInOutValues(model.getCallsign().asString(), model.getAircraftIcaoCode(), model.getLivery())
|
||||
{ }
|
||||
|
||||
MSInOutValues::MSInOutValues(const MSInOutValues &sv) :
|
||||
MSInOutValues(sv.m_callsign,
|
||||
sv.getAircraftIcao(), sv.getCombinedType(), sv.getDbAircraftIcaoId(),
|
||||
sv.getAirlineIcao(), sv.getVirtualAirlineIcao(), sv.getDbAirlineIcaoId(),
|
||||
sv.getLivery(), sv.getDbLiveryId(),
|
||||
sv.m_logMessage,
|
||||
sv.isModified(), sv.isRerun())
|
||||
{ }
|
||||
|
||||
void MSSwiftValues::setCallsign(const QString &callsign)
|
||||
void MSInOutValues::setCallsign(const QString &callsign)
|
||||
{
|
||||
if (m_callsign == callsign) { return; }
|
||||
m_callsign = callsign;
|
||||
emit this->callsignChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setDbAircraftIcaoId(int id)
|
||||
void MSInOutValues::setDbAircraftIcaoId(int id)
|
||||
{
|
||||
if (id == m_dbAircraftIcaoId) { return; }
|
||||
m_dbAircraftIcaoId = id;
|
||||
emit this->dbAircraftIcaoIdChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setDbAirlineIcaoId(int id)
|
||||
void MSInOutValues::setDbAirlineIcaoId(int id)
|
||||
{
|
||||
if (id == m_dbAirlineIcaoId) { return; }
|
||||
m_dbAirlineIcaoId = id;
|
||||
emit this->dbAirlineIcaoIdChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setDbLiveryId(int id)
|
||||
void MSInOutValues::setDbLiveryId(int id)
|
||||
{
|
||||
if (id == m_dbLiveryId) { return; }
|
||||
m_dbLiveryId = id;
|
||||
emit this->dbLiveryIdChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setAircraftIcao(const QString &aircraftIcao)
|
||||
void MSInOutValues::setDbModelId(int id)
|
||||
{
|
||||
if (id == m_dbModelId) { return; }
|
||||
m_dbModelId = id;
|
||||
emit this->dbModelIdChanged();
|
||||
}
|
||||
|
||||
void MSInOutValues::setAircraftIcao(const QString &aircraftIcao)
|
||||
{
|
||||
if (aircraftIcao == m_aircraftIcao) { return; }
|
||||
m_aircraftIcao = aircraftIcao;
|
||||
emit this->aircraftIcaoChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setAirlineIcao(const QString &airlineIcao)
|
||||
void MSInOutValues::setAirlineIcao(const QString &airlineIcao)
|
||||
{
|
||||
if (airlineIcao == m_airlineIcao) { return; }
|
||||
m_airlineIcao = airlineIcao;
|
||||
emit this->airlineIcaoChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setVirtualAirlineIcao(const QString &virtualAirlineIcao)
|
||||
void MSInOutValues::setVirtualAirlineIcao(const QString &virtualAirlineIcao)
|
||||
{
|
||||
if (virtualAirlineIcao == m_vAirlineIcao) { return; }
|
||||
m_vAirlineIcao = virtualAirlineIcao;
|
||||
emit this->virtualAirlineIcaoChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setLivery(const QString &livery)
|
||||
void MSInOutValues::setLivery(const QString &livery)
|
||||
{
|
||||
if (livery == m_livery) { return; }
|
||||
m_livery = livery;
|
||||
emit this->liveryChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setLogMessage(const QString &msg)
|
||||
void MSInOutValues::setModelString(const QString &modelString)
|
||||
{
|
||||
if (modelString == m_modelString) { return; }
|
||||
m_modelString = modelString;
|
||||
emit this->modelStringChanged();
|
||||
}
|
||||
|
||||
void MSInOutValues::setCombinedType(const QString &type)
|
||||
{
|
||||
if (type == m_combinedType) { return; }
|
||||
m_combinedType = type.trimmed().toUpper();
|
||||
emit this->combinedTypeChanged();
|
||||
}
|
||||
|
||||
void MSInOutValues::setLogMessage(const QString &msg)
|
||||
{
|
||||
if (msg == m_logMessage) { return; }
|
||||
m_logMessage = msg;
|
||||
emit this->logMessageChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setModified(bool modified)
|
||||
void MSInOutValues::setModified(bool modified)
|
||||
{
|
||||
if (modified == m_modified) { return; }
|
||||
m_modified = modified;
|
||||
emit this->modifiedChanged();
|
||||
}
|
||||
|
||||
void MSSwiftValues::setRerun(bool rerun)
|
||||
void MSInOutValues::setRerun(bool rerun)
|
||||
{
|
||||
if (rerun == m_rerun) { return; }
|
||||
m_rerun = rerun;
|
||||
emit this->rerunChanged();
|
||||
}
|
||||
|
||||
bool MSSwiftValues::hasChangedAircraftIcao(const Aviation::CAircraftIcaoCode &aircraftIcao) const
|
||||
void MSInOutValues::evaluateChanges(const CAircraftIcaoCode &aircraft, const CAirlineIcaoCode &airline)
|
||||
{
|
||||
m_modifiedAircraftDesignator = aircraft.getDesignator() != m_aircraftIcao;
|
||||
if (airline.isVirtualAirline())
|
||||
{
|
||||
m_modifiedAirlineDesignator = airline.getVDesignator() != m_vAirlineIcao;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_modifiedAirlineDesignator = airline.getDesignator() != m_airlineIcao;
|
||||
}
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedAircraftIcao(const Aviation::CAircraftIcaoCode &aircraftIcao) const
|
||||
{
|
||||
if (aircraftIcao.hasValidDbKey() && aircraftIcao.getDbKey() != m_dbAircraftIcaoId) { return true; }
|
||||
if (aircraftIcao.hasDesignator() && aircraftIcao.getDesignator() != m_aircraftIcao) { return true; }
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MSSwiftValues::hasChangedAirlineIcao(const Aviation::CAirlineIcaoCode &airlineIcao) const
|
||||
bool MSInOutValues::hasChangedAircraftIcaoId(const CAircraftIcaoCode &aircraftIcao) const
|
||||
{
|
||||
if (aircraftIcao.hasValidDbKey() && m_dbAircraftIcaoId >= 0)
|
||||
{
|
||||
// valid ids to be compared
|
||||
return m_dbAircraftIcaoId != aircraftIcao.getDbKey();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedAirlineIcao(const Aviation::CAirlineIcaoCode &airlineIcao) const
|
||||
{
|
||||
if (airlineIcao.hasValidDbKey() && airlineIcao.getDbKey() != m_dbAirlineIcaoId) { return true; }
|
||||
if (airlineIcao.hasValidDesignator() && airlineIcao.getDesignator() != m_airlineIcao) { return true; }
|
||||
if (airlineIcao.hasValidDesignator() && airlineIcao.getVDesignator() != m_vAirlineIcao) { return true; }
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedAirlineIcaoId(const CAirlineIcaoCode &airlineIcao) const
|
||||
{
|
||||
if (airlineIcao.hasValidDbKey() && m_dbAirlineIcaoId >= 0)
|
||||
{
|
||||
// valid ids to be compared
|
||||
return m_dbAirlineIcaoId != airlineIcao.getDbKey();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedModelString(const QString &modelString) const
|
||||
{
|
||||
return !stringCompare(m_modelString, modelString, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedLiveryId(const CLivery &livery) const
|
||||
{
|
||||
if (livery.hasValidDbKey() && m_dbLiveryId >= 0)
|
||||
{
|
||||
// valid ids to be compared
|
||||
return m_dbLiveryId != livery.getDbKey();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedModelId(const CAircraftModel &model) const
|
||||
{
|
||||
if (model.hasValidDbKey() && m_dbModelId >= 0)
|
||||
{
|
||||
// valid ids to be compared
|
||||
return m_dbModelId != model.getDbKey();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MSInOutValues::hasChangedModel(const CAircraftModel &model) const
|
||||
{
|
||||
return this->hasChangedModelString(model.getModelString()) || this->hasChangedModelId(model);
|
||||
}
|
||||
|
||||
void MSModelSet::setSimulator(const QString &simulator)
|
||||
{
|
||||
if (m_simulator == simulator) { return; }
|
||||
m_simulator = simulator.trimmed().toUpper();
|
||||
emit this->simulatorChanged();
|
||||
}
|
||||
|
||||
void MSModelSet::setAvailable(bool available)
|
||||
{
|
||||
if (m_available == available) { return; }
|
||||
m_available = available;
|
||||
emit this->availabilityChanged();
|
||||
}
|
||||
|
||||
void MSModelSet::setInputAircraftAndAirlineCount(int count)
|
||||
{
|
||||
if (m_inputAircraftAndAirlineCount == count) { return; }
|
||||
m_inputAircraftAndAirlineCount = count;
|
||||
emit this->inputAircraftAndAirlineCountChanged();
|
||||
}
|
||||
|
||||
QString MSModelSet::findCombinedTypeWithClosestColorLivery(const QString &combinedType, const QString &rgbColor) const
|
||||
{
|
||||
if (rgbColor.isEmpty()) { return {}; }
|
||||
CAircraftModelList models = m_modelSet.findByCombinedTypeWithColorLivery(combinedType);
|
||||
if (models.isEmpty()) { return {}; }
|
||||
const CRgbColor color(rgbColor);
|
||||
models = models.findClosestFuselageColorDistance(color);
|
||||
return models.isEmpty() ? QString() : models.front().getModelString();
|
||||
}
|
||||
|
||||
MSModelSet::MSModelSet(const CAircraftModelList &modelSet)
|
||||
{
|
||||
this->initByModelSet(modelSet);
|
||||
}
|
||||
|
||||
void MSModelSet::initByModelSet(const CAircraftModelList &modelSet)
|
||||
{
|
||||
m_modelSet = modelSet;
|
||||
m_available = !modelSet.isEmpty();
|
||||
}
|
||||
|
||||
void MSModelSet::initByAircraftAndAirline(const CAircraftIcaoCode &aircraft, const CAirlineIcaoCode &airline)
|
||||
{
|
||||
if (m_modelSet.isEmpty() || !aircraft.hasDesignator() || !airline.hasValidDesignator())
|
||||
{
|
||||
m_inputAircraftAndAirlineCount = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const CAircraftModelList models = m_modelSet.findByAircraftAndAirline(aircraft, airline);
|
||||
m_inputAircraftAndAirlineCount = models.size();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_MATCHINGSCRIPT_H
|
||||
#define BLACKMISC_SIMULATION_MATCHINGSCRIPT_H
|
||||
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
@@ -24,7 +25,7 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! The network values
|
||||
class BLACKMISC_EXPORT MSSwiftValues : public QObject
|
||||
class BLACKMISC_EXPORT MSInOutValues : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -33,29 +34,38 @@ namespace BlackMisc
|
||||
Q_PROPERTY(int dbAircraftIcaoId READ getDbAircraftIcaoId WRITE setDbAircraftIcaoId NOTIFY dbAircraftIcaoIdChanged)
|
||||
Q_PROPERTY(int dbAirlineIcaoId READ getDbAirlineIcaoId WRITE setDbAirlineIcaoId NOTIFY dbAirlineIcaoIdChanged)
|
||||
Q_PROPERTY(int dbLiveryId READ getDbLiveryId WRITE setDbLiveryId NOTIFY dbLiveryIdChanged)
|
||||
Q_PROPERTY(int dbModelId READ getDbModelId WRITE setDbModelId NOTIFY dbModelIdChanged)
|
||||
Q_PROPERTY(QString aircraftIcao READ getAircraftIcao WRITE setAircraftIcao NOTIFY aircraftIcaoChanged)
|
||||
Q_PROPERTY(QString airlineIcao READ getAirlineIcao WRITE setAirlineIcao NOTIFY airlineIcaoChanged)
|
||||
Q_PROPERTY(QString virtualAirlineIcao READ getVirtualAirlineIcao WRITE setVirtualAirlineIcao NOTIFY virtualAirlineIcaoChanged)
|
||||
Q_PROPERTY(QString livery READ getLivery WRITE setLivery NOTIFY liveryChanged)
|
||||
Q_PROPERTY(QString modelString READ getModelString WRITE setModelString NOTIFY modelStringChanged)
|
||||
Q_PROPERTY(QString combinedType READ getCombinedType WRITE setCombinedType NOTIFY combinedTypeChanged)
|
||||
Q_PROPERTY(QString logMessage READ getLogMessage WRITE setLogMessage NOTIFY logMessageChanged)
|
||||
Q_PROPERTY(bool modified READ isModified WRITE setModified NOTIFY modifiedChanged)
|
||||
Q_PROPERTY(bool rerun READ isRerun WRITE setRerun NOTIFY rerunChanged)
|
||||
// ----- status values -------
|
||||
Q_PROPERTY(bool hasAirlineIcao READ hasAirlineIcao)
|
||||
Q_PROPERTY(bool hasAircraftIcao READ hasAircraftIcao)
|
||||
Q_PROPERTY(bool hasModifiedAircraftIcaoDesignator READ hasModifiedAircraftIcaoDesignator)
|
||||
Q_PROPERTY(bool hasModifiedAirlineIcaoDesignator READ hasModifiedAirlineIcaoDesignator)
|
||||
Q_PROPERTY(bool hasUnmodifiedDesignators READ hasUnmodifiedDesignators)
|
||||
//! @}
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
Q_INVOKABLE MSSwiftValues() {}
|
||||
Q_INVOKABLE MSInOutValues() {}
|
||||
|
||||
//! Ctor
|
||||
Q_INVOKABLE MSSwiftValues(const QString &cs,
|
||||
const QString &aircraftIcao, int idAircraftIcao,
|
||||
Q_INVOKABLE MSInOutValues(const QString &cs,
|
||||
const QString &aircraftIcao, const QString &combinedType, int idAircraftIcao,
|
||||
const QString &airlineIcao, const QString &virtualAirlineIcao, int idAirlineIcao,
|
||||
const QString &livery, int liveryId,
|
||||
const QString &logMsg = {},
|
||||
bool modified = false, bool rerun = false) :
|
||||
m_callsign(cs.trimmed().toUpper()),
|
||||
m_aircraftIcao(aircraftIcao.trimmed().toUpper()),
|
||||
m_airlineIcao(airlineIcao.trimmed().toUpper()), m_vAirlineIcao(virtualAirlineIcao),
|
||||
m_aircraftIcao(aircraftIcao.trimmed().toUpper()), m_combinedType(combinedType.trimmed().toUpper()),
|
||||
m_airlineIcao(airlineIcao.trimmed().toUpper()), m_vAirlineIcao(virtualAirlineIcao),
|
||||
m_livery(livery.trimmed().toUpper()),
|
||||
m_dbAircraftIcaoId(idAircraftIcao), m_dbAirlineIcaoId(idAirlineIcao), m_dbLiveryId(liveryId),
|
||||
m_logMessage(logMsg),
|
||||
@@ -63,18 +73,21 @@ namespace BlackMisc
|
||||
{}
|
||||
|
||||
//! Ctor
|
||||
MSSwiftValues(const QString &cs,
|
||||
MSInOutValues(const QString &cs,
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode aircraftIcao,
|
||||
const BlackMisc::Aviation::CAirlineIcaoCode airlineIcao,
|
||||
const QString &livery, int liveryId);
|
||||
|
||||
//! Ctor
|
||||
MSSwiftValues(const QString &cs,
|
||||
MSInOutValues(const QString &cs,
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode aircraftIcao,
|
||||
const BlackMisc::Aviation::CLivery livery);
|
||||
|
||||
//! Ctor
|
||||
MSSwiftValues(const MSSwiftValues &sv);
|
||||
MSInOutValues(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
//! Ctor
|
||||
MSInOutValues(const MSInOutValues &sv);
|
||||
|
||||
//! Get callsign
|
||||
const QString &getCallsign() const { return m_callsign; }
|
||||
@@ -86,23 +99,32 @@ namespace BlackMisc
|
||||
bool isFoundDbAircraftIcao() const { return m_dbAircraftIcaoId >= 0; }
|
||||
bool isFoundDbAirlineIcao() const { return m_dbAirlineIcaoId >= 0; }
|
||||
bool isFoundDbLivery() const { return m_dbLiveryId >= 0; }
|
||||
bool isFoundDbModel() const { return m_dbModelId >= 0; }
|
||||
int getDbAircraftIcaoId() const { return m_dbAircraftIcaoId; }
|
||||
int getDbAirlineIcaoId() const { return m_dbAirlineIcaoId; }
|
||||
int getDbLiveryId() const { return m_dbLiveryId; }
|
||||
int getDbModelId() const { return m_dbModelId; }
|
||||
void setDbAircraftIcaoId(int id);
|
||||
void setDbAirlineIcaoId(int id);
|
||||
void setDbLiveryId(int id);
|
||||
void setDbModelId(int id);
|
||||
//! @}
|
||||
|
||||
//! Livery, airline, aircraft @{
|
||||
//! Livery, airline, aircraft, model string @{
|
||||
const QString &getAircraftIcao() const { return m_aircraftIcao; }
|
||||
const QString &getAirlineIcao() const { return m_airlineIcao; }
|
||||
const QString &getVirtualAirlineIcao() const { return m_vAirlineIcao; }
|
||||
const QString &getLivery() const { return m_livery; }
|
||||
const QString &getModelString() const { return m_modelString; }
|
||||
const QString &getCombinedType() const { return m_combinedType; }
|
||||
void setAircraftIcao(const QString &aircraftIcao);
|
||||
void setAirlineIcao(const QString &airlineIcao);
|
||||
void setVirtualAirlineIcao(const QString &virtualAirlineIcao);
|
||||
void setLivery(const QString &livery);
|
||||
void setModelString(const QString &modelString);
|
||||
void setCombinedType(const QString &type);
|
||||
bool hasAircraftIcao() const { return !m_aircraftIcao.isEmpty(); }
|
||||
bool hasAirlineIcao() const { return !m_airlineIcao.isEmpty(); }
|
||||
//! @}
|
||||
|
||||
//! Log. message @{
|
||||
@@ -120,26 +142,44 @@ namespace BlackMisc
|
||||
void setRerun(bool rerun);
|
||||
//! @}
|
||||
|
||||
//! Changed values such as modified values
|
||||
void evaluateChanges(const BlackMisc::Aviation::CAircraftIcaoCode &aircraft, const BlackMisc::Aviation::CAirlineIcaoCode &airline);
|
||||
|
||||
//! Changed values @{
|
||||
bool hasModifiedAircraftIcaoDesignator() const { return m_modifiedAircraftDesignator; }
|
||||
bool hasModifiedAirlineIcaoDesignator() const { return m_modifiedAirlineDesignator; }
|
||||
bool hasUnmodifiedDesignators() const { return !this->hasModifiedAirlineIcaoDesignator() && !this->hasModifiedAircraftIcaoDesignator(); }
|
||||
//! }
|
||||
|
||||
//! Changed values @{
|
||||
bool hasChangedAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcao) const;
|
||||
bool hasChangedAircraftIcaoId(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcao) const;
|
||||
bool hasChangedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcao) const;
|
||||
//! }
|
||||
bool hasChangedAirlineIcaoId(const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcao) const;
|
||||
bool hasChangedModelString(const QString &modelString) const;
|
||||
bool hasChangedLiveryId(const BlackMisc::Aviation::CLivery &livery) const;
|
||||
bool hasChangedModelId(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||
bool hasChangedModel(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||
//! @}
|
||||
|
||||
signals:
|
||||
//! Callsign changed
|
||||
void callsignChanged();
|
||||
|
||||
//! Livery, airline, aircraft changed @{
|
||||
//! Livery, airline, aircraft, or model changed @{
|
||||
void aircraftIcaoChanged();
|
||||
void airlineIcaoChanged();
|
||||
void virtualAirlineIcaoChanged();
|
||||
void liveryChanged();
|
||||
void modelStringChanged();
|
||||
void combinedTypeChanged();
|
||||
//! @}
|
||||
|
||||
//! DB id changed @{
|
||||
void dbAircraftIcaoIdChanged();
|
||||
void dbAirlineIcaoIdChanged();
|
||||
void dbLiveryIdChanged();
|
||||
void dbModelIdChanged();
|
||||
//! @}
|
||||
|
||||
//! Log. message has been changed
|
||||
@@ -154,16 +194,109 @@ namespace BlackMisc
|
||||
private:
|
||||
QString m_callsign;
|
||||
QString m_aircraftIcao;
|
||||
QString m_combinedType;
|
||||
QString m_airlineIcao;
|
||||
QString m_vAirlineIcao;
|
||||
QString m_livery;
|
||||
QString m_modelString;
|
||||
int m_dbAircraftIcaoId = -1;
|
||||
int m_dbAirlineIcaoId = -1;
|
||||
int m_dbLiveryId = -1;
|
||||
int m_dbModelId = -1;
|
||||
QString m_logMessage;
|
||||
bool m_modifiedAircraftDesignator = false;
|
||||
bool m_modifiedAirlineDesignator = false;
|
||||
bool m_modified = false;
|
||||
bool m_rerun = false;
|
||||
};
|
||||
|
||||
//! The model set values
|
||||
class BLACKMISC_EXPORT MSModelSet : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//! MSModelSet properties @{
|
||||
Q_PROPERTY(QString simulator READ getSimulator WRITE setSimulator NOTIFY simulatorChanged)
|
||||
Q_PROPERTY(bool available READ isAvailable WRITE setAvailable NOTIFY availabilityChanged)
|
||||
Q_PROPERTY(int inputAircraftAndAirlineCount READ getInputAircraftAndAirlineCount WRITE setInputAircraftAndAirlineCount NOTIFY inputAircraftAndAirlineCountChanged)
|
||||
Q_PROPERTY(int modelSetSize READ getModelSetSize)
|
||||
Q_PROPERTY(int countDifferentAirlines READ countVtolAircraft)
|
||||
Q_PROPERTY(int countVtolAircraft READ countCivilianAircraft)
|
||||
Q_PROPERTY(int countCivilianAircraft READ countCivilianAircraft)
|
||||
Q_PROPERTY(int countMilitaryAircraft READ countMilitaryAircraft)
|
||||
Q_PROPERTY(int countModelsWithColorLivery READ countModelsWithColorLivery)
|
||||
Q_PROPERTY(int countModelsWithAirlineLivery READ countModelsWithAirlineLivery)
|
||||
//! @}
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
Q_INVOKABLE MSModelSet() {}
|
||||
|
||||
//! Get callsign
|
||||
const QString &getSimulator() const { return m_simulator; }
|
||||
|
||||
//! Set callsign
|
||||
void setSimulator(const QString &simulator);
|
||||
|
||||
//! Availablity flag @{
|
||||
bool isAvailable() const { return m_available; }
|
||||
void setAvailable(bool available);
|
||||
//! @}
|
||||
|
||||
//! Input aircraft/airline available flag @{
|
||||
int getInputAircraftAndAirlineCount() const { return m_inputAircraftAndAirlineCount; }
|
||||
void setInputAircraftAndAirlineCount(int count);
|
||||
//! @}
|
||||
|
||||
//! Model set functions as properties @{
|
||||
int getModelSetSize() const { return m_modelSet.size(); }
|
||||
int countDifferentAirlines() const { return m_modelSet.countDifferentAirlines(); }
|
||||
int countVtolAircraft() const { return m_modelSet.countVtolAircraft(); }
|
||||
int countCivilianAircraft() const { return m_modelSet.countCivilianAircraft(); }
|
||||
int countMilitaryAircraft() const { return m_modelSet.countMilitaryAircraft(); }
|
||||
int countModelsWithColorLivery() const { return m_modelSet.countModelsWithColorLivery(); }
|
||||
int countModelsWithAirlineLivery() const { return m_modelSet.countModelsWithAirlineLivery(); }
|
||||
//! @}
|
||||
|
||||
//! Invokable model set functions as properties @{
|
||||
Q_INVOKABLE bool containsModelString(const QString &modelString) const { return m_modelSet.containsModelString(modelString, Qt::CaseInsensitive); }
|
||||
Q_INVOKABLE bool containsDbKey(int dbKey) const { return m_modelSet.containsDbKey(dbKey); }
|
||||
Q_INVOKABLE bool containsCombinedType(const QString &ct) const { return m_modelSet.containsCombinedType(ct); }
|
||||
//! @}
|
||||
|
||||
//! Model string of model with closest color distance
|
||||
Q_INVOKABLE QString findCombinedTypeWithClosestColorLivery(const QString &combinedType, const QString &rgbColor) const;
|
||||
|
||||
// ------- NOT EXPOSED TO JAVASCRIPT -------
|
||||
|
||||
//! Ctor
|
||||
MSModelSet(const BlackMisc::Simulation::CAircraftModelList &modelSet);
|
||||
|
||||
//! Init by model set
|
||||
void initByModelSet(const BlackMisc::Simulation::CAircraftModelList &modelSet);
|
||||
|
||||
//! Init by aircraft/airline
|
||||
void initByAircraftAndAirline(const BlackMisc::Aviation::CAircraftIcaoCode &aircraft, const BlackMisc::Aviation::CAirlineIcaoCode &airline);
|
||||
|
||||
// ------- NOT EXPOSED TO JAVASCRIPT -------
|
||||
|
||||
signals:
|
||||
//! Simulator changed
|
||||
void simulatorChanged();
|
||||
|
||||
//! Has been modified
|
||||
void availabilityChanged();
|
||||
|
||||
//! Aircraft and airline changed
|
||||
void inputAircraftAndAirlineCountChanged();
|
||||
|
||||
private:
|
||||
QString m_simulator;
|
||||
bool m_available = false;
|
||||
int m_inputAircraftAndAirlineCount; //! values in set for airline and aircraft
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user