Ref T335, misc. improvements of value classes/list

- verifyModelData
- setModelType
- getCallsignsAsString
This commit is contained in:
Klaus Basan
2018-09-12 16:18:56 +02:00
parent 7d715a909e
commit c675ef5c32
8 changed files with 61 additions and 4 deletions

View File

@@ -48,6 +48,12 @@ namespace BlackMisc
return callsigns; return callsigns;
} }
QString CCallsignSet::getCallsignsAsString(bool sorted, const QString &separator) const
{
if (this->isEmpty()) { return QStringLiteral(""); }
return this->getCallsignStrings(sorted).join(separator);
}
void CCallsignSet::registerMetadata() void CCallsignSet::registerMetadata()
{ {
qRegisterMetaType<BlackMisc::CSequence<CCallsign>>(); qRegisterMetaType<BlackMisc::CSequence<CCallsign>>();

View File

@@ -47,6 +47,9 @@ namespace BlackMisc
//! The callsign strings //! The callsign strings
QStringList getCallsignStrings(bool sorted = false) const; QStringList getCallsignStrings(bool sorted = false) const;
//! Callsigns as string
QString getCallsignsAsString(bool sorted = false, const QString &separator = ", ") const;
//! Register metadata //! Register metadata
static void registerMetadata(); static void registerMetadata();
}; };

View File

@@ -136,6 +136,26 @@ namespace BlackMisc
.arg(this->getLivery().asHtmlSummary("&nbsp;")).replace(" ", "&nbsp;"); .arg(this->getLivery().asHtmlSummary("&nbsp;")).replace(" ", "&nbsp;");
} }
CStatusMessageList CAircraftModel::verifyModelData() const
{
CStatusMessageList msgs;
const ModelType t = this->getModelType();
if (t == TypeOwnSimulatorModel || t == TypeManuallySet || t == TypeDatabaseEntry)
{
if (!this->existsCorrespondingFile())
{
const CStatusMessage m = CStatusMessage(this).validationError("File '%1' not readable") << this->getFileName();
msgs.push_back(m);
}
}
else
{
const CStatusMessage m = CStatusMessage(this).validationError("Invalid model type to check: '%1'") << this->getModelTypeAsString();
msgs.push_back(m);
}
return msgs;
}
bool CAircraftModel::canInitializeFromFsd() const bool CAircraftModel::canInitializeFromFsd() const
{ {
const bool nw = this->getModelType() == CAircraftModel::TypeQueriedFromNetwork || const bool nw = this->getModelType() == CAircraftModel::TypeQueriedFromNetwork ||
@@ -721,7 +741,7 @@ namespace BlackMisc
static const QString db("database"); static const QString db("database");
static const QString def("map.default"); static const QString def("map.default");
static const QString ownSim("own simulator"); static const QString ownSim("own simulator");
static const QString set("set"); static const QString set("manually set");
static const QString fsinn("FSInn"); static const QString fsinn("FSInn");
static const QString probe("probe"); static const QString probe("probe");
static const QString unknown("unknown"); static const QString unknown("unknown");

View File

@@ -424,6 +424,9 @@ namespace BlackMisc
// ---------------- end file related functions -------------- // ---------------- end file related functions --------------
//! Verify the model data
CStatusMessageList verifyModelData() const;
//! Model type //! Model type
static const QString &modelTypeToString(ModelType type); static const QString &modelTypeToString(ModelType type);

View File

@@ -474,6 +474,18 @@ namespace BlackMisc
return c; return c;
} }
int CAircraftModelList::setModelType(CAircraftModel::ModelType type)
{
int c = 0;
for (CAircraftModel &model : (*this))
{
if (model.getModelType() == type) { continue; }
model.setModelType(type);
c++;
}
return c;
}
int CAircraftModelList::setCG(const CLength &cg) int CAircraftModelList::setCG(const CLength &cg)
{ {
int c = 0; int c = 0;

View File

@@ -215,7 +215,10 @@ namespace BlackMisc
CSimulatorInfo simulatorsSupported() const; CSimulatorInfo simulatorsSupported() const;
//! Set mode for all elements //! Set mode for all elements
int setModelMode(Simulation::CAircraftModel::ModelMode mode); int setModelMode(CAircraftModel::ModelMode mode);
//! Set type for all elements
int setModelType(CAircraftModel::ModelType type);
//! Set center of gravity //! Set center of gravity
int setCG(const PhysicalQuantities::CLength &cg); int setCG(const PhysicalQuantities::CLength &cg);

View File

@@ -117,6 +117,13 @@ namespace BlackMisc
return m_enabled; return m_enabled;
} }
bool CSimulatedAircraft::setEnabled(bool enabled)
{
if (m_enabled == enabled) { return false; }
m_enabled = enabled;
return true;
}
bool CSimulatedAircraft::setFastPositionUpdates(bool useFastPositions) bool CSimulatedAircraft::setFastPositionUpdates(bool useFastPositions)
{ {
if (m_fastPositionUpdates == useFastPositions) { return false; } if (m_fastPositionUpdates == useFastPositions) { return false; }
@@ -494,7 +501,10 @@ namespace BlackMisc
const CLivery livery(this->getModel().getLivery()); const CLivery livery(this->getModel().getLivery());
const CLivery liveryNw(this->getNetworkModel().getLivery()); const CLivery liveryNw(this->getNetworkModel().getLivery());
if (livery.isDbEqual(liveryNw) || livery == liveryNw) { return QStringLiteral("[=] ") + livery.getCombinedCodePlusInfo(); } if (livery.isDbEqual(liveryNw) || livery == liveryNw) { return QStringLiteral("[==] ") + livery.getCombinedCodePlusInfo(); }
if (livery.getCombinedCode() == liveryNw.getCombinedCode()) { return QStringLiteral("[=] ") + livery.getCombinedCodePlusInfo(); }
if (livery.isAirlineLivery() && liveryNw.isAirlineLivery()) { return this->getNetworkModelAirlineIcaoDifference(); }
static const QString diff("%1 -> %2"); static const QString diff("%1 -> %2");
return diff.arg(liveryNw.getCombinedCodePlusInfo(), livery.getCombinedCodePlusInfo()); return diff.arg(liveryNw.getCombinedCodePlusInfo(), livery.getCombinedCodePlusInfo());
} }

View File

@@ -412,7 +412,7 @@ namespace BlackMisc
bool isEnabled() const; bool isEnabled() const;
//! Enabled / disabled //! Enabled / disabled
void setEnabled(bool enabled) { m_enabled = enabled; } bool setEnabled(bool enabled);
//! Rendered? //! Rendered?
bool isRendered() const { return m_rendered; } bool isRendered() const { return m_rendered; }