9#include "private/qobject_p.h"
10#include "private/qlocale_p.h"
11#include "private/qnumeric_p.h"
354 return (
int)std::log10(
double(
n)) + 1;
360 for (
int i = 0;
i < exp; ++
i)
365template <
typename T>
static inline
376 const bool signConflicts = (min >= 0 &&
ch ==
'-') || (max < 0 &&
ch ==
'+');
390 locale().numberOptions());
402 if (entered >=
b && entered <=
t) {
414 int buffLength = buff.
size();
417 const int tLength =
t != 0 ?
static_cast<int>(std::log10(
qAbs(
t))) + 1 : 1;
428 auto [parseState, buff] =
430 locale().numberOptions());
446 bool rangeChanged =
false;
637# define LLONG_MAX Q_INT64_C(0x7fffffffffffffff)
645 switch (
d->notation) {
673 if (
i >=
q->b && i <= q->
t)
683 if (convertDoubleTo(
qFloor(max), &
v)) {
693 if (
qAbs(
i) > (
n - std::pow(10, -
q->dec)))
746 auto [parseState, buff] =
761 mode =
input.contains(QChar::fromLatin1(
'E')) ?
'E' :
'e';
768 const auto decimalPointIndex = buff.indexOf(
'.');
769 precision = decimalPointIndex >= 0 ? buff.size() - decimalPointIndex - 1 : 0;
771 auto eIndex = buff.indexOf(
'e');
775 eIndex = buff.size();
776 precision = eIndex - (buff.contains(
'.') ? 1 : 0)
777 - (buff[0] ==
'-' || buff[0] ==
'+' ? 1 : 0);
798 bool rangeChanged =
false;
888 if (
d->notation != newNotation) {
889 d->notation = newNotation;
901#if QT_CONFIG(regularexpression)
937 Q_DECLARE_PUBLIC(QRegularExpressionValidator)
950QRegularExpressionValidator::QRegularExpressionValidator(
QObject *parent)
951 :
QValidator(*new QRegularExpressionValidatorPrivate, parent)
963 : QRegularExpressionValidator(parent)
965 Q_D(QRegularExpressionValidator);
966 d->setRegularExpression(re);
974QRegularExpressionValidator::~QRegularExpressionValidator()
996 Q_D(
const QRegularExpressionValidator);
1001 if (
d->origRe.pattern().isEmpty())
1007 }
else if (
input.isEmpty() ||
m.hasPartialMatch()) {
1008 return Intermediate;
1025 Q_D(
const QRegularExpressionValidator);
1031 Q_D(QRegularExpressionValidator);
1032 d->setRegularExpression(re);
1041void QRegularExpressionValidatorPrivate::setRegularExpression(
const QRegularExpression &re)
1043 Q_Q(QRegularExpressionValidator);
1046 usedRe = origRe = re;
1048 emit q->regularExpressionChanged(re);
1057#include "moc_qvalidator.cpp"
double toDouble(bool *ok=nullptr) const
QValidator::State validateWithLocale(QString &input, QLocaleData::NumberMode numMode, const QLocale &locale) const
void fixupWithLocale(QString &input, QLocaleData::NumberMode numMode, const QLocale &locale) const
QDoubleValidator::Notation notation
QDoubleValidatorPrivate()
The QDoubleValidator class provides range checking of floating-point numbers.
void bottomChanged(double bottom)
This signal is emitted after the bottom property changed.
double bottom
the validator's minimum acceptable value
void decimalsChanged(int decimals)
This signal is emitted after the decimals property changed.
Notation notation
the notation of how a string can describe a number
~QDoubleValidator()
Destroys the validator.
QDoubleValidator(QObject *parent=nullptr)
Constructs a validator object with a parent object that accepts any double.
void notationChanged(QDoubleValidator::Notation notation)
This signal is emitted after the notation property changed.
QValidator::State validate(QString &, int &) const override
Returns \l Acceptable if the string input is in the correct format and contains a double within the v...
void setRange(double bottom, double top, int decimals)
Sets the validator to accept doubles from minimum to maximum inclusive, with at most decimals digits ...
int decimals
the validator's maximum number of digits after the decimal point
void setNotation(Notation)
void topChanged(double top)
This signal is emitted after the top property changed.
double top
the validator's maximum acceptable value
void fixup(QString &input) const override
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
void topChanged(int top)
This signal is emitted after the top property changed.
void setRange(int bottom, int top)
Sets the range of the validator to only accept integers between bottom and top inclusive.
int bottom
the validator's lowest acceptable value
QValidator::State validate(QString &, int &) const override
Returns \l Acceptable if the input is an integer within the valid range.
void fixup(QString &input) const override
\reimp
int top
the validator's highest acceptable value
QIntValidator(QObject *parent=nullptr)
Constructs a validator with a parent object that accepts all integers.
void bottomChanged(int bottom)
This signal is emitted after the bottom property changed.
~QIntValidator()
Destroys the validator.
const QLocaleData *const m_data
double toDouble(const QString &s, bool *ok=nullptr) const
Returns the double represented by the localized string s.
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
QString toString(qlonglong i) const
Returns a localized string representation of i.
NumberOptions numberOptions() const
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
@ PartialPreferCompleteMatch
static QString anchoredPattern(const QString &expression)
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr size_type size() const noexcept
The QValidator class provides validation of input text.
void setLocale(const QLocale &locale)
Sets the locale that will be used for the validator.
State
This enum type defines the states in which a validated string can exist.
virtual void fixup(QString &) const
This function attempts to change input to be valid according to this validator's rules.
QValidator(QObject *parent=nullptr)
Sets up the validator.
QLocale locale() const
Returns the locale for the validator.
~QValidator()
Destroys the validator, freeing any storage and other resources used.
void changed()
This signal is emitted when any property that may affect the validity of a string has changed.
Combined button and popup list for selecting options.
bool qIsNaN(qfloat16 f) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLenum input
GLenum GLint GLint * precision
static qlonglong pow10(int exp)
static std::optional< QValidator::State > initialResultCheck(T min, T max, const ParsingResult &result)
static int numDigits(qlonglong n)
Q_CORE_EXPORT ParsingResult validateChars(QStringView str, NumberMode numMode, int decDigits=-1, QLocale::NumberOptions number_options=QLocale::DefaultNumberOptions) const
static Q_CORE_EXPORT QSimpleParsedNumber< qint64 > bytearrayToLongLong(QByteArrayView num, int base)