Commit 09a99ba9 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Port away from obsolete Qt functions

parent 68deb82a
......@@ -110,11 +110,12 @@ void AnnotationModelPrivate::notifySetup( const QVector< Okular::Page * > &pages
if ( !( setupFlags & Okular::DocumentObserver::DocumentChanged ) )
return;
q->beginResetModel();
qDeleteAll( root->children );
root->children.clear();
q->reset();
rebuildTree( pages );
q->endResetModel();
}
void AnnotationModelPrivate::notifyPageChanged( int page, int flags )
......
......@@ -219,6 +219,8 @@ void PageGroupProxyModel::setSourceModel( QAbstractItemModel *model )
void PageGroupProxyModel::rebuildIndexes()
{
beginResetModel();
if ( mGroupByPage ) {
mTreeIndexes.clear();
......@@ -243,7 +245,7 @@ void PageGroupProxyModel::rebuildIndexes()
}
}
reset();
endResetModel();
}
void PageGroupProxyModel::groupByPage( bool value )
......@@ -516,6 +518,7 @@ void AuthorGroupProxyModel::groupByAuthor( bool value )
void AuthorGroupProxyModel::rebuildIndexes()
{
beginResetModel();
delete d->mRoot;
d->mRoot = new AuthorGroupItem( 0 );
......@@ -594,7 +597,7 @@ void AuthorGroupProxyModel::rebuildIndexes()
}
}
reset();
endResetModel();
}
#include "moc_annotationproxymodels.cpp"
......@@ -396,8 +396,8 @@ void ProgressWidget::paintEvent( QPaintEvent * e )
int w = width(),
h = height(),
l = (int)( (float)w * m_progressPercentage );
QRect cRect = ( QApplication::isRightToLeft() ? QRect( 0, 0, w - l, h ) : QRect( l, 0, w - l, h ) ).intersect( e->rect() );
QRect fRect = ( QApplication::isRightToLeft() ? QRect( w - l, 0, l, h ) : QRect( 0, 0, l, h ) ).intersect( e->rect() );
QRect cRect = ( QApplication::isRightToLeft() ? QRect( 0, 0, w - l, h ) : QRect( l, 0, w - l, h ) ).intersected( e->rect() );
QRect fRect = ( QApplication::isRightToLeft() ? QRect( w - l, 0, l, h ) : QRect( 0, 0, l, h ) ).intersected( e->rect() );
QPalette pal = palette();
// paint clear rect
......
......@@ -384,7 +384,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
{
const Okular::NormalizedRect & r = (*hIt).second;
// find out the rect to highlight on pixmap
QRect highlightRect = r.geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() ).intersect( limits );
QRect highlightRect = r.geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() ).intersected( limits );
highlightRect.translate( -limits.left(), -limits.top() );
// highlight composition (product: highlight color * destcolor)
......@@ -676,7 +676,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
// get annotation boundary and drawn rect
QRect annotBoundary = a->transformedBoundingRectangle().geometry( scaledWidth, scaledHeight ).translated( -scaledCrop.topLeft() );
QRect annotRect = annotBoundary.intersect( limits );
QRect annotRect = annotBoundary.intersected( limits );
QRect innerRect( annotRect.left() - annotBoundary.left(), annotRect.top() -
annotBoundary.top(), annotRect.width(), annotRect.height() );
......@@ -724,7 +724,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
pixmap = GuiUtils::iconLoader()->loadIcon( text->textIcon().toLower(), KIconLoader::NoGroup, 32 );
QImage scaledImage;
QRect annotBoundary2 = QRect( annotBoundary.topLeft(), QSize( TEXTANNOTATION_ICONSIZE, TEXTANNOTATION_ICONSIZE ) );
QRect annotRect2 = annotBoundary2.intersect( limits );
QRect annotRect2 = annotBoundary2.intersected( limits );
QRect innerRect2( annotRect2.left() - annotBoundary2.left(), annotRect2.top() -
annotBoundary2.top(), annotRect2.width(), annotRect2.height() );
scalePixmapOnImage( scaledImage, &pixmap,
......
......@@ -1487,7 +1487,7 @@ void PageView::paintEvent(QPaintEvent *pe)
// create the rect into contents from the clipped screen rect
QRect viewportRect = viewport()->rect();
viewportRect.translate( areaPos );
QRect contentsRect = pe->rect().translated( areaPos ).intersect( viewportRect );
QRect contentsRect = pe->rect().translated( areaPos ).intersected( viewportRect );
if ( !contentsRect.isValid() )
return;
......@@ -1534,7 +1534,7 @@ void PageView::paintEvent(QPaintEvent *pe)
if ( useSubdivision )
{
// set 'contentsRect' to a part of the sub-divided region
contentsRect = allRects[i].translated( areaPos ).intersect( viewportRect );
contentsRect = allRects[i].translated( areaPos ).intersected( viewportRect );
if ( !contentsRect.isValid() )
continue;
}
......@@ -1560,7 +1560,7 @@ void PageView::paintEvent(QPaintEvent *pe)
if ( !selectionRect.isNull() && selectionRect.intersects( contentsRect ) &&
!selectionRectInternal.contains( contentsRect ) )
{
QRect blendRect = selectionRectInternal.intersect( contentsRect );
QRect blendRect = selectionRectInternal.intersected( contentsRect );
// skip rectangles covered by the selection's border
if ( blendRect.isValid() )
{
......@@ -1591,7 +1591,7 @@ void PageView::paintEvent(QPaintEvent *pe)
if ( !selectionPartRect.isNull() && selectionPartRect.intersects( contentsRect ) &&
!selectionPartRectInternal.contains( contentsRect ) )
{
QRect blendRect = selectionPartRectInternal.intersect( contentsRect );
QRect blendRect = selectionPartRectInternal.intersected( contentsRect );
// skip rectangles covered by the selection's border
if ( blendRect.isValid() )
{
......@@ -2699,7 +2699,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() );
// grab text in the rect that intersects itemRect
QRect relativeRect = selectionRect.intersect( itemRect );
QRect relativeRect = selectionRect.intersected( itemRect );
relativeRect.translate( -item->uncroppedGeometry().topLeft() );
Okular::RegularAreaRect rects;
rects.append( Okular::NormalizedRect( relativeRect, item->uncroppedWidth(), item->uncroppedHeight() ) );
......@@ -2854,9 +2854,9 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() );
// grab text in the rect that intersects itemRect
QRect rectInItem = selectionRect.intersect( itemRect );
QRect rectInItem = selectionRect.intersected( itemRect );
rectInItem.translate( -item->uncroppedGeometry().topLeft() );
QRect rectInSelection = selectionRect.intersect( itemRect );
QRect rectInSelection = selectionRect.intersected( itemRect );
rectInSelection.translate( -selectionRect.topLeft() );
d->tableSelectionParts.append(
TableSelectionPart(
......@@ -3354,13 +3354,13 @@ QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start
{
// first item
PageViewItem * first = d->items[ affectedItemsIds.first() ];
QRect geom = first->croppedGeometry().intersect( selectionRect ).translated( -first->uncroppedGeometry().topLeft() );
QRect geom = first->croppedGeometry().intersected( selectionRect ).translated( -first->uncroppedGeometry().topLeft() );
ret.append( textSelectionForItem( first,
selectionRect.bottom() > geom.height() ? ( direction_ne_sw ? geom.topRight() : geom.topLeft() ) : ( direction_ne_sw ? geom.bottomRight() : geom.bottomLeft() ),
QPoint() ) );
// last item
PageViewItem * last = d->items[ affectedItemsIds.last() ];
geom = last->croppedGeometry().intersect( selectionRect ).translated( -last->uncroppedGeometry().topLeft() );
geom = last->croppedGeometry().intersected( selectionRect ).translated( -last->uncroppedGeometry().topLeft() );
// the last item needs to appended at last...
Okular::RegularAreaRect * lastArea = textSelectionForItem( last,
QPoint(),
......@@ -3444,7 +3444,7 @@ void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
{
viewPortPoint = &point;
}
QRect pixmapRect = contentsRect.intersect( itemGeometry );
QRect pixmapRect = contentsRect.intersected( itemGeometry );
pixmapRect.translate( -item->croppedGeometry().topLeft() );
PagePainter::paintCroppedPageOnPainter( p, item->page(), this, pageflags,
item->uncroppedWidth(), item->uncroppedHeight(), pixmapRect,
......@@ -3452,7 +3452,7 @@ void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
}
// remove painted area from 'remainingArea' and restore painter
remainingArea -= outlineGeometry.intersect( contentsRect );
remainingArea -= outlineGeometry.intersected( contentsRect );
p->restore();
}
......@@ -4472,7 +4472,7 @@ void PageView::delayedResizeEvent()
static void slotRequestPreloadPixmap( Okular::DocumentObserver * observer, const PageViewItem * i, const QRect &expandedViewportRect, QLinkedList< Okular::PixmapRequest * > *requestedPixmaps )
{
Okular::NormalizedRect preRenderRegion;
const QRect intersectionRect = expandedViewportRect.intersect( i->croppedGeometry() );
const QRect intersectionRect = expandedViewportRect.intersected( i->croppedGeometry() );
if ( !intersectionRect.isEmpty() )
preRenderRegion = Okular::NormalizedRect( intersectionRect.translated( -i->uncroppedGeometry().topLeft() ), i->uncroppedWidth(), i->uncroppedHeight() );
......@@ -4544,7 +4544,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
qRound( i->uncroppedGeometry().left() + i->uncroppedWidth() * r.left ) + 1 - viewportRect.left(),
qRound( i->uncroppedGeometry().top() + i->uncroppedHeight() * r.top ) + 1 - viewportRect.top() );
if ( vw->isPlaying() && viewportRectAtZeroZero.intersect( vw->geometry() ).isEmpty() ) {
if ( vw->isPlaying() && viewportRectAtZeroZero.intersected( vw->geometry() ).isEmpty() ) {
vw->stop();
vw->pageLeft();
}
......@@ -4557,7 +4557,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
kWarning().nospace() << "viewportRect is " << viewportRect << ", page item is " << i->croppedGeometry() << " intersect : " << viewportRect.intersects( i->croppedGeometry() );
#endif
// if the item doesn't intersect the viewport, skip it
QRect intersectionRect = viewportRect.intersect( i->croppedGeometry() );
QRect intersectionRect = viewportRect.intersected( i->croppedGeometry() );
if ( intersectionRect.isEmpty() )
{
continue;
......
......@@ -756,7 +756,7 @@ void PresentationWidget::paintEvent( QPaintEvent * pe )
}
// check painting rect consistancy
QRect r = pe->rect().intersect( QRect( QPoint( 0, 0 ), geometry().size() ) );
QRect r = pe->rect().intersected( QRect( QPoint( 0, 0 ), geometry().size() ) );
if ( r.isNull() )
return;
......@@ -787,7 +787,7 @@ void PresentationWidget::paintEvent( QPaintEvent * pe )
pixPainter.drawPixmap( QPoint(0,0), m_lastRenderedPixmap, r );
// then blend the overlay (a piece of) over the background
QRect ovr = m_overlayGeometry.intersect( r );
QRect ovr = m_overlayGeometry.intersected( r );
pixPainter.drawPixmap( ovr.left() - r.left(), ovr.top() - r.top(),
m_lastRenderedOverlay, ovr.left() - m_overlayGeometry.left(),
ovr.top() - m_overlayGeometry.top(), ovr.width(), ovr.height() );
......@@ -817,7 +817,7 @@ void PresentationWidget::paintEvent( QPaintEvent * pe )
drawing.paint( &pmPainter, geom.width(), geom.height() );
if ( m_drawingEngine && m_drawingRect.intersects( pe->rect() ) )
m_drawingEngine->paint( &pmPainter, geom.width(), geom.height(), m_drawingRect.intersect( pe->rect() ) );
m_drawingEngine->paint( &pmPainter, geom.width(), geom.height(), m_drawingRect.intersected( pe->rect() ) );
painter.setRenderHints( QPainter::Antialiasing );
painter.drawPixmap( geom.topLeft() , pm );
......@@ -1077,7 +1077,7 @@ void PresentationWidget::generateContentsPage( int pageNum, QPainter & p )
// fill unpainted areas with background color
QRegion unpainted( QRect( 0, 0, m_width, m_height ) );
QVector<QRect> rects = unpainted.subtract( frame->geometry ).rects();
QVector<QRect> rects = unpainted.subtracted( frame->geometry ).rects();
for ( int i = 0; i < rects.count(); i++ )
{
const QRect & r = rects[i];
......
......@@ -940,7 +940,7 @@ void ThumbnailWidget::paint( QPainter &p, const QRect &_clipRect )
// draw the page using the shared PagePainter class
p.translate( m_margin/2, m_margin/2 );
clipRect.translate( -m_margin/2, -m_margin/2 );
clipRect = clipRect.intersect( QRect( 0, 0, m_pixmapWidth, m_pixmapHeight ) );
clipRect = clipRect.intersected( QRect( 0, 0, m_pixmapWidth, m_pixmapHeight ) );
if ( clipRect.isValid() )
{
int flags = PagePainter::Accessibility | PagePainter::Highlights |
......@@ -963,7 +963,7 @@ void ThumbnailWidget::paint( QPainter &p, const QRect &_clipRect )
{
int pixW = bookmarkPixmap->width(),
pixH = bookmarkPixmap->height();
clipRect = clipRect.intersect( QRect( m_pixmapWidth - pixW, 0, pixW, pixH ) );
clipRect = clipRect.intersected( QRect( m_pixmapWidth - pixW, 0, pixW, pixH ) );
if ( clipRect.isValid() )
p.drawPixmap( m_pixmapWidth - pixW, -pixH/8, *bookmarkPixmap );
}
......
......@@ -316,10 +316,11 @@ void TOCModel::clear()
if ( !d->dirty )
return;
beginResetModel();
qDeleteAll( d->root->children );
d->root->children.clear();
d->currentPage.clear();
reset();
endResetModel();
d->dirty = false;
}
......
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