Commit 208b3746 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

BaseTextEditor: adding translatedLineRegion()

this function returns the bound region for the text in
lineStart to lineEnd

We use this to position the context pane
parent 97eb3e13
...@@ -4270,6 +4270,22 @@ int BaseTextEditor::verticalBlockSelection() const ...@@ -4270,6 +4270,22 @@ int BaseTextEditor::verticalBlockSelection() const
return qAbs(b.positionInBlock() - e.positionInBlock()) + d->m_blockSelectionExtraX; return qAbs(b.positionInBlock() - e.positionInBlock()) + d->m_blockSelectionExtraX;
} }
QRegion BaseTextEditor::translatedLineRegion(int lineStart, int lineEnd) const
{
QRegion region;
for (int i = lineStart ; i <= lineEnd; i++) {
QTextBlock block = document()->findBlockByNumber(i);
QPoint topLeft = blockBoundingGeometry(block).translated(contentOffset()).topLeft().toPoint();
QTextLayout *layout = block.layout();
for (int i = 0; i < layout->lineCount();i++) {
QTextLine line = layout->lineAt(i);
region += line.naturalTextRect().translated(topLeft).toRect();
}
}
return region;
}
void BaseTextEditor::setFindScope(const QTextCursor &start, const QTextCursor &end, int verticalBlockSelection) void BaseTextEditor::setFindScope(const QTextCursor &start, const QTextCursor &end, int verticalBlockSelection)
{ {
if (start != d->m_findScopeStart || end != d->m_findScopeEnd) { if (start != d->m_findScopeStart || end != d->m_findScopeEnd) {
......
...@@ -216,6 +216,8 @@ public: ...@@ -216,6 +216,8 @@ public:
int verticalBlockSelection() const; int verticalBlockSelection() const;
QRegion translatedLineRegion(int lineStart, int lineEnd) const;
public slots: public slots:
void setDisplayName(const QString &title); void setDisplayName(const QString &title);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment