Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Dlg
DlgValidatorNumber.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#include "
DlgValidatorNumber.h
"
8
#include "
Logger.h
"
9
#include <QDoubleValidator>
10
#include <QLocale>
11
12
DlgValidatorNumber::DlgValidatorNumber
(
CoordScale
coordScale,
13
const
QLocale &locale,
14
QObject *parent) :
15
DlgValidatorAbstract
(parent),
16
m_coordScale (coordScale),
17
m_locale (locale)
18
{
19
qCInfo(ENGAUGE_LOG) <<
"DlgValidatorNumber::DlgValidatorNumber"
;
20
}
21
22
QValidator::State
DlgValidatorNumber::validate
(QString &input,
23
int
&pos)
const
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
}
CoordScale
CoordScale
Definition
CoordScale.h:12
COORD_SCALE_LOG
@ COORD_SCALE_LOG
Definition
CoordScale.h:14
DlgValidatorNumber.h
Logger.h
DlgValidatorAbstract::DlgValidatorAbstract
DlgValidatorAbstract(QObject *parent=0)
Single constructor.
Definition
DlgValidatorAbstract.cpp:10
DlgValidatorNumber::DlgValidatorNumber
DlgValidatorNumber(CoordScale coordScale, const QLocale &locale, QObject *parent=0)
Single constructor.
Definition
DlgValidatorNumber.cpp:12
DlgValidatorNumber::validate
virtual QValidator::State validate(QString &input, int &pos) const
Apply the standard validation with 0 as the exclusive minimum. Call setCoordScale just before calling...
Definition
DlgValidatorNumber.cpp:22
Generated on
for Engauge Digitizer by
1.17.0