Files
pilotclient/src/blackgui/uppercasevalidator.cpp
Roland Winklmeier f4c2939253 Fix BlackGui header includes
* Include only what is used
* Use forward declaration when possible
* Sorted includes

refs #598
2016-05-20 01:31:11 +02:00

47 lines
1.6 KiB
C++

/* Copyright (C) 2014
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "blackgui/uppercasevalidator.h"
#include <QString>
#include <QtGlobal>
namespace BlackGui
{
CUpperCaseValidator::CUpperCaseValidator(QObject *parent) : QValidator(parent)
{ }
CUpperCaseValidator::CUpperCaseValidator(int minLength, int maxLength, QObject *parent) : QValidator(parent),
m_minLength(minLength), m_maxLength(maxLength)
{ }
CUpperCaseValidator::CUpperCaseValidator(bool optionalValue, int minLength, int maxLength, QObject *parent) : QValidator(parent),
m_optionalValue(optionalValue), m_minLength(minLength), m_maxLength(maxLength)
{ }
QValidator::State CUpperCaseValidator::validate(QString &input, int &pos) const
{
Q_UNUSED(input);
Q_UNUSED(pos);
fixup(input);
if (m_optionalValue && input.isEmpty()) { return Acceptable; }
if (input.length() > m_maxLength) { return Invalid; }
if (input.length() < m_minLength) { return Intermediate; }
return Acceptable;
}
void CUpperCaseValidator::fixup(QString &input) const
{
if (input.isEmpty()) { return; }
input = input.toUpper();
}
} // namespace