mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
refs #618, support for incremental build in model set builder
This commit is contained in:
@@ -19,13 +19,15 @@ namespace BlackCore
|
|||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CModelSetBuilder::buildModelSet(const CAircraftModelList &models, Builder oprions, const CDistributorList &onlyByDistributors) const
|
CAircraftModelList CModelSetBuilder::buildModelSet(const CSimulatorInfo &simulator, const CAircraftModelList &models, const CAircraftModelList ¤tSet, Builder oprions, const CDistributorList &onlyByDistributors) const
|
||||||
{
|
{
|
||||||
if (models.isEmpty()) { return CAircraftModelList(); }
|
if (models.isEmpty()) { return CAircraftModelList(); }
|
||||||
CAircraftModelList modelSet;
|
CAircraftModelList modelSet;
|
||||||
if (oprions.testFlag(FilterDistributos))
|
|
||||||
|
// I avoid and empty distributor set wipes out everything
|
||||||
|
if (oprions.testFlag(FilterDistributos) && !onlyByDistributors.isEmpty())
|
||||||
{
|
{
|
||||||
modelSet = models.byDistributor(onlyByDistributors);
|
modelSet = models.findByDistributors(onlyByDistributors);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -40,13 +42,24 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_ASSERT_X(sApp->hasWebDataServices(), Q_FUNC_INFO, "No web data services");
|
Q_ASSERT_X(sApp->hasWebDataServices(), Q_FUNC_INFO, "No web data services");
|
||||||
const QStringList designators(sApp->getWebDataServices()->getAircraftIcaoCodes().allIcaoCodes());
|
const QStringList designators(sApp->getWebDataServices()->getAircraftIcaoCodes().allIcaoCodes());
|
||||||
modelSet = modelSet.withAircraftDesignator(designators);
|
modelSet = modelSet.findWithAircraftDesignator(designators);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// without any information we can not use them
|
// without any information we can not use them
|
||||||
modelSet = modelSet.withKnownAircraftDesignator();
|
modelSet = modelSet.findWithKnownAircraftDesignator();
|
||||||
}
|
}
|
||||||
return modelSet;
|
modelSet.setModelMode(CAircraftModel::Include); // in sets we only include, exclude means not present in set
|
||||||
|
if (oprions.testFlag(Incremental))
|
||||||
|
{
|
||||||
|
if (currentSet.isEmpty()) { return modelSet; }
|
||||||
|
CAircraftModelList copy(currentSet);
|
||||||
|
copy.replaceOrAddModelsWithString(modelSet, Qt::CaseInsensitive); // incremental
|
||||||
|
return copy.matchesSimulator(simulator);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
return modelSet.matchesSimulator(simulator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ namespace BlackCore
|
|||||||
NoOptions = 0,
|
NoOptions = 0,
|
||||||
FilterDistributos = 1 << 0,
|
FilterDistributos = 1 << 0,
|
||||||
OnlyDbData = 1 << 1,
|
OnlyDbData = 1 << 1,
|
||||||
OnlyDbIcaoCodes = 1 << 2
|
OnlyDbIcaoCodes = 1 << 2,
|
||||||
|
Incremental = 1 << 3
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Builder, BuilderFlag)
|
Q_DECLARE_FLAGS(Builder, BuilderFlag)
|
||||||
|
|
||||||
@@ -43,8 +44,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Build a model set
|
//! Build a model set
|
||||||
BlackMisc::Simulation::CAircraftModelList buildModelSet(
|
BlackMisc::Simulation::CAircraftModelList buildModelSet(
|
||||||
const BlackMisc::Simulation::CAircraftModelList &models, Builder oprions,
|
const BlackMisc::Simulation::CSimulatorInfo &simulator,
|
||||||
const BlackMisc::Simulation::CDistributorList &onlyByDistributors = BlackMisc::Simulation::CDistributorList()) const;
|
const BlackMisc::Simulation::CAircraftModelList &models,
|
||||||
|
const BlackMisc::Simulation::CAircraftModelList ¤tSet, Builder oprions,
|
||||||
|
const BlackMisc::Simulation::CDistributorList &onlyByDistributors = {}) const;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
@@ -64,17 +64,18 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else if (sender == ui->pb_Ok)
|
else if (sender == ui->pb_Ok)
|
||||||
{
|
{
|
||||||
this->m_modelSet = this->buildSet();
|
this->m_modelSet = this->buildSet(this->m_simulatorInfo, this->m_modelSet);
|
||||||
this->accept();
|
this->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CDbOwnModelSetDialog::buildSet()
|
CAircraftModelList CDbOwnModelSetDialog::buildSet(const CSimulatorInfo &simulator, const CAircraftModelList ¤tSet)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||||
const bool selectedProviders = this->ui->form_OwnModelSet->selectedDistributors();
|
const bool selectedProviders = this->ui->form_OwnModelSet->selectedDistributors();
|
||||||
const bool dbDataOnly = this->ui->form_OwnModelSet->dbDataOnly();
|
const bool dbDataOnly = this->ui->form_OwnModelSet->dbDataOnly();
|
||||||
const bool dbIcaoOnly = this->ui->form_OwnModelSet->dbIcaoCodesOnly();
|
const bool dbIcaoOnly = this->ui->form_OwnModelSet->dbIcaoCodesOnly();
|
||||||
|
const bool incremnental = this->ui->form_OwnModelSet->incrementalBuild();
|
||||||
|
|
||||||
const CAircraftModelList models = this->getMappingComponent()->getOwnModels();
|
const CAircraftModelList models = this->getMappingComponent()->getOwnModels();
|
||||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||||
@@ -85,7 +86,8 @@ namespace BlackGui
|
|||||||
CModelSetBuilder::Builder options = selectedProviders ? CModelSetBuilder::FilterDistributos : CModelSetBuilder::NoOptions;
|
CModelSetBuilder::Builder options = selectedProviders ? CModelSetBuilder::FilterDistributos : CModelSetBuilder::NoOptions;
|
||||||
if (dbDataOnly) { options |= CModelSetBuilder::OnlyDbData; }
|
if (dbDataOnly) { options |= CModelSetBuilder::OnlyDbData; }
|
||||||
if (dbIcaoOnly) { options |= CModelSetBuilder::OnlyDbIcaoCodes; }
|
if (dbIcaoOnly) { options |= CModelSetBuilder::OnlyDbIcaoCodes; }
|
||||||
return builder.buildModelSet(models, options, distributors);
|
if (incremnental) { options |= CModelSetBuilder::Incremental; }
|
||||||
|
return builder.buildModelSet(simulator, models, currentSet, options, distributors);
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace BlackGui
|
|||||||
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo;
|
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo;
|
||||||
|
|
||||||
//! Build the set
|
//! Build the set
|
||||||
BlackMisc::Simulation::CAircraftModelList buildSet();
|
BlackMisc::Simulation::CAircraftModelList buildSet(const BlackMisc::Simulation::CSimulatorInfo &simulator, const BlackMisc::Simulation::CAircraftModelList ¤tSet = {});
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ namespace BlackGui
|
|||||||
return this->ui->rb_DbDataOnly->isChecked();
|
return this->ui->rb_DbDataOnly->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool COwnModelSetForm::incrementalBuild() const
|
||||||
|
{
|
||||||
|
return ui->rb_Incremental->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
bool COwnModelSetForm::dbIcaoCodesOnly() const
|
bool COwnModelSetForm::dbIcaoCodesOnly() const
|
||||||
{
|
{
|
||||||
return this->ui->rb_DbIcaoCodesOnly->isChecked();
|
return this->ui->rb_DbIcaoCodesOnly->isChecked();
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ namespace BlackGui
|
|||||||
//! DB ICAO codes
|
//! DB ICAO codes
|
||||||
bool dbIcaoCodesOnly() const;
|
bool dbIcaoCodesOnly() const;
|
||||||
|
|
||||||
|
//! Request incremental build
|
||||||
|
bool incrementalBuild() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::COwnModelSetForm> ui;
|
QScopedPointer<Ui::COwnModelSetForm> ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,16 +37,13 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="2">
|
<item row="1" column="1">
|
||||||
<widget class="QRadioButton" name="rb_DbIcaoCodesOnly">
|
<widget class="QRadioButton" name="rb_DbDataOnly">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Model has ICAO code known in DB</string>
|
<string>Own models for which DB data are available</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>DB ICAO data</string>
|
<string>DB data only</string>
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<attribute name="buttonGroup">
|
||||||
<string notr="true">bg_SourceSet</string>
|
<string notr="true">bg_SourceSet</string>
|
||||||
@@ -54,13 +51,13 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="lbl_Providers">
|
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Distributors:</string>
|
<string>Source set:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="1" column="3">
|
||||||
<widget class="QRadioButton" name="rb_WithIcaoData">
|
<widget class="QRadioButton" name="rb_WithIcaoData">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Model has ICAO code</string>
|
<string>Model has ICAO code</string>
|
||||||
@@ -76,14 +73,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
|
||||||
<property name="text">
|
|
||||||
<string>Source set:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>selected</string>
|
<string>selected</string>
|
||||||
@@ -93,20 +83,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="2" column="2">
|
||||||
<widget class="QRadioButton" name="rb_DbDataOnly">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Own models for which DB data are available</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>DB data only</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="buttonGroup">
|
|
||||||
<string notr="true">bg_SourceSet</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QRadioButton" name="rb_DefaultDistributors">
|
<widget class="QRadioButton" name="rb_DefaultDistributors">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>default</string>
|
<string>default</string>
|
||||||
@@ -119,6 +96,59 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_Providers">
|
||||||
|
<property name="text">
|
||||||
|
<string>Distributors:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QRadioButton" name="rb_DbIcaoCodesOnly">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Model has ICAO code known in DB</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>DB ICAO data</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">bg_SourceSet</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_Mode">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mode:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QRadioButton" name="rb_Full">
|
||||||
|
<property name="text">
|
||||||
|
<string>full</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">bg_Mode</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QRadioButton" name="rb_Incremental">
|
||||||
|
<property name="text">
|
||||||
|
<string>incremental</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">bg_Mode</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -148,5 +178,6 @@
|
|||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="bg_Distributors"/>
|
<buttongroup name="bg_Distributors"/>
|
||||||
<buttongroup name="bg_SourceSet"/>
|
<buttongroup name="bg_SourceSet"/>
|
||||||
|
<buttongroup name="bg_Mode"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user