diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index f83f97ba7..504753fbf 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -450,21 +450,27 @@ void InputField::setHistorySize(int i) void InputField::selectNumber(void) { - QByteArray str = text().toLatin1(); + QString str = text(); unsigned int i = 0; - for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) { - if (*it >= '0' && *it <= '9') + QChar d = locale().decimalPoint(); + QChar g = locale().groupSeparator(); + QChar n = locale().negativeSign(); + + for (QString::iterator it = str.begin(); it != str.end(); ++it) { + if (it->isDigit()) i++; - else if (*it == ',' || *it == '.') + else if (*it == d) i++; - else if (*it == '-') + else if (*it == g) + i++; + else if (*it == n) i++; else // any non-number character break; } - setSelection(0,i); + setSelection(0, i); } void InputField::showEvent(QShowEvent * event) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 8425e46a4..c61694f22 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -326,15 +326,21 @@ void QuantitySpinBox::clear() void QuantitySpinBox::selectNumber() { - QByteArray str = lineEdit()->text().toLatin1(); + QString str = lineEdit()->text(); unsigned int i = 0; - for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) { - if (*it >= '0' && *it <= '9') + QChar d = locale().decimalPoint(); + QChar g = locale().groupSeparator(); + QChar n = locale().negativeSign(); + + for (QString::iterator it = str.begin(); it != str.end(); ++it) { + if (it->isDigit()) i++; - else if (*it == ',' || *it == '.') + else if (*it == d) i++; - else if (*it == '-') + else if (*it == g) + i++; + else if (*it == n) i++; else // any non-number character break;