mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 17:55:34 +08:00
Prepared for only A-Z/0-9 callsign entry
This commit is contained in:
@@ -122,8 +122,12 @@ namespace BlackGui
|
|||||||
// So I use no ranges in the CUpperCaseValidators, as this disables the signals for invalid values
|
// So I use no ranges in the CUpperCaseValidators, as this disables the signals for invalid values
|
||||||
|
|
||||||
// own aircraft
|
// own aircraft
|
||||||
ui->le_Callsign->setMaxLength(LogoffIntervalSeconds);
|
constexpr int MaxLength = 10;
|
||||||
ui->le_Callsign->setValidator(new CUpperCaseValidator(this));
|
constexpr int MinLength = 0;
|
||||||
|
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_Callsign);
|
||||||
|
// ucv->setAllowedCharacters09AZ();
|
||||||
|
ui->le_Callsign->setMaxLength(MaxLength);
|
||||||
|
ui->le_Callsign->setValidator(ucv);
|
||||||
connect(ui->le_Callsign, &QLineEdit::editingFinished, this, &CLoginComponent::validateAircraftValues);
|
connect(ui->le_Callsign, &QLineEdit::editingFinished, this, &CLoginComponent::validateAircraftValues);
|
||||||
|
|
||||||
ui->le_AircraftCombinedType->setMaxLength(3);
|
ui->le_AircraftCombinedType->setMaxLength(3);
|
||||||
|
|||||||
@@ -30,11 +30,17 @@ namespace BlackGui
|
|||||||
if (minLength < 1) { m_optionalValue = true; };
|
if (minLength < 1) { m_optionalValue = true; };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CUpperCaseValidator::setAllowedCharacters09AZ()
|
||||||
|
{
|
||||||
|
static const QString chars("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
|
this->setAllowedCharacters(chars);
|
||||||
|
}
|
||||||
|
|
||||||
QValidator::State CUpperCaseValidator::validate(QString &input, int &pos) const
|
QValidator::State CUpperCaseValidator::validate(QString &input, int &pos) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(input);
|
Q_UNUSED(input);
|
||||||
Q_UNUSED(pos);
|
Q_UNUSED(pos);
|
||||||
fixup(input);
|
this->fixup(input);
|
||||||
|
|
||||||
if (m_optionalValue && input.isEmpty()) { return Acceptable; }
|
if (m_optionalValue && input.isEmpty()) { return Acceptable; }
|
||||||
if (input.length() > m_maxLength) { return Invalid; }
|
if (input.length() > m_maxLength) { return Invalid; }
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace BlackGui
|
|||||||
//! Allowed characters
|
//! Allowed characters
|
||||||
void setAllowedCharacters(const QString &chars) { m_allowedCharacters = chars.toUpper(); }
|
void setAllowedCharacters(const QString &chars) { m_allowedCharacters = chars.toUpper(); }
|
||||||
|
|
||||||
|
//! Set the allowed characters as 0-9 and A-Z
|
||||||
|
void setAllowedCharacters09AZ();
|
||||||
|
|
||||||
//! \copydoc QValidator::validate
|
//! \copydoc QValidator::validate
|
||||||
virtual State validate(QString &input, int &pos) const override;
|
virtual State validate(QString &input, int &pos) const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user