mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +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 "blackgui/editors/modelmappingmodifyform.h"
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
|
#include "blackmisc/network/authenticateduser.h"
|
||||||
#include "ui_modelmappingmodifyform.h"
|
#include "ui_modelmappingmodifyform.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackGui::Components;
|
using namespace BlackGui::Components;
|
||||||
|
|
||||||
@@ -27,14 +29,16 @@ namespace BlackGui
|
|||||||
namespace Editors
|
namespace Editors
|
||||||
{
|
{
|
||||||
CModelMappingModifyForm::CModelMappingModifyForm(QWidget *parent) :
|
CModelMappingModifyForm::CModelMappingModifyForm(QWidget *parent) :
|
||||||
QFrame(parent),
|
CForm(parent),
|
||||||
ui(new Ui::CModelMappingModifyForm)
|
ui(new Ui::CModelMappingModifyForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->le_Description, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
connect(ui->le_Description, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
||||||
connect(ui->le_Name, &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->selector_ModeSelector, &CModelModeSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||||
connect(ui->frp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
connect(ui->selector_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||||
|
|
||||||
|
this->ps_userChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
CModelMappingModifyForm::~CModelMappingModifyForm()
|
CModelMappingModifyForm::~CModelMappingModifyForm()
|
||||||
@@ -55,19 +59,19 @@ namespace BlackGui
|
|||||||
vm.addValue(CAircraftModel::IndexDescription, ui->le_Description->text().trimmed());
|
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())
|
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())
|
if (ui->cb_Mode->isChecked())
|
||||||
{
|
{
|
||||||
vm.addValue(CAircraftModel::IndexModelMode, ui->frp_IncludeSelector->getMode());
|
vm.addValue(CAircraftModel::IndexModelMode, ui->selector_ModeSelector->getMode());
|
||||||
}
|
}
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
@@ -76,8 +80,30 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->ui->le_Description->setText(model.getDescription());
|
this->ui->le_Description->setText(model.getDescription());
|
||||||
this->ui->le_Name->setText(model.getName());
|
this->ui->le_Name->setText(model.getName());
|
||||||
this->ui->frp_SimulatorSelector->setValue(model.getSimulator());
|
this->ui->selector_SimulatorSelector->setValue(model.getSimulator());
|
||||||
this->ui->frp_IncludeSelector->setValue(model);
|
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()
|
void CModelMappingModifyForm::ps_returnPressed()
|
||||||
@@ -99,8 +125,8 @@ namespace BlackGui
|
|||||||
if (!widget) { return nullptr; }
|
if (!widget) { return nullptr; }
|
||||||
if (widget == ui->le_Description) { return ui->cb_Description; }
|
if (widget == ui->le_Description) { return ui->cb_Description; }
|
||||||
if (widget == ui->le_Name) { return ui->cb_Name; }
|
if (widget == ui->le_Name) { return ui->cb_Name; }
|
||||||
if (widget == ui->frp_IncludeSelector) { return ui->cb_Mode; }
|
if (widget == ui->selector_ModeSelector) { return ui->cb_Mode; }
|
||||||
if (widget == ui->frp_SimulatorSelector) { return ui->cb_Simulator; }
|
if (widget == ui->selector_SimulatorSelector) { return ui->cb_Simulator; }
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
#ifndef BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
||||||
#define BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
#define BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
||||||
|
|
||||||
|
#include "form.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/propertyindexvariantmap.h"
|
#include "blackmisc/propertyindexvariantmap.h"
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ namespace BlackGui
|
|||||||
/*!
|
/*!
|
||||||
* Allows to modify individual fields of the model form
|
* Allows to modify individual fields of the model form
|
||||||
*/
|
*/
|
||||||
class BLACKGUI_EXPORT CModelMappingModifyForm : public QFrame
|
class BLACKGUI_EXPORT CModelMappingModifyForm : public CForm
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -49,6 +50,13 @@ namespace BlackGui
|
|||||||
//! Set value
|
//! Set value
|
||||||
void setValue(const BlackMisc::Simulation::CAircraftModel &model);
|
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:
|
private slots:
|
||||||
//! Return pressed
|
//! Return pressed
|
||||||
void ps_returnPressed();
|
void ps_returnPressed();
|
||||||
|
|||||||
@@ -6,19 +6,19 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>195</width>
|
<width>300</width>
|
||||||
<height>112</height>
|
<height>150</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>300</width>
|
||||||
|
<height>150</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Modify model data</string>
|
<string>Modify model data</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gl_ModelMappingModifyForm">
|
<layout class="QGridLayout" name="gl_ModelMappingModifyForm">
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QCheckBox" name="cb_Simulator">
|
<widget class="QCheckBox" name="cb_Simulator">
|
||||||
@@ -28,12 +28,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="BlackGui::Components::CSimulatorSelector" name="frp_SimulatorSelector">
|
<widget class="BlackGui::Components::CSimulatorSelector" name="selector_SimulatorSelector">
|
||||||
<property name="frameShape">
|
<property name="minimumSize">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<property name="frameShadow">
|
<height>24</height>
|
||||||
<enum>QFrame::Raised</enum>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -109,12 +109,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
<widget class="BlackGui::Components::CModelModeSelector" name="frp_IncludeSelector">
|
<widget class="BlackGui::Components::CModelModeSelector" name="selector_ModeSelector">
|
||||||
<property name="frameShape">
|
<property name="minimumSize">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<property name="frameShadow">
|
<height>24</height>
|
||||||
<enum>QFrame::Raised</enum>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user