mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T472, allow to pass already existing values for model parsing
* list to map: toDbKeyValueMap * categories can also be passed, hence the categories can be seen in model views
This commit is contained in:
committed by
Mat Sutcliffe
parent
7a2ed1433d
commit
9cee34f4cc
@@ -961,7 +961,7 @@ namespace BlackMisc
|
||||
|
||||
CAircraftModel CAircraftModel::fromDatabaseJsonCaching(
|
||||
const QJsonObject &json,
|
||||
AircraftIcaoIdMap &aircraftIcaos, LiveryIdMap &liveries, DistributorIdMap &distributors,
|
||||
AircraftIcaoIdMap &aircraftIcaos, const AircraftCategoryIdMap &categories, LiveryIdMap &liveries, DistributorIdMap &distributors,
|
||||
const QString &prefix)
|
||||
{
|
||||
static const QString prefixAircraftIcao("ac_");
|
||||
@@ -987,11 +987,20 @@ namespace BlackMisc
|
||||
distributors[idDistributor] :
|
||||
CDistributor::fromDatabaseJson(json, prefixDistributor));
|
||||
|
||||
if (!aircraftIcao.isLoadedFromDb() && idAircraftIcao >= 0) { aircraftIcao.setDbKey(idAircraftIcao); }
|
||||
if (!aircraftIcao.isLoadedFromDb() && idAircraftIcao >= 0) { aircraftIcao.setDbKey(idAircraftIcao); }
|
||||
if (!livery.isLoadedFromDb() && idLivery >= 0) { livery.setDbKey(idLivery); }
|
||||
if (!distributor.isLoadedFromDb() && !idDistributor.isEmpty()) { distributor.setDbKey(idDistributor); }
|
||||
|
||||
// update category
|
||||
if (!cachedAircraftIcao)
|
||||
{
|
||||
const int catId = aircraftIcao.getCategory().getDbKey();
|
||||
if (catId >= 0 && categories.contains(catId))
|
||||
{
|
||||
aircraftIcao.setCategory(categories[catId]);
|
||||
}
|
||||
}
|
||||
|
||||
// store in temp.cache
|
||||
if (!cachedAircraftIcao && aircraftIcao.isLoadedFromDb()) { aircraftIcaos[aircraftIcao.getDbKey()] = aircraftIcao; }
|
||||
if (!cachedLivery && livery.isLoadedFromDb()) { liveries[livery.getDbKey()] = livery; }
|
||||
|
||||
Reference in New Issue
Block a user