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>
This commit is contained in:
Marc Mutz 2015-02-02 21:06:38 +01:00
parent d024f0a922
commit 9cf6e48525

View File

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