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

Method writeLine

src/difftextwindow.cpp:1080–1284  ·  view source on GitHub ↗

Don't try to use invalid rect to block drawing of lines based on there apparent horizontal dementions. This does not always work for very long lines being scrolled horizontally. (Causes blanking of diff text area) */

Source from the content-addressed store, hash-verified

1078 This does not always work for very long lines being scrolled horizontally. (Causes blanking of diff text area)
1079*/
1080void DiffTextWindowData::writeLine(
1081 RLPainter& p,
1082 const std::shared_ptr<const DiffList>& pLineDiff1,
1083 const std::shared_ptr<const DiffList>& pLineDiff2,
1084 const LineRef& line,
1085 const ChangeFlags whatChanged,
1086 const ChangeFlags whatChanged2,
1087 const LineRef& srcLineIdx,
1088 qint32 wrapLineOffset,
1089 qint32 wrapLineLength,
1090 bool bWrapLine,
1091 const QRect& invalidRect)
1092{
1093 //TODO: Fix after line number area is converted to a QWidget.
1094 const qint32 lineNumberWidth = gOptions->m_bShowLineNumbers ? m_pDiffTextWindow->getLineNumberWidth() : 0;
1095
1096 const LineData* pld = !srcLineIdx.isValid() ? nullptr : &(*m_pLineData)[srcLineIdx]; // Text in this line;
1097 QFont normalFont = p.font();
1098
1099 const QFontMetrics& fm = p.fontMetrics();
1100 qint32 fontHeight = fm.lineSpacing();
1101 qint32 fontAscent = fm.ascent();
1102 qint32 fontWidth = fm.horizontalAdvance('0');
1103
1104 qint32 xOffset = 0;
1105 qint32 yOffset = (line - m_firstLine) * fontHeight;
1106
1107 qint32 fastSelectorLine1 = m_pDiffTextWindow->convertDiff3LineIdxToLine(m_fastSelectorLine1);
1108 qint32 fastSelectorLine2 = m_pDiffTextWindow->convertDiff3LineIdxToLine(m_fastSelectorLine1 + m_fastSelectorNofLines) - 1;
1109
1110 bool bFastSelectionRange = (line >= fastSelectorLine1 && line <= fastSelectorLine2);
1111 QColor bgColor = gOptions->backgroundColor();
1112 QColor diffBgColor = gOptions->diffBackgroundColor();
1113
1114 if(bFastSelectionRange)
1115 {
1116 bgColor = gOptions->getCurrentRangeBgColor();
1117 diffBgColor = gOptions->getCurrentRangeDiffBgColor();
1118 }
1119
1120 if(yOffset + fontHeight < invalidRect.top() || invalidRect.bottom() < yOffset - fontHeight)
1121 return;
1122
1123 ChangeFlags changed = whatChanged;
1124 if(pLineDiff1 != nullptr) changed |= AChanged;
1125 if(pLineDiff2 != nullptr) changed |= BChanged;
1126
1127 QColor penColor = gOptions->foregroundColor();
1128 p.setPen(penColor);
1129 if(changed == BChanged)
1130 {
1131 penColor = diff2Color();
1132 }
1133 else if(changed == AChanged)
1134 {
1135 penColor = diff1Color();
1136 }
1137 else if(changed == Both)

Callers 1

drawMethod · 0.45

Calls 15

QPointClass · 0.85
getLineNumberWidthMethod · 0.80
setPenMethod · 0.80
getLineMethod · 0.80
isEndReachedMethod · 0.80
whatChangedMethod · 0.80
setBackgroundMethod · 0.80
withinMethod · 0.80
setFontMethod · 0.80
drawMethod · 0.80
fillRectMethod · 0.80

Tested by

no test coverage detected