00001
00002
00003
00004
00005
00006
00007 #include "DlgValidatorNumber.h"
00008 #include "Logger.h"
00009 #include <QDoubleValidator>
00010 #include <QLocale>
00011
00012 DlgValidatorNumber::DlgValidatorNumber(CoordScale coordScale,
00013 const QLocale &locale,
00014 QObject *parent) :
00015 DlgValidatorAbstract(parent),
00016 m_coordScale (coordScale),
00017 m_locale (locale)
00018 {
00019 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorNumber::DlgValidatorNumber";
00020 }
00021
00022 QValidator::State DlgValidatorNumber::validate (QString &input,
00023 int &pos) const
00024 {
00025
00026 QDoubleValidator validator;
00027 validator.setLocale (m_locale);
00028 QValidator::State state = validator.validate (input,
00029 pos);
00030 if (state == QValidator::Acceptable) {
00031
00032 if (m_coordScale == COORD_SCALE_LOG) {
00033 if (m_locale.toDouble (input) < 0.0) {
00034
00035
00036 state = QValidator::Invalid;
00037
00038 } if (m_locale.toDouble (input) == 0.0) {
00039
00040
00041 state = QValidator::Intermediate;
00042 }
00043 }
00044 }
00045
00046 return state;
00047 }