mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +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
|
||||
|
||||
@@ -58,21 +58,36 @@ namespace BlackGui
|
||||
this->initDistributorDisplay();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::useSelectedDistributors() const
|
||||
bool COwnModelSetForm::optionUseSelectedDistributors() const
|
||||
{
|
||||
return this->ui->rb_SelectedDistributors->isChecked();
|
||||
return ui->rb_DistributorsSelected->isChecked();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::dbDataOnly() const
|
||||
bool COwnModelSetForm::optionUseAllDistributors() const
|
||||
{
|
||||
return this->ui->rb_DbDataOnly->isChecked();
|
||||
return ui->rb_DistributorsAll->isChecked();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::incrementalBuild() const
|
||||
bool COwnModelSetForm::optionDbDataOnly() const
|
||||
{
|
||||
return ui->rb_DbDataOnly->isChecked();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::optionIncrementalBuild() const
|
||||
{
|
||||
return ui->rb_Incremental->isChecked();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::optionSortByDistributorPreferences() const
|
||||
{
|
||||
return ui->cb_SortByPreferences->isChecked() && this->hasDistributorPreferences();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::optionConsolidateModelSetWithDbData() const
|
||||
{
|
||||
return ui->cb_ConsolidateModelSet->isChecked();
|
||||
}
|
||||
|
||||
void COwnModelSetForm::ps_preferencesChanged()
|
||||
{
|
||||
// void
|
||||
@@ -120,6 +135,14 @@ namespace BlackGui
|
||||
{
|
||||
ui->tvp_Distributors->setDistributorMode(hasPreferences ? CDistributorListModel::MinimalWithOrder : CDistributorListModel::Minimal);
|
||||
ui->tvp_Distributors->fullResizeToContents();
|
||||
if (hasPreferences)
|
||||
{
|
||||
ui->tvp_Distributors->setSorting(CDistributor::IndexOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tvp_Distributors->setSorting(CDistributor::IndexDbStringKey);
|
||||
}
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributorsFromPreferences() const
|
||||
@@ -137,9 +160,18 @@ namespace BlackGui
|
||||
return sGui->getWebDataServices()->getDistributors().matchesSimulator(this->m_simulator);
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::dbIcaoCodesOnly() const
|
||||
CDistributorList COwnModelSetForm::getDistributorsBasedOnOptions() const
|
||||
{
|
||||
return this->ui->rb_DbIcaoCodesOnly->isChecked();
|
||||
if (ui->rb_DistributorsAll->isChecked()) { return this->getAllDistributors(); }
|
||||
if (ui->rb_DistributorsSelected->isChecked()) { return this->getSelectedDistributors(); }
|
||||
if (ui->rb_DistributorsFromBelow->isChecked()) { return this->getShownDistributors(); }
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong option");
|
||||
return CDistributorList();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::optionDbIcaoCodesOnly() const
|
||||
{
|
||||
return ui->rb_DbIcaoCodesOnly->isChecked();
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getSelectedDistributors() const
|
||||
@@ -147,6 +179,11 @@ namespace BlackGui
|
||||
return ui->tvp_Distributors->selectedObjects();
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getShownDistributors() const
|
||||
{
|
||||
return ui->tvp_Distributors->containerOrFilteredContainer();
|
||||
}
|
||||
|
||||
void COwnModelSetForm::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
|
||||
@@ -41,23 +41,35 @@ namespace BlackGui
|
||||
//! Reload data
|
||||
void reloadData();
|
||||
|
||||
//! Selected providers?
|
||||
bool useSelectedDistributors() const;
|
||||
|
||||
//! Get selected providers
|
||||
BlackMisc::Simulation::CDistributorList getSelectedDistributors() const;
|
||||
|
||||
//! Current simulator
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Selected distributors?
|
||||
bool optionUseSelectedDistributors() const;
|
||||
|
||||
//! All distributors?
|
||||
bool optionUseAllDistributors() const;
|
||||
|
||||
//! Only DB data
|
||||
bool dbDataOnly() const;
|
||||
bool optionDbDataOnly() const;
|
||||
|
||||
//! DB ICAO codes
|
||||
bool dbIcaoCodesOnly() const;
|
||||
bool optionDbIcaoCodesOnly() const;
|
||||
|
||||
//! Request incremental build
|
||||
bool incrementalBuild() const;
|
||||
bool optionIncrementalBuild() const;
|
||||
|
||||
//! Sort by distributor preferences
|
||||
bool optionSortByDistributorPreferences() const;
|
||||
|
||||
//! Consolidate with DB data?
|
||||
bool optionConsolidateModelSetWithDbData() const;
|
||||
|
||||
//! Get selected distributors
|
||||
BlackMisc::Simulation::CDistributorList getSelectedDistributors() const;
|
||||
|
||||
//! Get shown distributors
|
||||
BlackMisc::Simulation::CDistributorList getShownDistributors() const;
|
||||
|
||||
//! Distributors from preferences
|
||||
BlackMisc::Simulation::CDistributorList getDistributorsFromPreferences() const;
|
||||
@@ -65,6 +77,9 @@ namespace BlackGui
|
||||
//! All distributors
|
||||
BlackMisc::Simulation::CDistributorList getAllDistributors() const;
|
||||
|
||||
//! Get distributors based on options
|
||||
BlackMisc::Simulation::CDistributorList getDistributorsBasedOnOptions() const;
|
||||
|
||||
//! Preferences for given simulator?
|
||||
bool hasDistributorPreferences() const;
|
||||
|
||||
|
||||
@@ -74,19 +74,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="rb_AllDistributors">
|
||||
<property name="text">
|
||||
<string>all</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<property name="text">
|
||||
@@ -140,7 +127,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
||||
<widget class="QRadioButton" name="rb_DistributorsSelected">
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
</property>
|
||||
@@ -209,6 +196,29 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QRadioButton" name="rb_DistributorsAll">
|
||||
<property name="text">
|
||||
<string>all</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="rb_DistributorsFromBelow">
|
||||
<property name="text">
|
||||
<string>all from below</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -245,16 +255,15 @@
|
||||
<tabstop>rb_DbDataOnly</tabstop>
|
||||
<tabstop>rb_DbIcaoCodesOnly</tabstop>
|
||||
<tabstop>rb_WithIcaoData</tabstop>
|
||||
<tabstop>rb_SelectedDistributors</tabstop>
|
||||
<tabstop>rb_AllDistributors</tabstop>
|
||||
<tabstop>rb_DistributorsSelected</tabstop>
|
||||
<tabstop>tvp_Distributors</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
<buttongroup name="bg_Mode"/>
|
||||
<buttongroup name="bg_SourceSet"/>
|
||||
<buttongroup name="bg_DisplayedDistributors"/>
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
<buttongroup name="bg_SourceSet"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user