mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
refs #445, value objects and containers
* common base class for DB based classes * common base class for DB based containers * Livery, distributor value class * adjusted value classes to livery * utility functions for DB values (blackmisc free functions) * register new objects with metadata system
This commit is contained in:
committed by
Mathew Sutcliffe
parent
99b7c52383
commit
25fd0f4f2d
@@ -8,14 +8,26 @@
|
||||
*/
|
||||
|
||||
#include "aircraftmodel.h"
|
||||
#include "distributor.h"
|
||||
#include "blackmisc/datastoreutility.h"
|
||||
#include <QString>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CAircraftModel::CAircraftModel(const QString &model, CAircraftModel::ModelType type) :
|
||||
m_modelString(model), m_modelType(type)
|
||||
{}
|
||||
|
||||
CAircraftModel::CAircraftModel(const QString &model, CAircraftModel::ModelType type, const QString &description, const Aviation::CAircraftIcaoData &icao, const Aviation::CLivery &livery) :
|
||||
m_icao(icao), m_livery(livery), m_modelString(model), m_description(description), m_modelType(type)
|
||||
{}
|
||||
|
||||
CAircraftModel::CAircraftModel(const Aviation::CAircraft &aircraft) :
|
||||
m_callsign(aircraft.getCallsign()), m_icao(aircraft.getIcaoInfo())
|
||||
m_callsign(aircraft.getCallsign()), m_icao(aircraft.getIcaoInfo()), m_livery(aircraft.getLivery())
|
||||
{ }
|
||||
|
||||
QString CAircraftModel::convertToQString(bool i18n) const
|
||||
@@ -44,7 +56,7 @@ namespace BlackMisc
|
||||
case IndexHasQueriedModelString:
|
||||
return CVariant::fromValue(this->hasQueriedModelString());
|
||||
case IndexModelType:
|
||||
return CVariant::fromValue(this->m_modelType);
|
||||
return CVariant::fromValue(static_cast<int>(this->m_modelType));
|
||||
case IndexModelTypeAsString:
|
||||
return CVariant(this->getModelTypeAsString());
|
||||
case IndexDescription:
|
||||
@@ -53,6 +65,8 @@ namespace BlackMisc
|
||||
return CVariant(this->m_fileName);
|
||||
case IndexIcao:
|
||||
return m_icao.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLivery:
|
||||
return m_livery.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign:
|
||||
return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
@@ -72,6 +86,9 @@ namespace BlackMisc
|
||||
case IndexIcao:
|
||||
this->m_icao.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexLivery:
|
||||
this->m_livery.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexDescription:
|
||||
this->m_description = variant.toQString();
|
||||
break;
|
||||
@@ -82,7 +99,7 @@ namespace BlackMisc
|
||||
this->m_fileName = variant.toQString();
|
||||
break;
|
||||
case IndexModelType:
|
||||
this->m_modelType = variant.toInt();
|
||||
this->m_modelType = static_cast<ModelType>(variant.toInt());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
@@ -90,6 +107,16 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
const CAircraftIcaoCode &CAircraftModel::getAircraftIcaoCode() const
|
||||
{
|
||||
return m_icao.getAircraftIcaoCode();
|
||||
}
|
||||
|
||||
const CAirlineIcaoCode &CAircraftModel::getAirlineIcaoCode() const
|
||||
{
|
||||
return m_icao.getAirlineIcaoCode();
|
||||
}
|
||||
|
||||
void CAircraftModel::updateMissingParts(const CAircraftModel &model)
|
||||
{
|
||||
if (this->m_modelString.isEmpty()) { this->m_modelString = model.getModelString(); }
|
||||
@@ -138,5 +165,38 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftModel CAircraftModel::fromDatabaseJson(const QJsonObject &json)
|
||||
{
|
||||
QJsonArray inner = json["cell"].toArray();
|
||||
Q_ASSERT_X(!inner.isEmpty(), Q_FUNC_INFO, "Missing JSON");
|
||||
if (inner.isEmpty()) { return CAircraftModel(); }
|
||||
|
||||
// int i = 0;
|
||||
|
||||
int i = 0;
|
||||
int dbKey(inner.at(i++).toInt(-1));
|
||||
QString modelString(inner.at(i++).toString());
|
||||
QString distributorKey(inner.at(i++).toString());
|
||||
QString liveryDescription(inner.at(i++).toString());
|
||||
QString modelDescription;
|
||||
|
||||
CAircraftIcaoData aircraftIcao;
|
||||
CAirlineIcaoCode airlineIcao;
|
||||
CLivery livery;
|
||||
CDistributor distributor(distributorKey, "", "", "");
|
||||
|
||||
bool fsx = CDatastoreUtility::dbBoolStringToBool(inner.at(i++).toString());
|
||||
bool fs9 = CDatastoreUtility::dbBoolStringToBool(inner.at(i++).toString());
|
||||
bool xp = CDatastoreUtility::dbBoolStringToBool(inner.at(i++).toString());
|
||||
CSimulatorInfo simInfo(fsx, fs9, xp);
|
||||
|
||||
CAircraftModel model(
|
||||
modelString, CAircraftModel::TypeModelMapping, modelDescription, aircraftIcao, livery
|
||||
);
|
||||
model.setDbKey(dbKey);
|
||||
model.setSimulatorInfo(simInfo);
|
||||
return model;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#define BLACKMISC_SIMULATION_AIRCRAFTMODEL_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/aviation/aircrafticaodata.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
@@ -22,21 +24,23 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Aircraft model (other pilot, my models on disk)
|
||||
//! Aircraft model (used by another pilot, my models on disk)
|
||||
//! \remarks Simulator independent class, supposed to be common denominator
|
||||
class BLACKMISC_EXPORT CAircraftModel : public CValueObject<CAircraftModel>
|
||||
class BLACKMISC_EXPORT CAircraftModel :
|
||||
public CValueObject<CAircraftModel>,
|
||||
public BlackMisc::IDatastoreObjectWithIntegerKey
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
enum ModelType
|
||||
{
|
||||
TypeUnknown,
|
||||
TypeQueriedFromNetwork, //!< model was queried by network protocol
|
||||
TypeModelMatching, //!< model is result of model matching
|
||||
TypeQueriedFromNetwork, //!< model was queried by network protocol
|
||||
TypeModelMatching, //!< model is result of model matching
|
||||
TypeModelMatchingDefaultModel, //!< a default model assigned by model matching
|
||||
TypeModelMapping, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
TypeOwnSimulatorModel //!< represents own simulator model
|
||||
TypeModelMapping, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
TypeOwnSimulatorModel //!< represents own simulator model
|
||||
};
|
||||
|
||||
//! Indexes
|
||||
@@ -46,6 +50,7 @@ namespace BlackMisc
|
||||
IndexCallsign,
|
||||
IndexDescription,
|
||||
IndexIcao,
|
||||
IndexLivery,
|
||||
IndexFileName,
|
||||
IndexModelType,
|
||||
IndexModelTypeAsString,
|
||||
@@ -56,11 +61,10 @@ namespace BlackMisc
|
||||
CAircraftModel() {}
|
||||
|
||||
//! Constructor.
|
||||
CAircraftModel(const QString &model, ModelType type) : m_modelString(model), m_modelType(type) {}
|
||||
CAircraftModel(const QString &model, ModelType type);
|
||||
|
||||
//! Constructor.
|
||||
CAircraftModel(const QString &model, ModelType type, const QString &description, const BlackMisc::Aviation::CAircraftIcaoData &icao) :
|
||||
m_icao(icao), m_modelString(model), m_description(description), m_modelType(type) {}
|
||||
CAircraftModel(const QString &model, ModelType type, const QString &description, const BlackMisc::Aviation::CAircraftIcaoData &icao, const BlackMisc::Aviation::CLivery &livery = BlackMisc::Aviation::CLivery());
|
||||
|
||||
//! Constructor
|
||||
CAircraftModel(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||
@@ -80,7 +84,7 @@ namespace BlackMisc
|
||||
//! Callsign empty
|
||||
bool isCallsignEmpty() const { return this->m_callsign.isEmpty(); }
|
||||
|
||||
//! Queried model string
|
||||
//! Model string, either queried or loaded from simulator model
|
||||
const QString &getModelString() const { return this->m_modelString; }
|
||||
|
||||
//! Model string
|
||||
@@ -107,18 +111,42 @@ namespace BlackMisc
|
||||
//! \copydoc CAircraftIcaoData::hasAircraftDesignator
|
||||
bool hasAircraftDesignator() const { return this->m_icao.hasAircraftDesignator(); }
|
||||
|
||||
//! Aircraft ICAO code
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const;
|
||||
|
||||
//! Airline ICAO code
|
||||
const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const;
|
||||
|
||||
//! Get livery
|
||||
const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; }
|
||||
|
||||
//! Livery
|
||||
void setLivery(const BlackMisc::Aviation::CLivery &livery) { this->m_livery = livery; }
|
||||
|
||||
//! Livery available?
|
||||
bool hasLivery() const { return m_livery.hasCompleteData();}
|
||||
|
||||
//! Model type
|
||||
ModelType getModelType() const { return static_cast<ModelType>(m_modelType); }
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
|
||||
//! Model type
|
||||
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
|
||||
//! Set type
|
||||
void setModelType(ModelType type) { this->m_modelType = static_cast<int>(type); }
|
||||
void setModelType(ModelType type) { this->m_modelType = type; }
|
||||
|
||||
//! File name
|
||||
//! Simulator info
|
||||
CSimulatorInfo getSimulatorInfo() const { return this->m_simulator; }
|
||||
|
||||
//! Set simulator info
|
||||
void setSimulatorInfo(const CSimulatorInfo &simulator) { this->m_simulator = simulator; }
|
||||
|
||||
//! File name (corresponding data for simulator, only available if representing simulator model=
|
||||
QString getFileName() const { return m_fileName; }
|
||||
|
||||
//! File name?
|
||||
bool hasFileName() const { return !m_fileName.isEmpty(); }
|
||||
|
||||
//! File name
|
||||
void setFileName(const QString &fileName) { m_fileName = fileName; }
|
||||
|
||||
@@ -137,20 +165,25 @@ namespace BlackMisc
|
||||
//! Matches model string?
|
||||
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
|
||||
//! From swift DB JSON
|
||||
static CAircraftModel fromDatabaseJson(const QJsonObject &json);
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftModel)
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< aircraft's callsign
|
||||
BlackMisc::Aviation::CAircraftIcaoData m_icao; //!< ICAO data if available
|
||||
QString m_modelString; //!< Simulator model string
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
int m_modelType = static_cast<int>(TypeUnknown); //!< model string is queried from network?
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< aircraft's callsign if any
|
||||
BlackMisc::Aviation::CAircraftIcaoData m_icao; //!< ICAO data if available
|
||||
BlackMisc::Aviation::CLivery m_livery; //!< livery information
|
||||
CSimulatorInfo m_simulator; //!< model for given simulator
|
||||
QString m_modelString; //!< Simulator model string
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
ModelType m_modelType = TypeUnknown; //!< model string is coming from ...?
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -159,6 +192,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(
|
||||
BlackMisc::Simulation::CAircraftModel, (
|
||||
attr(o.m_callsign),
|
||||
attr(o.m_icao),
|
||||
attr(o.m_simulator),
|
||||
attr(o.m_modelString, flags<CaseInsensitiveComparison>()),
|
||||
attr(o.m_description, flags<DisabledForComparison>()),
|
||||
attr(o.m_fileName, flags <DisabledForComparison> ()),
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/datastoreobjectlist.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
@@ -24,6 +25,7 @@ namespace BlackMisc
|
||||
//! Value object encapsulating a list of aircraft models
|
||||
class BLACKMISC_EXPORT CAircraftModelList :
|
||||
public CSequence<CAircraftModel>,
|
||||
public IDatastoreObjectListWithIntegerKey<CAircraftModel, CAircraftModelList>,
|
||||
public BlackMisc::Mixin::MetaType<CAircraftModelList>
|
||||
{
|
||||
public:
|
||||
@@ -49,7 +51,6 @@ namespace BlackMisc
|
||||
|
||||
//! Model strings
|
||||
QStringList getSortedModelStrings() const;
|
||||
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
95
src/blackmisc/simulation/distributor.cpp
Normal file
95
src/blackmisc/simulation/distributor.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "distributor.h"
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CDistributor::CDistributor() { }
|
||||
|
||||
CDistributor::CDistributor(const QString &id, const QString &description, const QString &alias1, const QString &alias2) :
|
||||
m_description(description), m_alias1(alias1.trimmed().toUpper()), m_alias2(alias2.trimmed().toUpper())
|
||||
{
|
||||
this->setDbKey(id);
|
||||
}
|
||||
|
||||
CVariant CDistributor::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::propertyByIndex(index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAlias1: return CVariant::from(this->m_alias1);
|
||||
case IndexAlias2: return CVariant::from(this->m_alias2);
|
||||
case IndexDescription: return CVariant::from(this->m_description);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributor::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CDistributor>(); return; }
|
||||
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { IDatastoreObjectWithStringKey::setPropertyByIndex(variant, index); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAlias1:
|
||||
this->m_alias1 = variant.value<QString>();
|
||||
break;
|
||||
case IndexAlias2:
|
||||
this->m_alias2 = variant.value<QString>();
|
||||
break;
|
||||
case IndexDescription:
|
||||
this->m_description = variant.value<QString>();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CDistributor::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s("Id: %1");
|
||||
s.arg(m_dbKey);
|
||||
if (this->hasAlias1()) { s.append(" ").append(m_alias1); }
|
||||
if (this->hasAlias2()) { s.append(" ").append(m_alias2); }
|
||||
return s;
|
||||
}
|
||||
|
||||
bool CDistributor::hasCompleteData() const
|
||||
{
|
||||
return !this->m_description.isEmpty() && !this->m_dbKey.isEmpty();
|
||||
}
|
||||
|
||||
CDistributor CDistributor::fromDatabaseJson(const QJsonObject &json)
|
||||
{
|
||||
QJsonArray inner = json["cell"].toArray();
|
||||
Q_ASSERT_X(!inner.isEmpty(), Q_FUNC_INFO, "Missing JSON");
|
||||
if (inner.isEmpty()) { return CDistributor(); }
|
||||
|
||||
int i = 0;
|
||||
QString dbKey(inner.at(i++).toString());
|
||||
QString description(inner.at(i++).toString());
|
||||
QString alias1(inner.at(i++).toString());
|
||||
QString alias2(inner.at(i++).toString());
|
||||
Q_ASSERT_X(!dbKey.isEmpty(), Q_FUNC_INFO, "Missing key");
|
||||
Q_ASSERT_X(!description.isEmpty(), Q_FUNC_INFO, "Missing description");
|
||||
CDistributor distributor(dbKey, description, alias1, alias2);
|
||||
return distributor;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
101
src/blackmisc/simulation/distributor.h
Normal file
101
src/blackmisc/simulation/distributor.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_DISTRIBUTOR_H
|
||||
#define BLACKMISC_SIMULATION_DISTRIBUTOR_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/datastore.h"
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Value object encapsulating information of software distributor.
|
||||
class BLACKMISC_EXPORT CDistributor :
|
||||
public BlackMisc::CValueObject<CDistributor>,
|
||||
public BlackMisc::IDatastoreObjectWithStringKey
|
||||
{
|
||||
public:
|
||||
//! Property indexes
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexDescription = CPropertyIndex::GlobalIndexCDistributor,
|
||||
IndexAlias1,
|
||||
IndexAlias2
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CDistributor();
|
||||
|
||||
//! Constructor
|
||||
CDistributor(const QString &id, const QString &description, const QString &alias1, const QString &alias2);
|
||||
|
||||
//! Id
|
||||
const QString &getId() const { return this->getDbKey(); }
|
||||
|
||||
//! Get description
|
||||
const QString &getDescription() const { return this->m_description;}
|
||||
|
||||
//! Get alias1
|
||||
const QString &getAlias1() const { return this->m_alias1;}
|
||||
|
||||
//! Get alias2
|
||||
const QString &getAlias2() const { return this->m_alias2;}
|
||||
|
||||
//! Set alias1
|
||||
void setAlias1(const QString &alias) { this->m_alias1 = alias.trimmed().toUpper(); }
|
||||
|
||||
//! Set alias2
|
||||
void setAlias2(const QString &alias) { this->m_alias2 = alias.trimmed().toUpper(); }
|
||||
|
||||
//! Alias 1?
|
||||
bool hasAlias1() const { return !this->m_alias1.isEmpty(); }
|
||||
|
||||
//! Alias 2?
|
||||
bool hasAlias2() const { return !this->m_alias2.isEmpty(); }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Complete data?
|
||||
bool hasCompleteData() const;
|
||||
|
||||
//! Object from JSON
|
||||
static CDistributor fromDatabaseJson(const QJsonObject &json);
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CDistributor)
|
||||
QString m_description; //!< description
|
||||
QString m_alias1; //!< alias name
|
||||
QString m_alias2; //!< alias name
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CDistributor)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CDistributor, (
|
||||
attr(o.m_dbKey, flags <CaseInsensitiveComparison> ()),
|
||||
attr(o.m_description),
|
||||
attr(o.m_alias1, flags <CaseInsensitiveComparison> ()),
|
||||
attr(o.m_alias2, flags <CaseInsensitiveComparison> ())
|
||||
))
|
||||
|
||||
#endif // guard
|
||||
24
src/blackmisc/simulation/distributorlist.cpp
Normal file
24
src/blackmisc/simulation/distributorlist.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CDistributorList::CDistributorList() { }
|
||||
|
||||
CDistributorList::CDistributorList(const CSequence<CDistributor> &other) :
|
||||
CSequence<CDistributor>(other)
|
||||
{ }
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
50
src/blackmisc/simulation/distributorlist.h
Normal file
50
src/blackmisc/simulation/distributorlist.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_DISTRIBUTORLIST_H
|
||||
#define BLACKMISC_SIMULATION_DISTRIBUTORLIST_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/distributor.h"
|
||||
#include "blackmisc/datastoreobjectlist.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Value object encapsulating a list of distributors.
|
||||
class BLACKMISC_EXPORT CDistributorList :
|
||||
public BlackMisc::CSequence<CDistributor>,
|
||||
public BlackMisc::IDatastoreObjectListWithStringKey<CDistributor, CDistributorList>,
|
||||
public BlackMisc::Mixin::MetaType<CDistributorList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CDistributorList)
|
||||
|
||||
//! Default constructor.
|
||||
CDistributorList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CDistributorList(const CSequence<CDistributor> &other);
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CDistributorList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Simulation::CDistributor>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Simulation::CDistributor>)
|
||||
|
||||
#endif //guard
|
||||
@@ -18,7 +18,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
|
||||
CSimulatedAircraft::CSimulatedAircraft()
|
||||
{
|
||||
init();
|
||||
@@ -33,9 +32,11 @@ namespace BlackMisc
|
||||
void CSimulatedAircraft::init()
|
||||
{
|
||||
// sync some values, order here is crucial
|
||||
// set get/set thing here updates the redundant data (e.g. livery / model.livery)
|
||||
this->setCallsign(this->getCallsign());
|
||||
this->setIcaoInfo(this->getIcaoInfo());
|
||||
this->setModel(this->getModel()); // fix internal values
|
||||
this->setLivery(this->getLivery());
|
||||
this->setModel(this->getModel());
|
||||
this->setPilot(this->hasValidRealName() ? this->getPilot() : this->getClient().getUser());
|
||||
}
|
||||
|
||||
@@ -125,6 +126,12 @@ namespace BlackMisc
|
||||
CAircraft::setIcaoInfo(newIcao);
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setLivery(const CLivery &livery)
|
||||
{
|
||||
this->m_model.setLivery(livery);
|
||||
CAircraft::setLivery(livery);
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setPilot(const CUser &user)
|
||||
{
|
||||
this->m_client.setUser(user);
|
||||
|
||||
@@ -69,6 +69,9 @@ namespace BlackMisc
|
||||
//! \copydoc CAircraft::setIcaoInfo
|
||||
virtual void setIcaoInfo(const BlackMisc::Aviation::CAircraftIcaoData &icao) override;
|
||||
|
||||
//! \copydoc CAircraft::setLivery
|
||||
virtual void setLivery(const BlackMisc::Aviation::CLivery &livery) override;
|
||||
|
||||
//! \copydoc CAircraft::setPilot
|
||||
virtual void setPilot(const BlackMisc::Network::CUser &user) override;
|
||||
|
||||
@@ -115,8 +118,9 @@ namespace BlackMisc
|
||||
bool m_enabled = true; //!< to be displayed in sim
|
||||
bool m_rendered = false; //!< really shown in simulator
|
||||
bool m_partsSynchronized = false; //!< sync.parts
|
||||
bool m_fastPositionUpdates =false; //!<use fast position updates
|
||||
bool m_fastPositionUpdates = false; //!<use fast position updates
|
||||
|
||||
//! Init, which syncronizes some denormalized values
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user