diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-16 21:55:23 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-16 21:55:23 (GMT) |
commit | 1f5e32a11114370e4364fcfa77b9c4ab4bf192a3 (patch) | |
tree | 5761a1e1d6dfac01c50d1c91187c20378383fe6f /src/gui/text/qtextlist.cpp | |
parent | f60dea8315fef502f6f4c6941455a51bee66efd9 (diff) | |
parent | 6470f646d0815f67bab507c1362cdda775c42a6e (diff) | |
download | Qt-1f5e32a11114370e4364fcfa77b9c4ab4bf192a3.zip Qt-1f5e32a11114370e4364fcfa77b9c4ab4bf192a3.tar.gz Qt-1f5e32a11114370e4364fcfa77b9c4ab4bf192a3.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-gv
Conflicts:
src/declarative/fx/qfxitem.h
src/declarative/util/qfxview.h
src/gui/graphicsview/qgraphicsitem_p.h
Diffstat (limited to 'src/gui/text/qtextlist.cpp')
-rw-r--r-- | src/gui/text/qtextlist.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp index addd7a5..02b1c63 100644 --- a/src/gui/text/qtextlist.cpp +++ b/src/gui/text/qtextlist.cpp @@ -212,6 +212,55 @@ QString QTextList::itemText(const QTextBlock &blockIt) const } } break; + case QTextListFormat::ListLowerRoman: + case QTextListFormat::ListUpperRoman: + { + if (item < 5000) { + QByteArray romanNumeral; + + // works for up to 4999 items + static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm"; + static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM"; + QByteArray romanSymbols; // wrap to have "mid" + if (style == QTextListFormat::ListLowerRoman) + romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); + else + romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); + + int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 }; + int n = item; + for (int i = 12; i >= 0; n %= c[i], i--) { + int q = n / c[i]; + if (q > 0) { + int startDigit = i + (i+3)/4; + int numDigits; + if (i % 4) { + // c[i] == 4|5|9|40|50|90|400|500|900 + if ((i-2) % 4) { + // c[i] == 4|9|40|90|400|900 => with substraction (IV, IX, XL, XC, ...) + numDigits = 2; + } + else { + // c[i] == 5|50|500 (V, L, D) + numDigits = 1; + } + } + else { + // c[i] == 1|10|100|1000 (I, II, III, X, XX, ...) + numDigits = q; + } + + romanNumeral.append(romanSymbols.mid(startDigit, numDigits)); + } + } + result = QString::fromLatin1(romanNumeral); + } + else { + result = QLatin1String("?"); + } + + } + break; default: Q_ASSERT(false); } |