diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-01-10 10:08:37 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-01-28 04:12:25 +0100 |
commit | 4bb897a3841f0f79150787e29fe122e1410bc119 (patch) | |
tree | 76220d0132e0f64b61bfa8e371cf48c25acc3cea /tests | |
parent | be8c257da9a264994243c120231965ff0008ef09 (diff) |
Deprecate all methods that use QMatrix
Don't use QMatrix in implementation classes anymore.
Task-number: QTBUG-46653
Fixes: QTBUG-81627
Change-Id: I4806c1302e42645dc6a608062c8d9c336ae8629b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
15 files changed, 95 insertions, 48 deletions
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 8197c386c5..7873c94b6d 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -3296,7 +3296,10 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(col, color); stream >> rGrad; QCOMPARE(rGrad.style(), radialBrush.style()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(rGrad.matrix(), radialBrush.matrix()); +QT_WARNING_POP QCOMPARE(rGrad.gradient()->type(), radialBrush.gradient()->type()); QCOMPARE(rGrad.gradient()->stops(), radialBrush.gradient()->stops()); QCOMPARE(rGrad.gradient()->spread(), radialBrush.gradient()->spread()); @@ -3305,7 +3308,10 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(((QRadialGradient *)rGrad.gradient())->radius(), ((QRadialGradient *)radialBrush.gradient())->radius()); stream >> cGrad; QCOMPARE(cGrad.style(), conicalBrush.style()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(cGrad.matrix(), conicalBrush.matrix()); +QT_WARNING_POP QCOMPARE(cGrad.gradient()->type(), conicalBrush.gradient()->type()); QCOMPARE(cGrad.gradient()->stops(), conicalBrush.gradient()->stops()); QCOMPARE(cGrad.gradient()->spread(), conicalBrush.gradient()->spread()); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index bc964e0d5c..71aaa23da4 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -32,7 +32,7 @@ #include <qimage.h> #include <qimagereader.h> #include <qlist.h> -#include <qmatrix.h> +#include <qtransform.h> #include <qrandom.h> #include <stdio.h> @@ -1204,7 +1204,7 @@ void tst_QImage::rotate() // original.save("rotated90_original.png", "png"); // Initialize the matrix manually (do not use rotate) to avoid rounding errors - QMatrix matRotate90; + QTransform matRotate90; matRotate90.rotate(degrees); QImage dest = original; // And rotate it 4 times, then the image should be identical to the original @@ -1218,7 +1218,7 @@ void tst_QImage::rotate() // dest.save("rotated90_result.png","png"); QCOMPARE(original, dest); - // Test with QMatrix::rotate 90 also, since we trust that now + // Test with QTransform::rotate 90 also, since we trust that now matRotate90.rotate(degrees); dest = original; // And rotate it 4 times, then the image should be identical to the original diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index ba5df809f2..1d77f70919 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -32,7 +32,6 @@ #include <qbitmap.h> #include <qimage.h> #include <qimagereader.h> -#include <qmatrix.h> #ifndef QT_NO_WIDGETS #include <qdesktopwidget.h> #include <qsplashscreen.h> diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index 3ce65a6785..81f0183728 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -193,9 +193,14 @@ template<> struct TestValueFactory<QMetaType::QTextLength> { template<> struct TestValueFactory<QMetaType::QTextFormat> { static QTextFormat *create() { return new QTextFormat(QTextFormat::FrameFormat); } }; +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template<> struct TestValueFactory<QMetaType::QMatrix> { static QMatrix *create() { return new QMatrix(10, 20, 30, 40, 50, 60); } }; +QT_WARNING_POP +#endif template<> struct TestValueFactory<QMetaType::QTransform> { static QTransform *create() { return new QTransform(10, 20, 30, 40, 50, 60); } }; diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 0b9fc3c9ae..8b301c145a 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -402,6 +402,9 @@ void tst_QGuiVariant::toString() QCOMPARE( str, result ); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_QGuiVariant::matrix() { QVariant variant; @@ -414,6 +417,8 @@ void tst_QGuiVariant::matrix() QVERIFY(mmatrix); QMetaType::destroy(QVariant::Matrix, mmatrix); } +QT_WARNING_POP +#endif void tst_QGuiVariant::matrix4x4() { diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index e19f76d830..3c4f2f2e75 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -3061,6 +3061,9 @@ void tst_QMatrixNxN::columnsAndRows() QVERIFY(m1.row(3) == QVector4D(4, 8, 12, 16)); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // Test converting QMatrix objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. @@ -3107,6 +3110,8 @@ void tst_QMatrixNxN::convertQMatrix() QVERIFY(qFuzzyCompare(float(m5.dx()), float(m7.dx()))); QVERIFY(qFuzzyCompare(float(m5.dy()), float(m7.dy()))); } +QT_WARNING_POP +#endif // Test converting QTransform objects into QMatrix4x4 and then // checking that transformations in the original perform the diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index e05de64be5..9eb62ceab2 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -1704,8 +1704,11 @@ void tst_QPainter::combinedMatrix() QTransform ct = p.combinedTransform(); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QMatrix cm = p.combinedMatrix(); QCOMPARE(cm, ct.toAffine()); +QT_WARNING_POP #endif QPointF pt = QPointF(0, 0) * ct.toAffine(); @@ -2245,7 +2248,7 @@ void tst_QPainter::clippedPolygon() { QFETCH(QSize, imageSize); QFETCH(QPainterPath, path); - QPolygonF polygon = path.toFillPolygon(); + QPolygonF polygon = path.toFillPolygon(QTransform()); QFETCH(QRect, clipRect); QPainterPath clipPath; clipPath.addRect(clipRect); @@ -3066,7 +3069,7 @@ void tst_QPainter::fpe_steepSlopes_data() const qreal dsin = 0.000014946676875461832484392500630665523431162000633776187896728515625; const qreal dcos = 0.9999999998882984630910186751862056553363800048828125; - const QTransform transform = QTransform(QMatrix(dcos, dsin, -dsin, dcos, 64, 64)); + const QTransform transform = QTransform(dcos, dsin, -dsin, dcos, 64, 64); const QLineF line(2, 2, 2, 6); QTest::newRow("task 207147 aa") << transform << line << true; @@ -4064,7 +4067,7 @@ void tst_QPainter::drawPolygon() path.moveTo(2, 34); path.lineTo(34, 2); - QPolygonF poly = stroker.createStroke(path).toFillPolygon(); + QPolygonF poly = stroker.createStroke(path).toFillPolygon(QTransform()); img.fill(0xffffffff); QPainter p(&img); @@ -4133,7 +4136,10 @@ void tst_QPainter::inactivePainter() p.setClipping(true); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.combinedMatrix(); +QT_WARNING_POP #endif p.combinedTransform(); @@ -4142,7 +4148,10 @@ void tst_QPainter::inactivePainter() p.device(); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.deviceMatrix(); +QT_WARNING_POP #endif p.deviceTransform(); @@ -4168,7 +4177,10 @@ void tst_QPainter::inactivePainter() p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, false); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.resetMatrix(); +QT_WARNING_POP #endif p.resetTransform(); p.rotate(1); @@ -4186,8 +4198,11 @@ void tst_QPainter::inactivePainter() p.setWindow(QRect(10, 10, 620, 460)); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.worldMatrix(); p.setWorldMatrix(QMatrix().translate(43, 21), true); +QT_WARNING_POP #endif p.setWorldMatrixEnabled(true); diff --git a/tests/auto/gui/painting/qpathclipper/paths.cpp b/tests/auto/gui/painting/qpathclipper/paths.cpp index 1328befd1b..a814958394 100644 --- a/tests/auto/gui/painting/qpathclipper/paths.cpp +++ b/tests/auto/gui/painting/qpathclipper/paths.cpp @@ -713,9 +713,5 @@ QPainterPath Paths::bezierQuadrant() path.closeSubpath(); } - QMatrix m(2, 0, - 0, 2, - 0, 0); - return path; } diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp index 93035af7d3..01853d841a 100644 --- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp @@ -152,9 +152,9 @@ void tst_QPathClipper::initTestCase() for (int i = 0; i < paths.size(); ++i) { QRectF bounds = paths[i].boundingRect(); - QMatrix m(1, 0, - 0, 1, - -bounds.center().x(), -bounds.center().y()); + QTransform m(1, 0, + 0, 1, + -bounds.center().x(), -bounds.center().y()); paths[i] = m.map(paths[i]); } diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index f9366c9227..78638a7518 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -331,17 +331,13 @@ void tst_QTransform::mapToPolygon() void tst_QTransform::qhash() { - QMatrix m1; - m1.shear(3.0, 2.0); - m1.rotate(44); + QTransform t1; + t1.shear(3.0, 2.0); + t1.rotate(44); - QMatrix m2 = m1; - - QTransform t1(m1); - QTransform t2(m2); + QTransform t2 = t1; // not really much to test here, so just the bare minimum: - QCOMPARE(qHash(m1), qHash(m2)); QCOMPARE(qHash(t1), qHash(t2)); } @@ -376,6 +372,9 @@ void tst_QTransform::scale() QVERIFY( QTransform::fromScale( 1, 1 ) == QTransform()); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_QTransform::matrix() { QMatrix mat1; @@ -414,7 +413,7 @@ void tst_QTransform::matrix() QRect rect(43, 70, 200, 200); QPoint pt(43, 66); - QCOMPARE(tranInv.map(pt), matInv.map(pt)); + QCOMPARE(tranInv.mapRect(rect), matInv.mapRect(rect)); QCOMPARE(tranInv.map(pt), matInv.map(pt)); QPainterPath path; @@ -431,6 +430,8 @@ void tst_QTransform::testOffset() const QMatrix &aff = trans.toAffine(); QCOMPARE((void*)(&aff), (void*)(&trans)); } +QT_WARNING_POP +#endif void tst_QTransform::types() { diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp index da88a868f3..281639c27a 100644 --- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp +++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp @@ -32,6 +32,9 @@ #include <qmath.h> #include <qpolygon.h> +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED class tst_QWMatrix : public QObject { @@ -324,5 +327,8 @@ void tst_QWMatrix::mapPolygon() } } +QT_WARNING_POP +#endif + QTEST_APPLESS_MAIN(tst_QWMatrix) #include "tst_qwmatrix.moc" diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 262e1772a0..5b11cd5d11 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8014,11 +8014,21 @@ public: //Doesn't use the extended style option so the exposed rect is the boundingRect if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) { QCOMPARE(option->exposedRect, boundingRect()); +#if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(option->matrix, QMatrix()); +QT_WARNING_POP +#endif } else { QVERIFY(option->exposedRect != QRect()); QVERIFY(option->exposedRect != boundingRect()); +#if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(option->matrix, sceneTransform().toAffine()); +QT_WARNING_POP +#endif } } QGraphicsRectItem::paint(painter, option, widget); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp index ed79904ed8..0d8e5b4d54 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp @@ -31,7 +31,6 @@ #include <qgraphicsitemanimation.h> #include <QtCore/qtimeline.h> -#include <QtGui/qmatrix.h> class tst_QGraphicsItemAnimation : public QObject { diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index ea89e2422b..acf6ce1c68 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -67,7 +67,7 @@ using namespace QTestPrivate; Q_DECLARE_METATYPE(ExpectedValueDescription) Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QRectF>) -Q_DECLARE_METATYPE(QMatrix) +Q_DECLARE_METATYPE(QTransform) Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) Q_DECLARE_METATYPE(ScrollBarCount) @@ -291,7 +291,7 @@ void tst_QGraphicsView::construction() QCOMPARE(view.sceneRect(), QRectF()); QVERIFY(view.viewport()); QCOMPARE(view.viewport()->metaObject()->className(), "QWidget"); - QCOMPARE(view.matrix(), QMatrix()); + QCOMPARE(view.transform(), QTransform()); QVERIFY(view.items().isEmpty()); QVERIFY(view.items(QPoint()).isEmpty()); QVERIFY(view.items(QRect()).isEmpty()); @@ -1208,37 +1208,37 @@ void tst_QGraphicsView::matrix() void tst_QGraphicsView::matrix_convenience() { QGraphicsView view; - QCOMPARE(view.matrix(), QMatrix()); + QCOMPARE(view.transform(), QTransform()); // Check the convenience functions view.rotate(90); - QCOMPARE(view.matrix(), QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().rotate(90)); view.scale(2, 2); - QCOMPARE(view.matrix(), QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().scale(2, 2) * QTransform().rotate(90)); view.shear(1.2, 1.2); - QCOMPARE(view.matrix(), QMatrix().shear(1.2, 1.2) * QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().shear(1.2, 1.2) * QTransform().scale(2, 2) * QTransform().rotate(90)); view.translate(1, 1); - QCOMPARE(view.matrix(), QMatrix().translate(1, 1) * QMatrix().shear(1.2, 1.2) * QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().translate(1, 1) * QTransform().shear(1.2, 1.2) * QTransform().scale(2, 2) * QTransform().rotate(90)); } void tst_QGraphicsView::matrix_combine() { // Check matrix combining QGraphicsView view; - QCOMPARE(view.matrix(), QMatrix()); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - QCOMPARE(view.matrix(), QMatrix()); - - view.resetMatrix(); - QCOMPARE(view.matrix(), QMatrix()); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - QCOMPARE(view.matrix(), QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform()); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + QCOMPARE(view.transform(), QTransform()); + + view.resetTransform(); + QCOMPARE(view.transform(), QTransform()); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + QCOMPARE(view.transform(), QTransform().rotate(90)); } void tst_QGraphicsView::centerOnPoint() @@ -2125,8 +2125,8 @@ void tst_QGraphicsView::mapFromScenePath() QPainterPath path2; path2.addPolygon(polygon2); - QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(); - QPolygonF path2Poly = path2.toFillPolygon(); + QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(QTransform()); + QPolygonF path2Poly = path2.toFillPolygon(QTransform()); for (int i = 0; i < pathPoly.size(); ++i) { QVERIFY(qAbs(pathPoly[i].x() - path2Poly[i].x()) < 3); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp index 6e0ac445a6..60e8dd0032 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp @@ -187,7 +187,7 @@ void View::setupMatrix() { qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); - QMatrix matrix; + QTransform matrix; matrix.scale(scale, scale); matrix.rotate(rotateSlider->value()); |