mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
refs #452 selector for aircraft combined types
This commit is contained in:
committed by
Mathew Sutcliffe
parent
25471730e3
commit
f9048de1e6
102
src/blackgui/aircraftcombinedtypeselector.cpp
Normal file
102
src/blackgui/aircraftcombinedtypeselector.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "aircraftcombinedtypeselector.h"
|
||||
#include "ui_aircraftcombinedtypeselector.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CAircraftCombinedTypeSelector::CAircraftCombinedTypeSelector(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CAircraftCombinedTypeSelector)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->connect(ui->le_CombinedType, &QLineEdit::editingFinished, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered);
|
||||
this->connect(ui->le_CombinedType, &QLineEdit::returnPressed, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered);
|
||||
|
||||
this->connect(ui->cb_EngineCount, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||
this->connect(ui->cb_EngineType, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||
this->connect(ui->cb_Type, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||
}
|
||||
|
||||
CAircraftCombinedTypeSelector::~CAircraftCombinedTypeSelector()
|
||||
{ }
|
||||
|
||||
void CAircraftCombinedTypeSelector::setCombinedType(const QString &combinedCode)
|
||||
{
|
||||
QString engineCount, engineType, aircraftType;
|
||||
QString cc(combinedCode.trimmed().toUpper().left(3));
|
||||
if (cc.length() > 0) { aircraftType = cc.left(1); }
|
||||
if (cc.length() > 1) { engineCount = cc.mid(1, 1); }
|
||||
if (cc.length() > 2) { engineType = cc.mid(2, 1); }
|
||||
|
||||
CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineCount, engineCount, "unspecified");
|
||||
CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineType, engineType, "unspecified");
|
||||
CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Type, aircraftType, "unspecified");
|
||||
|
||||
this->ui->le_CombinedType->setText(cc);
|
||||
}
|
||||
|
||||
void CAircraftCombinedTypeSelector::setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao)
|
||||
{
|
||||
this->setCombinedType(icao.getCombinedType());
|
||||
}
|
||||
|
||||
void CAircraftCombinedTypeSelector::clear()
|
||||
{
|
||||
this->setCombinedType("");
|
||||
this->ui->le_CombinedType->clear();
|
||||
}
|
||||
|
||||
void CAircraftCombinedTypeSelector::setReadOnly(bool readOnly)
|
||||
{
|
||||
ui->le_CombinedType->setReadOnly(readOnly);
|
||||
ui->cb_EngineCount->setEnabled(!readOnly);
|
||||
ui->cb_EngineType->setEnabled(!readOnly);
|
||||
ui->cb_Type->setEnabled(!readOnly);
|
||||
}
|
||||
|
||||
QString CAircraftCombinedTypeSelector::getCombinedType() const
|
||||
{
|
||||
QString ct(ui->le_CombinedType->text().trimmed().toUpper());
|
||||
if (CAircraftIcaoCode::isValidCombinedType(ct)) { return ct; }
|
||||
|
||||
QString ct2(getCombinedTypeFromComboBoxes());
|
||||
return ct2;
|
||||
}
|
||||
|
||||
void CAircraftCombinedTypeSelector::ps_CombinedTypeEntered()
|
||||
{
|
||||
QString cc(ui->le_CombinedType->text().trimmed().toUpper());
|
||||
this->setCombinedType(cc);
|
||||
}
|
||||
|
||||
void CAircraftCombinedTypeSelector::ps_ChangedComboBox(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text);
|
||||
QString ct(getCombinedTypeFromComboBoxes());
|
||||
ui->le_CombinedType->setText(ct);
|
||||
}
|
||||
|
||||
QString CAircraftCombinedTypeSelector::getCombinedTypeFromComboBoxes() const
|
||||
{
|
||||
// try to get from combox boxes instead
|
||||
QString ec = ui->cb_EngineCount->currentText().left(1);
|
||||
QString t = ui->cb_Type->currentText().left(1);
|
||||
QString et = ui->cb_EngineType->currentText().left(1);
|
||||
|
||||
QString ct2(QString(t + ec + et).toUpper());
|
||||
return ct2.replace('U', '-');
|
||||
}
|
||||
|
||||
} // ns
|
||||
69
src/blackgui/aircraftcombinedtypeselector.h
Normal file
69
src/blackgui/aircraftcombinedtypeselector.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_AIRCRAFTCOMBINEDTYPESELECTOR_H
|
||||
#define BLACKGUI_AIRCRAFTCOMBINEDTYPESELECTOR_H
|
||||
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAircraftCombinedTypeSelector; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
/*!
|
||||
* Select by comined type ("L2J", "H1T", ...)
|
||||
*/
|
||||
class CAircraftCombinedTypeSelector : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftCombinedTypeSelector(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAircraftCombinedTypeSelector();
|
||||
|
||||
//! Set comined code, e.g. L1P
|
||||
void setCombinedType(const QString &combinedCode);
|
||||
|
||||
//! Combined code from aircraft ICAO
|
||||
void setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
//! Read only
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
//! Get the combined type, e.g. "L2P"
|
||||
QString getCombinedType() const;
|
||||
|
||||
private slots:
|
||||
//! Code has been entered
|
||||
void ps_CombinedTypeEntered();
|
||||
|
||||
//! Changed combobox
|
||||
void ps_ChangedComboBox(const QString &text);
|
||||
|
||||
private:
|
||||
//! Combined type from comboboxes
|
||||
QString getCombinedTypeFromComboBoxes() const;
|
||||
|
||||
QScopedPointer<Ui::CAircraftCombinedTypeSelector> ui;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
187
src/blackgui/aircraftcombinedtypeselector.ui
Normal file
187
src/blackgui/aircraftcombinedtypeselector.ui
Normal file
@@ -0,0 +1,187 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAircraftCombinedTypeSelector</class>
|
||||
<widget class="QFrame" name="CAircraftCombinedTypeSelector">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_AircraftCombinedType">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_CombinedType">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enter combined type, e.g. L2J, S1P</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>L1P</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_Type">
|
||||
<property name="toolTip">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Helicopter</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Glider</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Seaplane</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Landplane</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Tilt wing</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unspecified</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_EngineCount">
|
||||
<property name="toolTip">
|
||||
<string>Engines count</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_EngineType">
|
||||
<property name="toolTip">
|
||||
<string>Engine</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Electric</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Jet</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Piston</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Turboprop</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unspecified</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user