diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-02-20 17:16:29 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-05-29 14:00:10 +0000 |
commit | c0ddd5fa12f696838cb1d1de3f721f19a87c8509 (patch) | |
tree | d4678c4f5ba02b841c08af9046865a9609ab87c6 /src/gui/text/qtextlayout.cpp | |
parent | db54498fd124edc69313f64d2af8070afc104d07 (diff) |
QTextLayout: replace a use of an inefficient QList with QVector
The QTextLayout::FormatRange is larger than void* and thus should not be held in
QList. Use a QVector instead.
Other parts of Qt already hold FormatRanges in QVectors, so this also makes
handling FormatRanges more consistent.
To avoid ugly names for the getter which doesn't overload on return type alone),
rename the set of function to format (from additionalFormats).
[ChangeLog][QtGui][QTextLayout] Added QVector-based alternatives setFormat(),
format(), and clearFormat() to setAdditionalFormats(), additionalFormats(),
and clearAdditionalFormats(), resp.
Change-Id: Ie04a561b43c91c3b2befb3cac2981821f84d5f77
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 7da3e84041..dabe06fa88 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -485,7 +485,6 @@ QString QTextLayout::preeditAreaText() const return d->preeditAreaText(); } - /*! Sets the additional formats supported by the text layout to \a formatList. The formats are applied with preedit area text in place. @@ -494,7 +493,20 @@ QString QTextLayout::preeditAreaText() const */ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList) { - d->setFormats(formatList); + setFormats(formatList.toVector()); +} + +/*! + \since 5.6 + + Sets the additional formats supported by the text layout to \a formats. + The formats are applied with preedit area text in place. + + \sa formats(), clearFormats() +*/ +void QTextLayout::setFormats(const QVector<FormatRange> &formats) +{ + d->setFormats(formats); if (d->block.docHandle()) d->block.docHandle()->documentChange(d->block.position(), d->block.length()); @@ -507,6 +519,18 @@ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList) */ QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const { + return formats().toList(); +} + +/*! + \since 5.6 + + Returns the list of additional formats supported by the text layout. + + \sa setFormats(), clearFormats() +*/ +QVector<QTextLayout::FormatRange> QTextLayout::formats() const +{ return d->formats(); } @@ -521,6 +545,18 @@ void QTextLayout::clearAdditionalFormats() } /*! + \since 5.6 + + Clears the list of additional formats supported by the text layout. + + \sa formats(), setFormats() +*/ +void QTextLayout::clearFormats() +{ + setFormats(QVector<FormatRange>()); +} + +/*! Enables caching of the complete layout information if \a enable is true; otherwise disables layout caching. Usually QTextLayout throws most of the layouting information away after a |