34#include <NDEVR/Unit.h>
35#include <NDEVR/TypeInfo.h>
36#include <NDEVR/Pointer.h>
37#include <NDEVR/String.h>
107 void fixup(QString& input)
const override;
126 QValidator::State
validate(QString& input,
int& pos)
const override;
146 m_number_of_decimals = decimals;
153 m_number_of_decimals = Constant<uint04>::Invalid;
199 template<
class t_angle_type>
205 template<
class t_angle_type>
284 uint04 m_number_of_decimals;
289 bool m_allow_wrapping;
291 bool m_allow_newline =
true;
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
A specification of upper and lower bounds in N-dimensions.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
void fixup(StringAllocatingView &input, bool to_unit, bool from_unit=true) const
Fixes up an NDEVR string input with optional unit conversion.
void setMin(fltp08 min)
Sets the minimum allowed numeric value.
const TypeInfo & typeInfo() const
Returns the type information used by this validator.
fltp08 getMax() const
Returns the maximum allowed numeric value.
QCustomValidator(const TypeInfo &info, QObject *parent=nullptr)
Constructs a validator configured for the specified type info.
InvalidProperties getValidity(const StringView &input) const
Returns detailed validity information for the given input string.
fltp08 min() const
Returns the minimum allowed numeric value.
void fixup(StringAllocatingView &input) const
Fixes up an NDEVR string input by correcting or clamping invalid values.
const String & regex() const
Returns the regular expression pattern for validation.
uint01 unitDimension() const
Returns the unit dimension index used for multi-dimensional unit conversions.
void setMax(Angle< t_angle_type > max)
Sets the maximum allowed value from an angle type, converting to internal units.
TranslatedString getMessageString(ValidityMessage message)
Returns a user-facing translated message for the given validity state.
void setMin(Angle< t_angle_type > min)
Sets the minimum allowed value from an angle type, converting to internal units.
void fixup(QString &input) const override
Fixes up a Qt string input by correcting or clamping invalid values.
void setNumberOfDecimals(uint04 decimals)
Sets the maximum number of allowed decimal places.
void setAllowWrapping(bool allow_wrapping)
Sets whether values are allowed to wrap from max to min and vice versa.
fltp08 max() const
Returns the maximum allowed numeric value.
void setUnitValidator(const ConstPointer< Unit > &unit, uint01 dimension=Constant< uint01 >::Invalid)
Sets the unit used for converting between display and internal values.
void setAllowNewline(bool allow_newline)
Sets whether newline characters are allowed in the input.
fltp08 getMin() const
Returns the minimum allowed numeric value.
void setMax(fltp08 max)
Sets the maximum allowed numeric value.
void setStep(fltp08 step)
Sets the step increment used for value adjustment (e.g., spin box arrows).
void setCustomCallback(const std::function< ValidityMessage(const StringView &)> &callback)
Sets a custom validation callback that returns a ValidityMessage for the input.
const UnitCategory & unitType() const
Returns the unit category type.
QCustomValidator(QObject *parent=nullptr)
Constructs a validator with default settings.
ValidityMessage
Describes the type of validation failure encountered during input checking.
@ e_value_is_not_a_real_number
The input is not a valid real number.
@ e_value_too_low
The input value is below the minimum.
@ e_too_many_decimals
The input has more decimal places than allowed.
@ e_unexpected_format
The input has an unexpected format.
@ e_is_valid
The input is valid.
@ e_file_exists
The input refers to a file that already exists.
@ e_string_is_too_short
The input string is shorter than the minimum length.
@ e_string_is_too_long
The input string exceeds the maximum length.
@ e_value_too_high
The input value exceeds the maximum.
@ e_value_is_empty
The input is empty when not allowed.
QCustomValidator(const QCustomValidator &validator)
Copy constructor.
const ConstPointer< Unit > & unit() const
Returns the unit used for validation and conversion.
void setUnitType(UnitCategory type)
Sets the unit category type used for unit validation.
void setRegex(const StringView ®ex)
Sets a regular expression pattern that the input must match.
void clearNumberOfDecimals()
Clears the decimal place limit, allowing any number of decimals.
QValidator::State validate(QString &input, int &pos) const override
Validates a Qt string input and returns the validation state.
const QCustomValidator & operator=(const QCustomValidator &other)
Assignment operator.
fltp08 step() const
Returns the step increment value.
void setTypeInfo(const TypeInfo &info)
Sets the type information used to configure validation rules.
void setAllowEmpty(bool allow_empty)
Sets whether an empty input is considered valid.
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Stores information about a type, relevant for certain templated functions.
The primary namespace for the NDEVR SDK.
UnitCategory
A category of unit describing what it relates to.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Contains the result of a validation check, including the validity state, a suggested fix-up message,...
Bounds< 1, uint04 > range
The character range of the invalid portion.
ValidityMessage validity
The validity state of the input.
StringAllocatingView fixed_up_message
A suggested corrected version of the input.
InvalidProperties(ValidityMessage validity)
Constructs invalid properties with the given validity state.
Defines a unit of measurement for converting and displaying data values.