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>
This commit is contained in:
Christian Ehrlicher 2019-02-06 22:09:33 +01:00
parent 4ce485a2eb
commit 1b5a17632e
23 changed files with 212 additions and 219 deletions

View File

@ -116,10 +116,10 @@ void tst_QColorDialog::testGetRgba()
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QEXPECT_FAIL("", "Sending QTest::keyClick to OSX color dialog helper fails, see QTBUG-24320", Continue); QEXPECT_FAIL("", "Sending QTest::keyClick to OSX color dialog helper fails, see QTBUG-24320", Continue);
#endif #endif
bool ok = false; QTimer::singleShot(500, this, &tst_QColorDialog::postKeyReturn);
QTimer::singleShot(500, this, SLOT(postKeyReturn())); const QColor color = QColorDialog::getColor(QColor::fromRgba(0xffffffff), nullptr, QString(),
QColorDialog::getRgba(0xffffffff, &ok); QColorDialog::ShowAlphaChannel);
QVERIFY(ok); QVERIFY(color.isValid());
} }
void tst_QColorDialog::defaultOkButton() void tst_QColorDialog::defaultOkButton()

View File

@ -486,7 +486,7 @@ protected:
parentIndex = source_parent; parentIndex = source_parent;
QString path; QString path;
path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString(); path = sourceModel()->index(source_row, 0, parentIndex).data(Qt::DisplayRole).toString();
do { do {
path = parentIndex.data(Qt::DisplayRole).toString() + QLatin1Char('/') + path; path = parentIndex.data(Qt::DisplayRole).toString() + QLatin1Char('/') + path;

View File

@ -91,7 +91,7 @@ public:
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
painter->drawRoundRect(rect()); painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight()); painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight()); painter->drawLine(rect().bottomLeft(), rect().topRight());
} }

View File

@ -125,7 +125,7 @@ public:
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
painter->drawRoundRect(rect()); painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight()); painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight()); painter->drawLine(rect().bottomLeft(), rect().topRight());
} }

View File

@ -301,8 +301,8 @@ private slots:
void pos(); void pos();
void scenePos(); void scenePos();
void matrix(); void matrix();
void sceneMatrix(); void sceneTransform();
void setMatrix(); void setTransform();
void zValue(); void zValue();
void shape(); void shape();
void contains(); void contains();
@ -552,8 +552,8 @@ void tst_QGraphicsItem::construction()
QVERIFY(!item->acceptHoverEvents()); QVERIFY(!item->acceptHoverEvents());
QVERIFY(!item->hasFocus()); QVERIFY(!item->hasFocus());
QCOMPARE(item->pos(), QPointF()); QCOMPARE(item->pos(), QPointF());
QCOMPARE(item->matrix(), QMatrix()); QCOMPARE(item->transform(), QTransform());
QCOMPARE(item->sceneMatrix(), QMatrix()); QCOMPARE(item->sceneTransform(), QTransform());
QCOMPARE(item->zValue(), qreal(0)); QCOMPARE(item->zValue(), qreal(0));
QCOMPARE(item->sceneBoundingRect(), QRectF()); QCOMPARE(item->sceneBoundingRect(), QRectF());
QCOMPARE(item->shape(), QPainterPath()); QCOMPARE(item->shape(), QPainterPath());
@ -2116,68 +2116,68 @@ void tst_QGraphicsItem::scenePos()
void tst_QGraphicsItem::matrix() void tst_QGraphicsItem::matrix()
{ {
QGraphicsLineItem line; QGraphicsLineItem line;
QCOMPARE(line.matrix(), QMatrix()); QCOMPARE(line.transform(), QTransform());
line.setMatrix(QMatrix().rotate(90)); line.setTransform(QTransform().rotate(90));
QCOMPARE(line.matrix(), QMatrix().rotate(90)); QCOMPARE(line.transform(), QTransform().rotate(90));
line.setMatrix(QMatrix().rotate(90)); line.setTransform(QTransform().rotate(90));
QCOMPARE(line.matrix(), QMatrix().rotate(90)); QCOMPARE(line.transform(), QTransform().rotate(90));
line.setMatrix(QMatrix().rotate(90), true); line.setTransform(QTransform().rotate(90), true);
QCOMPARE(line.matrix(), QMatrix().rotate(180)); QCOMPARE(line.transform(), QTransform().rotate(180));
line.setMatrix(QMatrix().rotate(-90), true); line.setTransform(QTransform().rotate(-90), true);
QCOMPARE(line.matrix(), QMatrix().rotate(90)); QCOMPARE(line.transform(), QTransform().rotate(90));
line.resetMatrix(); line.resetTransform();
QCOMPARE(line.matrix(), QMatrix()); QCOMPARE(line.transform(), QTransform());
line.setTransform(QTransform().rotate(90), true); line.setTransform(QTransform().rotate(90), true);
QCOMPARE(line.matrix(), QMatrix().rotate(90)); QCOMPARE(line.transform(), QTransform().rotate(90));
line.setTransform(QTransform().rotate(90), true); line.setTransform(QTransform().rotate(90), true);
QCOMPARE(line.matrix(), QMatrix().rotate(90).rotate(90)); QCOMPARE(line.transform(), QTransform().rotate(90).rotate(90));
line.resetMatrix(); line.resetTransform();
line.setTransform(QTransform::fromScale(2, 4), true); 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); line.setTransform(QTransform::fromScale(2, 4), true);
QCOMPARE(line.matrix(), QMatrix().scale(2, 4).scale(2, 4)); QCOMPARE(line.transform(), QTransform::fromScale(2, 4).scale(2, 4));
line.resetMatrix(); line.resetTransform();
line.setTransform(QTransform().shear(2, 4), true); 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); line.setTransform(QTransform().shear(2, 4), true);
QCOMPARE(line.matrix(), QMatrix().shear(2, 4).shear(2, 4)); QCOMPARE(line.transform(), QTransform().shear(2, 4).shear(2, 4));
line.resetMatrix(); line.resetTransform();
line.setTransform(QTransform::fromTranslate(10, 10), true); 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); line.setTransform(QTransform::fromTranslate(10, 10), true);
QCOMPARE(line.matrix(), QMatrix().translate(10, 10).translate(10, 10)); QCOMPARE(line.transform(), QTransform::fromTranslate(10, 10).translate(10, 10));
line.resetMatrix(); line.resetTransform();
} }
void tst_QGraphicsItem::sceneMatrix() void tst_QGraphicsItem::sceneTransform()
{ {
QGraphicsLineItem *parent = new QGraphicsLineItem; QGraphicsLineItem *parent = new QGraphicsLineItem;
QGraphicsLineItem *child = new QGraphicsLineItem(QLineF(), parent); QGraphicsLineItem *child = new QGraphicsLineItem(QLineF(), parent);
QCOMPARE(parent->sceneMatrix(), QMatrix()); QCOMPARE(parent->sceneTransform(), QTransform());
QCOMPARE(child->sceneMatrix(), QMatrix()); QCOMPARE(child->sceneTransform(), QTransform());
parent->setTransform(QTransform::fromTranslate(10, 10), true); parent->setTransform(QTransform::fromTranslate(10, 10), true);
QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10)); QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10));
QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10)); QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10));
child->setTransform(QTransform::fromTranslate(10, 10), true); child->setTransform(QTransform::fromTranslate(10, 10), true);
QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10)); QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10));
QCOMPARE(child->sceneMatrix(), QMatrix().translate(20, 20)); QCOMPARE(child->sceneTransform(), QTransform().translate(20, 20));
parent->setTransform(QTransform().rotate(90), true); parent->setTransform(QTransform().rotate(90), true);
QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10).rotate(90)); QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10).rotate(90));
QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10).rotate(90).translate(10, 10)); QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10).rotate(90).translate(10, 10));
delete child; delete child;
delete parent; delete parent;
} }
void tst_QGraphicsItem::setMatrix() void tst_QGraphicsItem::setTransform()
{ {
QGraphicsScene scene; QGraphicsScene scene;
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>))); QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
@ -2190,7 +2190,7 @@ void tst_QGraphicsItem::setMatrix()
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
item.setMatrix(QMatrix().rotate(qreal(12.34))); item.setTransform(QTransform().rotate(qreal(12.34)));
QRectF rotatedRect = scene.sceneRect(); QRectF rotatedRect = scene.sceneRect();
QVERIFY(unrotatedRect != rotatedRect); QVERIFY(unrotatedRect != rotatedRect);
scene.update(scene.sceneRect()); scene.update(scene.sceneRect());
@ -2198,7 +2198,7 @@ void tst_QGraphicsItem::setMatrix()
QCOMPARE(spy.count(), 2); QCOMPARE(spy.count(), 2);
item.setMatrix(QMatrix()); item.setTransform(QTransform());
scene.update(scene.sceneRect()); scene.update(scene.sceneRect());
QApplication::instance()->processEvents(); QApplication::instance()->processEvents();
@ -2485,25 +2485,25 @@ void tst_QGraphicsItem::collidesWith_item()
void tst_QGraphicsItem::collidesWith_path_data() void tst_QGraphicsItem::collidesWith_path_data()
{ {
QTest::addColumn<QPointF>("pos"); QTest::addColumn<QPointF>("pos");
QTest::addColumn<QMatrix>("matrix"); QTest::addColumn<QTransform>("transform");
QTest::addColumn<QPainterPath>("shape"); QTest::addColumn<QPainterPath>("shape");
QTest::addColumn<bool>("rectCollides"); QTest::addColumn<bool>("rectCollides");
QTest::addColumn<bool>("ellipseCollides"); 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; QPainterPath rect;
rect.addRect(0, 0, 20, 20); rect.addRect(0, 0, 20, 20);
QTest::newRow("rect1") << QPointF(0, 0) << QMatrix() << rect << true << true; QTest::newRow("rect1") << QPointF(0, 0) << QTransform() << rect << true << true;
QTest::newRow("rect2") << QPointF(0, 0) << QMatrix().translate(21, 21) << rect << false << false; QTest::newRow("rect2") << QPointF(0, 0) << QTransform::fromTranslate(21, 21) << rect << false << false;
QTest::newRow("rect3") << QPointF(21, 21) << QMatrix() << rect << false << false; QTest::newRow("rect3") << QPointF(21, 21) << QTransform() << rect << false << false;
} }
void tst_QGraphicsItem::collidesWith_path() void tst_QGraphicsItem::collidesWith_path()
{ {
QFETCH(QPointF, pos); QFETCH(QPointF, pos);
QFETCH(QMatrix, matrix); QFETCH(QTransform, transform);
QFETCH(QPainterPath, shape); QFETCH(QPainterPath, shape);
QFETCH(bool, rectCollides); QFETCH(bool, rectCollides);
QFETCH(bool, ellipseCollides); QFETCH(bool, ellipseCollides);
@ -2512,12 +2512,12 @@ void tst_QGraphicsItem::collidesWith_path()
QGraphicsEllipseItem ellipse(QRectF(0, 0, 20, 20)); QGraphicsEllipseItem ellipse(QRectF(0, 0, 20, 20));
rect.setPos(pos); rect.setPos(pos);
rect.setMatrix(matrix); rect.setTransform(transform);
ellipse.setPos(pos); 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) if (rectCollides)
QVERIFY(rect.collidesWithPath(mappedShape)); QVERIFY(rect.collidesWithPath(mappedShape));
@ -2742,35 +2742,35 @@ void tst_QGraphicsItem::mapFromToParent()
item4->setPos(10, 10); item4->setPos(10, 10);
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
QMatrix matrix; QTransform transform;
matrix.rotate(i * 90); transform.rotate(i * 90);
matrix.translate(i * 100, -i * 100); transform.translate(i * 100, -i * 100);
matrix.scale(2, 4); transform.scale(2, 4);
item1->setMatrix(matrix); 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(item2->mapToParent(QPointF(0, 0)), item2->pos());
QCOMPARE(item3->mapToParent(QPointF(0, 0)), item3->pos()); QCOMPARE(item3->mapToParent(QPointF(0, 0)), item3->pos());
QCOMPARE(item4->mapToParent(QPointF(0, 0)), item4->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(item2->mapToParent(QPointF(10, -10)), item2->pos() + QPointF(10, -10));
QCOMPARE(item3->mapToParent(QPointF(10, -10)), item3->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(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(item2->mapToParent(QPointF(-10, 10)), item2->pos() + QPointF(-10, 10));
QCOMPARE(item3->mapToParent(QPointF(-10, 10)), item3->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(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(item2->mapFromParent(item2->pos()), QPointF(0, 0));
QCOMPARE(item3->mapFromParent(item3->pos()), QPointF(0, 0)); QCOMPARE(item3->mapFromParent(item3->pos()), QPointF(0, 0));
QCOMPARE(item4->mapFromParent(item4->pos()), QPointF(0, 0)); QCOMPARE(item4->mapFromParent(item4->pos()), QPointF(0, 0));
QCOMPARE(item1->mapFromParent(item1->pos() + 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(item2->mapFromParent(item2->pos() + QPointF(10, -10)), QPointF(10, -10));
QCOMPARE(item3->mapFromParent(item3->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(item4->mapFromParent(item4->pos() + QPointF(10, -10)), QPointF(10, -10));
QCOMPARE(item1->mapFromParent(item1->pos() + 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(item2->mapFromParent(item2->pos() + QPointF(-10, 10)), QPointF(-10, 10));
QCOMPARE(item3->mapFromParent(item3->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(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)); QCOMPARE(item4->mapFromScene(410, 400), QPointF(10, 0));
// Rotate item1 90 degrees clockwise // Rotate item1 90 degrees clockwise
QMatrix matrix; matrix.rotate(90); QTransform transform; transform.rotate(90);
item1->setMatrix(matrix); item1->setTransform(transform);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->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)); QCOMPARE(item4->mapFromScene(-200, 410), QPointF(10, 0));
// Rotate item2 90 degrees clockwise // Rotate item2 90 degrees clockwise
item2->setMatrix(matrix); item2->setTransform(transform);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->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)); QCOMPARE(item4->mapFromScene(-210, 0), QPointF(10, 0));
// Translate item3 50 points, then rotate 90 degrees counterclockwise // Translate item3 50 points, then rotate 90 degrees counterclockwise
QMatrix matrix2; QTransform transform2;
matrix2.translate(50, 0); transform2.translate(50, 0);
matrix2.rotate(-90); transform2.rotate(-90);
item3->setMatrix(matrix2); item3->setTransform(transform2);
QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item1->pos(), item1->mapToParent(0, 0));
QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0));
QCOMPARE(item3->pos(), item3->mapToParent(0, 0) - QPointF(50, 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(item3->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0)); QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0));
QMatrix matrix; QTransform transform;
matrix.translate(100, 100); transform.translate(100, 100);
item1->setMatrix(matrix); item1->setTransform(transform);
QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(100, -100)); QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(100, -100));
QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(0, 200)); 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(item3->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0)); QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0));
matrix.rotate(90); transform.rotate(90);
item1->setMatrix(matrix); item1->setTransform(transform);
item2->setMatrix(matrix); item2->setTransform(transform);
item3->setMatrix(matrix); item3->setTransform(transform);
item4->setMatrix(matrix); item4->setTransform(transform);
QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(0, -200)); QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(0, -200));
QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(200, 0)); QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(200, 0));
@ -4433,9 +4433,12 @@ protected:
case QGraphicsItem::ItemPositionHasChanged: case QGraphicsItem::ItemPositionHasChanged:
break; break;
case QGraphicsItem::ItemMatrixChange: { case QGraphicsItem::ItemMatrixChange: {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QVariant variant; QVariant variant;
variant.setValue<QMatrix>(matrix()); variant.setValue<QMatrix>(matrix());
oldValues << variant; oldValues << variant;
QT_WARNING_POP
} }
break; break;
case QGraphicsItem::ItemTransformChange: { case QGraphicsItem::ItemTransformChange: {
@ -4556,6 +4559,8 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.isEnabled(), true); QCOMPARE(tester.isEnabled(), true);
} }
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
// ItemMatrixChange / ItemTransformHasChanged // ItemMatrixChange / ItemTransformHasChanged
tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90)); tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90));
tester.setMatrix(QMatrix().translate(50, 0), true); tester.setMatrix(QMatrix().translate(50, 0), true);
@ -4570,6 +4575,7 @@ void tst_QGraphicsItem::itemChange()
variant.setValue<QMatrix>(QMatrix()); variant.setValue<QMatrix>(QMatrix());
QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.oldValues.last(), variant);
QCOMPARE(tester.matrix(), QMatrix().rotate(90)); QCOMPARE(tester.matrix(), QMatrix().rotate(90));
QT_WARNING_POP
} }
{ {
tester.resetTransform(); tester.resetTransform();

View File

@ -150,7 +150,7 @@ public:
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
painter->setBrush(m_brush); painter->setBrush(m_brush);
painter->drawRoundRect(rect()); painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
} }
void setSizeHint(Qt::SizeHint which, const QSizeF &size) { void setSizeHint(Qt::SizeHint which, const QSizeF &size) {

View File

@ -112,14 +112,14 @@ protected:
painter->setOpacity(0.75); painter->setOpacity(0.75);
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
painter->setBrush(Qt::darkGray); 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); painter->setPen(Qt::black);
if (isHovered) { if (isHovered) {
painter->setBrush(QColor(Qt::blue).light(120)); painter->setBrush(QColor(Qt::blue).lighter(120));
} else { } else {
painter->setBrush(Qt::gray); 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_sceneWithFocusWidgets();
void tabFocus_sceneWithNestedFocusWidgets(); void tabFocus_sceneWithNestedFocusWidgets();
void style(); void style();
void sorting_data();
void sorting(); void sorting();
void insertionOrder(); void insertionOrder();
void changedSignal_data(); void changedSignal_data();
@ -459,41 +458,41 @@ void tst_QGraphicsScene::items()
void tst_QGraphicsScene::itemsBoundingRect_data() void tst_QGraphicsScene::itemsBoundingRect_data()
{ {
QTest::addColumn<QList<QRectF> >("rects"); QTest::addColumn<QList<QRectF> >("rects");
QTest::addColumn<QMatrix>("matrix"); QTest::addColumn<QTransform>("transform");
QTest::addColumn<QRectF>("boundingRect"); QTest::addColumn<QRectF>("boundingRect");
QMatrix transformationMatrix; QTransform transformation;
transformationMatrix.translate(50, -50); transformation.translate(50, -50);
transformationMatrix.scale(2, 2); transformation.scale(2, 2);
transformationMatrix.rotate(90); transformation.rotate(90);
QTest::newRow("none") QTest::newRow("none")
<< QList<QRectF>() << QList<QRectF>()
<< QMatrix() << QTransform()
<< QRectF(); << QRectF();
QTest::newRow("{{0, 0, 10, 10}}") QTest::newRow("{{0, 0, 10, 10}}")
<< (QList<QRectF>() << QRectF(0, 0, 10, 10)) << (QList<QRectF>() << QRectF(0, 0, 10, 10))
<< QMatrix() << QTransform()
<< QRectF(0, 0, 10, 10); << QRectF(0, 0, 10, 10);
QTest::newRow("{{-10, -10, 10, 10}}") QTest::newRow("{{-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-10, -10, 10, 10)) << (QList<QRectF>() << QRectF(-10, -10, 10, 10))
<< QMatrix() << QTransform()
<< QRectF(-10, -10, 10, 10); << QRectF(-10, -10, 10, 10);
QTest::newRow("{{-1000, -1000, 1, 1}, {-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)) << (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10))
<< QMatrix() << QTransform()
<< QRectF(-1000, -1000, 1000, 1000); << QRectF(-1000, -1000, 1000, 1000);
QTest::newRow("transformed {{0, 0, 10, 10}}") QTest::newRow("transformed {{0, 0, 10, 10}}")
<< (QList<QRectF>() << QRectF(0, 0, 10, 10)) << (QList<QRectF>() << QRectF(0, 0, 10, 10))
<< transformationMatrix << transformation
<< QRectF(30, -50, 20, 20); << QRectF(30, -50, 20, 20);
QTest::newRow("transformed {{-10, -10, 10, 10}}") QTest::newRow("transformed {{-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-10, -10, 10, 10)) << (QList<QRectF>() << QRectF(-10, -10, 10, 10))
<< transformationMatrix << transformation
<< QRectF(50, -70, 20, 20); << QRectF(50, -70, 20, 20);
QTest::newRow("transformed {{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}") QTest::newRow("transformed {{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}")
<< (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10)) << (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10))
<< transformationMatrix << transformation
<< QRectF(50, -2050, 2000, 2000); << QRectF(50, -2050, 2000, 2000);
QList<QRectF> all; QList<QRectF> all;
@ -501,18 +500,18 @@ void tst_QGraphicsScene::itemsBoundingRect_data()
all << QRectF(randomX[i], randomY[i], 10, 10); all << QRectF(randomX[i], randomY[i], 10, 10);
QTest::newRow("all") QTest::newRow("all")
<< all << all
<< QMatrix() << QTransform()
<< QRectF(-980, -994, 1988, 1983); << QRectF(-980, -994, 1988, 1983);
QTest::newRow("transformed all") QTest::newRow("transformed all")
<< all << all
<< transformationMatrix << transformation
<< QRectF(-1928, -2010, 3966, 3976); << QRectF(-1928, -2010, 3966, 3976);
} }
void tst_QGraphicsScene::itemsBoundingRect() void tst_QGraphicsScene::itemsBoundingRect()
{ {
QFETCH(QList<QRectF>, rects); QFETCH(QList<QRectF>, rects);
QFETCH(QMatrix, matrix); QFETCH(QTransform, transform);
QFETCH(QRectF, boundingRect); QFETCH(QRectF, boundingRect);
QGraphicsScene scene; QGraphicsScene scene;
@ -522,7 +521,7 @@ void tst_QGraphicsScene::itemsBoundingRect()
path.addRect(rect); path.addRect(rect);
QGraphicsPathItem *item = scene.addPath(path); QGraphicsPathItem *item = scene.addPath(path);
item->setPen(QPen(Qt::black, 0)); item->setPen(QPen(Qt::black, 0));
item->setMatrix(matrix); item->setTransform(transform);
} }
QCOMPARE(scene.itemsBoundingRect(), boundingRect); QCOMPARE(scene.itemsBoundingRect(), boundingRect);
@ -2502,7 +2501,7 @@ void tst_QGraphicsScene::render_data()
QTest::addColumn<QRectF>("targetRect"); QTest::addColumn<QRectF>("targetRect");
QTest::addColumn<QRectF>("sourceRect"); QTest::addColumn<QRectF>("sourceRect");
QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode"); QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
QTest::addColumn<QMatrix>("matrix"); QTest::addColumn<QTransform>("transform");
QTest::addColumn<QPainterPath>("clip"); QTest::addColumn<QPainterPath>("clip");
QPainterPath clip_rect; QPainterPath clip_rect;
@ -2512,61 +2511,61 @@ void tst_QGraphicsScene::render_data()
clip_ellipse.addEllipse(100,50,150,200); clip_ellipse.addEllipse(100,50,150,200);
QTest::newRow("all-all-untransformed") << QRectF() << QRectF() 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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() 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() 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() 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() 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() 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() 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() QTest::newRow("all-all-untransformed-clip-ellipse") << QRectF() << QRectF()
<< Qt::IgnoreAspectRatio << QMatrix() << clip_ellipse; << Qt::IgnoreAspectRatio << QTransform() << clip_ellipse;
} }
void tst_QGraphicsScene::render() void tst_QGraphicsScene::render()
@ -2574,7 +2573,7 @@ void tst_QGraphicsScene::render()
QFETCH(QRectF, targetRect); QFETCH(QRectF, targetRect);
QFETCH(QRectF, sourceRect); QFETCH(QRectF, sourceRect);
QFETCH(Qt::AspectRatioMode, aspectRatioMode); QFETCH(Qt::AspectRatioMode, aspectRatioMode);
QFETCH(QMatrix, matrix); QFETCH(QTransform, transform);
QFETCH(QPainterPath, clip); QFETCH(QPainterPath, clip);
QPixmap pix(30, 30); QPixmap pix(30, 30);
@ -2602,7 +2601,7 @@ void tst_QGraphicsScene::render()
painter.setPen(QPen(Qt::darkGray, 2)); painter.setPen(QPen(Qt::darkGray, 2));
painter.drawLine(0, 150, 300, 150); painter.drawLine(0, 150, 300, 150);
painter.drawLine(150, 0, 150, 300); painter.drawLine(150, 0, 150, 300);
painter.setMatrix(matrix); painter.setTransform(transform);
if (!clip.isEmpty()) painter.setClipPath(clip); if (!clip.isEmpty()) painter.setClipPath(clip);
scene.render(&painter, targetRect, sourceRect, aspectRatioMode); scene.render(&painter, targetRect, sourceRect, aspectRatioMode);
painter.end(); painter.end();
@ -3519,20 +3518,9 @@ void tst_QGraphicsScene::task250680_childClip()
QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2); 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() void tst_QGraphicsScene::sorting()
{ {
QFETCH(bool, cache);
QGraphicsScene scene; QGraphicsScene scene;
scene.setSortCacheEnabled(cache);
QGraphicsRectItem *t_1 = new QGraphicsRectItem(0, 0, 50, 50); QGraphicsRectItem *t_1 = new QGraphicsRectItem(0, 0, 50, 50);
QGraphicsRectItem *c_1 = new QGraphicsRectItem(0, 0, 40, 40, t_1); QGraphicsRectItem *c_1 = new QGraphicsRectItem(0, 0, 40, 40, t_1);

View File

@ -502,11 +502,6 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)
view->commitData(0); view->commitData(0);
view->editorDestroyed(0); view->editorDestroyed(0);
view->setHorizontalStepsPerItem(2);
view->horizontalStepsPerItem();
view->setVerticalStepsPerItem(2);
view->verticalStepsPerItem();
// Will assert as it should // Will assert as it should
// view->setIndexWidget(QModelIndex(), 0); // view->setIndexWidget(QModelIndex(), 0);

View File

@ -85,7 +85,8 @@ class XResetModel : public QStandardItemModel
blockSignals(true); blockSignals(true);
bool r = QStandardItemModel::removeRows(row, count, parent); bool r = QStandardItemModel::removeRows(row, count, parent);
blockSignals(false); blockSignals(false);
emit reset(); emit beginResetModel();
emit endResetModel();
return r; return r;
} }
virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
@ -93,7 +94,8 @@ class XResetModel : public QStandardItemModel
blockSignals(true); blockSignals(true);
bool r = QStandardItemModel::insertRows(row, count, parent); bool r = QStandardItemModel::insertRows(row, count, parent);
blockSignals(false); blockSignals(false);
emit reset(); emit beginResetModel();
emit endResetModel();
return r; return r;
} }
}; };

View File

@ -403,14 +403,17 @@ void tst_QListWidget::closePersistentEditor()
void tst_QListWidget::setItemHidden() void tst_QListWidget::setItemHidden()
{ {
#if QT_DEPRECATED_SINCE(5, 13) #if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
// Boundary checking // Boundary checking
testWidget->setItemHidden(0, true); testWidget->setItemHidden(nullptr, true);
testWidget->setItemHidden(0, false); testWidget->setItemHidden(nullptr, false);
QT_WARNING_POP
#endif #endif
int totalHidden = 0; int totalHidden = 0;
for (int i = 0; i < testWidget->model()->rowCount(); ++i) for (int i = 0; i < testWidget->model()->rowCount(); ++i)
if (testWidget->isItemHidden(testWidget->item(i))) if (testWidget->item(i)->isHidden())
totalHidden++; totalHidden++;
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count())); QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
@ -419,7 +422,7 @@ void tst_QListWidget::setItemHidden()
// Check that nothing else changed // Check that nothing else changed
int newTotal = 0; int newTotal = 0;
for (int i = 0; i < testWidget->model()->rowCount(); ++i) for (int i = 0; i < testWidget->model()->rowCount(); ++i)
if (testWidget->isItemHidden(testWidget->item(i))) if (testWidget->item(i)->isHidden())
newTotal++; newTotal++;
QCOMPARE(newTotal, totalHidden); QCOMPARE(newTotal, totalHidden);

View File

@ -4253,7 +4253,7 @@ void tst_QTableView::task234926_setHeaderSorting()
QStringList sortedDataA = data; QStringList sortedDataA = data;
QStringList sortedDataD = data; QStringList sortedDataD = data;
std::sort(sortedDataA.begin(), sortedDataA.end()); std::sort(sortedDataA.begin(), sortedDataA.end());
std::sort(sortedDataD.begin(), sortedDataD.end(), qGreater<QString>()); std::sort(sortedDataD.begin(), sortedDataD.end(), std::greater<QString>());
model.setStringList(data); model.setStringList(data);
QTableView view; QTableView view;
view.setModel(&model); view.setModel(&model);

View File

@ -1567,7 +1567,7 @@ void tst_QTableWidget::task262056_sortDuplicate()
} }
testWidget->sortItems(0, Qt::AscendingOrder); testWidget->sortItems(0, Qt::AscendingOrder);
QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged())); QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
testWidget->item(3,0)->setBackgroundColor(Qt::red); testWidget->item(3,0)->setBackground(Qt::red);
QCOMPARE(layoutChangedSpy.count(),0); QCOMPARE(layoutChangedSpy.count(),0);

View File

@ -1796,7 +1796,7 @@ void tst_QTreeView::keyboardNavigation()
case Qt::Key_Down: case Qt::Key_Down:
if (view.isExpanded(index)) { if (view.isExpanded(index)) {
row = 0; row = 0;
index = index.child(row, column); index = model.index(row, column, index);
} else { } else {
row = qMin(rows - 1, row + 1); row = qMin(rows - 1, row + 1);
index = index.sibling(row, column); index = index.sibling(row, column);

View File

@ -874,9 +874,12 @@ void tst_QTreeWidget::selectedItems()
} }
#if QT_DEPRECATED_SINCE(5, 13) #if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
// Possible to select null without crashing? // Possible to select null without crashing?
testWidget->setItemSelected(0, true); testWidget->setItemSelected(nullptr, true);
QVERIFY(!testWidget->isItemSelected(0)); QVERIFY(!testWidget->isItemSelected(nullptr));
QT_WARNING_POP
#endif #endif
// unselect // unselect
@ -1876,14 +1879,14 @@ void tst_QTreeWidget::setData()
item->setBackground(j, backgroundColor); item->setBackground(j, backgroundColor);
QCOMPARE(itemChangedSpy.count(), 0); QCOMPARE(itemChangedSpy.count(), 0);
QColor textColor((i == 1) ? Qt::green : Qt::cyan); const QColor foregroundColor((i == 1) ? Qt::green : Qt::cyan);
item->setTextColor(j, textColor); item->setForeground(j, foregroundColor);
QCOMPARE(item->textColor(j), textColor); QCOMPARE(item->foreground(j), foregroundColor);
QCOMPARE(itemChangedSpy.count(), 1); QCOMPARE(itemChangedSpy.count(), 1);
args = itemChangedSpy.takeFirst(); args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j); QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setTextColor(j, textColor); item->setForeground(j, foregroundColor);
QCOMPARE(itemChangedSpy.count(), 0); QCOMPARE(itemChangedSpy.count(), 0);
Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked); Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked);
@ -1905,7 +1908,7 @@ void tst_QTreeWidget::setData()
QCOMPARE(item->font(j), font); QCOMPARE(item->font(j), font);
QCOMPARE(item->textAlignment(j), int(textAlignment)); QCOMPARE(item->textAlignment(j), int(textAlignment));
QCOMPARE(item->background(j).color(), backgroundColor); QCOMPARE(item->background(j).color(), backgroundColor);
QCOMPARE(item->textColor(j), textColor); QCOMPARE(item->foreground(j), foregroundColor);
QCOMPARE(item->checkState(j), checkState); QCOMPARE(item->checkState(j), checkState);
QCOMPARE(qvariant_cast<QString>(item->data(j, Qt::DisplayRole)), text); QCOMPARE(qvariant_cast<QString>(item->data(j, Qt::DisplayRole)), text);
@ -1917,7 +1920,7 @@ void tst_QTreeWidget::setData()
QCOMPARE(qvariant_cast<QFont>(item->data(j, Qt::FontRole)), font); QCOMPARE(qvariant_cast<QFont>(item->data(j, Qt::FontRole)), font);
QCOMPARE(qvariant_cast<int>(item->data(j, Qt::TextAlignmentRole)), int(textAlignment)); QCOMPARE(qvariant_cast<int>(item->data(j, Qt::TextAlignmentRole)), int(textAlignment));
QCOMPARE(qvariant_cast<QBrush>(item->data(j, Qt::BackgroundRole)), QBrush(backgroundColor)); QCOMPARE(qvariant_cast<QBrush>(item->data(j, Qt::BackgroundRole)), QBrush(backgroundColor));
QCOMPARE(qvariant_cast<QColor>(item->data(j, Qt::ForegroundRole)), textColor); QCOMPARE(qvariant_cast<QColor>(item->data(j, Qt::ForegroundRole)), foregroundColor);
QCOMPARE(qvariant_cast<int>(item->data(j, Qt::CheckStateRole)), int(checkState)); QCOMPARE(qvariant_cast<int>(item->data(j, Qt::CheckStateRole)), int(checkState));
item->setBackground(j, pixmap); item->setBackground(j, pixmap);

View File

@ -2200,8 +2200,6 @@ void tst_QApplication::abortQuitOnShow()
void tst_QApplication::staticFunctions() void tst_QApplication::staticFunctions()
{ {
QApplication::setStyle(QStringLiteral("blub")); QApplication::setStyle(QStringLiteral("blub"));
QApplication::colorSpec();
QApplication::setColorSpec(42);
QApplication::allWidgets(); QApplication::allWidgets();
QApplication::topLevelWidgets(); QApplication::topLevelWidgets();
QApplication::desktop(); QApplication::desktop();

View File

@ -32,6 +32,9 @@
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <QDebug> #include <QDebug>
// the complete class is deprecated
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
class tst_QDesktopWidget : public QObject class tst_QDesktopWidget : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -163,7 +166,7 @@ void tst_QDesktopWidget::topLevels()
QCOMPARE(topLevelDesktopWidgets, 0); QCOMPARE(topLevelDesktopWidgets, 0);
QCOMPARE(topLevelDesktopWindows, 0); QCOMPARE(topLevelDesktopWindows, 0);
} }
QT_WARNING_POP
QTEST_MAIN(tst_QDesktopWidget) QTEST_MAIN(tst_QDesktopWidget)
#include "tst_qdesktopwidget.moc" #include "tst_qdesktopwidget.moc"

View File

@ -197,7 +197,7 @@ void tst_QStyle::drawItemPixmap()
const QRgb green = QColor(Qt::green).rgb(); const QRgb green = QColor(Qt::green).rgb();
QVERIFY(image.reinterpretAsFormat(QImage::Format_RGB32)); QVERIFY(image.reinterpretAsFormat(QImage::Format_RGB32));
const QRgb *bits = reinterpret_cast<const QRgb *>(image.constBits()); const QRgb *bits = reinterpret_cast<const QRgb *>(image.constBits());
const QRgb *end = bits + image.byteCount() / sizeof(QRgb); const QRgb *end = bits + image.sizeInBytes() / sizeof(QRgb);
#ifdef Q_OS_WINRT #ifdef Q_OS_WINRT
QEXPECT_FAIL("", "QWidget::resize does not work on WinRT", Continue); QEXPECT_FAIL("", "QWidget::resize does not work on WinRT", Continue);
#endif #endif

View File

@ -1595,27 +1595,16 @@ void tst_QCompleter::task247560_keyboardNavigation()
} }
// Helpers for QTBUG_14292_filesystem: Recursion helper for below recurseTreeModel // Helpers for QTBUG_14292_filesystem: Recursion helper for below recurseTreeModel
template <class Function>
bool recurseTreeModelIndex(const QModelIndex &idx, Function f, int depth = 0)
{
if (f(idx, depth))
return true;
const int rowCount = idx.model()->rowCount(idx);
for (int row = 0; row < rowCount; ++row)
if (recurseTreeModelIndex(idx.child(row, 0), f, depth + 1))
return true;
return false;
}
// Function to recurse over a tree model applying a function // Function to recurse over a tree model applying a function
// taking index and depth, returning true to terminate recursion. // taking index and depth, returning true to terminate recursion.
template <class Function> template <class Function>
bool recurseTreeModel(const QAbstractItemModel &m, Function f) bool recurseTreeModel(const QAbstractItemModel &m, const QModelIndex &idx, Function f, int depth = 0)
{ {
const int rowCount = m.rowCount(QModelIndex()); if (idx.isValid() && f(idx, depth))
return true;
const int rowCount = m.rowCount(idx);
for (int row = 0; row < rowCount; ++row) for (int row = 0; row < rowCount; ++row)
if (recurseTreeModelIndex(m.index(row, 0, QModelIndex()), f)) if (recurseTreeModel(m, m.index(row, 0, idx), f, depth + 1))
return true; return true;
return false; return false;
} }
@ -1658,7 +1647,7 @@ QDebug operator<<(QDebug d, const QAbstractItemModel &m)
{ {
QDebug dns = d.nospace(); QDebug dns = d.nospace();
dns << '\n'; dns << '\n';
recurseTreeModel(m, DebugFunction(dns)); recurseTreeModel(m, QModelIndex(), DebugFunction(dns));
return d; return d;
} }
@ -1671,8 +1660,8 @@ static const char testDir2[] = "holla";
static inline bool testFileSystemReady(const QAbstractItemModel &model) static inline bool testFileSystemReady(const QAbstractItemModel &model)
{ {
return recurseTreeModel(model, SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole)) return recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole))
&& recurseTreeModel(model, SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole)); && recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole));
} }
void tst_QCompleter::QTBUG_14292_filesystem() void tst_QCompleter::QTBUG_14292_filesystem()

View File

@ -823,7 +823,7 @@ void tst_QDateTimeEdit::displayFormat_data()
<< QString("31 12 2999::59:59:03") << dt; << QString("31 12 2999::59:59:03") << dt;
QTest::newRow("valid-2") << QString("hh-dd-mm-MM-yy") << true << QString("03-31-59-12-99") << dt; QTest::newRow("valid-2") << QString("hh-dd-mm-MM-yy") << true << QString("03-31-59-12-99") << dt;
QTest::newRow("valid-3") << QString("ddd MM d yyyy::ss:mm:hh") << true QTest::newRow("valid-3") << QString("ddd MM d yyyy::ss:mm:hh") << true
<< QDate::shortDayName(2) + " 12 31 2999::59:59:03" << dt; << QLocale::system().dayName(2, QLocale::ShortFormat) + " 12 31 2999::59:59:03" << dt;
QTest::newRow("valid-4") << QString("hh-dd-mm-MM-yyyy") << true << QString("03-31-59-12-2999") << dt; QTest::newRow("valid-4") << QString("hh-dd-mm-MM-yyyy") << true << QString("03-31-59-12-2999") << dt;
QTest::newRow("invalid-0") << QString("yyyy.MM.yy") << true << QString("2999.12.99") << dt; QTest::newRow("invalid-0") << QString("yyyy.MM.yy") << true << QString("2999.12.99") << dt;
QTest::newRow("invalid-1") << QString("y") << false << QString() << dt; QTest::newRow("invalid-1") << QString("y") << false << QString() << dt;
@ -2611,9 +2611,13 @@ void tst_QDateTimeEdit::weirdCase()
void tst_QDateTimeEdit::newCase() void tst_QDateTimeEdit::newCase()
{ {
if (QDate::shortMonthName(6) != "Jun" || QDate::shortMonthName(7) != "Jul" || const auto locale = QLocale::system();
QDate::longMonthName(6) != "June" || QDate::longMonthName(7) != "July") if (locale.monthName(6, QLocale::ShortFormat) != "Jun" ||
locale.monthName(7, QLocale::ShortFormat) != "Jul" ||
locale.monthName(6, QLocale::LongFormat) != "June" ||
locale.monthName(7, QLocale::LongFormat) != "July") {
QSKIP("This test only works in English"); QSKIP("This test only works in English");
}
testWidget->setDisplayFormat("MMMM'a'MbMMMcMM"); testWidget->setDisplayFormat("MMMM'a'MbMMMcMM");
testWidget->setDate(QDate(2005, 6, 1)); testWidget->setDate(QDate(2005, 6, 1));
@ -2656,12 +2660,12 @@ void tst_QDateTimeEdit::newCase2()
testWidget->setDate(QDate(2005, 8, 8)); testWidget->setDate(QDate(2005, 8, 8));
QTest::keyClick(testWidget, Qt::Key_Return); QTest::keyClick(testWidget, Qt::Key_Return);
QTest::keyClick(testWidget, Qt::Key_Backspace); QTest::keyClick(testWidget, Qt::Key_Backspace);
QCOMPARE(testWidget->text(), QString(" 2005-08-08 ") + QDate::longMonthName(8)); QCOMPARE(testWidget->text(), QString(" 2005-08-08 ") + QLocale::system().monthName(8, QLocale::LongFormat));
} }
void tst_QDateTimeEdit::newCase3() void tst_QDateTimeEdit::newCase3()
{ {
if (!QDate::longMonthName(1).startsWith("Januar")) if (!QLocale::system().monthName(1, QLocale::LongFormat).startsWith("Januar"))
QSKIP("This test does not work in this locale"); QSKIP("This test does not work in this locale");
testWidget->setDisplayFormat("dd MMMM yyyy"); testWidget->setDisplayFormat("dd MMMM yyyy");
@ -2681,7 +2685,7 @@ void tst_QDateTimeEdit::newCase3()
void tst_QDateTimeEdit::cursorPos() void tst_QDateTimeEdit::cursorPos()
{ {
if (QDate::longMonthName(1) != "January") if (QLocale::system().monthName(1, QLocale::LongFormat) != "January")
QSKIP("This test only works in English"); QSKIP("This test only works in English");
testWidget->setDisplayFormat("dd MMMM yyyy"); testWidget->setDisplayFormat("dd MMMM yyyy");
@ -3017,7 +3021,7 @@ void tst_QDateTimeEdit::yyTest()
testWidget->setDate(testWidget->minimumDate()); testWidget->setDate(testWidget->minimumDate());
testWidget->setCurrentSection(QDateTimeEdit::YearSection); testWidget->setCurrentSection(QDateTimeEdit::YearSection);
QString jan = QDate::shortMonthName(1); QString jan = QLocale::system().monthName(1, QLocale::ShortFormat);
QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-05"); QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-05");
QTest::keyClick(testWidget, Qt::Key_Up); QTest::keyClick(testWidget, Qt::Key_Up);
QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-06"); QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-06");
@ -3130,7 +3134,7 @@ void tst_QDateTimeEdit::ddMMMMyyyy()
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QEXPECT_FAIL("", "QTBUG-23674", Abort); QEXPECT_FAIL("", "QTBUG-23674", Abort);
#endif #endif
QCOMPARE(testWidget->lineEdit()->text(), "01." + QDate::longMonthName(1) + ".200"); QCOMPARE(testWidget->lineEdit()->text(), "01." + QLocale::system().monthName(1, QLocale::LongFormat) + ".200");
} }
void tst_QDateTimeEdit::wheelEvent_data() void tst_QDateTimeEdit::wheelEvent_data()

View File

@ -1001,7 +1001,7 @@ void tst_QMenu::task258920_mouseBorder()
menu.setMouseTracking(true); menu.setMouseTracking(true);
QAction *action = menu.addAction("test"); QAction *action = menu.addAction("test");
const QPoint center = QApplication::desktop()->availableGeometry().center(); const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
menu.popup(center); menu.popup(center);
QVERIFY(QTest::qWaitForWindowExposed(&menu)); QVERIFY(QTest::qWaitForWindowExposed(&menu));
QRect actionRect = menu.actionGeometry(action); QRect actionRect = menu.actionGeometry(action);
@ -1073,9 +1073,9 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow()
QMenu *buttonMenu= new PopulateOnAboutToShowTestMenu(&b); QMenu *buttonMenu= new PopulateOnAboutToShowTestMenu(&b);
b.setMenu(buttonMenu); b.setMenu(buttonMenu);
const int scrNumber = QApplication::desktop()->screenNumber(&b); const QScreen *scr = QGuiApplication::screenAt(b.pos());
b.show(); b.show();
const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); const QRect screen = scr->geometry();
QRect desiredGeometry = b.geometry(); QRect desiredGeometry = b.geometry();
desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5)); desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5));
@ -1450,13 +1450,14 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber()
QString longString; QString longString;
longString.fill(QLatin1Char('Q'), 3000); longString.fill(QLatin1Char('Q'), 3000);
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { const QList<QScreen *> screens = QGuiApplication::screens();
for (QScreen *screen : screens) {
QMenu menu; QMenu menu;
menu.addAction(longString); menu.addAction(longString);
menu.popup(QApplication::desktop()->screen(i)->geometry().center()); menu.popup(screen->geometry().center());
QVERIFY(QTest::qWaitForWindowExposed(&menu)); QVERIFY(QTest::qWaitForWindowExposed(&menu));
QVERIFY(menu.isVisible()); QVERIFY(menu.isVisible());
QCOMPARE(QApplication::desktop()->screenNumber(&menu), i); QCOMPARE(QGuiApplication::screenAt(menu.pos()), screen);
} }
} }
@ -1468,19 +1469,20 @@ void tst_QMenu::QTBUG_56917_wideSubmenuScreenNumber()
QString longString; QString longString;
longString.fill(QLatin1Char('Q'), 3000); longString.fill(QLatin1Char('Q'), 3000);
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { const QList<QScreen *> screens = QGuiApplication::screens();
for (QScreen *screen : screens) {
QMenu menu; QMenu menu;
QMenu submenu("Submenu"); QMenu submenu("Submenu");
submenu.addAction(longString); submenu.addAction(longString);
QAction *action = menu.addMenu(&submenu); QAction *action = menu.addMenu(&submenu);
menu.popup(QApplication::desktop()->screen(i)->geometry().center()); menu.popup(screen->geometry().center());
QVERIFY(QTest::qWaitForWindowExposed(&menu)); QVERIFY(QTest::qWaitForWindowExposed(&menu));
QVERIFY(menu.isVisible()); QVERIFY(menu.isVisible());
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center()); QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center());
QTest::qWait(100); QTest::qWait(100);
QVERIFY(QTest::qWaitForWindowExposed(&submenu)); QVERIFY(QTest::qWaitForWindowExposed(&submenu));
QVERIFY(submenu.isVisible()); QVERIFY(submenu.isVisible());
QCOMPARE(QApplication::desktop()->screenNumber(&submenu), i); QCOMPARE(QGuiApplication::screenAt(submenu.pos()), screen);
} }
} }

View File

@ -326,7 +326,7 @@ TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb)
connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered()));
result.actions << action; result.actions << action;
qFill(m_complexTriggerCount, m_complexTriggerCount + sizeof(m_complexTriggerCount) / sizeof(int), 0); std::fill(m_complexTriggerCount, m_complexTriggerCount + sizeof(m_complexTriggerCount) / sizeof(int), 0);
return result; return result;
} }

View File

@ -209,12 +209,12 @@ void tst_QPlainTextEdit::getSetCheck()
// int QPlainTextEdit::tabStopWidth() // int QPlainTextEdit::tabStopWidth()
// void QPlainTextEdit::setTabStopWidth(int) // void QPlainTextEdit::setTabStopWidth(int)
obj1.setTabStopWidth(0); obj1.setTabStopDistance(0);
QCOMPARE(0, obj1.tabStopWidth()); QCOMPARE(0, obj1.tabStopDistance());
obj1.setTabStopWidth(INT_MIN); obj1.setTabStopDistance(-1);
QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value QCOMPARE(0, obj1.tabStopDistance()); // Makes no sense to set a negative tabstop value
obj1.setTabStopWidth(INT_MAX); obj1.setTabStopDistance(std::numeric_limits<qreal>::max());
QCOMPARE(INT_MAX, obj1.tabStopWidth()); QCOMPARE(std::numeric_limits<qreal>::max(), obj1.tabStopDistance());
} }
class QtTestDocumentLayout : public QAbstractTextDocumentLayout class QtTestDocumentLayout : public QAbstractTextDocumentLayout

View File

@ -282,12 +282,12 @@ void tst_QTextEdit::getSetCheck()
// int QTextEdit::tabStopWidth() // int QTextEdit::tabStopWidth()
// void QTextEdit::setTabStopWidth(int) // void QTextEdit::setTabStopWidth(int)
obj1.setTabStopWidth(0); obj1.setTabStopDistance(0);
QCOMPARE(0, obj1.tabStopWidth()); QCOMPARE(0, obj1.tabStopDistance());
obj1.setTabStopWidth(INT_MIN); obj1.setTabStopDistance(-1);
QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value QCOMPARE(0, obj1.tabStopDistance()); // Makes no sense to set a negative tabstop value
obj1.setTabStopWidth(INT_MAX); obj1.setTabStopDistance(std::numeric_limits<qreal>::max());
QCOMPARE(INT_MAX, obj1.tabStopWidth()); QCOMPARE(std::numeric_limits<qreal>::max(), obj1.tabStopDistance());
// bool QTextEdit::acceptRichText() // bool QTextEdit::acceptRichText()
// void QTextEdit::setAcceptRichText(bool) // void QTextEdit::setAcceptRichText(bool)