refs #335, SELCAL tweaks discovered during refactoring

* better case handling in SELCAL
* SELCAL in aircraft
* SELCAL selector, improved getter / setters
* changed cockpit SELCAL elements to promoted GUI element
* synchronized flightplan and cockpit SELCAL codes, used new signal/slot syntacs in flightplan
* added SELCAL in own aircraft context
This commit is contained in:
Klaus Basan
2014-11-25 23:46:55 +01:00
committed by Roland Winklmeier
parent dd587207fe
commit 0c6f5f1777
16 changed files with 169 additions and 77 deletions

View File

@@ -11,13 +11,15 @@
#include "ui_selcalcodeselector.h"
#include "blackmisc/avselcal.h"
using namespace BlackMisc::Aviation;
namespace BlackGui
{
CSelcalCodeSelector::CSelcalCodeSelector(QWidget *parent) :
QFrame(parent), ui(new Ui::CSelcalCodeSelector)
{
this->ui->setupUi(this);
this->resetSelcalCodes(false);
this->resetSelcalCodes(true);
bool c;
c = connect(this->ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SIGNAL(valueChanged()));
@@ -27,9 +29,7 @@ namespace BlackGui
}
CSelcalCodeSelector::~CSelcalCodeSelector()
{
delete ui;
}
{ }
QString CSelcalCodeSelector::getSelcalCode() const
{
@@ -38,6 +38,12 @@ namespace BlackGui
return selcal;
}
BlackMisc::Aviation::CSelcal CSelcalCodeSelector::getSelcal() const
{
CSelcal selcal(getSelcalCode());
return selcal;
}
void CSelcalCodeSelector::resetSelcalCodes(bool allowEmptyValue)
{
this->ui->cb_SelcalPairs1->clear();
@@ -50,15 +56,25 @@ namespace BlackGui
void CSelcalCodeSelector::setSelcalCode(const QString &selcal)
{
if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals
QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed();
Q_ASSERT(s.length() == 4);
if (s.length() != 4) return;
QString s1 = s.left(2);
QString s2 = s.right(2);
if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1))
{
this->ui->cb_SelcalPairs1->setCurrentText(s1);
}
if (BlackMisc::Aviation::CSelcal::codePairs().contains(s2))
this->ui->cb_SelcalPairs1->setCurrentText(s2);
{
this->ui->cb_SelcalPairs2->setCurrentText(s2);
}
}
void CSelcalCodeSelector::setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal)
{
this->setSelcalCode(selcal.getCode());
}
bool CSelcalCodeSelector::hasValidCode() const
@@ -67,4 +83,11 @@ namespace BlackGui
if (s.length() != 4) return false;
return BlackMisc::Aviation::CSelcal::isValidCode(s);
}
void CSelcalCodeSelector::clear()
{
if (this->ui->cb_SelcalPairs1->count() < 1) { this->resetSelcalCodes(true); }
this->ui->cb_SelcalPairs1->setCurrentIndex(0);
this->ui->cb_SelcalPairs2->setCurrentIndex(0);
}
}