diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-05-31 17:26:27 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-06-01 13:09:48 +0000 |
commit | 926b898a9ca0778b30a5cb3eb01f826754b08f8b (patch) | |
tree | 8c9800f17d9b84492defba2fc4b228ec43ee0038 /src/svg | |
parent | 0a3d8caa793c5412ccbba69ebe04178c65ab1040 (diff) | |
download | qtsvg-926b898a9ca0778b30a5cb3eb01f826754b08f8b.tar.gz |
Fix users of QTextLayout::additionalFormats to use the new API
QTextLayout::additionalFormats setters and getters using QList<FormatRange> have
been deprecated; port to the QVector versions.
Also perform two drive-by optimizations: using resize() instead of push_back()
to append default-constructed elements (saving one or two copy ctor calls).
Change-Id: I8b6d424f9d3ba2eb0f12098f92bb7bee11ab6d76
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvggraphics.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index 3a3830d..e297a76 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -311,9 +311,8 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states) bool appendSpace = false; QVector<QString> paragraphs; QStack<QTextCharFormat> formats; - QVector<QList<QTextLayout::FormatRange> > formatRanges; + QVector<QVector<QTextLayout::FormatRange> > formatRanges(1); paragraphs.push_back(QString()); - formatRanges.push_back(QList<QTextLayout::FormatRange>()); for (int i = 0; i < m_tspans.size(); ++i) { if (m_tspans[i] == LINEBREAK) { @@ -332,7 +331,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states) } appendSpace = false; paragraphs.push_back(QString()); - formatRanges.push_back(QList<QTextLayout::FormatRange>()); + formatRanges.resize(formatRanges.size() + 1); } } else { WhitespaceMode mode = m_tspans[i]->whitespaceMode(); @@ -394,7 +393,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states) QTextOption op = tl.textOption(); op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); tl.setTextOption(op); - tl.setAdditionalFormats(formatRanges[i]); + tl.setFormats(formatRanges[i]); tl.beginLayout(); forever { |