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:
parent
d024f0a922
commit
9cf6e48525
@ -67,16 +67,7 @@ namespace {
|
|||||||
|
|
||||||
static QString formatNumber(int number, int fieldWidth)
|
static QString formatNumber(int number, int fieldWidth)
|
||||||
{
|
{
|
||||||
QString str;
|
return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class QCalendarDateSectionValidator
|
class QCalendarDateSectionValidator
|
||||||
|
Loading…
Reference in New Issue
Block a user