mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-11 06:25:33 +08:00
Ref T111, some cleanup of XPDR mode and SELCAL selector
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4013154a20
commit
31d398ffc8
@@ -35,11 +35,8 @@ namespace BlackGui
|
|||||||
ui->cb_SelcalPairs1->setStyleSheet("combobox-popup: 0;");
|
ui->cb_SelcalPairs1->setStyleSheet("combobox-popup: 0;");
|
||||||
ui->cb_SelcalPairs2->setStyleSheet("combobox-popup: 0;");
|
ui->cb_SelcalPairs2->setStyleSheet("combobox-popup: 0;");
|
||||||
|
|
||||||
bool c = connect(ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged()));
|
connect(ui->cb_SelcalPairs1, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
|
||||||
Q_ASSERT(c);
|
connect(ui->cb_SelcalPairs2, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
|
||||||
c = connect(ui->cb_SelcalPairs2, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged()));
|
|
||||||
Q_ASSERT(c);
|
|
||||||
Q_UNUSED(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSelcalCodeSelector::~CSelcalCodeSelector()
|
CSelcalCodeSelector::~CSelcalCodeSelector()
|
||||||
@@ -52,7 +49,7 @@ namespace BlackGui
|
|||||||
return selcal;
|
return selcal;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::Aviation::CSelcal CSelcalCodeSelector::getSelcal() const
|
CSelcal CSelcalCodeSelector::getSelcal() const
|
||||||
{
|
{
|
||||||
CSelcal selcal(getSelcalCode());
|
CSelcal selcal(getSelcalCode());
|
||||||
return selcal;
|
return selcal;
|
||||||
@@ -71,11 +68,11 @@ namespace BlackGui
|
|||||||
void CSelcalCodeSelector::setSelcalCode(const QString &selcal)
|
void CSelcalCodeSelector::setSelcalCode(const QString &selcal)
|
||||||
{
|
{
|
||||||
if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals
|
if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals
|
||||||
QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed();
|
const QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed();
|
||||||
Q_ASSERT(s.length() == 4);
|
Q_ASSERT(s.length() == 4);
|
||||||
if (s.length() != 4) return;
|
if (s.length() != 4) return;
|
||||||
QString s1 = s.left(2);
|
const QString s1 = s.left(2);
|
||||||
QString s2 = s.right(2);
|
const QString s2 = s.right(2);
|
||||||
if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1))
|
if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1))
|
||||||
{
|
{
|
||||||
ui->cb_SelcalPairs1->setCurrentText(s1);
|
ui->cb_SelcalPairs1->setCurrentText(s1);
|
||||||
@@ -86,14 +83,14 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSelcalCodeSelector::setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal)
|
void CSelcalCodeSelector::setSelcal(const BlackMisc::Aviation::CSelcal &selcal)
|
||||||
{
|
{
|
||||||
this->setSelcalCode(selcal.getCode());
|
this->setSelcalCode(selcal.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSelcalCodeSelector::hasValidCode() const
|
bool CSelcalCodeSelector::hasValidCode() const
|
||||||
{
|
{
|
||||||
QString s = this->getSelcalCode();
|
const QString s = this->getSelcalCode();
|
||||||
if (s.length() != 4) return false;
|
if (s.length() != 4) return false;
|
||||||
return BlackMisc::Aviation::CSelcal::isValidCode(s);
|
return BlackMisc::Aviation::CSelcal::isValidCode(s);
|
||||||
}
|
}
|
||||||
@@ -105,8 +102,9 @@ namespace BlackGui
|
|||||||
ui->cb_SelcalPairs2->setCurrentIndex(0);
|
ui->cb_SelcalPairs2->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSelcalCodeSelector::ps_selcalIndexChanged()
|
void CSelcalCodeSelector::selcalIndexChanged(int index)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
this->setValidityHint();
|
this->setValidityHint();
|
||||||
emit valueChanged();
|
emit valueChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
namespace Ui { class CSelcalCodeSelector; }
|
|
||||||
|
|
||||||
|
namespace Ui { class CSelcalCodeSelector; }
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
@@ -37,7 +37,7 @@ namespace BlackGui
|
|||||||
explicit CSelcalCodeSelector(QWidget *parent = nullptr);
|
explicit CSelcalCodeSelector(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~CSelcalCodeSelector();
|
virtual ~CSelcalCodeSelector();
|
||||||
|
|
||||||
//! SELCAL code
|
//! SELCAL code
|
||||||
QString getSelcalCode() const;
|
QString getSelcalCode() const;
|
||||||
@@ -52,7 +52,7 @@ namespace BlackGui
|
|||||||
void setSelcalCode(const QString &selcal);
|
void setSelcalCode(const QString &selcal);
|
||||||
|
|
||||||
//! Set the SELCAL code
|
//! Set the SELCAL code
|
||||||
void setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal);
|
void setSelcal(const BlackMisc::Aviation::CSelcal &selcal);
|
||||||
|
|
||||||
//! Valid code?
|
//! Valid code?
|
||||||
bool hasValidCode() const;
|
bool hasValidCode() const;
|
||||||
@@ -64,13 +64,12 @@ namespace BlackGui
|
|||||||
//! Value has been changed
|
//! Value has been changed
|
||||||
void valueChanged();
|
void valueChanged();
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! SELCAL changed
|
|
||||||
void ps_selcalIndexChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSelcalCodeSelector> ui;
|
QScopedPointer<Ui::CSelcalCodeSelector> ui;
|
||||||
|
|
||||||
|
//! SELCAL changed
|
||||||
|
void selcalIndexChanged(int index);
|
||||||
|
|
||||||
//! Set valid/invalid icon
|
//! Set valid/invalid icon
|
||||||
void setValidityHint();
|
void setValidityHint();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,13 +46,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
const QStringList &CTransponderModeSelector::modes()
|
const QStringList &CTransponderModeSelector::modes()
|
||||||
{
|
{
|
||||||
static QStringList modes;
|
static const QStringList modes(
|
||||||
if (modes.isEmpty())
|
|
||||||
{
|
{
|
||||||
modes << CTransponderModeSelector::transponderStateStandby();
|
CTransponderModeSelector::transponderStateStandby(),
|
||||||
modes << CTransponderModeSelector::transponderModeC();
|
CTransponderModeSelector::transponderModeC(),
|
||||||
modes << CTransponderModeSelector::transponderStateIdent();
|
CTransponderModeSelector::transponderStateIdent()
|
||||||
}
|
});
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +60,18 @@ namespace BlackGui
|
|||||||
return this->m_currentMode;
|
return this->m_currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTransponderModeSelector::isIdentSelected() const
|
||||||
|
{
|
||||||
|
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
|
||||||
|
}
|
||||||
|
|
||||||
void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode)
|
void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode)
|
||||||
{
|
{
|
||||||
if (mode != CTransponder::StateIdent) { this->m_resetMode = mode; }
|
if (mode != CTransponder::StateIdent) { this->m_resetMode = mode; }
|
||||||
if (this->m_currentMode == mode) { return; }
|
if (this->m_currentMode == mode) { return; }
|
||||||
if (this->m_currentMode == CTransponder::StateIdent) { emit this->transponderStateIdentEnded(); }
|
if (this->m_currentMode == CTransponder::StateIdent) { emit this->transponderStateIdentEnded(); }
|
||||||
this->m_currentMode = mode;
|
this->m_currentMode = mode;
|
||||||
QString m = CTransponder::modeAsString(mode);
|
const QString m = CTransponder::modeAsString(mode);
|
||||||
QComboBox::setCurrentText(m);
|
QComboBox::setCurrentText(m);
|
||||||
if (mode == CTransponder::StateIdent)
|
if (mode == CTransponder::StateIdent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CTransponderModeSelector(QWidget *parent = nullptr);
|
explicit CTransponderModeSelector(QWidget *parent = nullptr);
|
||||||
@@ -54,12 +53,8 @@ namespace BlackGui
|
|||||||
BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const;
|
BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const;
|
||||||
|
|
||||||
//! Ident selected
|
//! Ident selected
|
||||||
bool isIdentSelected() const
|
bool isIdentSelected() const;
|
||||||
{
|
|
||||||
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! reset to last mode (unequal ident)
|
//! reset to last mode (unequal ident)
|
||||||
void resetTransponderMode();
|
void resetTransponderMode();
|
||||||
|
|
||||||
@@ -82,8 +77,7 @@ namespace BlackGui
|
|||||||
private:
|
private:
|
||||||
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||||
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||||
QTimer m_resetTimer;
|
QTimer m_resetTimer { this };
|
||||||
|
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user