10 #include "ui_modelmappingmodifyform.h"
21 using namespace swift::misc::network;
22 using namespace swift::misc::physical_quantities;
23 using namespace swift::misc::simulation;
26 namespace swift::gui::editors
28 CModelMappingModifyForm::CModelMappingModifyForm(QWidget *parent)
32 ui->le_Parts->setPlaceholderText(
"Parts " + CAircraftModel::supportedParts());
38 ui->le_Parts->setValidator(ucv);
47 connect(ui->le_CG, &QLineEdit::editingFinished,
this, &CModelMappingModifyForm::onCGEdited);
59 if (ui->cb_Name->isChecked()) { vm.
addValue(CAircraftModel::IndexName, ui->le_Name->text().trimmed()); }
61 if (ui->cb_Description->isChecked())
63 vm.
addValue(CAircraftModel::IndexDescription, ui->le_Description->text().trimmed());
66 if (ui->cb_Mode->isChecked())
68 vm.
addValue(CAircraftModel::IndexModelMode, ui->selector_ModeSelector->getMode());
71 if (ui->cb_Simulator->isChecked())
73 vm.
addValue(CAircraftModel::IndexSimulatorInfo, ui->selector_SimulatorSelector->getValue());
76 if (ui->cb_Mode->isChecked())
78 vm.
addValue(CAircraftModel::IndexModelMode, ui->selector_ModeSelector->getMode());
81 if (ui->cb_Parts->isChecked())
83 vm.
addValue(CAircraftModel::IndexSupportedParts, ui->le_Parts->text().toUpper());
86 if (ui->cb_CG->isChecked())
88 const QString cgv = ui->le_CG->text().trimmed();
90 if (!cgv.isEmpty()) { cg.
parseFromString(cgv, CPqString::SeparatorBestGuess); }
91 vm.
addValue(CAircraftModel::IndexCG, cg);
100 ui->le_Name->setText(model.
getName());
101 ui->selector_SimulatorSelector->setValue(model.
getSimulator());
102 ui->selector_ModeSelector->setValue(model);
117 ui->selector_ModeSelector->setValue(CAircraftModel::Include);
118 ui->selector_ModeSelector->setReadOnly(
false);
120 else { ui->selector_ModeSelector->setReadOnly(
true); }
125 void CModelMappingModifyForm::returnPressed()
127 QCheckBox *cb = widgetToCheckbox(sender());
129 cb->setChecked(
true);
132 void CModelMappingModifyForm::changed()
134 QCheckBox *cb = widgetToCheckbox(sender());
136 cb->setChecked(
true);
139 QCheckBox *CModelMappingModifyForm::widgetToCheckbox(QObject *widget)
const
141 if (!widget) {
return nullptr; }
142 if (widget == ui->le_Description) {
return ui->cb_Description; }
143 if (widget == ui->le_Name) {
return ui->cb_Name; }
144 if (widget == ui->selector_ModeSelector) {
return ui->cb_Mode; }
145 if (widget == ui->le_CG) {
return ui->cb_CG; }
146 if (widget == ui->le_Parts) {
return ui->cb_Parts; }
147 if (widget == ui->selector_SimulatorSelector) {
return ui->cb_Simulator; }
151 void CModelMappingModifyForm::onCGEdited()
153 QString cgv = ui->le_CG->text().trimmed();
void setAllowedCharacters(const QString &chars)
Allowed characters.
Specialized value object compliant map for variants, based on indexes.
void addValue(const CPropertyIndex &index, const CVariant &value)
Add a value.
QString toQString(bool i18n=false) const
Cast as QString.
Value object encapsulating information of an authentiated user.
bool hasAdminRole() const
Admin?
Physical unit length (length)
void parseFromString(const QString &value)
Parse value from string.
bool isNull() const
Is quantity null?
Aircraft model (used by another pilot, my models on disk)
CSimulatorInfo getSimulator() const
Simulator info.
const QString & getName() const
Name.
const QString & getDescription() const
Descriptive text.
High level reusable GUI components.
Free functions in swift::misc.
bool isDigitsOnlyString(const QString &testString)
String with digits only.