From 87d57d19941fba4a921020480ca5761f23536c93 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 21 Feb 2014 15:15:29 +0100 Subject: Fix users of QTextLayout::additionalFormats to use the new API QTextLayout::additionalFormats setters and getters using QList 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 --- .../qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp | 31 ++++++++-------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp') 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 &fmts, QTextDocument *parent) + inline TestHighlighter(const QVector &fmts, QTextDocument *parent) : QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {} inline TestHighlighter(QObject *parent) : QSyntaxHighlighter(parent) {} @@ -138,24 +138,15 @@ public: ++callCount; } - QList formats; + QVector 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 formats; + QVector 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 formats; + QVector 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 formats; + QVector 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 formats; + QVector formats; QTextLayout::FormatRange range; range.start = 0; range.length = 10; -- cgit v1.2.3