+ fix gcc build failure
This commit is contained in:
parent
3c754da0cb
commit
ca0fb1480e
|
@ -113,79 +113,81 @@ public:
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy.at(0) == locale.groupSeparator()) {
|
{
|
||||||
state = QValidator::Invalid;
|
if (copy.at(0) == locale.groupSeparator()) {
|
||||||
goto end;
|
state = QValidator::Invalid;
|
||||||
}
|
goto end;
|
||||||
else if (len > 1) {
|
}
|
||||||
const int dec = copy.indexOf(locale.decimalPoint());
|
else if (len > 1) {
|
||||||
if (dec != -1) {
|
const int dec = copy.indexOf(locale.decimalPoint());
|
||||||
if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {
|
if (dec != -1) {
|
||||||
copy.remove(dec + 1, 1);
|
if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {
|
||||||
|
copy.remove(dec + 1, 1);
|
||||||
|
}
|
||||||
|
else if (copy.indexOf(locale.decimalPoint(), dec + 1) != -1) {
|
||||||
|
// trying to add a second decimal point is not allowed
|
||||||
|
state = QValidator::Invalid;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (copy.indexOf(locale.decimalPoint(), dec + 1) != -1) {
|
for (int i=dec + 1; i<copy.size(); ++i) {
|
||||||
// trying to add a second decimal point is not allowed
|
// a group separator after the decimal point is not allowed
|
||||||
state = QValidator::Invalid;
|
if (copy.at(i) == locale.groupSeparator()) {
|
||||||
goto end;
|
state = QValidator::Invalid;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=dec + 1; i<copy.size(); ++i) {
|
|
||||||
// a group separator after the decimal point is not allowed
|
bool ok = false;
|
||||||
if (copy.at(i) == locale.groupSeparator()) {
|
double value = min;
|
||||||
state = QValidator::Invalid;
|
|
||||||
goto end;
|
if (locale.negativeSign() != QLatin1Char('-'))
|
||||||
}
|
copy.replace(locale.negativeSign(), QLatin1Char('-'));
|
||||||
|
if (locale.positiveSign() != QLatin1Char('+'))
|
||||||
|
copy.replace(locale.positiveSign(), QLatin1Char('+'));
|
||||||
|
|
||||||
|
try {
|
||||||
|
QString copy2 = copy;
|
||||||
|
copy2.remove(locale.groupSeparator());
|
||||||
|
|
||||||
|
res = Base::Quantity::parse(copy2);
|
||||||
|
value = res.getValue();
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
catch (Base::Exception&) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = false;
|
if (!ok) {
|
||||||
double value = min;
|
// input may not be finished
|
||||||
|
|
||||||
if (locale.negativeSign() != QLatin1Char('-'))
|
|
||||||
copy.replace(locale.negativeSign(), QLatin1Char('-'));
|
|
||||||
if (locale.positiveSign() != QLatin1Char('+'))
|
|
||||||
copy.replace(locale.positiveSign(), QLatin1Char('+'));
|
|
||||||
|
|
||||||
try {
|
|
||||||
QString copy2 = copy;
|
|
||||||
copy2.remove(locale.groupSeparator());
|
|
||||||
|
|
||||||
res = Base::Quantity::parse(copy2);
|
|
||||||
value = res.getValue();
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
catch (Base::Exception&) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
// input may not be finished
|
|
||||||
state = QValidator::Intermediate;
|
|
||||||
}
|
|
||||||
else if (value >= min && value <= max) {
|
|
||||||
if (copy.endsWith(locale.decimalPoint())) {
|
|
||||||
// input shouldn't end with a decimal point
|
|
||||||
state = QValidator::Intermediate;
|
state = QValidator::Intermediate;
|
||||||
}
|
}
|
||||||
else if (res.getUnit().isEmpty() && !this->unit.isEmpty()) {
|
else if (value >= min && value <= max) {
|
||||||
// if not dimensionless the input should have a dimension
|
if (copy.endsWith(locale.decimalPoint())) {
|
||||||
state = QValidator::Intermediate;
|
// input shouldn't end with a decimal point
|
||||||
|
state = QValidator::Intermediate;
|
||||||
|
}
|
||||||
|
else if (res.getUnit().isEmpty() && !this->unit.isEmpty()) {
|
||||||
|
// if not dimensionless the input should have a dimension
|
||||||
|
state = QValidator::Intermediate;
|
||||||
|
}
|
||||||
|
else if (res.getUnit() != this->unit) {
|
||||||
|
state = QValidator::Invalid;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
state = QValidator::Acceptable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (res.getUnit() != this->unit) {
|
else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
|
||||||
state = QValidator::Invalid;
|
state = QValidator::Invalid;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state = QValidator::Acceptable;
|
if ((value >= 0 && value > max) || (value < 0 && value < min)) {
|
||||||
}
|
state = QValidator::Invalid;
|
||||||
}
|
}
|
||||||
else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
|
else {
|
||||||
state = QValidator::Invalid;
|
state = QValidator::Intermediate;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if ((value >= 0 && value > max) || (value < 0 && value < min)) {
|
|
||||||
state = QValidator::Invalid;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
state = QValidator::Intermediate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user