mirror of https://github.com/qt/qtbase.git
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:
parent
4ce485a2eb
commit
1b5a17632e
|
@ -116,10 +116,10 @@ void tst_QColorDialog::testGetRgba()
|
|||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL("", "Sending QTest::keyClick to OSX color dialog helper fails, see QTBUG-24320", Continue);
|
||||
#endif
|
||||
bool ok = false;
|
||||
QTimer::singleShot(500, this, SLOT(postKeyReturn()));
|
||||
QColorDialog::getRgba(0xffffffff, &ok);
|
||||
QVERIFY(ok);
|
||||
QTimer::singleShot(500, this, &tst_QColorDialog::postKeyReturn);
|
||||
const QColor color = QColorDialog::getColor(QColor::fromRgba(0xffffffff), nullptr, QString(),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
QVERIFY(color.isValid());
|
||||
}
|
||||
|
||||
void tst_QColorDialog::defaultOkButton()
|
||||
|
|
|
@ -486,7 +486,7 @@ protected:
|
|||
parentIndex = source_parent;
|
||||
|
||||
QString path;
|
||||
path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
|
||||
path = sourceModel()->index(source_row, 0, parentIndex).data(Qt::DisplayRole).toString();
|
||||
|
||||
do {
|
||||
path = parentIndex.data(Qt::DisplayRole).toString() + QLatin1Char('/') + path;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -502,11 +502,6 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)
|
|||
view->commitData(0);
|
||||
view->editorDestroyed(0);
|
||||
|
||||
view->setHorizontalStepsPerItem(2);
|
||||
view->horizontalStepsPerItem();
|
||||
view->setVerticalStepsPerItem(2);
|
||||
view->verticalStepsPerItem();
|
||||
|
||||
// Will assert as it should
|
||||
// view->setIndexWidget(QModelIndex(), 0);
|
||||
|
||||
|
|
|
@ -85,7 +85,8 @@ class XResetModel : public QStandardItemModel
|
|||
blockSignals(true);
|
||||
bool r = QStandardItemModel::removeRows(row, count, parent);
|
||||
blockSignals(false);
|
||||
emit reset();
|
||||
emit beginResetModel();
|
||||
emit endResetModel();
|
||||
return r;
|
||||
}
|
||||
virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
|
||||
|
@ -93,7 +94,8 @@ class XResetModel : public QStandardItemModel
|
|||
blockSignals(true);
|
||||
bool r = QStandardItemModel::insertRows(row, count, parent);
|
||||
blockSignals(false);
|
||||
emit reset();
|
||||
emit beginResetModel();
|
||||
emit endResetModel();
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -403,14 +403,17 @@ void tst_QListWidget::closePersistentEditor()
|
|||
void tst_QListWidget::setItemHidden()
|
||||
{
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
// Boundary checking
|
||||
testWidget->setItemHidden(0, true);
|
||||
testWidget->setItemHidden(0, false);
|
||||
testWidget->setItemHidden(nullptr, true);
|
||||
testWidget->setItemHidden(nullptr, false);
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
|
||||
int totalHidden = 0;
|
||||
for (int i = 0; i < testWidget->model()->rowCount(); ++i)
|
||||
if (testWidget->isItemHidden(testWidget->item(i)))
|
||||
if (testWidget->item(i)->isHidden())
|
||||
totalHidden++;
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
|
||||
|
@ -419,7 +422,7 @@ void tst_QListWidget::setItemHidden()
|
|||
// Check that nothing else changed
|
||||
int newTotal = 0;
|
||||
for (int i = 0; i < testWidget->model()->rowCount(); ++i)
|
||||
if (testWidget->isItemHidden(testWidget->item(i)))
|
||||
if (testWidget->item(i)->isHidden())
|
||||
newTotal++;
|
||||
QCOMPARE(newTotal, totalHidden);
|
||||
|
||||
|
|
|
@ -4253,7 +4253,7 @@ void tst_QTableView::task234926_setHeaderSorting()
|
|||
QStringList sortedDataA = data;
|
||||
QStringList sortedDataD = data;
|
||||
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);
|
||||
QTableView view;
|
||||
view.setModel(&model);
|
||||
|
|
|
@ -1567,7 +1567,7 @@ void tst_QTableWidget::task262056_sortDuplicate()
|
|||
}
|
||||
testWidget->sortItems(0, Qt::AscendingOrder);
|
||||
QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
|
||||
testWidget->item(3,0)->setBackgroundColor(Qt::red);
|
||||
testWidget->item(3,0)->setBackground(Qt::red);
|
||||
|
||||
QCOMPARE(layoutChangedSpy.count(),0);
|
||||
|
||||
|
|
|
@ -1796,7 +1796,7 @@ void tst_QTreeView::keyboardNavigation()
|
|||
case Qt::Key_Down:
|
||||
if (view.isExpanded(index)) {
|
||||
row = 0;
|
||||
index = index.child(row, column);
|
||||
index = model.index(row, column, index);
|
||||
} else {
|
||||
row = qMin(rows - 1, row + 1);
|
||||
index = index.sibling(row, column);
|
||||
|
|
|
@ -874,9 +874,12 @@ void tst_QTreeWidget::selectedItems()
|
|||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
// Possible to select null without crashing?
|
||||
testWidget->setItemSelected(0, true);
|
||||
QVERIFY(!testWidget->isItemSelected(0));
|
||||
testWidget->setItemSelected(nullptr, true);
|
||||
QVERIFY(!testWidget->isItemSelected(nullptr));
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
|
||||
// unselect
|
||||
|
@ -1876,14 +1879,14 @@ void tst_QTreeWidget::setData()
|
|||
item->setBackground(j, backgroundColor);
|
||||
QCOMPARE(itemChangedSpy.count(), 0);
|
||||
|
||||
QColor textColor((i == 1) ? Qt::green : Qt::cyan);
|
||||
item->setTextColor(j, textColor);
|
||||
QCOMPARE(item->textColor(j), textColor);
|
||||
const QColor foregroundColor((i == 1) ? Qt::green : Qt::cyan);
|
||||
item->setForeground(j, foregroundColor);
|
||||
QCOMPARE(item->foreground(j), foregroundColor);
|
||||
QCOMPARE(itemChangedSpy.count(), 1);
|
||||
args = itemChangedSpy.takeFirst();
|
||||
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
|
||||
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
|
||||
item->setTextColor(j, textColor);
|
||||
item->setForeground(j, foregroundColor);
|
||||
QCOMPARE(itemChangedSpy.count(), 0);
|
||||
|
||||
Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked);
|
||||
|
@ -1905,7 +1908,7 @@ void tst_QTreeWidget::setData()
|
|||
QCOMPARE(item->font(j), font);
|
||||
QCOMPARE(item->textAlignment(j), int(textAlignment));
|
||||
QCOMPARE(item->background(j).color(), backgroundColor);
|
||||
QCOMPARE(item->textColor(j), textColor);
|
||||
QCOMPARE(item->foreground(j), foregroundColor);
|
||||
QCOMPARE(item->checkState(j), checkState);
|
||||
|
||||
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<int>(item->data(j, Qt::TextAlignmentRole)), int(textAlignment));
|
||||
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));
|
||||
|
||||
item->setBackground(j, pixmap);
|
||||
|
|
|
@ -2200,8 +2200,6 @@ void tst_QApplication::abortQuitOnShow()
|
|||
void tst_QApplication::staticFunctions()
|
||||
{
|
||||
QApplication::setStyle(QStringLiteral("blub"));
|
||||
QApplication::colorSpec();
|
||||
QApplication::setColorSpec(42);
|
||||
QApplication::allWidgets();
|
||||
QApplication::topLevelWidgets();
|
||||
QApplication::desktop();
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include <QtGui/QWindow>
|
||||
#include <QDebug>
|
||||
|
||||
// the complete class is deprecated
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
class tst_QDesktopWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -163,7 +166,7 @@ void tst_QDesktopWidget::topLevels()
|
|||
QCOMPARE(topLevelDesktopWidgets, 0);
|
||||
QCOMPARE(topLevelDesktopWindows, 0);
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
QTEST_MAIN(tst_QDesktopWidget)
|
||||
#include "tst_qdesktopwidget.moc"
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ void tst_QStyle::drawItemPixmap()
|
|||
const QRgb green = QColor(Qt::green).rgb();
|
||||
QVERIFY(image.reinterpretAsFormat(QImage::Format_RGB32));
|
||||
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
|
||||
QEXPECT_FAIL("", "QWidget::resize does not work on WinRT", Continue);
|
||||
#endif
|
||||
|
|
|
@ -1595,27 +1595,16 @@ void tst_QCompleter::task247560_keyboardNavigation()
|
|||
}
|
||||
|
||||
// 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
|
||||
// taking index and depth, returning true to terminate recursion.
|
||||
|
||||
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)
|
||||
if (recurseTreeModelIndex(m.index(row, 0, QModelIndex()), f))
|
||||
if (recurseTreeModel(m, m.index(row, 0, idx), f, depth + 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -1658,7 +1647,7 @@ QDebug operator<<(QDebug d, const QAbstractItemModel &m)
|
|||
{
|
||||
QDebug dns = d.nospace();
|
||||
dns << '\n';
|
||||
recurseTreeModel(m, DebugFunction(dns));
|
||||
recurseTreeModel(m, QModelIndex(), DebugFunction(dns));
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -1671,8 +1660,8 @@ static const char testDir2[] = "holla";
|
|||
|
||||
static inline bool testFileSystemReady(const QAbstractItemModel &model)
|
||||
{
|
||||
return recurseTreeModel(model, SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole))
|
||||
&& recurseTreeModel(model, SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole));
|
||||
return recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole))
|
||||
&& recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole));
|
||||
}
|
||||
|
||||
void tst_QCompleter::QTBUG_14292_filesystem()
|
||||
|
|
|
@ -823,7 +823,7 @@ void tst_QDateTimeEdit::displayFormat_data()
|
|||
<< 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-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("invalid-0") << QString("yyyy.MM.yy") << true << QString("2999.12.99") << dt;
|
||||
QTest::newRow("invalid-1") << QString("y") << false << QString() << dt;
|
||||
|
@ -2611,9 +2611,13 @@ void tst_QDateTimeEdit::weirdCase()
|
|||
|
||||
void tst_QDateTimeEdit::newCase()
|
||||
{
|
||||
if (QDate::shortMonthName(6) != "Jun" || QDate::shortMonthName(7) != "Jul" ||
|
||||
QDate::longMonthName(6) != "June" || QDate::longMonthName(7) != "July")
|
||||
const auto locale = QLocale::system();
|
||||
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");
|
||||
}
|
||||
|
||||
testWidget->setDisplayFormat("MMMM'a'MbMMMcMM");
|
||||
testWidget->setDate(QDate(2005, 6, 1));
|
||||
|
@ -2656,12 +2660,12 @@ void tst_QDateTimeEdit::newCase2()
|
|||
testWidget->setDate(QDate(2005, 8, 8));
|
||||
QTest::keyClick(testWidget, Qt::Key_Return);
|
||||
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()
|
||||
{
|
||||
if (!QDate::longMonthName(1).startsWith("Januar"))
|
||||
if (!QLocale::system().monthName(1, QLocale::LongFormat).startsWith("Januar"))
|
||||
QSKIP("This test does not work in this locale");
|
||||
|
||||
testWidget->setDisplayFormat("dd MMMM yyyy");
|
||||
|
@ -2681,7 +2685,7 @@ void tst_QDateTimeEdit::newCase3()
|
|||
|
||||
void tst_QDateTimeEdit::cursorPos()
|
||||
{
|
||||
if (QDate::longMonthName(1) != "January")
|
||||
if (QLocale::system().monthName(1, QLocale::LongFormat) != "January")
|
||||
QSKIP("This test only works in English");
|
||||
|
||||
testWidget->setDisplayFormat("dd MMMM yyyy");
|
||||
|
@ -3017,7 +3021,7 @@ void tst_QDateTimeEdit::yyTest()
|
|||
testWidget->setDate(testWidget->minimumDate());
|
||||
testWidget->setCurrentSection(QDateTimeEdit::YearSection);
|
||||
|
||||
QString jan = QDate::shortMonthName(1);
|
||||
QString jan = QLocale::system().monthName(1, QLocale::ShortFormat);
|
||||
QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-05");
|
||||
QTest::keyClick(testWidget, Qt::Key_Up);
|
||||
QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-06");
|
||||
|
@ -3130,7 +3134,7 @@ void tst_QDateTimeEdit::ddMMMMyyyy()
|
|||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL("", "QTBUG-23674", Abort);
|
||||
#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()
|
||||
|
|
|
@ -1001,7 +1001,7 @@ void tst_QMenu::task258920_mouseBorder()
|
|||
menu.setMouseTracking(true);
|
||||
QAction *action = menu.addAction("test");
|
||||
|
||||
const QPoint center = QApplication::desktop()->availableGeometry().center();
|
||||
const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
|
||||
menu.popup(center);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&menu));
|
||||
QRect actionRect = menu.actionGeometry(action);
|
||||
|
@ -1073,9 +1073,9 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow()
|
|||
|
||||
QMenu *buttonMenu= new PopulateOnAboutToShowTestMenu(&b);
|
||||
b.setMenu(buttonMenu);
|
||||
const int scrNumber = QApplication::desktop()->screenNumber(&b);
|
||||
const QScreen *scr = QGuiApplication::screenAt(b.pos());
|
||||
b.show();
|
||||
const QRect screen = QApplication::desktop()->screenGeometry(scrNumber);
|
||||
const QRect screen = scr->geometry();
|
||||
|
||||
QRect desiredGeometry = b.geometry();
|
||||
desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5));
|
||||
|
@ -1450,13 +1450,14 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber()
|
|||
QString longString;
|
||||
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;
|
||||
menu.addAction(longString);
|
||||
menu.popup(QApplication::desktop()->screen(i)->geometry().center());
|
||||
menu.popup(screen->geometry().center());
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&menu));
|
||||
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;
|
||||
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 submenu("Submenu");
|
||||
submenu.addAction(longString);
|
||||
QAction *action = menu.addMenu(&submenu);
|
||||
menu.popup(QApplication::desktop()->screen(i)->geometry().center());
|
||||
menu.popup(screen->geometry().center());
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&menu));
|
||||
QVERIFY(menu.isVisible());
|
||||
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center());
|
||||
QTest::qWait(100);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&submenu));
|
||||
QVERIFY(submenu.isVisible());
|
||||
QCOMPARE(QApplication::desktop()->screenNumber(&submenu), i);
|
||||
QCOMPARE(QGuiApplication::screenAt(submenu.pos()), screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb)
|
|||
connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered()));
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -209,12 +209,12 @@ void tst_QPlainTextEdit::getSetCheck()
|
|||
|
||||
// int QPlainTextEdit::tabStopWidth()
|
||||
// void QPlainTextEdit::setTabStopWidth(int)
|
||||
obj1.setTabStopWidth(0);
|
||||
QCOMPARE(0, obj1.tabStopWidth());
|
||||
obj1.setTabStopWidth(INT_MIN);
|
||||
QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value
|
||||
obj1.setTabStopWidth(INT_MAX);
|
||||
QCOMPARE(INT_MAX, obj1.tabStopWidth());
|
||||
obj1.setTabStopDistance(0);
|
||||
QCOMPARE(0, obj1.tabStopDistance());
|
||||
obj1.setTabStopDistance(-1);
|
||||
QCOMPARE(0, obj1.tabStopDistance()); // Makes no sense to set a negative tabstop value
|
||||
obj1.setTabStopDistance(std::numeric_limits<qreal>::max());
|
||||
QCOMPARE(std::numeric_limits<qreal>::max(), obj1.tabStopDistance());
|
||||
}
|
||||
|
||||
class QtTestDocumentLayout : public QAbstractTextDocumentLayout
|
||||
|
|
|
@ -282,12 +282,12 @@ void tst_QTextEdit::getSetCheck()
|
|||
|
||||
// int QTextEdit::tabStopWidth()
|
||||
// void QTextEdit::setTabStopWidth(int)
|
||||
obj1.setTabStopWidth(0);
|
||||
QCOMPARE(0, obj1.tabStopWidth());
|
||||
obj1.setTabStopWidth(INT_MIN);
|
||||
QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value
|
||||
obj1.setTabStopWidth(INT_MAX);
|
||||
QCOMPARE(INT_MAX, obj1.tabStopWidth());
|
||||
obj1.setTabStopDistance(0);
|
||||
QCOMPARE(0, obj1.tabStopDistance());
|
||||
obj1.setTabStopDistance(-1);
|
||||
QCOMPARE(0, obj1.tabStopDistance()); // Makes no sense to set a negative tabstop value
|
||||
obj1.setTabStopDistance(std::numeric_limits<qreal>::max());
|
||||
QCOMPARE(std::numeric_limits<qreal>::max(), obj1.tabStopDistance());
|
||||
|
||||
// bool QTextEdit::acceptRichText()
|
||||
// void QTextEdit::setAcceptRichText(bool)
|
||||
|
|
Loading…
Reference in New Issue