summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qcalendarwidget.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-02-02 21:06:38 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-04 06:32:39 +0000
commit9cf6e485250a8bfaf6c478d0569900b15661b35c (patch)
tree0d80f562756f2558165e05c49895e539624b1d74 /src/widgets/widgets/qcalendarwidget.cpp
parentd024f0a9228a33787f2e9b0ecb2573041fa048df (diff)
QCalendarWidget: simplify formatNumber()
The code just does the sprintf-equivalent of %0<n>d where <n>=fieldWidth. Be explicit and use QString::rightJustified(). Change-Id: I7d72b5d62e5de581ba4207eba0d358a18f0b1972 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/widgets/qcalendarwidget.cpp')
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 673c8e7cb8..099727cbd3 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -67,16 +67,7 @@ namespace {
static QString formatNumber(int number, int fieldWidth)
{
- QString str;
- int pow = 10;
- for (int i = 0; i < fieldWidth - 1; ++i) {
- if (number / pow == 0)
- str += QLatin1Char('0');
- pow *= 10;
- }
- str += QString::number(number);
-
- return str;
+ return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
}
class QCalendarDateSectionValidator