mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
refs #661, improved model set dialog
* allow to change simulator * consider distributor preferences for new model set * error messages in dialog, therefor use CForm as base class
This commit is contained in:
@@ -16,8 +16,7 @@ namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CForm::CForm(QWidget *parent) :
|
||||
QFrame(parent)
|
||||
CForm::CForm(QWidget *parent) : COverlayMessagesFrame(parent)
|
||||
{ }
|
||||
|
||||
CForm::~CForm() { }
|
||||
@@ -31,6 +30,5 @@ namespace BlackGui
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
#ifndef BLACKGUI_EDITORS_FORM_H
|
||||
#define BLACKGUI_EDITORS_FORM_H
|
||||
|
||||
#include "blackcore/data/authenticateduser.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/data/authenticateduser.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
|
||||
#include <QFrame>
|
||||
@@ -30,7 +31,7 @@ namespace BlackGui
|
||||
/*!
|
||||
* Form base class
|
||||
*/
|
||||
class BLACKGUI_EXPORT CForm : public QFrame
|
||||
class BLACKGUI_EXPORT CForm : public COverlayMessagesFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -51,7 +52,7 @@ namespace BlackGui
|
||||
//! Is read only?
|
||||
bool isReadOnly() const { return m_readOnly; }
|
||||
|
||||
//! Authenticated user
|
||||
//! Authenticated DB user
|
||||
const BlackMisc::Network::CAuthenticatedUser &getSwiftDbUser() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackgui/editors/ownmodelsetform.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/models/distributorlistmodel.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/views/distributorview.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "ui_ownmodelsetform.h"
|
||||
@@ -20,17 +21,23 @@
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
COwnModelSetForm::COwnModelSetForm(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CForm(parent),
|
||||
ui(new Ui::COwnModelSetForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->tvp_Distributors->setDistributorMode(CDistributorListModel::Minimal);
|
||||
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);
|
||||
}
|
||||
|
||||
COwnModelSetForm::~COwnModelSetForm()
|
||||
@@ -40,8 +47,10 @@ namespace BlackGui
|
||||
|
||||
void COwnModelSetForm::reloadData()
|
||||
{
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
|
||||
const CDistributorList distributors(sGui->getWebDataServices()->getDistributors());
|
||||
const CDistributorList distributors(this->getDistributors());
|
||||
const bool hasPreferences = this->hasDIstributorPreferences();
|
||||
ui->cb_Preferences->setChecked(hasPreferences);
|
||||
ui->comp_SimulatorSelector->setValue(this->m_simulator);
|
||||
if (!distributors.isEmpty())
|
||||
{
|
||||
this->ui->tvp_Distributors->updateContainerMaybeAsync(distributors);
|
||||
@@ -63,6 +72,29 @@ namespace BlackGui
|
||||
return ui->rb_Incremental->isChecked();
|
||||
}
|
||||
|
||||
void COwnModelSetForm::ps_preferencesChanged()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
void COwnModelSetForm::ps_simulatorChanged(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->setSimulator(simulator);
|
||||
this->reloadData();
|
||||
emit simulatorChanged(simulator);
|
||||
}
|
||||
|
||||
CDistributorList COwnModelSetForm::getDistributors() const
|
||||
{
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy());
|
||||
const CDistributorList distributors(prefs.getDistributors(this->m_simulator));
|
||||
if (!distributors.isEmpty()) { return distributors; }
|
||||
|
||||
// no preferences
|
||||
return sGui->getWebDataServices()->getDistributors().matchesSimulator(this->m_simulator);
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::dbIcaoCodesOnly() const
|
||||
{
|
||||
return this->ui->rb_DbIcaoCodesOnly->isChecked();
|
||||
@@ -72,6 +104,18 @@ namespace BlackGui
|
||||
{
|
||||
return ui->tvp_Distributors->selectedObjects();
|
||||
}
|
||||
|
||||
void COwnModelSetForm::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
m_simulator = simulator;
|
||||
}
|
||||
|
||||
bool COwnModelSetForm::hasDIstributorPreferences() const
|
||||
{
|
||||
const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy());
|
||||
return !prefs.getDistributors(this->m_simulator).isEmpty();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -12,16 +12,14 @@
|
||||
#ifndef BLACKGUI_EDITORS_OWNMODELSETFORM_H
|
||||
#define BLACKGUI_EDITORS_OWNMODELSETFORM_H
|
||||
|
||||
#include "form.h"
|
||||
#include "blackcore/settings/distributorpreferences.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class COwnModelSetForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
@@ -29,7 +27,7 @@ namespace BlackGui
|
||||
/*!
|
||||
* Selection for own model set
|
||||
*/
|
||||
class COwnModelSetForm : public QFrame
|
||||
class COwnModelSetForm : public CForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -49,6 +47,9 @@ namespace BlackGui
|
||||
//! Get selected providers
|
||||
BlackMisc::Simulation::CDistributorList getSelectedDistributors() const;
|
||||
|
||||
//! Current simulator
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Only DB data
|
||||
bool dbDataOnly() const;
|
||||
|
||||
@@ -58,8 +59,33 @@ namespace BlackGui
|
||||
//! Request incremental build
|
||||
bool incrementalBuild() const;
|
||||
|
||||
//! Distributors
|
||||
BlackMisc::Simulation::CDistributorList getDistributors() const;
|
||||
|
||||
//! Preferences for given simulator
|
||||
bool hasDIstributorPreferences() const;
|
||||
|
||||
//! \name Form functions, here not used
|
||||
//! \@{
|
||||
virtual void setReadOnly(bool readOnly) override { Q_UNUSED(readOnly); }
|
||||
virtual void setSelectOnly() override {}
|
||||
//! \@}
|
||||
|
||||
signals:
|
||||
//! Simulator changed
|
||||
void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
private slots:
|
||||
//! Changed preferences
|
||||
void ps_preferencesChanged();
|
||||
|
||||
//! Simulator changed
|
||||
void ps_simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::COwnModelSetForm> ui;
|
||||
QScopedPointer<Ui::COwnModelSetForm> ui;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &COwnModelSetForm::ps_preferencesChanged };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="rb_DbDataOnly">
|
||||
<property name="toolTip">
|
||||
<string>Own models for which DB data are available</string>
|
||||
@@ -50,14 +50,27 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SelectSourceSet">
|
||||
<property name="text">
|
||||
<string>Source set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<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>
|
||||
@@ -73,7 +86,14 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Providers">
|
||||
<property name="text">
|
||||
<string>Distributors:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QRadioButton" name="rb_SelectedDistributors">
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
@@ -83,27 +103,37 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="rb_DefaultDistributors">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<property name="text">
|
||||
<string>default</string>
|
||||
<string>Mode:</string>
|
||||
</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_Distributors</string>
|
||||
<string notr="true">bg_Mode</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Providers">
|
||||
<item row="1" column="2">
|
||||
<widget class="QRadioButton" name="rb_Incremental">
|
||||
<property name="text">
|
||||
<string>Distributors:</string>
|
||||
<string>incremental</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bg_Mode</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="rb_DbIcaoCodesOnly">
|
||||
<property name="toolTip">
|
||||
<string>Model has ICAO code known in DB</string>
|
||||
@@ -119,36 +149,30 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="cb_Preferences">
|
||||
<property name="text">
|
||||
<string>preferences</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
<string>Simulator:</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>
|
||||
</item>
|
||||
<item>
|
||||
@@ -172,12 +196,18 @@
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/distributorview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSimulatorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/simulatorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
<buttongroup name="bg_SourceSet"/>
|
||||
<buttongroup name="bg_Mode"/>
|
||||
<buttongroup name="bg_Distributors"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user