summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-06 22:09:33 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-08 18:00:51 +0000
commit1b5a17632efbaf6c1d0eacdda72fad3bc9d5fe13 (patch)
tree336afc751c787a9aa376ef895750d4bce74619a3 /tests/auto/widgets/graphicsview
parent4ce485a2eba40cc6d1edcf4baa794276432e1bea (diff)
Fix deprecation warnings in widget autotests
Fix all deprecation warnings within tests/auto/widgets Change-Id: I854f54c0a1dc0a0086f626b93cd39f63cb1b6033 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/widgets/graphicsview')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp154
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp112
5 files changed, 133 insertions, 139 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 67e1f9ce30..2f5fc597dc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -91,7 +91,7 @@ public:
{
Q_UNUSED(option);
Q_UNUSED(widget);
- painter->drawRoundRect(rect());
+ painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight());
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 34646a9074..2f0c43552f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -125,7 +125,7 @@ public:
{
Q_UNUSED(option);
Q_UNUSED(widget);
- painter->drawRoundRect(rect());
+ painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight());
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 9a75774927..bca664c05b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -301,8 +301,8 @@ private slots:
void pos();
void scenePos();
void matrix();
- void sceneMatrix();
- void setMatrix();
+ void sceneTransform();
+ void setTransform();
void zValue();
void shape();
void contains();
@@ -552,8 +552,8 @@ void tst_QGraphicsItem::construction()
QVERIFY(!item->acceptHoverEvents());
QVERIFY(!item->hasFocus());
QCOMPARE(item->pos(), QPointF());
- QCOMPARE(item->matrix(), QMatrix());
- QCOMPARE(item->sceneMatrix(), QMatrix());
+ QCOMPARE(item->transform(), QTransform());
+ QCOMPARE(item->sceneTransform(), QTransform());
QCOMPARE(item->zValue(), qreal(0));
QCOMPARE(item->sceneBoundingRect(), QRectF());
QCOMPARE(item->shape(), QPainterPath());
@@ -2116,68 +2116,68 @@ void tst_QGraphicsItem::scenePos()
void tst_QGraphicsItem::matrix()
{
QGraphicsLineItem line;
- QCOMPARE(line.matrix(), QMatrix());
- line.setMatrix(QMatrix().rotate(90));
- QCOMPARE(line.matrix(), QMatrix().rotate(90));
- line.setMatrix(QMatrix().rotate(90));
- QCOMPARE(line.matrix(), QMatrix().rotate(90));
- line.setMatrix(QMatrix().rotate(90), true);
- QCOMPARE(line.matrix(), QMatrix().rotate(180));
- line.setMatrix(QMatrix().rotate(-90), true);
- QCOMPARE(line.matrix(), QMatrix().rotate(90));
- line.resetMatrix();
- QCOMPARE(line.matrix(), QMatrix());
+ QCOMPARE(line.transform(), QTransform());
+ line.setTransform(QTransform().rotate(90));
+ QCOMPARE(line.transform(), QTransform().rotate(90));
+ line.setTransform(QTransform().rotate(90));
+ QCOMPARE(line.transform(), QTransform().rotate(90));
+ line.setTransform(QTransform().rotate(90), true);
+ QCOMPARE(line.transform(), QTransform().rotate(180));
+ line.setTransform(QTransform().rotate(-90), true);
+ QCOMPARE(line.transform(), QTransform().rotate(90));
+ line.resetTransform();
+ QCOMPARE(line.transform(), QTransform());
line.setTransform(QTransform().rotate(90), true);
- QCOMPARE(line.matrix(), QMatrix().rotate(90));
+ QCOMPARE(line.transform(), QTransform().rotate(90));
line.setTransform(QTransform().rotate(90), true);
- QCOMPARE(line.matrix(), QMatrix().rotate(90).rotate(90));
- line.resetMatrix();
+ QCOMPARE(line.transform(), QTransform().rotate(90).rotate(90));
+ line.resetTransform();
line.setTransform(QTransform::fromScale(2, 4), true);
- QCOMPARE(line.matrix(), QMatrix().scale(2, 4));
+ QCOMPARE(line.transform(), QTransform::fromScale(2, 4));
line.setTransform(QTransform::fromScale(2, 4), true);
- QCOMPARE(line.matrix(), QMatrix().scale(2, 4).scale(2, 4));
- line.resetMatrix();
+ QCOMPARE(line.transform(), QTransform::fromScale(2, 4).scale(2, 4));
+ line.resetTransform();
line.setTransform(QTransform().shear(2, 4), true);
- QCOMPARE(line.matrix(), QMatrix().shear(2, 4));
+ QCOMPARE(line.transform(), QTransform().shear(2, 4));
line.setTransform(QTransform().shear(2, 4), true);
- QCOMPARE(line.matrix(), QMatrix().shear(2, 4).shear(2, 4));
- line.resetMatrix();
+ QCOMPARE(line.transform(), QTransform().shear(2, 4).shear(2, 4));
+ line.resetTransform();
line.setTransform(QTransform::fromTranslate(10, 10), true);
- QCOMPARE(line.matrix(), QMatrix().translate(10, 10));
+ QCOMPARE(line.transform(), QTransform::fromTranslate(10, 10));
line.setTransform(QTransform::fromTranslate(10, 10), true);
- QCOMPARE(line.matrix(), QMatrix().translate(10, 10).translate(10, 10));
- line.resetMatrix();
+ QCOMPARE(line.transform(), QTransform::fromTranslate(10, 10).translate(10, 10));
+ line.resetTransform();
}
-void tst_QGraphicsItem::sceneMatrix()
+void tst_QGraphicsItem::sceneTransform()
{
QGraphicsLineItem *parent = new QGraphicsLineItem;
QGraphicsLineItem *child = new QGraphicsLineItem(QLineF(), parent);
- QCOMPARE(parent->sceneMatrix(), QMatrix());
- QCOMPARE(child->sceneMatrix(), QMatrix());
+ QCOMPARE(parent->sceneTransform(), QTransform());
+ QCOMPARE(child->sceneTransform(), QTransform());
parent->setTransform(QTransform::fromTranslate(10, 10), true);
- QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10));
- QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10));
+ QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10));
+ QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10));
child->setTransform(QTransform::fromTranslate(10, 10), true);
- QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10));
- QCOMPARE(child->sceneMatrix(), QMatrix().translate(20, 20));
+ QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10));
+ QCOMPARE(child->sceneTransform(), QTransform().translate(20, 20));
parent->setTransform(QTransform().rotate(90), true);
- QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10).rotate(90));
- QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10).rotate(90).translate(10, 10));
+ QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10).rotate(90));
+ QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10).rotate(90).translate(10, 10));
delete child;
delete parent;
}
-void tst_QGraphicsItem::setMatrix()
+void tst_QGraphicsItem::setTransform()
{
QGraphicsScene scene;
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
@@ -2190,7 +2190,7 @@ void tst_QGraphicsItem::setMatrix()
QCOMPARE(spy.count(), 1);
- item.setMatrix(QMatrix().rotate(qreal(12.34)));
+ item.setTransform(QTransform().rotate(qreal(12.34)));
QRectF rotatedRect = scene.sceneRect();
QVERIFY(unrotatedRect != rotatedRect);
scene.update(scene.sceneRect());
@@ -2198,7 +2198,7 @@ void tst_QGraphicsItem::setMatrix()
QCOMPARE(spy.count(), 2);
- item.setMatrix(QMatrix());
+ item.setTransform(QTransform());
scene.update(scene.sceneRect());
QApplication::instance()->processEvents();
@@ -2485,25 +2485,25 @@ void tst_QGraphicsItem::collidesWith_item()
void tst_QGraphicsItem::collidesWith_path_data()
{
QTest::addColumn<QPointF>("pos");
- QTest::addColumn<QMatrix>("matrix");
+ QTest::addColumn<QTransform>("transform");
QTest::addColumn<QPainterPath>("shape");
QTest::addColumn<bool>("rectCollides");
QTest::addColumn<bool>("ellipseCollides");
- QTest::newRow("nothing") << QPointF(0, 0) << QMatrix() << QPainterPath() << false << false;
+ QTest::newRow("nothing") << QPointF(0, 0) << QTransform() << QPainterPath() << false << false;
QPainterPath rect;
rect.addRect(0, 0, 20, 20);
- QTest::newRow("rect1") << QPointF(0, 0) << QMatrix() << rect << true << true;
- QTest::newRow("rect2") << QPointF(0, 0) << QMatrix().translate(21, 21) << rect << false << false;
- QTest::newRow("rect3") << QPointF(21, 21) << QMatrix() << rect << false << false;
+ QTest::newRow("rect1") << QPointF(0, 0) << QTransform() << rect << true << true;
+ QTest::newRow("rect2") << QPointF(0, 0) << QTransform::fromTranslate(21, 21) << rect << false << false;
+ QTest::newRow("rect3") << QPointF(21, 21) << QTransform() << rect << false << false;
}
void tst_QGraphicsItem::collidesWith_path()
{
QFETCH(QPointF, pos);
- QFETCH(QMatrix, matrix);
+ QFETCH(QTransform, transform);
QFETCH(QPainterPath, shape);
QFETCH(bool, rectCollides);
QFETCH(bool, ellipseCollides);
@@ -2512,12 +2512,12 @@ void tst_QGraphicsItem::collidesWith_path()
QGraphicsEllipseItem ellipse(QRectF(0, 0, 20, 20));
rect.setPos(pos);
- rect.setMatrix(matrix);
+ rect.setTransform(transform);
ellipse.setPos(pos);
- ellipse.setMatrix(matrix);
+ ellipse.setTransform(transform);
- QPainterPath mappedShape = rect.sceneMatrix().inverted().map(shape);
+ QPainterPath mappedShape = rect.sceneTransform().inverted().map(shape);
if (rectCollides)
QVERIFY(rect.collidesWithPath(mappedShape));
@@ -2742,35 +2742,35 @@ void tst_QGraphicsItem::mapFromToParent()
item4->setPos(10, 10);
for (int i = 0; i < 4; ++i) {
- QMatrix matrix;
- matrix.rotate(i * 90);
- matrix.translate(i * 100, -i * 100);
- matrix.scale(2, 4);
- item1->setMatrix(matrix);
+ QTransform transform;
+ transform.rotate(i * 90);
+ transform.translate(i * 100, -i * 100);
+ transform.scale(2, 4);
+ item1->setTransform(transform);
- QCOMPARE(item1->mapToParent(QPointF(0, 0)), item1->pos() + matrix.map(QPointF(0, 0)));
+ QCOMPARE(item1->mapToParent(QPointF(0, 0)), item1->pos() + transform.map(QPointF(0, 0)));
QCOMPARE(item2->mapToParent(QPointF(0, 0)), item2->pos());
QCOMPARE(item3->mapToParent(QPointF(0, 0)), item3->pos());
QCOMPARE(item4->mapToParent(QPointF(0, 0)), item4->pos());
- QCOMPARE(item1->mapToParent(QPointF(10, -10)), item1->pos() + matrix.map(QPointF(10, -10)));
+ QCOMPARE(item1->mapToParent(QPointF(10, -10)), item1->pos() + transform.map(QPointF(10, -10)));
QCOMPARE(item2->mapToParent(QPointF(10, -10)), item2->pos() + QPointF(10, -10));
QCOMPARE(item3->mapToParent(QPointF(10, -10)), item3->pos() + QPointF(10, -10));
QCOMPARE(item4->mapToParent(QPointF(10, -10)), item4->pos() + QPointF(10, -10));
- QCOMPARE(item1->mapToParent(QPointF(-10, 10)), item1->pos() + matrix.map(QPointF(-10, 10)));
+ QCOMPARE(item1->mapToParent(QPointF(-10, 10)), item1->pos() + transform.map(QPointF(-10, 10)));
QCOMPARE(item2->mapToParent(QPointF(-10, 10)), item2->pos() + QPointF(-10, 10));
QCOMPARE(item3->mapToParent(QPointF(-10, 10)), item3->pos() + QPointF(-10, 10));
QCOMPARE(item4->mapToParent(QPointF(-10, 10)), item4->pos() + QPointF(-10, 10));
- QCOMPARE(item1->mapFromParent(item1->pos()), matrix.inverted().map(QPointF(0, 0)));
+ QCOMPARE(item1->mapFromParent(item1->pos()), transform.inverted().map(QPointF(0, 0)));
QCOMPARE(item2->mapFromParent(item2->pos()), QPointF(0, 0));
QCOMPARE(item3->mapFromParent(item3->pos()), QPointF(0, 0));
QCOMPARE(item4->mapFromParent(item4->pos()), QPointF(0, 0));
QCOMPARE(item1->mapFromParent(item1->pos() + QPointF(10, -10)),
- matrix.inverted().map(QPointF(10, -10)));
+ transform.inverted().map(QPointF(10, -10)));
QCOMPARE(item2->mapFromParent(item2->pos() + QPointF(10, -10)), QPointF(10, -10));
QCOMPARE(item3->mapFromParent(item3->pos() + QPointF(10, -10)), QPointF(10, -10));
QCOMPARE(item4->mapFromParent(item4->pos() + QPointF(10, -10)), QPointF(10, -10));
QCOMPARE(item1->mapFromParent(item1->pos() + QPointF(-10, 10)),
- matrix.inverted().map(QPointF(-10, 10)));
+ transform.inverted().map(QPointF(-10, 10)));
QCOMPARE(item2->mapFromParent(item2->pos() + QPointF(-10, 10)), QPointF(-10, 10));
QCOMPARE(item3->mapFromParent(item3->pos() + QPointF(-10, 10)), QPointF(-10, 10));
QCOMPARE(item4->mapFromParent(item4->pos() + QPointF(-10, 10)), QPointF(-10, 10));
@@ -2820,8 +2820,8 @@ void tst_QGraphicsItem::mapFromToScene()
QCOMPARE(item4->mapFromScene(410, 400), QPointF(10, 0));
// Rotate item1 90 degrees clockwise
- QMatrix matrix; matrix.rotate(90);
- item1->setMatrix(matrix);
+ QTransform transform; transform.rotate(90);
+ item1->setTransform(transform);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->mapToParent(0, 0));
@@ -2848,7 +2848,7 @@ void tst_QGraphicsItem::mapFromToScene()
QCOMPARE(item4->mapFromScene(-200, 410), QPointF(10, 0));
// Rotate item2 90 degrees clockwise
- item2->setMatrix(matrix);
+ item2->setTransform(transform);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->mapToParent(0, 0));
@@ -2875,10 +2875,10 @@ void tst_QGraphicsItem::mapFromToScene()
QCOMPARE(item4->mapFromScene(-210, 0), QPointF(10, 0));
// Translate item3 50 points, then rotate 90 degrees counterclockwise
- QMatrix matrix2;
- matrix2.translate(50, 0);
- matrix2.rotate(-90);
- item3->setMatrix(matrix2);
+ QTransform transform2;
+ transform2.translate(50, 0);
+ transform2.rotate(-90);
+ item3->setTransform(transform2);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->mapToParent(0, 0) - QPointF(50, 0));
@@ -2928,9 +2928,9 @@ void tst_QGraphicsItem::mapFromToItem()
QCOMPARE(item3->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0));
- QMatrix matrix;
- matrix.translate(100, 100);
- item1->setMatrix(matrix);
+ QTransform transform;
+ transform.translate(100, 100);
+ item1->setTransform(transform);
QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(100, -100));
QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(0, 200));
@@ -2941,11 +2941,11 @@ void tst_QGraphicsItem::mapFromToItem()
QCOMPARE(item3->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0));
- matrix.rotate(90);
- item1->setMatrix(matrix);
- item2->setMatrix(matrix);
- item3->setMatrix(matrix);
- item4->setMatrix(matrix);
+ transform.rotate(90);
+ item1->setTransform(transform);
+ item2->setTransform(transform);
+ item3->setTransform(transform);
+ item4->setTransform(transform);
QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(200, 0));
@@ -4433,9 +4433,12 @@ protected:
case QGraphicsItem::ItemPositionHasChanged:
break;
case QGraphicsItem::ItemMatrixChange: {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QVariant variant;
variant.setValue<QMatrix>(matrix());
oldValues << variant;
+QT_WARNING_POP
}
break;
case QGraphicsItem::ItemTransformChange: {
@@ -4556,6 +4559,8 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.isEnabled(), true);
}
{
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
// ItemMatrixChange / ItemTransformHasChanged
tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90));
tester.setMatrix(QMatrix().translate(50, 0), true);
@@ -4570,6 +4575,7 @@ void tst_QGraphicsItem::itemChange()
variant.setValue<QMatrix>(QMatrix());
QCOMPARE(tester.oldValues.last(), variant);
QCOMPARE(tester.matrix(), QMatrix().rotate(90));
+QT_WARNING_POP
}
{
tester.resetTransform();
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index f9b6fe3ebd..9369470ce5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -150,7 +150,7 @@ public:
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setBrush(m_brush);
- painter->drawRoundRect(rect());
+ painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
}
void setSizeHint(Qt::SizeHint which, const QSizeF &size) {
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 48488abfb8..46f1d5df5c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -112,14 +112,14 @@ protected:
painter->setOpacity(0.75);
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::darkGray);
- painter->drawRoundRect(boundingRect().adjusted(3, 3, -3, -3), Qt::darkGray);
+ painter->drawRoundedRect(boundingRect().adjusted(3, 3, -3, -3), 25, 25, Qt::RelativeSize);
painter->setPen(Qt::black);
if (isHovered) {
- painter->setBrush(QColor(Qt::blue).light(120));
+ painter->setBrush(QColor(Qt::blue).lighter(120));
} else {
painter->setBrush(Qt::gray);
}
- painter->drawRoundRect(boundingRect().adjusted(0, 0, -5, -5));
+ painter->drawRoundedRect(boundingRect().adjusted(0, 0, -5, -5), 25, 25, Qt::RelativeSize);
}
};
@@ -233,7 +233,6 @@ private slots:
void tabFocus_sceneWithFocusWidgets();
void tabFocus_sceneWithNestedFocusWidgets();
void style();
- void sorting_data();
void sorting();
void insertionOrder();
void changedSignal_data();
@@ -459,41 +458,41 @@ void tst_QGraphicsScene::items()
void tst_QGraphicsScene::itemsBoundingRect_data()
{
QTest::addColumn<QList<QRectF> >("rects");
- QTest::addColumn<QMatrix>("matrix");
+ QTest::addColumn<QTransform>("transform");
QTest::addColumn<QRectF>("boundingRect");
- QMatrix transformationMatrix;
- transformationMatrix.translate(50, -50);
- transformationMatrix.scale(2, 2);
- transformationMatrix.rotate(90);
+ QTransform transformation;
+ transformation.translate(50, -50);
+ transformation.scale(2, 2);
+ transformation.rotate(90);
QTest::newRow("none")
<< QList<QRectF>()
- << QMatrix()
+ << QTransform()
<< QRectF();
QTest::newRow("{{0, 0, 10, 10}}")
<< (QList<QRectF>() << QRectF(0, 0, 10, 10))
- << QMatrix()
+ << QTransform()
<< QRectF(0, 0, 10, 10);
QTest::newRow("{{-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-10, -10, 10, 10))
- << QMatrix()
+ << QTransform()
<< QRectF(-10, -10, 10, 10);
QTest::newRow("{{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10))
- << QMatrix()
+ << QTransform()
<< QRectF(-1000, -1000, 1000, 1000);
QTest::newRow("transformed {{0, 0, 10, 10}}")
<< (QList<QRectF>() << QRectF(0, 0, 10, 10))
- << transformationMatrix
+ << transformation
<< QRectF(30, -50, 20, 20);
QTest::newRow("transformed {{-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-10, -10, 10, 10))
- << transformationMatrix
+ << transformation
<< QRectF(50, -70, 20, 20);
QTest::newRow("transformed {{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10))
- << transformationMatrix
+ << transformation
<< QRectF(50, -2050, 2000, 2000);
QList<QRectF> all;
@@ -501,18 +500,18 @@ void tst_QGraphicsScene::itemsBoundingRect_data()
all << QRectF(randomX[i], randomY[i], 10, 10);
QTest::newRow("all")
<< all
- << QMatrix()
+ << QTransform()
<< QRectF(-980, -994, 1988, 1983);
QTest::newRow("transformed all")
<< all
- << transformationMatrix
+ << transformation
<< QRectF(-1928, -2010, 3966, 3976);
}
void tst_QGraphicsScene::itemsBoundingRect()
{
QFETCH(QList<QRectF>, rects);
- QFETCH(QMatrix, matrix);
+ QFETCH(QTransform, transform);
QFETCH(QRectF, boundingRect);
QGraphicsScene scene;
@@ -522,7 +521,7 @@ void tst_QGraphicsScene::itemsBoundingRect()
path.addRect(rect);
QGraphicsPathItem *item = scene.addPath(path);
item->setPen(QPen(Qt::black, 0));
- item->setMatrix(matrix);
+ item->setTransform(transform);
}
QCOMPARE(scene.itemsBoundingRect(), boundingRect);
@@ -2502,7 +2501,7 @@ void tst_QGraphicsScene::render_data()
QTest::addColumn<QRectF>("targetRect");
QTest::addColumn<QRectF>("sourceRect");
QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
- QTest::addColumn<QMatrix>("matrix");
+ QTest::addColumn<QTransform>("transform");
QTest::addColumn<QPainterPath>("clip");
QPainterPath clip_rect;
@@ -2512,61 +2511,61 @@ void tst_QGraphicsScene::render_data()
clip_ellipse.addEllipse(100,50,150,200);
QTest::newRow("all-all-untransformed") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("all-topleft-untransformed") << QRectF(0, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("all-topright-untransformed") << QRectF(150, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("all-bottomleft-untransformed") << QRectF(0, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("all-bottomright-untransformed") << QRectF(150, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("topleft-all-untransformed") << QRectF() << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("topright-all-untransformed") << QRectF() << QRectF(0, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottomleft-all-untransformed") << QRectF() << QRectF(-10, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottomright-all-untransformed") << QRectF() << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("topleft-topleft-untransformed") << QRectF(0, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("topright-topleft-untransformed") << QRectF(150, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottomleft-topleft-untransformed") << QRectF(0, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottomright-topleft-untransformed") << QRectF(150, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("top-topleft-untransformed") << QRectF(0, 0, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottom-topleft-untransformed") << QRectF(0, 150, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("left-topleft-untransformed") << QRectF(0, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("right-topleft-untransformed") << QRectF(150, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("top-bottomright-untransformed") << QRectF(0, 0, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("bottom-bottomright-untransformed") << QRectF(0, 150, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("left-bottomright-untransformed") << QRectF(0, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("right-bottomright-untransformed") << QRectF(150, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform() << QPainterPath();
QTest::newRow("all-all-45-deg-right") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(-45) << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform().rotate(-45) << QPainterPath();
QTest::newRow("all-all-45-deg-left") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(45) << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform().rotate(45) << QPainterPath();
QTest::newRow("all-all-scale-2x") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2) << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform::fromScale(2, 2) << QPainterPath();
QTest::newRow("all-all-translate-50-0") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0) << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform::fromTranslate(50, 0) << QPainterPath();
QTest::newRow("all-all-translate-0-50") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50) << QPainterPath();
+ << Qt::IgnoreAspectRatio << QTransform::fromTranslate(0, 50) << QPainterPath();
QTest::newRow("all-all-untransformed-clip-rect") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix() << clip_rect;
+ << Qt::IgnoreAspectRatio << QTransform() << clip_rect;
QTest::newRow("all-all-untransformed-clip-ellipse") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix() << clip_ellipse;
+ << Qt::IgnoreAspectRatio << QTransform() << clip_ellipse;
}
void tst_QGraphicsScene::render()
@@ -2574,7 +2573,7 @@ void tst_QGraphicsScene::render()
QFETCH(QRectF, targetRect);
QFETCH(QRectF, sourceRect);
QFETCH(Qt::AspectRatioMode, aspectRatioMode);
- QFETCH(QMatrix, matrix);
+ QFETCH(QTransform, transform);
QFETCH(QPainterPath, clip);
QPixmap pix(30, 30);
@@ -2602,7 +2601,7 @@ void tst_QGraphicsScene::render()
painter.setPen(QPen(Qt::darkGray, 2));
painter.drawLine(0, 150, 300, 150);
painter.drawLine(150, 0, 150, 300);
- painter.setMatrix(matrix);
+ painter.setTransform(transform);
if (!clip.isEmpty()) painter.setClipPath(clip);
scene.render(&painter, targetRect, sourceRect, aspectRatioMode);
painter.end();
@@ -3519,20 +3518,9 @@ void tst_QGraphicsScene::task250680_childClip()
QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
}
-void tst_QGraphicsScene::sorting_data()
-{
- QTest::addColumn<bool>("cache");
-
- QTest::newRow("Normal sorting") << false;
- QTest::newRow("Cached sorting") << true;
-}
-
void tst_QGraphicsScene::sorting()
{
- QFETCH(bool, cache);
-
QGraphicsScene scene;
- scene.setSortCacheEnabled(cache);
QGraphicsRectItem *t_1 = new QGraphicsRectItem(0, 0, 50, 50);
QGraphicsRectItem *c_1 = new QGraphicsRectItem(0, 0, 40, 40, t_1);