| 284 | } |
| 285 | |
| 286 | void TextEditor::paintLineNumbers(QPaintEvent* e, const QColor& textColor) |
| 287 | { |
| 288 | QStyleOption opt; |
| 289 | opt.initFrom(m_lineNumbers); |
| 290 | |
| 291 | QPainter painter(m_lineNumbers); |
| 292 | |
| 293 | QTextBlock block = firstVisibleBlock(); |
| 294 | int blockNumber = block.blockNumber(); |
| 295 | int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top(); |
| 296 | int bottom = top + (int)blockBoundingRect(block).height(); |
| 297 | |
| 298 | while (block.isValid() && top <= e->rect().bottom()) { |
| 299 | if (block.isVisible() && bottom >= e->rect().top()) { |
| 300 | QString number = QString::number(blockNumber + 1); |
| 301 | painter.setPen(textColor); |
| 302 | |
| 303 | painter.drawText(0, top, m_lineNumbers->width() - 3, fontMetrics().height(), |
| 304 | Qt::AlignRight, number); |
| 305 | } |
| 306 | |
| 307 | block = block.next(); |
| 308 | top = bottom; |
| 309 | bottom = top + (int)blockBoundingRect(block).height(); |
| 310 | ++blockNumber; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | void TextEditor::highlightCurrentLine() |
| 315 | { |
no test coverage detected