-----------------------------------------------------------------------------
| 37 | |
| 38 | //----------------------------------------------------------------------------- |
| 39 | void pqPythonLineNumberArea::paintEvent(QPaintEvent* event) |
| 40 | { |
| 41 | QPainter painter(this); |
| 42 | |
| 43 | const QPalette& palette = this->palette(); |
| 44 | |
| 45 | painter.fillRect(event->rect(), palette.window()); |
| 46 | painter.setFont(this->TextEdit.font()); |
| 47 | |
| 48 | const QSize size = this->sizeHint(); |
| 49 | |
| 50 | std::int32_t firstBlockId = std::max(0, details::getFirstVisibleBlockId(this->TextEdit) - 1); |
| 51 | QTextBlock block = this->TextEdit.document()->findBlockByNumber(firstBlockId); |
| 52 | |
| 53 | while (block.isValid() && block.isVisible()) |
| 54 | { |
| 55 | const QTextCursor blockCursor(block); |
| 56 | const QRect blockCursorRect = this->TextEdit.cursorRect(blockCursor); |
| 57 | |
| 58 | painter.setPen((this->TextEdit.textCursor().blockNumber() == firstBlockId) |
| 59 | ? palette.text().color() |
| 60 | : palette.placeholderText().color()); |
| 61 | const QString number = QString::number(firstBlockId + 1); |
| 62 | painter.drawText(-5, blockCursorRect.y() + 2, size.width(), |
| 63 | this->TextEdit.fontMetrics().height(), Qt::AlignRight, number); |
| 64 | |
| 65 | block = block.next(); |
| 66 | firstBlockId++; |
| 67 | } |
| 68 | } |
nothing calls this directly
no test coverage detected