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

Method convertToLinePos

src/difftextwindow.cpp:932–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

930}
931
932void DiffTextWindow::convertToLinePos(qint32 x, qint32 y, LineRef& line, qint32& pos)
933{
934 const QFontMetrics& fm = fontMetrics();
935 qint32 fontHeight = fm.lineSpacing();
936
937 qint32 yOffset = d->m_firstLine * fontHeight;
938
939 if((y + yOffset) >= 0)
940 line = (y + yOffset) / fontHeight;
941 else
942 line = LineRef::invalid;
943
944 if(line.isValid() && (!gOptions->wordWrapOn() || (size_t)line < d->m_diff3WrapLineVector.size()))
945 {
946 QString s = d->getLineString(line);
947 QTextLayout textLayout(s, font(), this);
948 d->prepareTextLayout(textLayout);
949 pos = textLayout.lineAt(0).xToCursor(x - textLayout.position().x());
950 }
951 else
952 pos = -1;
953}
954
955class FormatRangeHelper
956{

Callers

nothing calls this directly

Calls 5

wordWrapOnMethod · 0.80
getLineStringMethod · 0.80
prepareTextLayoutMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected