+ fix regression in selectNumber(), + little performance boost, fix whitespaces

This commit is contained in:
wmayer 2014-08-11 10:46:43 +02:00
parent 915ea8a609
commit 17e2737062
2 changed files with 12 additions and 16 deletions

View File

@ -450,9 +450,7 @@ void InputField::setHistorySize(int i)
void InputField::selectNumber(void)
{
QString input = text();
fixup(input);
QByteArray str = input.toLatin1();
QByteArray str = text().toLatin1();
unsigned int i = 0;
for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) {
@ -460,7 +458,7 @@ void InputField::selectNumber(void)
i++;
else if (*it == ',' || *it == '.')
i++;
else if (*it == '-' )
else if (*it == '-')
i++;
else // any non-number character
break;
@ -531,10 +529,10 @@ void InputField::wheelEvent (QWheelEvent * event)
void InputField::fixup(QString& input) const
{
input.remove(locale().groupSeparator());
if(locale().negativeSign() != QChar::fromAscii('-'))
input.replace(locale().negativeSign(), QChar::fromAscii('-'));
if(locale().positiveSign() != QChar::fromAscii('+'))
input.replace(locale().positiveSign(), QChar::fromAscii('+'));
if (locale().negativeSign() != QLatin1Char('-'))
input.replace(locale().negativeSign(), QLatin1Char('-'));
if (locale().positiveSign() != QLatin1Char('+'))
input.replace(locale().positiveSign(), QLatin1Char('+'));
}
QValidator::State InputField::validate(QString& input, int& pos) const

View File

@ -326,9 +326,7 @@ void QuantitySpinBox::clear()
void QuantitySpinBox::selectNumber()
{
QString input = lineEdit()->text();
fixup(input);
QByteArray str = input.toLatin1();
QByteArray str = lineEdit()->text().toLatin1();
unsigned int i = 0;
for (QByteArray::iterator it = str.begin(); it != str.end(); ++it) {
@ -336,7 +334,7 @@ void QuantitySpinBox::selectNumber()
i++;
else if (*it == ',' || *it == '.')
i++;
else if (*it == '-' )
else if (*it == '-')
i++;
else // any non-number character
break;
@ -381,10 +379,10 @@ QValidator::State QuantitySpinBox::validate(QString &text, int &pos) const
void QuantitySpinBox::fixup(QString &input) const
{
input.remove(locale().groupSeparator());
if(locale().negativeSign() != QChar::fromAscii('-'))
input.replace(locale().negativeSign(), QChar::fromAscii('-'));
if(locale().positiveSign() != QChar::fromAscii('+'))
input.replace(locale().positiveSign(), QChar::fromAscii('+'));
if (locale().negativeSign() != QLatin1Char('-'))
input.replace(locale().negativeSign(), QLatin1Char('-'));
if (locale().positiveSign() != QLatin1Char('+'))
input.replace(locale().positiveSign(), QLatin1Char('+'));
}