Ref T265, Ref T430, Ref T473 improved validator for parts

This commit is contained in:
Klaus Basan
2018-12-20 04:03:15 +01:00
committed by Mat Sutcliffe
parent d89b217e9b
commit 6bd3a50ed8
3 changed files with 29 additions and 4 deletions

View File

@@ -7,11 +7,13 @@
* contained in the LICENSE file.
*/
#include "blackmisc/stringutils.h"
#include "blackgui/uppercasevalidator.h"
#include <QString>
#include <QtGlobal>
using namespace BlackMisc;
namespace BlackGui
{
CUpperCaseValidator::CUpperCaseValidator(QObject *parent) : QValidator(parent)
@@ -19,11 +21,15 @@ namespace BlackGui
CUpperCaseValidator::CUpperCaseValidator(int minLength, int maxLength, QObject *parent) : QValidator(parent),
m_minLength(minLength), m_maxLength(maxLength)
{ }
{
if (minLength < 1) { m_optionalValue = true; };
}
CUpperCaseValidator::CUpperCaseValidator(bool optionalValue, int minLength, int maxLength, QObject *parent) : QValidator(parent),
m_optionalValue(optionalValue), m_minLength(minLength), m_maxLength(maxLength)
{ }
{
if (minLength < 1) { m_optionalValue = true; };
}
QValidator::State CUpperCaseValidator::validate(QString &input, int &pos) const
{
@@ -54,6 +60,9 @@ namespace BlackGui
{
if (input.isEmpty()) { return; }
input = input.toUpper();
if (!m_allowedCharacters.isEmpty())
{
input = removeIfNotInString(input, m_allowedCharacters);
}
}
} // namespace