forked from qt-creator/qt-creator
TextEditor: Allow to programmatically highlight a block by cursor
This can be used in QmlDesigner to highlight the currently selected QML object. Change-Id: I9907d54f767c7d034739d4111a46cd994c961426 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -6240,9 +6240,6 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
|
||||
QTextCursor cursor = cursorForPosition(QPoint(0, pos.y()));
|
||||
|
||||
// Update which folder marker is highlighted
|
||||
const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber;
|
||||
d->extraAreaHighlightFoldedBlockNumber = -1;
|
||||
|
||||
int boxWidth = 0;
|
||||
if (TextEditorSettings::fontSettings().relativeLineSpacing() == 100)
|
||||
boxWidth = foldBoxWidth(fontMetrics());
|
||||
@@ -6250,13 +6247,25 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
|
||||
boxWidth = foldBoxWidth();
|
||||
|
||||
if (pos.x() > extraArea()->width() - boxWidth) {
|
||||
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
||||
updateFoldingHighlight(cursor);
|
||||
} else if (d->m_displaySettings.m_highlightBlocks) {
|
||||
QTextCursor cursor = textCursor();
|
||||
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
||||
updateFoldingHighlight(cursor);
|
||||
} else {
|
||||
updateFoldingHighlight(QTextCursor());
|
||||
}
|
||||
}
|
||||
|
||||
if (highlightBlockNumber != d->extraAreaHighlightFoldedBlockNumber)
|
||||
void TextEditorWidget::updateFoldingHighlight(const QTextCursor &cursor)
|
||||
{
|
||||
const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber;
|
||||
const bool curserIsNull = !cursor.isNull();
|
||||
if (curserIsNull)
|
||||
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
||||
else
|
||||
d->extraAreaHighlightFoldedBlockNumber = -1;
|
||||
|
||||
if (curserIsNull || (highlightBlockNumber != d->extraAreaHighlightFoldedBlockNumber))
|
||||
d->m_highlightBlocksTimer.start(d->m_highlightBlocksInfo.isEmpty() ? 120 : 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user