mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #745, improved own model set dialog
* allow to consolidate data * display either preferences or all distributors
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -118,7 +118,7 @@ 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->selectedDistributors();
|
||||
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();
|
||||
@@ -127,13 +127,13 @@ namespace BlackGui
|
||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||
const CDistributorList distributors = selectedProviders ?
|
||||
ui->form_OwnModelSet->getSelectedDistributors() :
|
||||
ui->form_OwnModelSet->getDistributors();
|
||||
ui->form_OwnModelSet->getDistributorsFromPreferences();
|
||||
const CModelSetBuilder builder(this);
|
||||
CModelSetBuilder::Builder options = selectedProviders ? CModelSetBuilder::FilterDistributos : 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 (ui->form_OwnModelSet->hasDistributorPreferences()) { options |= CModelSetBuilder::SortByDistributors; }
|
||||
return builder.buildModelSet(simulator, models, currentSet, options, distributors);
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -35,9 +35,12 @@ namespace BlackGui
|
||||
ui->tvp_Distributors->setDistributorMode(CDistributorListModel::Minimal);
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
ui->comp_SimulatorSelector->setLeftMargin(0);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Preferences, true);
|
||||
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &COwnModelSetForm::ps_simulatorChanged);
|
||||
connect(ui->rb_DisplayAllDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::ps_changeDistributorDisplay);
|
||||
connect(ui->rb_DisplayPreferencesDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::ps_changeDistributorDisplay);
|
||||
|
||||
this->ps_simulatorChanged(ui->comp_SimulatorSelector->getValue());
|
||||
}
|
||||
|
||||
COwnModelSetForm::~COwnModelSetForm()
|
||||
@@ -47,18 +50,15 @@ namespace BlackGui
|
||||
|
||||
void COwnModelSetForm::reloadData()
|
||||
{
|
||||
const CDistributorList distributors(this->getDistributors());
|
||||
const bool hasPreferences = this->hasDIstributorPreferences();
|
||||
ui->cb_Preferences->setChecked(hasPreferences);
|
||||
const bool hasPreferences = this->hasDistributorPreferences();
|
||||
ui->cb_SortByPreferences->setChecked(hasPreferences);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_SortByPreferences, !hasPreferences);
|
||||
ui->comp_SimulatorSelector->setValue(this->m_simulator);
|
||||
ui->tvp_Distributors->setDistributorMode(hasPreferences ? CDistributorListModel::MinimalWithOrder : CDistributorListModel::Minimal);
|
||||
if (!distributors.isEmpty())
|
||||
{
|
||||
this->ui->tvp_Distributors->updateContainerMaybeAsync(distributors);
|
||||
}
|
||||
this->setDistributorView(hasPreferences);
|
||||
this->initDistributorDisplay();
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::selectedDistributors() const
|
||||
bool COwnModelSetForm::useSelectedDistributors() const
|
||||
{
|
||||
return this->ui->rb_SelectedDistributors->isChecked();
|
||||
}
|
||||
@@ -85,15 +85,55 @@ namespace BlackGui
|
||||
emit simulatorChanged(simulator);
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributors() const
|
||||
void COwnModelSetForm::ps_changeDistributorDisplay()
|
||||
{
|
||||
if (ui->rb_DisplayAllDistributors->isChecked())
|
||||
{
|
||||
ui->tvp_Distributors->updateContainerMaybeAsync(this->getAllDistributors());
|
||||
ui->cb_SortByPreferences->setChecked(false);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_SortByPreferences, true);
|
||||
this->setDistributorView(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tvp_Distributors->updateContainerMaybeAsync(this->getDistributorsFromPreferences());
|
||||
ui->cb_SortByPreferences->setChecked(true);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_SortByPreferences, false);
|
||||
this->setDistributorView(true);
|
||||
}
|
||||
}
|
||||
|
||||
void COwnModelSetForm::initDistributorDisplay()
|
||||
{
|
||||
if (this->hasDistributorPreferences())
|
||||
{
|
||||
ui->rb_DisplayPreferencesDistributors->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->rb_DisplayAllDistributors->setChecked(true);
|
||||
}
|
||||
this->ps_changeDistributorDisplay();
|
||||
}
|
||||
|
||||
void COwnModelSetForm::setDistributorView(bool hasPreferences)
|
||||
{
|
||||
ui->tvp_Distributors->setDistributorMode(hasPreferences ? CDistributorListModel::MinimalWithOrder : CDistributorListModel::Minimal);
|
||||
ui->tvp_Distributors->fullResizeToContents();
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributorsFromPreferences() const
|
||||
{
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
|
||||
Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
|
||||
const CDistributorList distributors(prefs.getDistributors(this->m_simulator));
|
||||
if (!distributors.isEmpty()) { return distributors; }
|
||||
return distributors;
|
||||
}
|
||||
|
||||
// no preferences
|
||||
CDistributorList COwnModelSetForm::getAllDistributors() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
|
||||
return sGui->getWebDataServices()->getDistributors().matchesSimulator(this->m_simulator);
|
||||
}
|
||||
|
||||
@@ -113,11 +153,10 @@ namespace BlackGui
|
||||
m_simulator = simulator;
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::hasDIstributorPreferences() const
|
||||
bool COwnModelSetForm::hasDistributorPreferences() const
|
||||
{
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
|
||||
return !prefs.getDistributors(this->m_simulator).isEmpty();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace BlackGui
|
||||
void reloadData();
|
||||
|
||||
//! Selected providers?
|
||||
bool selectedDistributors() const;
|
||||
bool useSelectedDistributors() const;
|
||||
|
||||
//! Get selected providers
|
||||
BlackMisc::Simulation::CDistributorList getSelectedDistributors() const;
|
||||
@@ -59,11 +59,14 @@ namespace BlackGui
|
||||
//! Request incremental build
|
||||
bool incrementalBuild() const;
|
||||
|
||||
//! Distributors (from preferences or web)
|
||||
BlackMisc::Simulation::CDistributorList getDistributors() const;
|
||||
//! Distributors from preferences
|
||||
BlackMisc::Simulation::CDistributorList getDistributorsFromPreferences() const;
|
||||
|
||||
//! Preferences for given simulator
|
||||
bool hasDIstributorPreferences() const;
|
||||
//! All distributors
|
||||
BlackMisc::Simulation::CDistributorList getAllDistributors() const;
|
||||
|
||||
//! Preferences for given simulator?
|
||||
bool hasDistributorPreferences() const;
|
||||
|
||||
//! \name Form functions, here not used
|
||||
//! \@{
|
||||
@@ -81,7 +84,16 @@ namespace BlackGui
|
||||
//! Simulator changed
|
||||
void ps_simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Display distributors based on checkboxes
|
||||
void ps_changeDistributorDisplay();
|
||||
|
||||
private:
|
||||
//! Init the options which distributors are displayed
|
||||
void initDistributorDisplay();
|
||||
|
||||
//! Set mode for view
|
||||
void setDistributorView(bool hasPreferences);
|
||||
|
||||
QScopedPointer<Ui::COwnModelSetForm> ui;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
BlackMisc::CSetting<BlackCore::Simulator::TDistributorListPreferences> m_distributorPreferences { this, &COwnModelSetForm::ps_preferencesChanged };
|
||||
|
||||
@@ -6,19 +6,13 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>433</width>
|
||||
<height>324</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_OwnModelSetForm">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
@@ -35,7 +29,7 @@
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gq_OwnModelSetForm">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="rb_DbDataOnly">
|
||||
@@ -50,30 +44,10 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||
<property name="text">
|
||||
<string>Source set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="rb_DefaultDistributors">
|
||||
<property name="text">
|
||||
<string>default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QRadioButton" name="rb_WithIcaoData">
|
||||
<property name="toolTip">
|
||||
<string>Model has ICAO code</string>
|
||||
<string>Model has ICAO code, but not necessarily valid data</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> ICAO data</string>
|
||||
@@ -93,10 +67,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
<string>Source set:</string>
|
||||
</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>
|
||||
@@ -110,29 +94,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" 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="1" 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>
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="rb_DbIcaoCodesOnly">
|
||||
<property name="toolTip">
|
||||
@@ -149,11 +110,43 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="cb_Preferences">
|
||||
<property name="text">
|
||||
<string>preferences</string>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="rb_Full">
|
||||
<property name="toolTip">
|
||||
<string>new set, existing data will be deleted</string>
|
||||
</property>
|
||||
<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="1" column="2">
|
||||
<widget class="QRadioButton" name="rb_Incremental">
|
||||
<property name="toolTip">
|
||||
<string>add to existing set</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>incremental</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Mode</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Distributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
@@ -166,6 +159,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="cb_ConsolidateModelSet">
|
||||
<property name="text">
|
||||
<string>consolidate with DB</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
@@ -173,6 +176,39 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QRadioButton" name="rb_DisplayPreferencesDistributors">
|
||||
<property name="text">
|
||||
<string>from preferences</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_DisplayedDistributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QCheckBox" name="cb_SortByPreferences">
|
||||
<property name="toolTip">
|
||||
<string>If checked the distributors from the settings page will be used</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>sort by dist. preferences</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QRadioButton" name="rb_DisplayAllDistributors">
|
||||
<property name="text">
|
||||
<string>all distributors</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_DisplayedDistributors</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -210,8 +246,7 @@
|
||||
<tabstop>rb_DbIcaoCodesOnly</tabstop>
|
||||
<tabstop>rb_WithIcaoData</tabstop>
|
||||
<tabstop>rb_SelectedDistributors</tabstop>
|
||||
<tabstop>rb_DefaultDistributors</tabstop>
|
||||
<tabstop>cb_Preferences</tabstop>
|
||||
<tabstop>rb_AllDistributors</tabstop>
|
||||
<tabstop>tvp_Distributors</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
@@ -220,5 +255,6 @@
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
<buttongroup name="bg_Mode"/>
|
||||
<buttongroup name="bg_SourceSet"/>
|
||||
<buttongroup name="bg_DisplayedDistributors"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user