Engauge Digitizer  2
DlgValidatorAboveZero.cpp
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 "DlgValidatorAboveZero.h"
8 #include "Logger.h"
9 #include <QDoubleValidator>
10 #include <QLocale>
11 
13  QObject *parent) :
14  DlgValidatorAbstract(parent),
15  m_locale (locale)
16 {
17  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorAboveZero::DlgValidatorAboveZero";
18 }
19 
20 QValidator::State DlgValidatorAboveZero::validate (QString &input,
21  int &pos) const
22 {
23  // First do standard check
24  QDoubleValidator validator;
25  validator.setLocale (m_locale);
26  QValidator::State state = validator.validate (input,
27  pos);
28  if (state == QValidator::Acceptable) {
29 
30  if (m_locale.toDouble (input) <= 0.0) {
31 
32  // Cannot allow negative number or zero value
33  state = QValidator::Invalid;
34 
35  }
36  }
37 
38  return state;
39 }
virtual QValidator::State validate(QString &input, int &pos) const
Apply the standard validation with 0 as the exclusive minimum. Call setCoordScale just before calling...
Abstract validator for all numeric formats.
DlgValidatorAboveZero(const QLocale &locale, QObject *parent=0)
Single constructor.