15 CUpperCaseValidator::CUpperCaseValidator(QObject *parent) : QValidator(parent) {}
18 : QValidator(parent), m_minLength(minLength), m_maxLength(maxLength)
20 if (minLength < 1) { m_optionalValue =
true; };
24 : QValidator(parent), m_optionalValue(optionalValue), m_minLength(minLength), m_maxLength(maxLength)
26 if (minLength < 1) { m_optionalValue =
true; };
31 static const QString chars(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
41 if (m_optionalValue && input.isEmpty()) {
return Acceptable; }
42 if (input.length() > m_maxLength) {
return Invalid; }
43 if (input.length() < m_minLength) {
return Intermediate; }
44 if (!m_restrictions.isEmpty())
47 for (
const QString &r : m_restrictions)
49 if (r.startsWith(input))
55 if (!valid) {
return Invalid; }
62 if (input.isEmpty()) {
return; }
63 input = input.toUpper();
64 if (!m_allowedCharacters.isEmpty()) { input =
removeIfNotInString(input, m_allowedCharacters); }
CUpperCaseValidator(QObject *parent=nullptr)
Constructor.
void setAllowedCharacters09AZ()
Set the allowed characters as 0-9 and A-Z.
virtual void fixup(QString &input) const
virtual State validate(QString &input, int &pos) const
void setAllowedCharacters(const QString &chars)
Allowed characters.
Free functions in swift::misc.
QString removeIfNotInString(const QString &string, const QString &inString)
Remove if NOT in string.