mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T261, CG in aircraft model
This commit is contained in:
committed by
Roland Winklmeier
parent
784cf29af5
commit
a8ab2a37b8
@@ -62,6 +62,7 @@ namespace BlackMisc
|
||||
(this->hasModelString() ? inApostrophes(m_modelString, true) % QStringLiteral(" ") : QStringLiteral("")) %
|
||||
QStringLiteral(" type: '") % this->getModelTypeAsString() %
|
||||
QStringLiteral("' ICAO: '") % this->getAircraftIcaoCode().toQString(i18n) %
|
||||
QStringLiteral(" CG: ") % this->getCG().valueRoundedWithUnit(1) %
|
||||
QStringLiteral("' {") % m_livery.toQString(i18n) %
|
||||
QStringLiteral("} file: '") % m_fileName % QStringLiteral("'");
|
||||
return s;
|
||||
@@ -190,6 +191,7 @@ namespace BlackMisc
|
||||
case IndexDescription: return CVariant(m_description);
|
||||
case IndexName: return CVariant(m_name);
|
||||
case IndexFileName: return CVariant(m_fileName);
|
||||
case IndexCG: return m_cg.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexFileTimestamp: return CVariant::fromValue(this->getFileTimestamp());
|
||||
case IndexFileTimestampFormattedYmdhms: return CVariant::fromValue(this->getFormattedFileTimestampYmdhms());
|
||||
case IndexIconPath: return CVariant(m_iconPath);
|
||||
@@ -218,6 +220,7 @@ namespace BlackMisc
|
||||
case IndexSimulatorInfo: m_simulator.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexName: m_name = variant.toQString(); break;
|
||||
case IndexIconPath: m_iconPath = variant.toQString(); break;
|
||||
case IndexCG: m_cg.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexModelType: m_modelType = variant.value<ModelType>(); break;
|
||||
case IndexFileName: m_fileName = variant.toQString(); break;
|
||||
case IndexCallsign:
|
||||
@@ -265,6 +268,7 @@ namespace BlackMisc
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexFileName: return m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
|
||||
case IndexIconPath: return m_iconPath.compare(compareValue.getIconPath(), Qt::CaseInsensitive);
|
||||
case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG());
|
||||
case IndexModelType: return Compare::compare(m_modelType, compareValue.getModelType());
|
||||
case IndexSimulatorInfoAsString:
|
||||
case IndexSimulatorInfo: return m_simulator.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSimulator());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/db/datastore.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
@@ -93,6 +94,7 @@ namespace BlackMisc
|
||||
IndexSimulatorInfoAsString,
|
||||
IndexAircraftIcaoCode,
|
||||
IndexLivery,
|
||||
IndexCG,
|
||||
IndexDistributor,
|
||||
IndexFileName,
|
||||
IndexFileTimestamp,
|
||||
@@ -260,6 +262,12 @@ namespace BlackMisc
|
||||
//! Name
|
||||
void setName(const QString &name) { m_name = name.trimmed(); }
|
||||
|
||||
//! Get center of gravity
|
||||
const PhysicalQuantities::CLength &getCG() const { return m_cg; }
|
||||
|
||||
//! Get center of gravity
|
||||
void setCG(const PhysicalQuantities::CLength &cg) { m_cg = cg; }
|
||||
|
||||
//! Model type
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
|
||||
@@ -433,6 +441,7 @@ namespace BlackMisc
|
||||
Aviation::CLivery m_livery; //!< livery information
|
||||
CSimulatorInfo m_simulator; //!< model for given simulator
|
||||
CDistributor m_distributor; //!< who designed or distributed the model
|
||||
PhysicalQuantities::CLength m_cg = PhysicalQuantities::CLength::null(); //!< center of gravity
|
||||
QString m_modelString; //!< Simulator model key, unique
|
||||
QString m_name; //!< Model name
|
||||
QString m_description; //!< descriptive text
|
||||
@@ -452,6 +461,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(livery),
|
||||
BLACK_METAMEMBER(simulator),
|
||||
BLACK_METAMEMBER(distributor),
|
||||
BLACK_METAMEMBER(cg),
|
||||
BLACK_METAMEMBER(modelString, 0, CaseInsensitiveComparison),
|
||||
BLACK_METAMEMBER(name),
|
||||
BLACK_METAMEMBER(description, 0, DisabledForComparison),
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -472,6 +473,18 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
int CAircraftModelList::setCG(const CLength &cg)
|
||||
{
|
||||
int c = 0;
|
||||
for (CAircraftModel &model : (*this))
|
||||
{
|
||||
if (model.getCG() == cg) { continue; }
|
||||
model.setCG(cg);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int CAircraftModelList::keepModelsWithString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity)
|
||||
{
|
||||
const int cs = this->size();
|
||||
|
||||
@@ -215,6 +215,9 @@ namespace BlackMisc
|
||||
//! Set mode for all elements
|
||||
int setModelMode(Simulation::CAircraftModel::ModelMode mode);
|
||||
|
||||
//! Set center of gravity
|
||||
int setCG(const PhysicalQuantities::CLength &cg);
|
||||
|
||||
//! Keep only those models with given model strings
|
||||
//! \return number of elements removed
|
||||
int keepModelsWithString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity);
|
||||
|
||||
Reference in New Issue
Block a user