Zwrotomat/codedisplay.cpp
/**
 * @brief CodeDisplay::lineNumberAreaPaintEvent Painting line Number Area
 * @param event
 */
@brief CodeDisplay::lineNumberAreaPaintEvent Painting line Number Area
@param event
@brief CodeDisplay :: lineNumberAreaPaintEvent Painting line Number Area @param event
void CodeDisplay::lineNumberAreaPaintEvent(QPaintEvent *event)
{
    QPainter painter(lineNumberArea);
    painter.fillRect(event->rect(), Qt::lightGray);
    QTextBlock block = firstVisibleBlock();
        int blockNumber = block.blockNumber();
        int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
        int bottom = top + qRound(blockBoundingRect(block).height());
        while (block.isValid() && top <= event->rect().bottom()) {
                if (block.isVisible() && bottom >= event->rect().top()) {
                    QString number = QString::number(blockNumber + 1);
                    painter.setPen(Qt::black);
                    painter.drawText(0, top, lineNumberArea->width()-2, fontMetrics().height(),
                                     Qt::AlignRight, number);
                }
                block = block.next();
                top = bottom;
                bottom = top + qRound(blockBoundingRect(block).height());
                ++blockNumber;
            }
}
void CodeDisplay :: lineNumberAreaPaintEvent ( QPaintEvent * event ) { QPainter painter ( lineNumberArea ) ; painter . fillRect ( event -> rect ( ) , Qt :: lightGray ) ; QTextBlock block = firstVisibleBlock ( ) ; int blockNumber = block . blockNumber ( ) ; int top = qRound ( blockBoundingGeometry ( block ) . translated ( contentOffset ( ) ) . top ( ) ) ; int bottom = top + qRound ( blockBoundingRect ( block ) . height ( ) ) ; while ( block . isValid ( ) && top <= event -> rect ( ) . bottom ( ) ) { if ( block . isVisible ( ) && bottom >= event -> rect ( ) . top ( ) ) { QString number = QString :: number ( blockNumber + 1 ) ; painter . setPen ( Qt :: black ) ; painter . drawText ( 0 , top , lineNumberArea -> width ( ) - 2 , fontMetrics ( ) . height ( ) , Qt :: AlignRight , number ) ; } block = block . next ( ) ; top = bottom ; bottom = top + qRound ( blockBoundingRect ( block ) . height ( ) ) ; ++ blockNumber ; } }
@brief CodeDisplay::lineNumberAreaPaintEvent Painting line Number Area
 @param event
@brief CodeDisplay :: lineNumberAreaPaintEvent Painting line Number Area @param event