Commit d84f781e authored by Albert Astals Cid's avatar Albert Astals Cid

Stop using QRegion:: rects and just iterate over the region

QRegion::rects is deprecated
parent 18e11fc5
......@@ -1611,8 +1611,8 @@ void PartTest::testAnnotWindow()
auto widget = win2->window()->childAt(win2->mapTo(win2->window(), QPoint(10, 10)));
QTest::mouseMove(win2->window(), win2->mapTo(win2->window(), QPoint(10, 10)));
QTest::mouseClick(widget, Qt::LeftButton, Qt::NoModifier, widget->mapFrom(win2, QPoint(10, 10)));
QVERIFY( win1->visibleRegion().rects().count() == 3);
QVERIFY( win2->visibleRegion().rects().count() == 4);
QVERIFY( win1->visibleRegion().rectCount() == 3);
QVERIFY( win2->visibleRegion().rectCount() == 4);
}
// Helper for testAdditionalActionTriggers
......
......@@ -1681,28 +1681,27 @@ void PageView::paintEvent(QPaintEvent *pe)
d->mouseSelectionColor : Qt::red;
// subdivide region into rects
const QVector<QRect> &allRects = pe->region().rects();
uint numRects = allRects.count();
QRegion rgn = pe->region();
// preprocess rects area to see if it worths or not using subdivision
uint summedArea = 0;
for ( uint i = 0; i < numRects; i++ )
for ( const QRect & r : rgn )
{
const QRect & r = allRects[i];
summedArea += r.width() * r.height();
}
// very elementary check: SUMj(Region[j].area) is less than boundingRect.area
bool useSubdivision = summedArea < (0.6 * contentsRect.width() * contentsRect.height());
const bool useSubdivision = summedArea < (0.6 * contentsRect.width() * contentsRect.height());
if ( !useSubdivision )
numRects = 1;
{
rgn = contentsRect;
}
// iterate over the rects (only one loop if not using subdivision)
for ( uint i = 0; i < numRects; i++ )
for ( const QRect & r : rgn )
{
if ( useSubdivision )
{
// set 'contentsRect' to a part of the sub-divided region
contentsRect = allRects[i].translated( areaPos ).intersected( viewportRect );
contentsRect = r.translated( areaPos ).intersected( viewportRect );
if ( !contentsRect.isValid() )
continue;
}
......@@ -3432,7 +3431,7 @@ void PageView::scrollContentsBy( int dx, int dy )
QRegion rgn( r );
rgn -= rgn & r.translated( dx, dy );
foreach ( const QRect &rect, rgn.rects() )
for ( const QRect &rect : rgn )
viewport()->update( rect );
}
//END widget events
......
......@@ -839,10 +839,10 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E
m_lastDrawnRect = paintRect;
m_lastDrawnRect.translate( itemRect.left(), itemRect.top() );
// 3.2. decompose paint region in rects and send paint events
const QVector<QRect> rects = compoundRegion.united( m_lastDrawnRect ).rects();
const QRegion rgn = compoundRegion.united( m_lastDrawnRect );
const QPoint areaPos = m_pageView->contentAreaPosition();
for ( int i = 0; i < rects.count(); i++ )
m_pageView->viewport()->update( rects[i].translated( -areaPos ) );
for ( const QRect &r : rgn )
m_pageView->viewport()->update( r.translated( -areaPos ) );
modifiedRect = compoundRegion.boundingRect() | m_lastDrawnRect;
}
......
......@@ -853,12 +853,9 @@ void PresentationWidget::paintEvent( QPaintEvent * pe )
}
// blit the pixmap to the screen
QVector<QRect> allRects = pe->region().rects();
uint numRects = allRects.count();
QPainter painter( this );
for ( uint i = 0; i < numRects; i++ )
for ( const QRect &r : pe->region() )
{
const QRect & r = allRects[i];
if ( !r.isValid() )
continue;
#ifdef ENABLE_PROGRESS_OVERLAY
......@@ -1177,11 +1174,10 @@ void PresentationWidget::generateContentsPage( int pageNum, QPainter & p )
p.translate( -frame->geometry.left(), -frame->geometry.top() );
// fill unpainted areas with background color
QRegion unpainted( QRect( 0, 0, m_width, m_height ) );
QVector<QRect> rects = unpainted.subtracted( frame->geometry ).rects();
for ( int i = 0; i < rects.count(); i++ )
const QRegion unpainted( QRect( 0, 0, m_width, m_height ) );
const QRegion rgn = unpainted.subtracted( frame->geometry );
for ( const QRect & r : rgn )
{
const QRect & r = rects[i];
p.fillRect( r, Okular::Settings::slidesBackgroundColor() );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment