Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgValidatorNumber Class Reference

Validator for generic (=simple) numbers. More...

#include <DlgValidatorNumber.h>

Inheritance diagram for DlgValidatorNumber:
Inheritance graph
Collaboration diagram for DlgValidatorNumber:
Collaboration graph

Public Member Functions

 DlgValidatorNumber (CoordScale coordScale, const QLocale &locale, QObject *parent=0)
 Single constructor.
virtual QValidator::State validate (QString &input, int &pos) const
 Apply the standard validation with 0 as the exclusive minimum. Call setCoordScale just before calling this method.
Public Member Functions inherited from DlgValidatorAbstract
 DlgValidatorAbstract (QObject *parent=0)
 Single constructor.
virtual ~DlgValidatorAbstract ()

Detailed Description

Validator for generic (=simple) numbers.

Definition at line 17 of file DlgValidatorNumber.h.

Constructor & Destructor Documentation

◆ DlgValidatorNumber()

DlgValidatorNumber::DlgValidatorNumber ( CoordScale coordScale,
const QLocale & locale,
QObject * parent = 0 )

Single constructor.

Definition at line 12 of file DlgValidatorNumber.cpp.

14 :
16 m_coordScale (coordScale),
17 m_locale (locale)
18{
19 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorNumber::DlgValidatorNumber";
20}
log4cpp::Category * mainCat
Definition Logger.cpp:14
DlgValidatorAbstract(QObject *parent=0)
Single constructor.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

Member Function Documentation

◆ validate()

QValidator::State DlgValidatorNumber::validate ( QString & input,
int & pos ) const
virtual

Apply the standard validation with 0 as the exclusive minimum. Call setCoordScale just before calling this method.

Implements DlgValidatorAbstract.

Definition at line 22 of file DlgValidatorNumber.cpp.

24{
25 // First do standard check
26 QDoubleValidator validator;
27 validator.setLocale (m_locale);
28 QValidator::State state = validator.validate (input,
29 pos);
30 if (state == QValidator::Acceptable) {
31
32 if (m_coordScale == COORD_SCALE_LOG) {
33 if (m_locale.toDouble (input) < 0.0) {
34
35 // Cannot allow negative number
36 state = QValidator::Invalid;
37
38 } if (m_locale.toDouble (input) == 0.0) {
39
40 // Treat as a leading zero, which is legal
41 state = QValidator::Intermediate;
42 }
43 }
44 }
45
46 return state;
47}
@ COORD_SCALE_LOG
Definition CoordScale.h:14

The documentation for this class was generated from the following files: