mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
* fixed missing tuple attribute * improved toQString conversion
This commit is contained in:
@@ -262,6 +262,7 @@ namespace BlackMisc
|
||||
if (!this->hasIataCode()) { return ""; }
|
||||
QString s(getIataCode());
|
||||
s = s.append(" [IATA]");
|
||||
if (hasDesignator()) { s.append(" ").append(getDesignator()); }
|
||||
if (hasManufacturer()) { s = s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s = s.append(" ").append(getModelDescription()); }
|
||||
return s.append(" ").append(getDbKeyAsStringInParentheses());
|
||||
@@ -272,8 +273,9 @@ namespace BlackMisc
|
||||
if (!this->hasFamily()) { return ""; }
|
||||
QString s(getFamily());
|
||||
s = s.append(" [family]");
|
||||
if (hasManufacturer()) { s = s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s = s.append(" ").append(getModelDescription()); }
|
||||
if (hasDesignator()) { s.append(" ").append(getDesignator()); }
|
||||
if (hasManufacturer()) { s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s.append(" ").append(getModelDescription()); }
|
||||
return s.append(" ").append(getDbKeyAsStringInParentheses());
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ namespace BlackMisc
|
||||
QString s(this->m_designator);
|
||||
if (this->m_name.isEmpty()) { return ""; }
|
||||
if (!this->m_name.isEmpty()) { s.append(" (").append(this->m_name).append(")"); }
|
||||
|
||||
s.append(" Op: ").append(boolToYesNo(this->isOperating()));
|
||||
s.append(" VA: ").append(boolToYesNo(this->isVirtualAirline()));
|
||||
s.append(" Mil: ").append(boolToYesNo(this->isMilitary()));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,8 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(combinedCode, 0, CaseInsensitiveComparison),
|
||||
BLACK_METAMEMBER(description),
|
||||
BLACK_METAMEMBER(colorFuselage),
|
||||
BLACK_METAMEMBER(colorTail)
|
||||
BLACK_METAMEMBER(colorTail),
|
||||
BLACK_METAMEMBER(military)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -278,6 +278,12 @@ namespace BlackMisc
|
||||
return this->m_livery.hasValidAirlineDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::isMilitary() const
|
||||
{
|
||||
return this->getAircraftIcaoCode().isMilitary() ||
|
||||
this->getLivery().isMilitary();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasDistributor() const
|
||||
{
|
||||
return this->m_distributor.hasValidDbKey();
|
||||
@@ -329,6 +335,15 @@ namespace BlackMisc
|
||||
return (static_cast<int>(simulator.getSimulator()) & static_cast<int>(this->getSimulatorInfo().getSimulator())) > 0;
|
||||
}
|
||||
|
||||
QString CAircraftModel::getSwiftLiveryString() const
|
||||
{
|
||||
const QString cc(this->getLivery().getCombinedCode());
|
||||
if (cc.isEmpty() && !this->hasModelString()) { return ""; }
|
||||
if (cc.isEmpty()) { return this->getModelString(); }
|
||||
if (!this->hasModelString()) { return cc; }
|
||||
return cc + " [" + this->getModelString() + "]";
|
||||
}
|
||||
|
||||
void CAircraftModel::updateMissingParts(const CAircraftModel &otherModel, bool dbModelPriority)
|
||||
{
|
||||
if (dbModelPriority && !this->hasValidDbKey() && otherModel.hasValidDbKey())
|
||||
@@ -472,5 +487,36 @@ namespace BlackMisc
|
||||
model.setKeyAndTimestampFromDatabaseJson(json, prefix);
|
||||
return model;
|
||||
}
|
||||
|
||||
QStringList CAircraftModel::splitNetworkLiveryString(const QString &liveryString)
|
||||
{
|
||||
QStringList liveryModelStrings({ "", "" });
|
||||
if (liveryString.isEmpty()) { return liveryModelStrings; }
|
||||
const QString l(liveryString.toUpper().trimmed());
|
||||
if (liveryString.contains('[') && liveryString.contains(']'))
|
||||
{
|
||||
// seems to be a valid swift string
|
||||
const QStringList split = l.split("[");
|
||||
if (split.size() > 0)
|
||||
{
|
||||
liveryModelStrings[0] = split[0].trimmed();
|
||||
}
|
||||
if (split.size() > 1)
|
||||
{
|
||||
QString m = split[1];
|
||||
m.replace('[', ' ');
|
||||
m.replace(']', ' ');
|
||||
liveryModelStrings[1] = m.trimmed();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CLivery::isValidCombinedCode(l))
|
||||
{
|
||||
liveryModelStrings[0] = l;
|
||||
}
|
||||
}
|
||||
return liveryModelStrings;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -164,6 +164,9 @@ namespace BlackMisc
|
||||
//! Airline designator?
|
||||
bool hasAirlineDesignator() const;
|
||||
|
||||
//! Military modles
|
||||
bool isMilitary() const;
|
||||
|
||||
//! Get livery
|
||||
const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; }
|
||||
|
||||
@@ -239,6 +242,10 @@ namespace BlackMisc
|
||||
//! File name
|
||||
void setFileName(const QString &fileName) { m_fileName = fileName; }
|
||||
|
||||
//! swift livery string (to be sent via network), "liveryCode [modelString]";
|
||||
//! \sa splitNetworkLiveryString
|
||||
QString getSwiftLiveryString() const;
|
||||
|
||||
//! Update missing parts from another model
|
||||
void updateMissingParts(const CAircraftModel &otherModel, bool dbModelPriority = true);
|
||||
|
||||
@@ -287,6 +294,11 @@ namespace BlackMisc
|
||||
//! From swift DB JSON
|
||||
static CAircraftModel fromDatabaseJson(const QJsonObject &json, const QString prefix = QString("mod_"));
|
||||
|
||||
//! Split swift network string "DLH._STD" [modelname]"
|
||||
//! \return QStringList [0] livery code , [1] model string
|
||||
//! \sa getSwiftLiveryString
|
||||
static QStringList splitNetworkLiveryString(const QString &liveryString);
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< aircraft's callsign if any
|
||||
BlackMisc::Aviation::CAircraftIcaoCode m_aircraftIcao; //!< ICAO code if available
|
||||
|
||||
Reference in New Issue
Block a user