80 int max = qMax(1, blockCount());
86 int space = 3 + fontMetrics().width(QLatin1Char(
'9')) * digits;
101 if (rect.contains(viewport()->rect())) {
108 QPlainTextEdit::resizeEvent(e);
109 QRect cr = contentsRect();
115 QList<QTextEdit::ExtraSelection> extraSelections;
117 QTextEdit::ExtraSelection selection;
119 QColor lineColor = QColor(Qt::lightGray).lighter(120);
120 selection.format.setBackground(lineColor);
121 selection.format.setProperty(QTextFormat::FullWidthSelection,
true);
122 selection.cursor = textCursor();
123 selection.cursor.clearSelection();
124 extraSelections.append(selection);
127 setExtraSelections(extraSelections);
133 painter.fillRect(event->rect(), Qt::lightGray);
135 QTextBlock block = firstVisibleBlock();
136 int blockNumber = block.blockNumber();
137 int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
138 int bottom = top + (int)blockBoundingRect(block).height();
140 while (block.isValid() && top <=
event->rect().bottom()) {
141 if (block.isVisible() && bottom >=
event->rect().top()) {
142 QString number = QString::number(blockNumber + 1);
143 painter.setPen(Qt::black);
144 painter.drawText(0, top,
lineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number);
147 block = block.next();
149 bottom = top + (int)blockBoundingRect(block).height();