MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / paintLineNumbers

Method paintLineNumbers

src/texteditor.cpp:286–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void 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
314void TextEditor::highlightCurrentLine()
315{

Callers 1

paintEventMethod · 0.80

Calls 3

isVisibleMethod · 0.80
isValidMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected