mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #745, improved own model set dialog
* allow to consolidate data * display either preferences or all distributors * builder can consolidate * get model set from mapping component
This commit is contained in:
@@ -814,6 +814,11 @@ namespace BlackGui
|
||||
ui->comp_OwnModelSet->setModelSetSimulator(simulator);
|
||||
}
|
||||
|
||||
CAircraftModelList CDbMappingComponent::getOwnModelSet() const
|
||||
{
|
||||
return ui->comp_OwnModelSet->getModelSet();
|
||||
}
|
||||
|
||||
CStatusMessage CDbMappingComponent::stashModel(const CAircraftModel &model, bool replace)
|
||||
{
|
||||
return ui->comp_StashAircraft->stashModel(model, replace);
|
||||
|
||||
@@ -148,11 +148,14 @@ namespace BlackGui
|
||||
int getOwnModelsCount() const;
|
||||
//! @}
|
||||
|
||||
// ---------------- own models -----------------
|
||||
// ---------------- own model set -----------------
|
||||
|
||||
//! Set simulator for own models
|
||||
void setOwnModelSetSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Own model set
|
||||
BlackMisc::Simulation::CAircraftModelList getOwnModelSet() const;
|
||||
|
||||
public slots:
|
||||
//! \copydoc CDbStashComponent::stashModel
|
||||
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
||||
|
||||
@@ -31,6 +31,5 @@ namespace BlackGui
|
||||
if (!m) { return; }
|
||||
m_mappingComponent = m;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace BlackGui
|
||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||
Q_ASSERT_X(this->m_simulatorInfo.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
ui->form_OwnModelSet->setSimulator(this->m_simulatorInfo);
|
||||
this->ui->form_OwnModelSet->reloadData();
|
||||
ui->form_OwnModelSet->reloadData();
|
||||
this->m_modelSet = this->getMappingComponent()->getOwnModelSet();
|
||||
}
|
||||
|
||||
int CDbOwnModelSetDialog::exec()
|
||||
@@ -118,22 +119,30 @@ namespace BlackGui
|
||||
CAircraftModelList CDbOwnModelSetDialog::buildSet(const CSimulatorInfo &simulator, const CAircraftModelList ¤tSet)
|
||||
{
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
const bool selectedProviders = this->ui->form_OwnModelSet->useSelectedDistributors();
|
||||
const bool dbDataOnly = this->ui->form_OwnModelSet->dbDataOnly();
|
||||
const bool dbIcaoOnly = this->ui->form_OwnModelSet->dbIcaoCodesOnly();
|
||||
const bool incremnental = this->ui->form_OwnModelSet->incrementalBuild();
|
||||
const bool givenDistributorsOnly = !ui->form_OwnModelSet->optionUseAllDistributors();
|
||||
const bool dbDataOnly = ui->form_OwnModelSet->optionDbDataOnly();
|
||||
const bool dbIcaoOnly = ui->form_OwnModelSet->optionDbIcaoCodesOnly();
|
||||
const bool incremnental = ui->form_OwnModelSet->optionIncrementalBuild();
|
||||
const bool sortByDistributor = ui->form_OwnModelSet->optionSortByDistributorPreferences();
|
||||
const bool consolidateWithDb = ui->form_OwnModelSet->optionConsolidateModelSetWithDbData();
|
||||
|
||||
const CAircraftModelList models = this->getMappingComponent()->getOwnModels();
|
||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||
const CDistributorList distributors = selectedProviders ?
|
||||
ui->form_OwnModelSet->getSelectedDistributors() :
|
||||
ui->form_OwnModelSet->getDistributorsFromPreferences();
|
||||
const CAircraftModelList models = this->getMappingComponent()->getOwnModels();
|
||||
const CDistributorList distributors = ui->form_OwnModelSet->getDistributorsBasedOnOptions();
|
||||
|
||||
if (givenDistributorsOnly && distributors.isEmpty())
|
||||
{
|
||||
// nothing to do, keep current set
|
||||
return currentSet;
|
||||
}
|
||||
|
||||
const CModelSetBuilder builder(this);
|
||||
CModelSetBuilder::Builder options = selectedProviders ? CModelSetBuilder::FilterDistributos : CModelSetBuilder::NoOptions;
|
||||
CModelSetBuilder::Builder options = givenDistributorsOnly ? CModelSetBuilder::GivenDistributorsOnly : CModelSetBuilder::NoOptions;
|
||||
if (dbDataOnly) { options |= CModelSetBuilder::OnlyDbData; }
|
||||
if (dbIcaoOnly) { options |= CModelSetBuilder::OnlyDbIcaoCodes; }
|
||||
if (incremnental) { options |= CModelSetBuilder::Incremental; }
|
||||
if (ui->form_OwnModelSet->hasDistributorPreferences()) { options |= CModelSetBuilder::SortByDistributors; }
|
||||
if (sortByDistributor) { options |= CModelSetBuilder::SortByDistributors; }
|
||||
if (consolidateWithDb) { options |= CModelSetBuilder::ConsolidateWithDb; }
|
||||
return builder.buildModelSet(simulator, models, currentSet, options, distributors);
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -51,10 +51,13 @@ namespace BlackGui
|
||||
//! Last build set
|
||||
const BlackMisc::Simulation::CAircraftModelList &getModelSet() const { return m_modelSet; }
|
||||
|
||||
//! Init last set
|
||||
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models) { m_modelSet = models; }
|
||||
|
||||
//! Simulator info
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getSimulatorInfo() const { return m_simulatorInfo; }
|
||||
|
||||
//! Reload data
|
||||
//! Reload data e.g. current model set and simulator
|
||||
void reloadData();
|
||||
|
||||
//! Exec and display simulator
|
||||
|
||||
Reference in New Issue
Block a user