mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #535, updated aircraft model / view
* add functions to apply changes to selected objects * allow to highlight models by their model strings * Utility function to show which parts come from DB * model strings can be obtained sorted/unsorted
This commit is contained in:
@@ -132,7 +132,7 @@ namespace BlackMisc
|
||||
|
||||
int CAircraftMatcher::synchronize()
|
||||
{
|
||||
return synchronizeWithExistingModels(m_installedModels.getSortedModelStrings());
|
||||
return synchronizeWithExistingModels(m_installedModels.getModelStrings());
|
||||
}
|
||||
|
||||
void CAircraftMatcher::cancelInit()
|
||||
|
||||
@@ -92,6 +92,8 @@ namespace BlackMisc
|
||||
return m_livery.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign:
|
||||
return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPartsDbStatus:
|
||||
return getPartsDbStatus();
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -179,6 +181,8 @@ namespace BlackMisc
|
||||
return Compare::compare(this->m_modelType, compareValue.getModelType());
|
||||
case IndexModelMode:
|
||||
return Compare::compare(this->m_modelMode, compareValue.getModelMode());
|
||||
case IndexPartsDbStatus:
|
||||
return getPartsDbStatus().compare(compareValue.getPartsDbStatus());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -255,6 +259,16 @@ namespace BlackMisc
|
||||
return m_simulator.isAnySimulator();
|
||||
}
|
||||
|
||||
QString CAircraftModel::getPartsDbStatus() const
|
||||
{
|
||||
QString s(hasValidDbKey() ? "M" : "m");
|
||||
s = s.append(getDistributor().hasValidDbKey() ? 'D' : 'd');
|
||||
s = s.append(getAircraftIcaoCode().hasValidDbKey() ? 'A' : 'a');
|
||||
s = s.append(getLivery().hasValidDbKey() ? 'L' : 'l');
|
||||
s = s.append(getLivery().getAirlineIcaoCode().hasValidDbKey() ? 'A' : 'a');
|
||||
return s;
|
||||
}
|
||||
|
||||
bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||
{
|
||||
if (sensitivity == Qt::CaseSensitive)
|
||||
|
||||
@@ -70,7 +70,8 @@ namespace BlackMisc
|
||||
IndexModelTypeAsString,
|
||||
IndexModelMode,
|
||||
IndexModelModeAsString,
|
||||
IndexHasQueriedModelString
|
||||
IndexHasQueriedModelString,
|
||||
IndexPartsDbStatus
|
||||
};
|
||||
|
||||
//! \copydoc BlackMisc::CValueObject::registerMetadata
|
||||
@@ -199,7 +200,7 @@ namespace BlackMisc
|
||||
//! Set simulator info
|
||||
void setSimulatorInfo(const CSimulatorInfo &simulator) { this->m_simulator = simulator; }
|
||||
|
||||
//! File name (corresponding data for simulator, only available if representing simulator model=
|
||||
//! File name (corresponding data for simulator, only available if representing simulator model
|
||||
QString getFileName() const { return m_fileName; }
|
||||
|
||||
//! File name?
|
||||
@@ -226,6 +227,9 @@ namespace BlackMisc
|
||||
//! Valid simulator
|
||||
bool hasValidSimulator() const;
|
||||
|
||||
//! Info, which parts/subparts (Livery, Aircraft ICAO, ...) are already based on DB data
|
||||
QString getPartsDbStatus() const;
|
||||
|
||||
//! Matches model string?
|
||||
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||
|
||||
|
||||
@@ -138,16 +138,40 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
QStringList CAircraftModelList::getSortedModelStrings() const
|
||||
QStringList CAircraftModelList::getModelStrings(bool sort) const
|
||||
{
|
||||
QStringList ms;
|
||||
for (const CAircraftModel &model : (*this))
|
||||
{
|
||||
ms.append(model.getModelString());
|
||||
}
|
||||
ms.sort(Qt::CaseInsensitive);
|
||||
if (sort) { ms.sort(Qt::CaseInsensitive); }
|
||||
return ms;
|
||||
}
|
||||
|
||||
void CAircraftModelList::updateDistributor(const CDistributor &distributor)
|
||||
{
|
||||
for (CAircraftModel &model : *this)
|
||||
{
|
||||
model.setDistributor(distributor);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftModelList::updateAircraftIcao(const CAircraftIcaoCode &icao)
|
||||
{
|
||||
for (CAircraftModel &model : *this)
|
||||
{
|
||||
model.setAircraftIcaoCode(icao);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftModelList::updateLivery(const CLivery &livery)
|
||||
{
|
||||
for (CAircraftModel &model : *this)
|
||||
{
|
||||
model.setLivery(livery);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -76,7 +76,16 @@ namespace BlackMisc
|
||||
int removeModelsWithString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity);
|
||||
|
||||
//! Model strings
|
||||
QStringList getSortedModelStrings() const;
|
||||
QStringList getModelStrings(bool sort = true) const;
|
||||
|
||||
//! Update distributors
|
||||
void updateDistributor(const CDistributor &distributor);
|
||||
|
||||
//! Update aircraft ICAO
|
||||
void updateAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
||||
|
||||
//! Update livery
|
||||
void updateLivery(const BlackMisc::Aviation::CLivery &livery);
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user