diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-02-21 15:15:29 +0100 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2015-05-30 10:56:24 +0000 |
commit | 87d57d19941fba4a921020480ca5761f23536c93 (patch) | |
tree | 9157982715d32e8a9c014fbdc104d9721aac525f /tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp | |
parent | 9eff0dd19d6507ec400f036dd27efe960e4e5f78 (diff) |
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.
Moved op== definition for FormatRange needed in tst_qsyntaxhighlighter.cpp
to a friend declaration in FormatRange itself, because MSVC 2008 doesn't find
it otherwise.
Change-Id: Ibab6589df057f02377d895079b56395859e3401e
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp')
-rw-r--r-- | tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index 014ed4c7c8..c0b0738e2a 100644 --- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -120,7 +120,7 @@ void tst_QSyntaxHighlighter::cleanup() class TestHighlighter : public QSyntaxHighlighter { public: - inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent) + inline TestHighlighter(const QVector<QTextLayout::FormatRange> &fmts, QTextDocument *parent) : QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {} inline TestHighlighter(QObject *parent) : QSyntaxHighlighter(parent) {} @@ -138,24 +138,15 @@ public: ++callCount; } - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; bool highlighted; int callCount; QString highlightedText; }; -QT_BEGIN_NAMESPACE -bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) -{ - return lhs.start == rhs.start - && lhs.length == rhs.length - && lhs.format == rhs.format; -} -QT_END_NAMESPACE - void tst_QSyntaxHighlighter::basic() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 2; @@ -179,7 +170,7 @@ void tst_QSyntaxHighlighter::basic() QVERIFY(hl->highlighted); QVERIFY(lout->documentChangedCalled); - QVERIFY(doc->begin().layout()->additionalFormats() == formats); + QVERIFY(doc->begin().layout()->formats() == formats); } class CommentTestHighlighter : public QSyntaxHighlighter @@ -222,7 +213,7 @@ void tst_QSyntaxHighlighter::basicTwo() void tst_QSyntaxHighlighter::removeFormatsOnDelete() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 9; @@ -237,9 +228,9 @@ void tst_QSyntaxHighlighter::removeFormatsOnDelete() QVERIFY(lout->documentChangedCalled); lout->documentChangedCalled = false; - QVERIFY(!doc->begin().layout()->additionalFormats().isEmpty()); + QVERIFY(!doc->begin().layout()->formats().isEmpty()); delete hl; - QVERIFY(doc->begin().layout()->additionalFormats().isEmpty()); + QVERIFY(doc->begin().layout()->formats().isEmpty()); QVERIFY(lout->documentChangedCalled); } @@ -405,7 +396,7 @@ void tst_QSyntaxHighlighter::highlightToEndOfDocument2() void tst_QSyntaxHighlighter::preservePreeditArea() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 8; @@ -432,12 +423,12 @@ void tst_QSyntaxHighlighter::preservePreeditArea() hl->callCount = 0; cursor.beginEditBlock(); - layout->setAdditionalFormats(formats); + layout->setFormats(formats); cursor.endEditBlock(); QCOMPARE(hl->callCount, 1); - formats = layout->additionalFormats(); + formats = layout->formats(); QCOMPARE(formats.count(), 3); range = formats.at(0); @@ -483,7 +474,7 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight() void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 10; |