6#include "extendeddoublevalidator.h"
8#include "extendeddoublevalidator_p.h"
10#include "constpropagatinguniquepointer.h"
11#include <qstringbuilder.h>
18ExtendedDoubleValidator::ExtendedDoubleValidator(
QObject *parent)
20 , d_pointer(new ExtendedDoubleValidatorPrivate)
25ExtendedDoubleValidator::~ExtendedDoubleValidator() noexcept
31QString ExtendedDoubleValidator::prefix()
const
33 return d_pointer->m_prefix;
37void ExtendedDoubleValidator::setPrefix(
const QString &prefix)
39 if (prefix != d_pointer->m_prefix) {
40 d_pointer->m_prefix = prefix;
41 Q_EMIT prefixChanged(prefix);
46void ExtendedDoubleValidator::setSuffix(
const QString &suffix)
48 if (suffix != d_pointer->m_suffix) {
49 d_pointer->m_suffix = suffix;
50 Q_EMIT suffixChanged(suffix);
56QString ExtendedDoubleValidator::suffix()
const
58 return d_pointer->m_suffix;
79 if (!d_pointer->m_prefix.isEmpty()) {
81 myInput.
remove(0, d_pointer->m_prefix.size());
85 myPos -=
static_cast<int>(d_pointer->m_prefix.size());
87 return QValidator::State::Invalid;
90 if (!d_pointer->m_suffix.isEmpty()) {
91 if (myInput.
endsWith(d_pointer->m_suffix)) {
92 myInput.
chop(d_pointer->m_suffix.size());
94 return QValidator::State::Invalid;
104 input = d_pointer->m_prefix + myInput + d_pointer->m_suffix;
The namespace of this library.
virtual QValidator::State validate(QString &input, int &pos) const const override
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const