Skip to content

Commit

Permalink
+ change selectNumber() to check against the locale signs
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 11, 2014
1 parent 17e2737 commit b8df459
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/Gui/InputField.cpp
Expand Up @@ -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 == d)
i++;
else if (*it == ',' || *it == '.')
else if (*it == g)
i++;
else if (*it == '-')
else if (*it == n)
i++;
else // any non-number character
break;
}

setSelection(0,i);
setSelection(0, i);
}

void InputField::showEvent(QShowEvent * event)
Expand Down
16 changes: 11 additions & 5 deletions src/Gui/QuantitySpinBox.cpp
Expand Up @@ -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 == d)
i++;
else if (*it == ',' || *it == '.')
else if (*it == g)
i++;
else if (*it == '-')
else if (*it == n)
i++;
else // any non-number character
break;
Expand Down

0 comments on commit b8df459

Please sign in to comment.