Ref T417, flight plan follow ups

* fixed eventfilter, only allow ASCII values, disable in read only mode
* set remarks values "from external"
* set SELCAL value
This commit is contained in:
Klaus Basan
2019-07-01 16:45:32 +02:00
committed by Mat Sutcliffe
parent 35b0836754
commit be3283305a
9 changed files with 706 additions and 567 deletions

View File

@@ -108,21 +108,25 @@ namespace BlackGui
ui->le_EquipmentSuffix->setCompleter(completer);
CUpperCaseEventFilter *ef = new CUpperCaseEventFilter(ui->pte_Route);
ef->setOnlyAscii();
ui->pte_Route->installEventFilter(ef);
ef = new CUpperCaseEventFilter(ui->pte_Remarks);
ef->setOnlyAscii();
ui->pte_Remarks->installEventFilter(ef);
ef = new CUpperCaseEventFilter(ui->pte_AdditionalRemarks);
ef->setOnlyAscii();
ui->pte_AdditionalRemarks->installEventFilter(ef);
ef = new CUpperCaseEventFilter(ui->pte_RemarksGenerated);
ui->pte_RemarksGenerated->installEventFilter(ef);
// readonly
// ef = new CUpperCaseEventFilter(ui->pte_RemarksGenerated);
// ui->pte_RemarksGenerated->installEventFilter(ef);
// connect
connect(ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan, Qt::QueuedConnection);
connect(ui->pb_Load, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlanFromNetwork, Qt::QueuedConnection);
connect(ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan, Qt::QueuedConnection);
connect(ui->pb_Load, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlanFromNetwork, Qt::QueuedConnection);
connect(ui->pb_Reset, &QPushButton::pressed, this, &CFlightPlanComponent::resetFlightPlan, Qt::QueuedConnection);
connect(ui->pb_ValidateFlightPlan, &QPushButton::pressed, this, &CFlightPlanComponent::validateFlightPlan, Qt::QueuedConnection);
connect(ui->tb_SyncWithSimulator, &QPushButton::released, this, &CFlightPlanComponent::syncWithSimulator, Qt::QueuedConnection);
connect(ui->pb_Prefill, &QPushButton::pressed, this, &CFlightPlanComponent::anticipateValues, Qt::QueuedConnection);
connect(ui->pb_Prefill, &QPushButton::pressed, this, &CFlightPlanComponent::anticipateValues, Qt::QueuedConnection);
connect(ui->pb_SimBrief, &QPushButton::pressed, this, &CFlightPlanComponent::loadFromSimBrief, Qt::QueuedConnection);
connect(ui->cb_VoiceCapabilities, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::currentTextChangedToBuildRemarks, Qt::QueuedConnection);
@@ -267,6 +271,10 @@ namespace BlackGui
this->showOverlayMessage(m);
}
if (!flightPlan.getRemarks().isEmpty())
{
this->setRemarksUIValues(flightPlan.getRemarks());
}
}
const CLogCategoryList &CFlightPlanComponent::getLogCategories()
@@ -931,6 +939,47 @@ namespace BlackGui
}
}
void CFlightPlanComponent::setRemarksUIValues(const QString &remarks)
{
if (remarks.isEmpty()) { return; }
const QString r = remarks.toUpper();
if (remarks.contains("/V"))
{
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilitiesFirstPage, "FULL");
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilities, "FULL");
}
else if (remarks.contains("/T"))
{
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilitiesFirstPage, "TEXT ONLY");
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilities, "FULL");
}
else if (remarks.contains("/R"))
{
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilitiesFirstPage, "RECEIVE");
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilities, "RECEIVE");
}
if (remarks.contains("NAV/GPSRNAV"))
{
CGuiUtility::setComboBoxValueByContainingString(ui->cb_NavigationEquipment, "GPS OR FMC");
}
else if (remarks.contains("NAV/VORNDB"))
{
CGuiUtility::setComboBoxValueByContainingString(ui->cb_NavigationEquipment, "DIRECT VOR");
}
const int selcal = remarks.indexOf("SEL/");
if (selcal >= 0 && remarks.length() > selcal + 7)
{
const QString code = remarks.mid(selcal + 4, 4);
if (code.length() == 4)
{
ui->frp_SelcalCode->setSelcal(code);
}
}
}
void CFlightPlanComponent::loadFromSimBrief()
{
if (!sGui || sGui->isShuttingDown()) { return; }
@@ -1059,7 +1108,10 @@ namespace BlackGui
{
ui->cb_VoiceCapabilities->setCurrentText(text);
const QString r = CFlightPlanRemarks::replaceVoiceCapabilities(CFlightPlanRemarks::textToVoiceCapabilitiesRemarks(text), ui->pte_Remarks->toPlainText());
ui->pte_Remarks->setPlainText(r);
if (ui->pte_Remarks->toPlainText() != r)
{
ui->pte_Remarks->setPlainText(r);
}
}
}
} // namespace

View File

@@ -224,6 +224,9 @@ namespace BlackGui
//! Update the remarks histories
void updateRemarksHistories();
//! Set remark values
void setRemarksUIValues(const QString &remarks);
//! Load from SimBrief
void loadFromSimBrief();

File diff suppressed because it is too large Load Diff

View File

@@ -24,21 +24,30 @@ namespace BlackGui
// processing proceed as it may be a control (e.g. cursor movement)
// key. Otherwise convert the text to upper case and insert it at
// the current cursor position.
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>(object);
if (!pte) { return false; }
if (pte->isReadOnly()) { return false; }
if (e->text().length() == 1)
{
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>(object);
if (!pte) { return false; }
const QChar c = e->text().front();
if (!c.isLower()) { return false; }
if (!c.isLetter()) { return false; }
if (m_illegalChars.contains(c)) { return true; }
if (c.isLetter())
{
const ushort unicode = c.unicode();
if (m_onlyAscii && unicode > 127) { return true; }
pte->insertPlainText(e->text().toUpper());
// return true to prevent further processing
return true;
}
}
pte->insertPlainText(e->text().toUpper());
// return true to prevent further processing
return true;
}
else
{
// all codes like backspace etc.
return false;
}
} // length
} // key event
}
return false;
}

View File

@@ -23,9 +23,19 @@ namespace BlackGui
public:
using QObject::QObject;
//! Not allowed characters
void setIllegalCharacters(const QString &illegal) { m_illegalChars = illegal; }
//! Allow only ASCII
void setOnlyAscii() { m_onlyAscii = true; }
protected:
//! Filter
bool eventFilter(QObject *object, QEvent *event);
private:
QString m_illegalChars;
bool m_onlyAscii = false;
};
} // namespace

View File

@@ -245,6 +245,36 @@ namespace BlackGui
return false;
}
bool CGuiUtility::setComboBoxValueByContainingString(QComboBox *box, const QString &candidate, const QString &unspecified)
{
if (!box) { return false; }
if (!candidate.isEmpty())
{
for (int i = 0; i < box->count(); i++)
{
const QString t(box->itemText(i));
if (t.contains(candidate, Qt::CaseInsensitive))
{
box->setCurrentIndex(i);
return true;
}
}
}
// not found
if (unspecified.isEmpty()) { return false; }
for (int i = 0; i < box->count(); i++)
{
const QString t(box->itemText(i));
if (t.contains(unspecified, Qt::CaseInsensitive))
{
box->setCurrentIndex(i);
return true;
}
}
return false;
}
bool CGuiUtility::hasSwiftVariantMimeType(const QMimeData *mime)
{
return mime && mime->hasFormat(swiftJsonDragAndDropMimeType());

View File

@@ -100,6 +100,9 @@ namespace BlackGui
//! Find best match in comboBox
static bool setComboBoxValueByStartingString(QComboBox *box, const QString &candidate, const QString &unspecified = QString());
//! Find best match in comboBox
static bool setComboBoxValueByContainingString(QComboBox *box, const QString &candidate, const QString &unspecified = QString());
//! Mime data with swift type
static bool hasSwiftVariantMimeType(const QMimeData *mime);