mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
refs #745, made modify form a CForm
* disable exclude mode when not admin * set min. sizes for UI (better layout)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0d70e87d11
commit
02e8d4a4cb
@@ -12,6 +12,7 @@
|
||||
#include "blackgui/editors/modelmappingmodifyform.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/network/authenticateduser.h"
|
||||
#include "ui_modelmappingmodifyform.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
@@ -19,6 +20,7 @@
|
||||
#include <QString>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
@@ -27,14 +29,16 @@ namespace BlackGui
|
||||
namespace Editors
|
||||
{
|
||||
CModelMappingModifyForm::CModelMappingModifyForm(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CForm(parent),
|
||||
ui(new Ui::CModelMappingModifyForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->le_Description, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
||||
connect(ui->le_Name, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
||||
connect(ui->frp_IncludeSelector, &CModelModeSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
connect(ui->frp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
connect(ui->selector_ModeSelector, &CModelModeSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
connect(ui->selector_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
|
||||
this->ps_userChanged();
|
||||
}
|
||||
|
||||
CModelMappingModifyForm::~CModelMappingModifyForm()
|
||||
@@ -55,19 +59,19 @@ namespace BlackGui
|
||||
vm.addValue(CAircraftModel::IndexDescription, ui->le_Description->text().trimmed());
|
||||
}
|
||||
|
||||
if (ui->cb_Simulator->isChecked())
|
||||
if (ui->cb_Mode->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexSimulatorInfo, ui->frp_SimulatorSelector->getValue());
|
||||
vm.addValue(CAircraftModel::IndexModelMode, ui->selector_ModeSelector->getMode());
|
||||
}
|
||||
|
||||
if (ui->cb_Simulator->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexSimulatorInfo, ui->frp_SimulatorSelector->getValue());
|
||||
vm.addValue(CAircraftModel::IndexSimulatorInfo, ui->selector_SimulatorSelector->getValue());
|
||||
}
|
||||
|
||||
if (ui->cb_Mode->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexModelMode, ui->frp_IncludeSelector->getMode());
|
||||
vm.addValue(CAircraftModel::IndexModelMode, ui->selector_ModeSelector->getMode());
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
@@ -76,8 +80,30 @@ namespace BlackGui
|
||||
{
|
||||
this->ui->le_Description->setText(model.getDescription());
|
||||
this->ui->le_Name->setText(model.getName());
|
||||
this->ui->frp_SimulatorSelector->setValue(model.getSimulator());
|
||||
this->ui->frp_IncludeSelector->setValue(model);
|
||||
this->ui->selector_SimulatorSelector->setValue(model.getSimulator());
|
||||
this->ui->selector_ModeSelector->setValue(model);
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
// void
|
||||
Q_UNUSED(readOnly);
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::ps_userChanged()
|
||||
{
|
||||
const CAuthenticatedUser user(this->getSwiftDbUser());
|
||||
if (user.isAdmin())
|
||||
{
|
||||
ui->selector_ModeSelector->setValue(CAircraftModel::Include);
|
||||
ui->selector_ModeSelector->setReadOnly(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->selector_ModeSelector->setReadOnly(true);
|
||||
}
|
||||
|
||||
CForm::ps_userChanged();
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::ps_returnPressed()
|
||||
@@ -99,8 +125,8 @@ namespace BlackGui
|
||||
if (!widget) { return nullptr; }
|
||||
if (widget == ui->le_Description) { return ui->cb_Description; }
|
||||
if (widget == ui->le_Name) { return ui->cb_Name; }
|
||||
if (widget == ui->frp_IncludeSelector) { return ui->cb_Mode; }
|
||||
if (widget == ui->frp_SimulatorSelector) { return ui->cb_Simulator; }
|
||||
if (widget == ui->selector_ModeSelector) { return ui->cb_Mode; }
|
||||
if (widget == ui->selector_SimulatorSelector) { return ui->cb_Simulator; }
|
||||
return nullptr;
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
||||
#define BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
||||
|
||||
#include "form.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
|
||||
@@ -32,7 +33,7 @@ namespace BlackGui
|
||||
/*!
|
||||
* Allows to modify individual fields of the model form
|
||||
*/
|
||||
class BLACKGUI_EXPORT CModelMappingModifyForm : public QFrame
|
||||
class BLACKGUI_EXPORT CModelMappingModifyForm : public CForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -49,6 +50,13 @@ namespace BlackGui
|
||||
//! Set value
|
||||
void setValue(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
//! \copydoc CForm::setReadOnly
|
||||
virtual void setReadOnly(bool readOnly) override;
|
||||
|
||||
protected slots:
|
||||
//! \copydoc CForm::ps_userChanged
|
||||
virtual void ps_userChanged() override;
|
||||
|
||||
private slots:
|
||||
//! Return pressed
|
||||
void ps_returnPressed();
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>195</width>
|
||||
<height>112</height>
|
||||
<width>300</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Modify model data</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_ModelMappingModifyForm">
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="cb_Simulator">
|
||||
@@ -28,12 +28,12 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="frp_SimulatorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="selector_SimulatorSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -109,12 +109,12 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="BlackGui::Components::CModelModeSelector" name="frp_IncludeSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<widget class="BlackGui::Components::CModelModeSelector" name="selector_ModeSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user