MCPcopy Create free account
hub / github.com/KDE/kdiff3 / writeLine

Method writeLine

src/mergeresultwindow.cpp:1463–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1461}
1462
1463void MergeResultWindow::writeLine(
1464 RLPainter& p, LineRef line, const QString& str,
1465 e_SrcSelector srcSelect, e_MergeDetails mergeDetails, RangeFlags rangeMark, bool bUserModified, bool bLineRemoved, bool bWhiteSpaceConflict)
1466{
1467 const QFontMetrics& fm = fontMetrics();
1468 qint32 fontHeight = fm.lineSpacing();
1469 qint32 fontAscent = fm.ascent();
1470
1471 qint32 topLineYOffset = 0;
1472 qint32 xOffset = getTextXOffset();
1473
1474 qint32 yOffset = (line - m_firstLine) * fontHeight;
1475 if(yOffset < 0 || yOffset > height())
1476 return;
1477
1478 yOffset += topLineYOffset;
1479
1480 QString srcName = QChar(' ');
1481 if(bUserModified)
1482 srcName = QChar('m');
1483 else if(srcSelect == e_SrcSelector::A && mergeDetails != e_MergeDetails::eNoChange)
1484 srcName = QStringLiteral("A");
1485 else if(srcSelect == e_SrcSelector::B)
1486 srcName = QStringLiteral("B");
1487 else if(srcSelect == e_SrcSelector::C)
1488 srcName = QStringLiteral("C");
1489
1490 if(rangeMark & RangeMark::current)
1491 {
1492 p.fillRect(xOffset, yOffset, width(), fontHeight, gOptions->getCurrentRangeBgColor());
1493 }
1494
1495 if((srcSelect > e_SrcSelector::None || bUserModified) && !bLineRemoved)
1496 {
1497 if(!gOptions->m_bRightToLeftLanguage)
1498 p.setClipRect(QRectF(xOffset, 0, width() - xOffset, height()));
1499 else
1500 p.setClipRect(QRectF(0, 0, width() - xOffset, height()));
1501
1502 p.setPen(gOptions->foregroundColor());
1503
1504 QTextLayout textLayout(str, font(), this);
1505 QVector<QTextLayout::FormatRange> selectionFormat = getTextLayoutForLine(line, str, textLayout);
1506 textLayout.draw(&p, QPointF(0, yOffset), selectionFormat);
1507
1508 if(line == m_cursorYPos)
1509 {
1510 m_cursorXPixelPos = qCeil(textLayout.lineAt(0).cursorToX((qint32)m_cursorXPos));
1511 if(gOptions->m_bRightToLeftLanguage)
1512 m_cursorXPixelPos += qCeil(textLayout.position().x() - m_horizScrollOffset);
1513 }
1514
1515 p.setClipping(false);
1516
1517 p.setPen(gOptions->foregroundColor());
1518
1519 p.drawText(1, yOffset + fontAscent, srcName, true);
1520 }

Callers

nothing calls this directly

Calls 5

fillRectMethod · 0.80
setPenMethod · 0.80
drawMethod · 0.80
drawTextMethod · 0.80
drawLineMethod · 0.80

Tested by

no test coverage detected