mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
Ref T265, Ref T430, Ref T473 CG in model form
This commit is contained in:
committed by
Mat Sutcliffe
parent
c14e85a805
commit
298f746862
@@ -14,6 +14,7 @@
|
|||||||
#include "blackgui/labelandicon.h"
|
#include "blackgui/labelandicon.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include "blackmisc/network/authenticateduser.h"
|
#include "blackmisc/network/authenticateduser.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
#include "ui_modelmappingform.h"
|
#include "ui_modelmappingform.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@@ -21,7 +22,9 @@
|
|||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackGui::Components;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -34,7 +37,10 @@ namespace BlackGui
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->le_LastUpdated->setReadOnly(true);
|
ui->le_LastUpdated->setReadOnly(true);
|
||||||
ui->le_Id->setReadOnly(true);
|
ui->le_Id->setReadOnly(true);
|
||||||
|
|
||||||
ui->lai_Id->set(CIcons::appMappings16(), "Id:");
|
ui->lai_Id->set(CIcons::appMappings16(), "Id:");
|
||||||
|
|
||||||
|
connect(ui->le_CG, &QLineEdit::editingFinished, this, &CModelMappingForm::onCgEditFinished);
|
||||||
connect(ui->pb_Stash, &QPushButton::clicked, this, &CModelMappingForm::requestStash);
|
connect(ui->pb_Stash, &QPushButton::clicked, this, &CModelMappingForm::requestStash);
|
||||||
|
|
||||||
// for setting mode (include/exclude)
|
// for setting mode (include/exclude)
|
||||||
@@ -52,6 +58,7 @@ namespace BlackGui
|
|||||||
model.setModelString(ui->le_ModelKey->text());
|
model.setModelString(ui->le_ModelKey->text());
|
||||||
model.setName(ui->le_Name->text());
|
model.setName(ui->le_Name->text());
|
||||||
model.setModelMode(ui->selector_ModelMode->getMode());
|
model.setModelMode(ui->selector_ModelMode->getMode());
|
||||||
|
model.setCG(this->getCGFromUI());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +93,7 @@ namespace BlackGui
|
|||||||
ui->le_FileName->setText(model.getFileName());
|
ui->le_FileName->setText(model.getFileName());
|
||||||
ui->selector_ModelMode->setValue(model.getModelMode());
|
ui->selector_ModelMode->setValue(model.getModelMode());
|
||||||
ui->selector_Simulator->setValue(model.getSimulator());
|
ui->selector_Simulator->setValue(model.getSimulator());
|
||||||
|
this->setCGtoUI(model.getCG());
|
||||||
m_originalModel = model;
|
m_originalModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,5 +112,42 @@ namespace BlackGui
|
|||||||
|
|
||||||
CFormDbUser::userChanged();
|
CFormDbUser::userChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLength CModelMappingForm::getCGFromUI() const
|
||||||
|
{
|
||||||
|
if (ui->le_CG->text().isEmpty()) { return CLength::null(); }
|
||||||
|
const QString v = ui->le_CG->text();
|
||||||
|
|
||||||
|
// without unit we assume ft
|
||||||
|
if (isDigitsOnlyString(v))
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
const double cgv = v.toDouble(&ok);
|
||||||
|
if (!ok) { return CLength::null(); }
|
||||||
|
return CLength(cgv, CLengthUnit::ft());
|
||||||
|
}
|
||||||
|
|
||||||
|
CLength cg;
|
||||||
|
cg.parseFromString(v);
|
||||||
|
return cg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelMappingForm::setCGtoUI(const CLength &cg)
|
||||||
|
{
|
||||||
|
if (cg.isNull())
|
||||||
|
{
|
||||||
|
ui->le_CG->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->le_CG->setText(cg.valueRoundedWithUnit(CLengthUnit::ft(), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelMappingForm::onCgEditFinished()
|
||||||
|
{
|
||||||
|
const CLength cg = this->getCGFromUI();
|
||||||
|
this->setCGtoUI(cg);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
#ifndef BLACKGUI_EDITORS_MODELMAPPINGFORM_H
|
#ifndef BLACKGUI_EDITORS_MODELMAPPINGFORM_H
|
||||||
#define BLACKGUI_EDITORS_MODELMAPPINGFORM_H
|
#define BLACKGUI_EDITORS_MODELMAPPINGFORM_H
|
||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
|
||||||
#include "blackgui/editors/form.h"
|
#include "blackgui/editors/form.h"
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
|
||||||
@@ -51,7 +51,6 @@ namespace BlackGui
|
|||||||
virtual BlackMisc::CStatusMessageList validate(bool withNestedObjects) const override;
|
virtual BlackMisc::CStatusMessageList validate(bool withNestedObjects) const override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! Set model
|
//! Set model
|
||||||
void setValue(BlackMisc::Simulation::CAircraftModel &model);
|
void setValue(BlackMisc::Simulation::CAircraftModel &model);
|
||||||
|
|
||||||
@@ -64,6 +63,15 @@ namespace BlackGui
|
|||||||
virtual void userChanged() override;
|
virtual void userChanged() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! CG (aka vertical offset) from UI
|
||||||
|
BlackMisc::PhysicalQuantities::CLength getCGFromUI() const;
|
||||||
|
|
||||||
|
//! Set CG value properly formatted
|
||||||
|
void setCGtoUI(const BlackMisc::PhysicalQuantities::CLength &cg);
|
||||||
|
|
||||||
|
//! CG edited
|
||||||
|
void onCgEditFinished();
|
||||||
|
|
||||||
QScopedPointer<Ui::CModelMappingForm> ui;
|
QScopedPointer<Ui::CModelMappingForm> ui;
|
||||||
BlackMisc::Simulation::CAircraftModel m_originalModel;
|
BlackMisc::Simulation::CAircraftModel m_originalModel;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>452</width>
|
||||||
<height>104</height>
|
<height>104</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Simulator model</string>
|
<string>Simulator model</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gl_ModelMappingForm" columnstretch="1,2,1,2,2,1,0">
|
<layout class="QGridLayout" name="gl_ModelMappingForm" columnstretch="0,1,0,1,1,0,1,1,0">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -50,34 +50,6 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="3" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="le_Description">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Model description</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_Updated">
|
|
||||||
<property name="text">
|
|
||||||
<string>Updated:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="le_FileName">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="le_ModelKey">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Model key</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="lbl_ModelKey">
|
<widget class="QLabel" name="lbl_ModelKey">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -88,16 +60,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QLabel" name="lbl_Description">
|
|
||||||
<property name="text">
|
|
||||||
<string>Description:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>le_Description</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="le_Id">
|
<widget class="QLineEdit" name="le_Id">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
@@ -111,20 +73,40 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="7" alignment="Qt::AlignRight">
|
||||||
<widget class="QLineEdit" name="le_Name">
|
<widget class="QPushButton" name="pb_Stash">
|
||||||
<property name="placeholderText">
|
<property name="text">
|
||||||
<string>Name</string>
|
<string>Stash</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="0" column="8" rowspan="3">
|
||||||
<widget class="QLabel" name="lbl_Path">
|
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>File:</string>
|
<size>
|
||||||
|
<width>10</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="5">
|
||||||
|
<widget class="QLabel" name="lbl_CG">
|
||||||
|
<property name="text">
|
||||||
|
<string>CG:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_Updated">
|
||||||
|
<property name="text">
|
||||||
|
<string>Updated:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_LastUpdated"/>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="lbl_Name">
|
<widget class="QLabel" name="lbl_Name">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -135,27 +117,38 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="5" alignment="Qt::AlignRight">
|
<item row="1" column="3" colspan="2">
|
||||||
<widget class="QPushButton" name="pb_Stash">
|
<widget class="QLineEdit" name="le_Description">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Model description</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLabel" name="lbl_Path">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Stash</string>
|
<string>File:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="1" column="2">
|
||||||
<widget class="QLineEdit" name="le_LastUpdated"/>
|
<widget class="QLabel" name="lbl_Description">
|
||||||
</item>
|
<property name="text">
|
||||||
<item row="0" column="6" rowspan="3">
|
<string>Description:</string>
|
||||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="buddy">
|
||||||
<size>
|
<cstring>le_Description</cstring>
|
||||||
<width>10</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="5">
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_Name">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="7">
|
||||||
<widget class="BlackGui::Components::CModelModeSelector" name="selector_ModelMode">
|
<widget class="BlackGui::Components::CModelModeSelector" name="selector_ModelMode">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -168,7 +161,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="0">
|
||||||
|
<widget class="BlackGui::CLabelAndIcon" name="lai_Id"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="7">
|
||||||
<widget class="BlackGui::Components::CSimulatorSelector" name="selector_Simulator">
|
<widget class="BlackGui::Components::CSimulatorSelector" name="selector_Simulator">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -187,13 +183,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="1" column="6">
|
||||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
|
<widget class="QLineEdit" name="le_CG">
|
||||||
<property name="frameShape">
|
<property name="maximumSize">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
</widget>
|
||||||
<enum>QFrame::Raised</enum>
|
</item>
|
||||||
|
<item row="2" column="3" colspan="4">
|
||||||
|
<widget class="QLineEdit" name="le_FileName">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3" colspan="4">
|
||||||
|
<widget class="QLineEdit" name="le_ModelKey">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Model key</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -209,6 +219,12 @@
|
|||||||
<header>blackgui/components/simulatorselector.h</header>
|
<header>blackgui/components/simulatorselector.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CModelModeSelector</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/modelmodeselector.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::CLabelAndIcon</class>
|
<class>BlackGui::CLabelAndIcon</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QFrame</extends>
|
||||||
@@ -221,12 +237,6 @@
|
|||||||
<header>blackgui/editors/validationindicator.h</header>
|
<header>blackgui/editors/validationindicator.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>BlackGui::Components::CModelModeSelector</class>
|
|
||||||
<extends>QFrame</extends>
|
|
||||||
<header>blackgui/components/modelmodeselector.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>le_Id</tabstop>
|
<tabstop>le_Id</tabstop>
|
||||||
@@ -234,6 +244,7 @@
|
|||||||
<tabstop>selector_Simulator</tabstop>
|
<tabstop>selector_Simulator</tabstop>
|
||||||
<tabstop>le_Name</tabstop>
|
<tabstop>le_Name</tabstop>
|
||||||
<tabstop>le_Description</tabstop>
|
<tabstop>le_Description</tabstop>
|
||||||
|
<tabstop>le_CG</tabstop>
|
||||||
<tabstop>selector_ModelMode</tabstop>
|
<tabstop>selector_ModelMode</tabstop>
|
||||||
<tabstop>le_LastUpdated</tabstop>
|
<tabstop>le_LastUpdated</tabstop>
|
||||||
<tabstop>le_FileName</tabstop>
|
<tabstop>le_FileName</tabstop>
|
||||||
|
|||||||
Reference in New Issue
Block a user