+ change selectNumber() to check against the locale signs

This commit is contained in:
wmayer 2014-08-11 11:07:24 +02:00
parent 17e2737062
commit b8df4593c9
2 changed files with 23 additions and 11 deletions

View File

@ -450,15 +450,21 @@ 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;

View File

@ -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;