8 #include <QStringBuilder>
11 #include "ui_aircraftcombinedtypeselector.h"
17 using namespace swift::misc::aviation;
21 CAircraftCombinedTypeSelector::CAircraftCombinedTypeSelector(QWidget *parent)
25 connect(ui->le_CombinedType, &QLineEdit::editingFinished,
this,
26 &CAircraftCombinedTypeSelector::combinedTypeEntered);
27 connect(ui->le_CombinedType, &QLineEdit::returnPressed,
this,
28 &CAircraftCombinedTypeSelector::combinedTypeEntered);
30 connect(ui->cb_EngineCount, &QComboBox::currentTextChanged,
this,
31 &CAircraftCombinedTypeSelector::changedComboBox);
32 connect(ui->cb_EngineType, &QComboBox::currentTextChanged,
this,
33 &CAircraftCombinedTypeSelector::changedComboBox);
34 connect(ui->cb_Type, &QComboBox::currentTextChanged,
this, &CAircraftCombinedTypeSelector::changedComboBox);
43 QString engineCount, engineType, aircraftType;
44 const QString cc(combinedCode.trimmed().toUpper().left(3));
45 if (m_cc == cc) {
return; }
48 if (cc.length() > 0) { aircraftType = cc.at(0); }
49 if (cc.length() > 1) { engineCount = cc.mid(1, 1); }
50 if (cc.length() > 2) { engineType = cc.mid(2, 1); }
52 if (this->getCombinedTypeFromComboBoxes() != cc)
59 if (ui->le_CombinedType->text() != cc) { ui->le_CombinedType->setText(cc); }
71 ui->le_CombinedType->clear();
76 ui->le_CombinedType->setReadOnly(readOnly);
77 ui->cb_EngineCount->setEnabled(!readOnly);
78 ui->cb_EngineType->setEnabled(!readOnly);
79 ui->cb_Type->setEnabled(!readOnly);
84 QString ct(ui->le_CombinedType->text().trimmed().toUpper());
85 if (ct.isEmpty() || ct == QStringView(u
"---")) {
return {}; }
86 if (CAircraftIcaoCode::isValidCombinedType(ct)) {
return ct; }
88 QString ct2(getCombinedTypeFromComboBoxes());
92 void CAircraftCombinedTypeSelector::combinedTypeEntered()
94 const QString cc(ui->le_CombinedType->text().trimmed().toUpper() % u
"---");
98 void CAircraftCombinedTypeSelector::changedComboBox(
const QString &text)
101 const QString ct(this->getCombinedTypeFromComboBoxes());
102 if (ui->le_CombinedType->text() == ct) {
return; }
103 ui->le_CombinedType->setText(ct);
107 QString CAircraftCombinedTypeSelector::getCombinedTypeFromComboBoxes()
const
110 QString ec = ui->cb_EngineCount->currentText().left(1);
111 QString t = ui->cb_Type->currentText().left(1);
112 QString et = ui->cb_EngineType->currentText().left(1);
114 QString ct2(QString(t + ec + et).toUpper());
115 return ct2.replace(
'U',
'-');
static bool setComboBoxValueByStartingString(QComboBox *box, const QString &candidate, const QString &unspecified=QString())
Find best match in comboBox.
Select by comined type ("L2J", "H1T", ...)
void setReadOnly(bool readOnly)
Read only.
void setCombinedType(const QString &combinedCode)
Set comined code, e.g. L1P.
void changedCombinedType(const QString &cominedType)
Combined type has beend changed.
QString getCombinedType() const
Get the combined type, e.g. "L2P".
virtual ~CAircraftCombinedTypeSelector()
Destructor.
Value object for ICAO classification.
const QString & getCombinedType() const
Get type, e.g. "L2J".
High level reusable GUI components.