summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qspinbox.cpp
diff options
context:
space:
mode:
authorOto Magaldadze <omagaldadze@gmail.com>2013-09-17 14:02:49 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 12:12:16 +0100
commite913972d5268a2b1e5bfc12a0a72e4811e764d86 (patch)
tree93edbd28c651e9862fc4fd6b681d7a8d62f625bc /src/widgets/widgets/qspinbox.cpp
parentfc5d07cee3c2d0f90badd24ddab0b220492f474f (diff)
added QAbstractSpinBox::setGroupSeparatorShown function.
[ChangeLog][QtWidgets][QAbstractSpinBox] QTBUG-5142 - This will allow a group (thousand) separator to be shown in QSpinBox and QDoubleSpinBox widgets. Task-number: QTBUG-5142 Change-Id: I2e23f5f83c93bb092a2dbd784e06d17d40d42909 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qspinbox.cpp')
-rw-r--r--src/widgets/widgets/qspinbox.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index bf4e130d4e..a43b937951 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -463,8 +463,8 @@ void QSpinBox::setDisplayIntegerBase(int base)
display the given \a value. The default implementation returns a
string containing \a value printed in the standard way using
QWidget::locale().toString(), but with the thousand separator
- removed. Reimplementations may return anything. (See the example
- in the detailed description.)
+ removed unless setGroupSeparatorShown() is set. Reimplementations may
+ return anything. (See the example in the detailed description.)
Note: QSpinBox does not call this function for specialValueText()
and that neither prefix() nor suffix() should be included in the
@@ -487,7 +487,7 @@ QString QSpinBox::textFromValue(int value) const
str.prepend('-');
} else {
str = locale().toString(value);
- if (qAbs(value) >= 1000 || value == INT_MIN) {
+ if (!d->showGroupSeparator && (qAbs(value) >= 1000 || value == INT_MIN)) {
str.remove(locale().groupSeparator());
}
}
@@ -538,7 +538,8 @@ QValidator::State QSpinBox::validate(QString &text, int &pos) const
*/
void QSpinBox::fixup(QString &input) const
{
- input.remove(locale().groupSeparator());
+ if (!isGroupSeparatorShown())
+ input.remove(locale().groupSeparator());
}
@@ -891,7 +892,8 @@ void QDoubleSpinBox::setDecimals(int decimals)
display the given \a value. The default implementation returns a string
containing \a value printed using QWidget::locale().toString(\a value,
QLatin1Char('f'), decimals()) and will remove the thousand
- separator. Reimplementations may return anything.
+ separator unless setGroupSeparatorShown() is set. Reimplementations may
+ return anything.
Note: QDoubleSpinBox does not call this function for
specialValueText() and that neither prefix() nor suffix() should
@@ -908,9 +910,9 @@ QString QDoubleSpinBox::textFromValue(double value) const
{
Q_D(const QDoubleSpinBox);
QString str = locale().toString(value, 'f', d->decimals);
- if (qAbs(value) >= 1000.0) {
+ if (!d->showGroupSeparator && qAbs(value) >= 1000.0)
str.remove(locale().groupSeparator());
- }
+
return str;
}