in win/Qt/qttableview.cpp [1273:1408]
void QtTableView::paintEvent( QPaintEvent *e )
{
QRect updateR = e->rect(); // update rectangle
if ( sbDirty ) {
bool e = eraseInPaint;
updateScrollBars();
eraseInPaint = e;
}
QPainter paint( this );
if ( !contentsRect().contains( updateR, TRUE ) ) {// update frame ?
drawFrame( &paint );
if ( updateR.left() < frameWidth() ) //###
updateR.setLeft( frameWidth() );
if ( updateR.top() < frameWidth() )
updateR.setTop( frameWidth() );
}
int maxWX = maxViewX();
int maxWY = maxViewY();
if ( updateR.right() > maxWX )
updateR.setRight( maxWX );
if ( updateR.bottom() > maxWY )
updateR.setBottom( maxWY );
setupPainter( &paint ); // prepare for painting table
int firstRow = findRow( updateR.y() );
int firstCol = findCol( updateR.x() );
int xStart, yStart;
if ( !colXPos( firstCol, &xStart ) || !rowYPos( firstRow, &yStart ) ) {
paint.eraseRect( updateR ); // erase area outside cells but in view
return;
}
int maxX = updateR.right();
int maxY = updateR.bottom();
int row = firstRow;
int col;
int yPos = yStart;
int xPos = maxX+1; // in case the while() is empty
int nextX;
int nextY;
QRect winR = viewRect();
QRect cellR;
QRect cellUR;
#ifndef QT_NO_TRANSFORMATIONS
QWMatrix matrix;
#endif
while ( yPos <= maxY && row < nRows ) {
nextY = yPos + (cellH ? cellH : cellHeight( row ));
if ( testTableFlags( Tbl_cutCellsV ) && nextY > ( maxWY + 1 ) )
break;
col = firstCol;
xPos = xStart;
while ( xPos <= maxX && col < nCols ) {
nextX = xPos + (cellW ? cellW : cellWidth( col ));
if ( testTableFlags( Tbl_cutCellsH ) && nextX > ( maxWX + 1 ) )
break;
cellR.setRect( xPos, yPos, cellW ? cellW : cellWidth(col),
cellH ? cellH : cellHeight(row) );
cellUR = cellR.intersect( updateR );
if ( cellUR.isValid() ) {
cellUpdateR = cellUR;
cellUpdateR.moveBy( -xPos, -yPos ); // cell coordinates
if ( eraseInPaint )
paint.eraseRect( cellUR );
#ifndef QT_NO_TRANSFORMATIONS
matrix.translate( xPos, yPos );
paint.setWorldMatrix( matrix );
if ( testTableFlags(Tbl_clipCellPainting) ||
frameWidth() > 0 && !winR.contains( cellR ) ) { //##arnt
paint.setClipRect( cellUR );
paintCell( &paint, row, col );
paint.setClipping( FALSE );
} else {
paintCell( &paint, row, col );
}
matrix.reset();
paint.setWorldMatrix( matrix );
#else
paint.translate( xPos, yPos );
if ( testTableFlags(Tbl_clipCellPainting) ||
frameWidth() > 0 && !winR.contains( cellR ) ) { //##arnt
paint.setClipRect( cellUR );
paintCell( &paint, row, col );
paint.setClipping( FALSE );
} else {
paintCell( &paint, row, col );
}
paint.translate( -xPos, -yPos );
#endif
}
col++;
xPos = nextX;
}
row++;
yPos = nextY;
}
// while painting we have to erase any areas in the view that
// are not covered by cells but are covered by the paint event
// rectangle these must be erased. We know that xPos is the last
// x pixel updated + 1 and that yPos is the last y pixel updated + 1.
// Note that this needs to be done regardless whether we do
// eraseInPaint or not. Reason: a subclass may implement
// flicker-freeness and encourage the use of repaint(FALSE).
// The subclass, however, cannot draw all pixels, just those
// inside the cells. So QtTableView is reponsible for all pixels
// outside the cells.
QRect viewR = viewRect();
const QColorGroup g = colorGroup();
if ( xPos <= maxX ) {
QRect r = viewR;
r.setLeft( xPos );
r.setBottom( yPos<maxY?yPos:maxY );
if ( inherits( "QMultiLineEdit" ) )
paint.fillRect( r.intersect( updateR ), g.base() );
else
paint.eraseRect( r.intersect( updateR ) );
}
if ( yPos <= maxY ) {
QRect r = viewR;
r.setTop( yPos );
if ( inherits( "QMultiLineEdit" ) )
paint.fillRect( r.intersect( updateR ), g.base() );
else
paint.eraseRect( r.intersect( updateR ) );
}
}