Port away from QRegion::rects()

Use being()/end() instead.

These were the last remaining uses of QRegion::rects() within qtbase.

Change-Id: I264beb6f660968f40eecbbee2260341fca94ddb5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Marc Mutz 2017-12-07 09:50:08 +01:00
parent a31f65d8c8
commit f33a1f574a
3 changed files with 20 additions and 10 deletions

View File

@ -1471,6 +1471,15 @@ protected:
}
};
// ### work around missing QVector ctor from iterator pair:
static QVector<QRect> rects(const QRegion &region)
{
QVector<QRect> result;
for (QRect r : region)
result.push_back(r);
return result;
}
void tst_QGraphicsProxyWidget::scrollUpdate()
{
ScrollWidget *widget = new ScrollWidget;
@ -1492,10 +1501,10 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
// QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2)
// QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2),
// intersected with the above update.
QCOMPARE(view.paintEventRegion.rects(),
QCOMPARE(rects(view.paintEventRegion),
QVector<QRect>() << QRect(0, 0, 200, 12) << QRect(0, 12, 102, 10));
QCOMPARE(widget->npaints, 2);
QCOMPARE(widget->paintEventRegion.rects(),
QCOMPARE(rects(widget->paintEventRegion),
QVector<QRect>() << QRect(0, 0, 200, 12) << QRect(0, 12, 102, 10));
}

View File

@ -2464,9 +2464,9 @@ void tst_QGraphicsView::viewportUpdateMode()
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(14, 14));
QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(14, 14));
QCOMPARE(view.lastUpdateRegions.last().rectCount(), 2);
QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), QSize(14, 14));
QCOMPARE(view.lastUpdateRegions.last().begin()[1].size(), QSize(14, 14));
#endif
// Set full update mode.
@ -2481,8 +2481,8 @@ void tst_QGraphicsView::viewportUpdateMode()
qApp->processEvents();
// The view gets one full viewport update for the update scene updates.
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 1);
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), view.viewport()->size());
QCOMPARE(view.lastUpdateRegions.last().rectCount(), 1);
QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), view.viewport()->size());
view.lastUpdateRegions.clear();
// Set smart update mode
@ -2499,8 +2499,8 @@ void tst_QGraphicsView::viewportUpdateMode()
qApp->processEvents();
// The view gets one bounding rect update.
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 1);
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(32, 32));
QCOMPARE(view.lastUpdateRegions.last().rectCount(), 1);
QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), QSize(32, 32));
// Set no update mode
view.setViewportUpdateMode(QGraphicsView::NoViewportUpdate);

View File

@ -4364,7 +4364,8 @@ void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection()
QItemSelection selection;
selection << range;
QRegion region = view.visualRegionForSelection(selection);
QCOMPARE(region.rects().at(0), view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight()));
QVERIFY(!region.isEmpty());
QCOMPARE(region.begin()[0], view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight()));
}
void tst_QTableView::taskQTBUG_8777_scrollToSpans()