mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #755, restore distributor order when consolidating with DB data
(formerly order was overridden)
This commit is contained in:
committed by
Roland Winklmeier
parent
1e8090d366
commit
cbc095d230
@@ -30,12 +30,14 @@ namespace BlackCore
|
||||
if (modified) { *modified = false; }
|
||||
if (!model.hasModelString()) { return model; }
|
||||
if (!force && model.hasValidDbKey()) { return model; }
|
||||
const int distributorOrder = model.getDistributorOrder(); // later restore that order
|
||||
|
||||
CAircraftModel dbModel(sApp->getWebDataServices()->getModelForModelString(model.getModelString()));
|
||||
if (dbModel.hasValidDbKey())
|
||||
{
|
||||
if (modified) { *modified = true; }
|
||||
dbModel.updateByLocalFileNames(model);
|
||||
dbModel.setDistributorOrder(distributorOrder);
|
||||
return dbModel;
|
||||
}
|
||||
|
||||
@@ -69,6 +71,7 @@ namespace BlackCore
|
||||
consolidatedModel.setDistributor(dbDistributor);
|
||||
}
|
||||
consolidatedModel.updateByLocalFileNames(model);
|
||||
consolidatedModel.setDistributorOrder(distributorOrder);
|
||||
return consolidatedModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,15 @@ namespace BlackMisc
|
||||
this->getLivery().isMilitary();
|
||||
}
|
||||
|
||||
bool CAircraftModel::updateDistributorOrder(const CDistributorList &distributors)
|
||||
bool CAircraftModel::setDistributorOrder(int order)
|
||||
{
|
||||
if (order < 0) { return false; }
|
||||
if (!this->m_distributor.isLoadedFromDb()) { return false; }
|
||||
this->m_distributor.setOrder(order);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraftModel::setDistributorOrder(const CDistributorList &distributors)
|
||||
{
|
||||
if (distributors.isEmpty()) { return false; }
|
||||
bool found = false;
|
||||
|
||||
@@ -216,8 +216,11 @@ namespace BlackMisc
|
||||
//! Set distributor
|
||||
void setDistributor(const CDistributor &distributor) { m_distributor = distributor; }
|
||||
|
||||
//! Set the distributor order
|
||||
bool setDistributorOrder(int order);
|
||||
|
||||
//! Update distributor`s order attribute
|
||||
bool updateDistributorOrder(const CDistributorList &distributors);
|
||||
bool setDistributorOrder(const CDistributorList &distributors);
|
||||
|
||||
//! Distributor
|
||||
bool hasDistributor() const;
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace BlackMisc
|
||||
int found = 0;
|
||||
for (CAircraftModel &model : *this)
|
||||
{
|
||||
if (model.updateDistributorOrder(distributors)) { found ++; }
|
||||
if (model.setDistributorOrder(distributors)) { found ++; }
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user