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)
369 locale().numberOptions())) {
376 const bool startsWithMinus(buff[0] ==
'-');
377 if (
b >= 0 && startsWithMinus)
380 const bool startsWithPlus(buff[0] ==
'+');
381 if (
t < 0 && startsWithPlus)
384 if (buff.
size() == 1 && (startsWithPlus || startsWithMinus))
392 if (entered >=
b && entered <=
t) {
403 int buffLength = buff.
size();
406 const int tLength =
t != 0 ?
static_cast<int>(std::log10(
qAbs(
t))) + 1 : 1;
419 locale().numberOptions())) {
435 bool rangeChanged =
false;
626# define LLONG_MAX Q_INT64_C(0x7fffffffffffffff)
634 switch (
d->notation) {
669 if (
i >=
q->b && i <= q->
t)
679 if (convertDoubleTo(
qFloor(max), &
v)) {
689 if (
qAbs(
i) > (
n - std::pow(10, -
q->dec)))
763 const auto decimalPointIndex = buff.
indexOf(
'.');
764 precision = decimalPointIndex >= 0 ? buff.
size() - decimalPointIndex - 1 : 0;
766 auto eIndex = buff.
indexOf(
'e');
770 eIndex = buff.
size();
793 bool rangeChanged =
false;
883 if (
d->notation != newNotation) {
884 d->notation = newNotation;
896#if QT_CONFIG(regularexpression)
932 Q_DECLARE_PUBLIC(QRegularExpressionValidator)
945QRegularExpressionValidator::QRegularExpressionValidator(
QObject *
parent)
958 : QRegularExpressionValidator(
parent)
960 Q_D(QRegularExpressionValidator);
961 d->setRegularExpression(re);
969QRegularExpressionValidator::~QRegularExpressionValidator()
991 Q_D(
const QRegularExpressionValidator);
996 if (
d->origRe.pattern().isEmpty())
1002 }
else if (
input.isEmpty() ||
m.hasPartialMatch()) {
1003 return Intermediate;
1020 Q_D(
const QRegularExpressionValidator);
1026 Q_D(QRegularExpressionValidator);
1027 d->setRegularExpression(re);
1036void QRegularExpressionValidatorPrivate::setRegularExpression(
const QRegularExpression &re)
1038 Q_Q(QRegularExpressionValidator);
1041 usedRe = origRe = re;
1043 emit q->regularExpressionChanged(re);
1052#include "moc_qvalidator.cpp"
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double toDouble(bool *ok=nullptr) const
Returns the byte array converted to a double value.
bool startsWith(QByteArrayView bv) const
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static constexpr QChar fromLatin1(char c) noexcept
Converts the Latin-1 character c to its equivalent QChar.
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
void setPattern(const QString &pattern)
Sets the pattern string of the regular expression to pattern.
@ PartialPreferCompleteMatch
QString pattern() const
Returns the pattern string of the regular expression.
static QString anchoredPattern(const QString &expression)
\macro QT_RESTRICTED_CAST_FROM_ASCII
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 int numDigits(qlonglong n)
Q_CORE_EXPORT bool validateChars(QStringView str, NumberMode numMode, QByteArray *buff, int decDigits=-1, QLocale::NumberOptions number_options=QLocale::DefaultNumberOptions) const
static Q_CORE_EXPORT qint64 bytearrayToLongLong(QByteArrayView num, int base, bool *ok)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent