10 #include "ui_selcalcodeselector.h"
16 using namespace swift::misc::aviation;
20 CSelcalCodeSelector::CSelcalCodeSelector(QWidget *parent) : QFrame(parent), ui(new Ui::
CSelcalCodeSelector)
24 this->setValidityHint();
25 ui->lblp_ValidCodeIcon->setToolTips(
"valid SELCAL",
"invalid SELCAL");
28 ui->cb_SelcalPairs1->setStyleSheet(
"combobox-popup: 0;");
29 ui->cb_SelcalPairs2->setStyleSheet(
"combobox-popup: 0;");
31 connect(ui->cb_SelcalPairs1, qOverload<int>(&QComboBox::currentIndexChanged),
this,
32 &CSelcalCodeSelector::selcalIndexChanged);
33 connect(ui->cb_SelcalPairs2, qOverload<int>(&QComboBox::currentIndexChanged),
this,
34 &CSelcalCodeSelector::selcalIndexChanged);
41 QString selcal = ui->cb_SelcalPairs1->currentText();
42 selcal.append(ui->cb_SelcalPairs2->currentText());
54 ui->cb_SelcalPairs1->clear();
55 if (allowEmptyValue) ui->cb_SelcalPairs1->addItem(
" ");
57 ui->cb_SelcalPairs2->clear();
58 if (allowEmptyValue) ui->cb_SelcalPairs2->addItem(
" ");
64 const QString s = selcal.isEmpty() ?
" " : selcal.toUpper().trimmed();
65 if (s.length() != 4) {
return; }
67 const QString s1 = s.left(2);
68 const QString s2 = s.right(2);
81 if (s.length() != 4)
return false;
88 ui->cb_SelcalPairs1->setCurrentIndex(0);
89 ui->cb_SelcalPairs2->setCurrentIndex(0);
96 ui->cb_SelcalPairs1->setMinimumHeight(h);
97 ui->cb_SelcalPairs2->setMinimumHeight(h);
100 void CSelcalCodeSelector::selcalIndexChanged(
int index)
103 this->setValidityHint();
107 void CSelcalCodeSelector::setValidityHint() { ui->lblp_ValidCodeIcon->setTicked(this->
hasValidCode()); }
void valueChanged()
Value has been changed.
QString getSelcalCode() const
SELCAL code.
void setComboBoxMinimumHeight(int h)
Set the combobox height.
swift::misc::aviation::CSelcal getSelcal() const
SELCAL.
int getComboBoxHeight() const
The height of the combobox.
void resetSelcalCodes(bool allowEmptyValue=false)
Reset the SELCAL code.
void setSelcalCode(const QString &selcal)
Set the SELCAL code.
virtual ~CSelcalCodeSelector()
Destructor.
void setSelcal(const swift::misc::aviation::CSelcal &selcal)
Set the SELCAL code.
bool hasValidCode() const
Valid code?
const QString & getCode() const
Get SELCAL code.
static const QStringList & codePairs()
All valid code pairs: AB, AC, AD ...
static bool isValidCode(const QString &code)
Valid SELCAL code?
High level reusable GUI components.
Free functions in swift::misc.