diff options
Diffstat (limited to 'src/gui/text')
32 files changed, 220 insertions, 78 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 70be92535d..7735fd6b46 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -40,6 +40,15 @@ QT_BEGIN_NAMESPACE +QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate() +{ +} + +QTextObjectInterface::~QTextObjectInterface() +{ + // must be empty until ### Qt 6 +} + /*! \class QAbstractTextDocumentLayout \reentrant diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h index 27135b0476..68e7a0e4e9 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -126,7 +126,7 @@ private: class Q_GUI_EXPORT QTextObjectInterface { public: - virtual ~QTextObjectInterface() {} + virtual ~QTextObjectInterface(); virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0; virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0; }; diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h index 505135fa4b..a7f28ebf96 100644 --- a/src/gui/text/qabstracttextdocumentlayout_p.h +++ b/src/gui/text/qabstracttextdocumentlayout_p.h @@ -58,13 +58,14 @@ struct QTextObjectHandler }; typedef QHash<int, QTextObjectHandler> HandlerHash; -class QAbstractTextDocumentLayoutPrivate : public QObjectPrivate +class Q_GUI_EXPORT QAbstractTextDocumentLayoutPrivate : public QObjectPrivate { public: Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout) inline QAbstractTextDocumentLayoutPrivate() : paintDevice(0) {} + ~QAbstractTextDocumentLayoutPrivate(); inline void setDocument(QTextDocument *doc) { document = doc; diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 3c98cb568d..adbb3df3bf 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -461,6 +461,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m) } QList<QVariant> v; + v.reserve(4); for (i = 0; i < 4; i++) { v += QVariant::fromValue<LengthData>(datas[i]); m[i] = lengthValueFromData(datas[i], f); diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 3c6709e685..796f223797 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1860,14 +1860,9 @@ void QFont::removeSubstitutions(const QString &familyName) */ QStringList QFont::substitutions() { - typedef QFontSubst::const_iterator QFontSubstConstIterator; - QFontSubst *fontSubst = globalFontSubst(); Q_ASSERT(fontSubst != 0); - QStringList ret; - const QFontSubstConstIterator cend = fontSubst->constEnd(); - for (QFontSubstConstIterator it = fontSubst->constBegin(); it != cend; ++it) - ret.append(it.key()); + QStringList ret = fontSubst->keys(); ret.sort(); return ret; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 6b7a9837cb..0b0940855d 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1369,22 +1369,30 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const QT_PREPEND_NAMESPACE(load)(); - QList<WritingSystem> list; + quint64 writingSystemsFound = 0; + Q_STATIC_ASSERT(WritingSystemsCount < 64); + for (int i = 0; i < d->count; ++i) { QtFontFamily *family = d->families[i]; family->ensurePopulated(); if (family->count == 0) continue; - for (int x = Latin; x < WritingSystemsCount; ++x) { - const WritingSystem writingSystem = WritingSystem(x); - if (!(family->writingSystems[writingSystem] & QtFontFamily::Supported)) - continue; - if (!list.contains(writingSystem)) - list.append(writingSystem); + for (uint x = Latin; x < uint(WritingSystemsCount); ++x) { + if (family->writingSystems[x] & QtFontFamily::Supported) + writingSystemsFound |= quint64(1) << x; } } - std::sort(list.begin(), list.end()); + + // mutex protection no longer needed - just working on local data now: + locker.unlock(); + + QList<WritingSystem> list; + list.reserve(qPopulationCount(writingSystemsFound)); + for (uint x = Latin ; x < uint(WritingSystemsCount); ++x) { + if (writingSystemsFound & (quint64(1) << x)) + list.push_back(WritingSystem(x)); + } return list; } diff --git a/src/gui/text/qfontengineglyphcache.cpp b/src/gui/text/qfontengineglyphcache.cpp new file mode 100644 index 0000000000..f6fdfa3ce3 --- /dev/null +++ b/src/gui/text/qfontengineglyphcache.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <private/qfontengineglyphcache_p.h> + +QT_BEGIN_NAMESPACE + +// out-of-line to avoid vtable duplication, breaking e.g. RTTI +QFontEngineGlyphCache::~QFontEngineGlyphCache() +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index 6cf4d2f1ba..def42c22a3 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -class QFontEngineGlyphCache: public QSharedData +class Q_GUI_EXPORT QFontEngineGlyphCache: public QSharedData { public: QFontEngineGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) : m_format(format), m_transform(matrix) @@ -64,7 +64,7 @@ public: Q_ASSERT(m_format != QFontEngine::Format_None); } - virtual ~QFontEngineGlyphCache() { } + virtual ~QFontEngineGlyphCache(); QFontEngine::GlyphFormat glyphFormat() const { return m_format; } const QTransform &transform() const { return m_transform; } diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 9f652084be..dc32405f36 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -350,6 +350,7 @@ struct qttf_head_table { quint16 macStyle; qint16 indexToLocFormat; }; +Q_DECLARE_TYPEINFO(qttf_head_table, Q_PRIMITIVE_TYPE); struct qttf_hhea_table { @@ -362,6 +363,7 @@ struct qttf_hhea_table { qint16 xMaxExtent; quint16 numberOfHMetrics; }; +Q_DECLARE_TYPEINFO(qttf_hhea_table, Q_PRIMITIVE_TYPE); struct qttf_maxp_table { @@ -373,6 +375,7 @@ struct qttf_maxp_table { quint16 maxComponentElements; quint16 maxComponentDepth; }; +Q_DECLARE_TYPEINFO(qttf_maxp_table, Q_PRIMITIVE_TYPE); struct qttf_name_table { QString copyright; @@ -380,6 +383,7 @@ struct qttf_name_table { QString subfamily; QString postscript_name; }; +Q_DECLARE_TYPEINFO(qttf_name_table, Q_MOVABLE_TYPE); static QTtfTable generateHead(const qttf_head_table &head); @@ -411,9 +415,9 @@ Q_DECLARE_TYPEINFO(QTtfGlyph, Q_MOVABLE_TYPE); static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advance, qreal lsb, qreal ppem); // generates glyf, loca and hmtx -static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QList<QTtfGlyph> &_glyphs); +static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QVector<QTtfGlyph> &_glyphs); -static QByteArray bindFont(const QList<QTtfTable>& _tables); +static QByteArray bindFont(const QVector<QTtfTable>& _tables); static quint32 checksum(const QByteArray &table) @@ -607,12 +611,13 @@ struct QTtfNameRecord { quint16 nameId; QString value; }; +Q_DECLARE_TYPEINFO(QTtfNameRecord, Q_MOVABLE_TYPE); -static QTtfTable generateName(const QList<QTtfNameRecord> &name); +static QTtfTable generateName(const QVector<QTtfNameRecord> &name); static QTtfTable generateName(const qttf_name_table &name) { - QList<QTtfNameRecord> list; + QVector<QTtfNameRecord> list; QTtfNameRecord rec; rec.nameId = 0; rec.value = name.copyright; @@ -636,7 +641,7 @@ static QTtfTable generateName(const qttf_name_table &name) } // ####### should probably generate Macintosh/Roman name entries as well -static QTtfTable generateName(const QList<QTtfNameRecord> &name) +static QTtfTable generateName(const QVector<QTtfNameRecord> &name) { const int char_size = 2; @@ -707,7 +712,7 @@ struct TTF_POINT { }; Q_DECLARE_TYPEINFO(TTF_POINT, Q_PRIMITIVE_TYPE); -static void convertPath(const QPainterPath &path, QList<TTF_POINT> *points, QList<int> *endPoints, qreal ppem) +static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QVector<int> *endPoints, qreal ppem) { int numElements = path.elementCount(); for (int i = 0; i < numElements - 1; ++i) { @@ -829,7 +834,7 @@ static void convertPath(const QPainterPath &path, QList<TTF_POINT> *points, QLis endPoints->append(points->size() - 1); } -static void getBounds(const QList<TTF_POINT> &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax) +static void getBounds(const QVector<TTF_POINT> &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax) { *xmin = points.at(0).x; *xmax = *xmin; @@ -844,7 +849,7 @@ static void getBounds(const QList<TTF_POINT> &points, qint16 *xmin, qint16 *xmax } } -static int convertToRelative(QList<TTF_POINT> *points) +static int convertToRelative(QVector<TTF_POINT> *points) { // convert points to relative and setup flags // qDebug() << "relative points:"; @@ -897,7 +902,7 @@ static int convertToRelative(QList<TTF_POINT> *points) return point_array_size; } -static void getGlyphData(QTtfGlyph *glyph, const QList<TTF_POINT> &points, const QList<int> &endPoints, int point_array_size) +static void getGlyphData(QTtfGlyph *glyph, const QVector<TTF_POINT> &points, const QVector<int> &endPoints, int point_array_size) { const int max_size = 5*sizeof(qint16) // header + endPoints.size()*sizeof(quint16) // end points of contours @@ -947,8 +952,8 @@ static void getGlyphData(QTtfGlyph *glyph, const QList<TTF_POINT> &points, const static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advance, qreal lsb, qreal ppem) { - QList<TTF_POINT> points; - QList<int> endPoints; + QVector<TTF_POINT> points; + QVector<int> endPoints; QTtfGlyph glyph; glyph.index = index; glyph.advanceWidth = qRound(advance * 2048. / ppem); @@ -983,10 +988,10 @@ static bool operator <(const QTtfGlyph &g1, const QTtfGlyph &g2) return g1.index < g2.index; } -static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QList<QTtfGlyph> &_glyphs) +static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QVector<QTtfGlyph> &_glyphs) { const int max_size_small = 65536*2; - QList<QTtfGlyph> glyphs = _glyphs; + QVector<QTtfGlyph> glyphs = _glyphs; std::sort(glyphs.begin(), glyphs.end()); Q_ASSERT(tables.maxp.numGlyphs == glyphs.at(glyphs.size()-1).index + 1); @@ -1049,7 +1054,7 @@ static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QLis Q_ASSERT(loca.data.size() == ls.offset()); Q_ASSERT(hmtx.data.size() == hs.offset()); - QList<QTtfTable> list; + QVector<QTtfTable> list; list.append(glyf); list.append(loca); list.append(hmtx); @@ -1061,9 +1066,9 @@ static bool operator <(const QTtfTable &t1, const QTtfTable &t2) return t1.tag < t2.tag; } -static QByteArray bindFont(const QList<QTtfTable>& _tables) +static QByteArray bindFont(const QVector<QTtfTable>& _tables) { - QList<QTtfTable> tables = _tables; + QVector<QTtfTable> tables = _tables; std::sort(tables.begin(), tables.end()); @@ -1154,7 +1159,7 @@ QByteArray QFontSubset::toTruetype() const qreal ppem = fontEngine->fontDef.pixelSize; #define TO_TTF(x) qRound(x * 2048. / ppem) - QList<QTtfGlyph> glyphs; + QVector<QTtfGlyph> glyphs; QFontEngine::Properties properties = fontEngine->properties(); // initialize some stuff needed in createWidthArray @@ -1225,7 +1230,7 @@ QByteArray QFontSubset::toTruetype() const } - QList<QTtfTable> tables = generateGlyphTables(font, glyphs); + QVector<QTtfTable> tables = generateGlyphTables(font, glyphs); tables.append(generateHead(font.head)); tables.append(generateHhea(font.hhea)); tables.append(generateMaxp(font.maxp)); diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h index da8589de3f..4abdb48c0d 100644 --- a/src/gui/text/qfontsubset_p.h +++ b/src/gui/text/qfontsubset_p.h @@ -79,7 +79,7 @@ public: const int object_id; bool noEmbed; QFontEngine *fontEngine; - QList<int> glyph_indices; + QVector<int> glyph_indices; mutable int downloaded_glyphs; mutable bool standard_font; int nGlyphs() const { return glyph_indices.size(); } diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp index e6d6863134..642313d340 100644 --- a/src/gui/text/qglyphrun.cpp +++ b/src/gui/text/qglyphrun.cpp @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE \ingroup text \ingroup shared - \mainclass When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index d3034b7546..9f51a49a6d 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -59,9 +59,13 @@ public: QGlyphRun(); QGlyphRun(const QGlyphRun &other); +#ifdef Q_COMPILER_RVALUE_REFS + QGlyphRun &operator=(QGlyphRun &&other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif + QGlyphRun &operator=(const QGlyphRun &other); ~QGlyphRun(); - void swap(QGlyphRun &other) { qSwap(d, other.d); } + void swap(QGlyphRun &other) Q_DECL_NOTHROW { qSwap(d, other.d); } QRawFont rawFont() const; void setRawFont(const QRawFont &rawFont); @@ -78,8 +82,6 @@ public: void clear(); - QGlyphRun &operator=(const QGlyphRun &other); - bool operator==(const QGlyphRun &other) const; inline bool operator!=(const QGlyphRun &other) const { return !operator==(other); } diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 0615df65d6..3331d96f8b 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -47,7 +47,9 @@ #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> +#if QT_DEPRECATED_SINCE(5, 5) #include <QtCore/QHash> +#endif #include <QtGui/QFontDatabase> #include <QtGui/private/qfontengine_p.h> #include <QtGui/private/qfont_p.h> diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index fedf58872b..0fd5f510c7 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE \ingroup text \ingroup shared - \mainclass \note QRawFont is a low level class. For most purposes QFont is a more appropriate class. diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 3798555de5..d710658a9b 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -72,13 +72,15 @@ public: qreal pixelSize, QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting); QRawFont(const QRawFont &other); +#ifdef Q_COMPILER_RVALUE_REFS + QRawFont &operator=(QRawFont &&other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif + QRawFont &operator=(const QRawFont &other); ~QRawFont(); - bool isValid() const; + void swap(QRawFont &other) Q_DECL_NOTHROW { qSwap(d, other.d); } - QRawFont &operator=(const QRawFont &other); - - void swap(QRawFont &other) { qSwap(d, other.d); } + bool isValid() const; bool operator==(const QRawFont &other) const; inline bool operator!=(const QRawFont &other) const diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index fc95a859e7..5d31ab9711 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -39,6 +39,10 @@ QT_BEGIN_NAMESPACE +QStaticTextUserData::~QStaticTextUserData() +{ +} + /*! \class QStaticText \brief The QStaticText class enables optimized drawing of text when the text and its layout @@ -49,7 +53,6 @@ QT_BEGIN_NAMESPACE \ingroup multimedia \ingroup text \ingroup shared - \mainclass QStaticText provides a way to cache layout data for a block of text so that it can be drawn more efficiently than by using QPainter::drawText() in which the layout information is diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index d2825e73ac..0a1d9429b4 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -57,9 +57,13 @@ public: QStaticText(); QStaticText(const QString &text); QStaticText(const QStaticText &other); +#ifdef Q_COMPILER_RVALUE_REFS + QStaticText &operator=(QStaticText &&other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif + QStaticText &operator=(const QStaticText &); ~QStaticText(); - void swap(QStaticText &other) { qSwap(data, other.data); } + void swap(QStaticText &other) Q_DECL_NOTHROW { qSwap(data, other.data); } void setText(const QString &text); QString text() const; @@ -80,7 +84,6 @@ public: void setPerformanceHint(PerformanceHint performanceHint); PerformanceHint performanceHint() const; - QStaticText &operator=(const QStaticText &); bool operator==(const QStaticText &) const; bool operator!=(const QStaticText &) const; diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 088e49e2fc..49ca24d51c 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -52,7 +52,8 @@ QT_BEGIN_NAMESPACE -class QStaticTextUserData +// ### Qt 6: Unexport again, if QOpenGLStaticTextUserData (the one from QtOpenGL) is gone by then +class Q_GUI_EXPORT QStaticTextUserData { public: enum Type { @@ -61,7 +62,7 @@ public: }; QStaticTextUserData(Type t) : ref(0), type(t) {} - virtual ~QStaticTextUserData() {} + virtual ~QStaticTextUserData(); QAtomicInt ref; Type type; diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 162c646a98..f180a839b7 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -90,13 +90,13 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() QTextLayout *layout = currentBlock.layout(); - QList<QTextLayout::FormatRange> ranges = layout->additionalFormats(); + QVector<QTextLayout::FormatRange> ranges = layout->formats(); const int preeditAreaStart = layout->preeditAreaPosition(); const int preeditAreaLength = layout->preeditAreaText().length(); if (preeditAreaLength != 0) { - QList<QTextLayout::FormatRange>::Iterator it = ranges.begin(); + QVector<QTextLayout::FormatRange>::Iterator it = ranges.begin(); while (it != ranges.end()) { if (it->start >= preeditAreaStart && it->start + it->length <= preeditAreaStart + preeditAreaLength) { @@ -142,7 +142,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } if (formatsChanged) { - layout->setAdditionalFormats(ranges); + layout->setFormats(ranges); doc->markContentsDirty(currentBlock.position(), currentBlock.length()); } } @@ -329,7 +329,7 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc) QTextCursor cursor(d->doc); cursor.beginEditBlock(); for (QTextBlock blk = d->doc->begin(); blk.isValid(); blk = blk.next()) - blk.layout()->clearAdditionalFormats(); + blk.layout()->clearFormats(); cursor.endEditBlock(); } d->doc = doc; diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index f04055603c..350f38cd02 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -66,10 +66,13 @@ public: explicit QTextCursor(const QTextBlock &block); explicit QTextCursor(QTextCursorPrivate *d); QTextCursor(const QTextCursor &cursor); +#ifdef Q_COMPILER_RVALUE_REFS + QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif QTextCursor &operator=(const QTextCursor &other); ~QTextCursor(); - void swap(QTextCursor &other) { qSwap(d, other.d); } + void swap(QTextCursor &other) Q_DECL_NOTHROW { qSwap(d, other.d); } bool isNull() const; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index d3b70aaf26..3d248f4afc 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1949,7 +1949,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); srcBlock.isValid() && dstBlock.isValid(); srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { - dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats()); + dstBlock.layout()->setFormats(srcBlock.layout()->formats()); } QAbstractTextDocumentLayout *layout = doc->documentLayout(); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 5864ca0b1a..7d75e649b0 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -106,7 +106,7 @@ public: bool sizeDirty; bool layoutDirty; - QList<QPointer<QTextFrame> > floats; + QVector<QPointer<QTextFrame> > floats; }; QTextFrameData::QTextFrameData() @@ -1071,7 +1071,9 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain it = frameIteratorForYPosition(QFixed::fromReal(context.clip.top())); QList<QTextFrame *> floats; - for (int i = 0; i < fd->floats.count(); ++i) + const int numFloats = fd->floats.count(); + floats.reserve(numFloats); + for (int i = 0; i < numFloats; ++i) floats.append(fd->floats.at(i)); drawFlow(off, painter, context, it, floats, &cursorBlockNeedingRepaint); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 67a19804a3..e87711ef99 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2571,7 +2571,7 @@ void QTextEngine::setPreeditArea(int position, const QString &preeditText) clearLineData(); } -void QTextEngine::setFormats(const QList<QTextLayout::FormatRange> &formats) +void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats) { if (formats.isEmpty()) { if (!specialData) @@ -2863,6 +2863,7 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const if (!tabArray.isEmpty()) { if (isRightToLeft()) { // rebase the tabArray positions. QList<QTextOption::Tab> newTabs; + newTabs.reserve(tabArray.count()); QList<QTextOption::Tab>::Iterator iter = tabArray.begin(); while(iter != tabArray.end()) { QTextOption::Tab tab = *iter; @@ -2946,17 +2947,17 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const namespace { class FormatRangeComparatorByStart { - const QList<QTextLayout::FormatRange> &list; + const QVector<QTextLayout::FormatRange> &list; public: - FormatRangeComparatorByStart(const QList<QTextLayout::FormatRange> &list) : list(list) { } + FormatRangeComparatorByStart(const QVector<QTextLayout::FormatRange> &list) : list(list) { } bool operator()(int a, int b) { return list.at(a).start < list.at(b).start; } }; class FormatRangeComparatorByEnd { - const QList<QTextLayout::FormatRange> &list; + const QVector<QTextLayout::FormatRange> &list; public: - FormatRangeComparatorByEnd(const QList<QTextLayout::FormatRange> &list) : list(list) { } + FormatRangeComparatorByEnd(const QVector<QTextLayout::FormatRange> &list) : list(list) { } bool operator()(int a, int b) { return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length; } diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 39b9e0cb5a..3590c6da07 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -570,9 +570,9 @@ public: inline bool hasFormats() const { return block.docHandle() || (specialData && !specialData->formats.isEmpty()); } - inline QList<QTextLayout::FormatRange> formats() const - { return specialData ? specialData->formats : QList<QTextLayout::FormatRange>(); } - void setFormats(const QList<QTextLayout::FormatRange> &formats); + inline QVector<QTextLayout::FormatRange> formats() const + { return specialData ? specialData->formats : QVector<QTextLayout::FormatRange>(); } + void setFormats(const QVector<QTextLayout::FormatRange> &formats); private: static void init(QTextEngine *e); @@ -580,7 +580,7 @@ private: struct SpecialData { int preeditPosition; QString preeditText; - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QVector<QTextCharFormat> resolvedFormats; // only used when no docHandle is available QScopedPointer<QTextFormatCollection> formatCollection; diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index ba4bdcc5ad..7dcd060ba1 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -38,7 +38,7 @@ #include <qdatastream.h> #include <qdebug.h> #include <qmap.h> -#include <qhash.h> +#include <qhashfunctions.h> QT_BEGIN_NAMESPACE @@ -1115,7 +1115,9 @@ void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value) if (!d) d = new QTextFormatPrivate; QVariantList list; - for (int i=0; i<value.size(); ++i) + const int numValues = value.size(); + list.reserve(numValues); + for (int i = 0; i < numValues; ++i) list << value.at(i); d->insertProperty(propertyId, list); } @@ -2041,6 +2043,7 @@ QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt) void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs) { QList<QVariant> list; + list.reserve(tabs.count()); QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin(); while (iter != tabs.constEnd()) { QVariant v; @@ -2065,6 +2068,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const QList<QTextOption::Tab> answer; QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant); QList<QVariant>::Iterator iter = variantsList.begin(); + answer.reserve(variantsList.count()); while(iter != variantsList.end()) { answer.append( qvariant_cast<QTextOption::Tab>(*iter)); ++iter; diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 29656bbafe..928cef6488 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -47,7 +47,6 @@ #include "QtGui/qtextformat.h" #include "QtCore/qvector.h" -#include "QtCore/qhash.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 7da3e84041..c42054c07c 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE for a specified area in the text layout's content. \inmodule QtGui - \sa QTextLayout::setAdditionalFormats(), QTextLayout::draw() + \sa QTextLayout::setFormats(), QTextLayout::draw() */ /*! @@ -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(); } @@ -517,7 +541,19 @@ QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const */ void QTextLayout::clearAdditionalFormats() { - setAdditionalFormats(QList<FormatRange>()); + clearFormats(); +} + +/*! + \since 5.6 + + Clears the list of additional formats supported by the text layout. + + \sa formats(), setFormats() +*/ +void QTextLayout::clearFormats() +{ + setFormats(QVector<FormatRange>()); } /*! diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 47dcd388e2..9709af4fd1 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -125,10 +125,18 @@ public: int start; int length; QTextCharFormat format; + + friend bool operator==(const FormatRange &lhs, const FormatRange &rhs) + { return lhs.start == rhs.start && lhs.length == rhs.length && lhs.format == rhs.format; } + friend bool operator!=(const FormatRange &lhs, const FormatRange &rhs) + { return !operator==(lhs, rhs); } }; void setAdditionalFormats(const QList<FormatRange> &overrides); QList<FormatRange> additionalFormats() const; void clearAdditionalFormats(); + void setFormats(const QVector<FormatRange> &overrides); + QVector<FormatRange> formats() const; + void clearFormats(); void setCacheEnabled(bool enable); bool cacheEnabled() const; diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index dbafcfd58e..5a4f6b7954 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -146,6 +146,7 @@ void QTextOption::setTabArray(const QList<qreal> &tabStops) d = new QTextOptionPrivate; QList<QTextOption::Tab> tabs; QTextOption::Tab tab; + tabs.reserve(tabStops.count()); foreach (qreal pos, tabStops) { tab.position = pos; tabs.append(tab); @@ -174,10 +175,11 @@ void QTextOption::setTabs(const QList<QTextOption::Tab> &tabStops) */ QList<qreal> QTextOption::tabArray() const { + QList<qreal> answer; if (!d) - return QList<qreal>(); + return answer; - QList<qreal> answer; + answer.reserve(d->tabStops.count()); QList<QTextOption::Tab>::ConstIterator iter = d->tabStops.constBegin(); while(iter != d->tabStops.constEnd()) { answer.append( (*iter).position); diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index 1d621db0e6..40088d573a 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -303,6 +303,7 @@ enum HostOS { HostOS400 = 18, HostOSX = 19 }; +Q_DECLARE_TYPEINFO(HostOS, Q_PRIMITIVE_TYPE); enum GeneralPurposeFlag { Encrypted = 0x01, @@ -314,6 +315,7 @@ enum GeneralPurposeFlag { Utf8Names = 0x0800, CentralDirectoryEncrypted = 0x2000 }; +Q_DECLARE_TYPEINFO(GeneralPurposeFlag, Q_PRIMITIVE_TYPE); enum CompressionMethod { CompressionMethodStored = 0, @@ -340,6 +342,7 @@ enum CompressionMethod { CompressionMethodPPMd = 98, CompressionMethodWzAES = 99 }; +Q_DECLARE_TYPEINFO(CompressionMethod, Q_PRIMITIVE_TYPE); struct LocalFileHeader { @@ -354,6 +357,7 @@ struct LocalFileHeader uchar file_name_length[2]; uchar extra_field_length[2]; }; +Q_DECLARE_TYPEINFO(LocalFileHeader, Q_PRIMITIVE_TYPE); struct DataDescriptor { @@ -361,6 +365,7 @@ struct DataDescriptor uchar compressed_size[4]; uchar uncompressed_size[4]; }; +Q_DECLARE_TYPEINFO(DataDescriptor, Q_PRIMITIVE_TYPE); struct CentralFileHeader { @@ -382,6 +387,7 @@ struct CentralFileHeader uchar offset_local_header[4]; LocalFileHeader toLocalHeader() const; }; +Q_DECLARE_TYPEINFO(CentralFileHeader, Q_PRIMITIVE_TYPE); struct EndOfDirectory { @@ -394,6 +400,7 @@ struct EndOfDirectory uchar dir_start_offset[4]; uchar comment_length[2]; }; +Q_DECLARE_TYPEINFO(EndOfDirectory, Q_PRIMITIVE_TYPE); struct FileHeader { @@ -402,6 +409,7 @@ struct FileHeader QByteArray extra_field; QByteArray file_comment; }; +Q_DECLARE_TYPEINFO(FileHeader, Q_MOVABLE_TYPE); QZipReader::FileInfo::FileInfo() : isDir(false), isFile(false), isSymLink(false), crc(0), size(0) @@ -917,7 +925,9 @@ QList<QZipReader::FileInfo> QZipReader::fileInfoList() const { d->scanFiles(); QList<QZipReader::FileInfo> files; - for (int i = 0; i < d->fileHeaders.size(); ++i) { + const int numFileHeaders = d->fileHeaders.size(); + files.reserve(numFileHeaders); + for (int i = 0; i < numFileHeaders; ++i) { QZipReader::FileInfo fi; d->fillFileInfo(i, fi); files.append(fi); diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index df7e2d26e9..7a18dc7340 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -111,6 +111,8 @@ private: QZipReaderPrivate *d; Q_DISABLE_COPY(QZipReader) }; +Q_DECLARE_TYPEINFO(QZipReader::FileInfo, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QZipReader::Status, Q_PRIMITIVE_TYPE); QT_END_NAMESPACE diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index 61e239f678..be60ba72cc 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -21,6 +21,7 @@ HEADERS += \ text/qtextdocument_p.h \ text/qtexthtmlparser_p.h \ text/qabstracttextdocumentlayout.h \ + text/qabstracttextdocumentlayout_p.h \ text/qtextdocumentlayout_p.h \ text/qtextcursor.h \ text/qtextcursor_p.h \ @@ -47,6 +48,7 @@ HEADERS += \ SOURCES += \ text/qfont.cpp \ text/qfontengine.cpp \ + text/qfontengineglyphcache.cpp \ text/qfontsubset.cpp \ text/qfontmetrics.cpp \ text/qfontdatabase.cpp \ |