Adding selectNumber handling of locale, this wont work with groupseparators

This commit is contained in:
Johan K 2014-08-03 22:31:57 +02:00
parent 5cfdabb45a
commit 83a5f1547f
2 changed files with 8 additions and 5 deletions

View File

@ -450,16 +450,17 @@ void InputField::setHistorySize(int i)
void InputField::selectNumber(void)
{
QByteArray str = text().toLatin1();
QString input = text();
fixup(input);
QByteArray str = input.toLatin1();
unsigned int i = 0;
Base::Console().Message("%i", locale().negativeSign().toAscii());
for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) {
if (*it >= '0' && *it <= '9')
i++;
else if (*it == ',' || *it == '.')
i++;
else if (*it == '-' || *it == locale().negativeSign().toAscii())
else if (*it == '-' )
i++;
else // any non-number character
break;

View File

@ -326,7 +326,9 @@ void QuantitySpinBox::clear()
void QuantitySpinBox::selectNumber()
{
QByteArray str = lineEdit()->text().toLatin1();
QString input = lineEdit()->text();
fixup(input);
QByteArray str = input.toLatin1();
unsigned int i = 0;
for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) {
@ -334,7 +336,7 @@ void QuantitySpinBox::selectNumber()
i++;
else if (*it == ',' || *it == '.')
i++;
else if (*it == '-' || *it == locale().negativeSign().toAscii())
else if (*it == '-' )
i++;
else // any non-number character
break;