summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-10-17 20:00:44 +0300
committerOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-10-17 20:00:44 +0300
commit371b2bbbab6b4bdc300ef7c3d4ce9c504ac25472 (patch)
tree0987f23b83e9031e35fa84d9495ee4b538f87e81 /src/plugins/texteditor
parent5c554c0de9fd9115dbcfa010353640b11e349c6c (diff)
parentaa4e05f07b22b062316bf8a35517956c3770e0f6 (diff)
downloadqt-creator-371b2bbbab6b4bdc300ef7c3d4ce9c504ac25472.tar.gz
Merge remote-tracking branch 'origin/4.5' into master
Change-Id: Ibcdd1230b40d1ca7a414843ee0f9ae4cddb29f6f
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r--src/plugins/texteditor/texteditor.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 5da5372bd1..1b0128350d 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -397,7 +397,7 @@ public:
bool expanded,
bool active,
bool hovered) const;
- void drawLineAnnotation(QPainter &painter, const QTextBlock &block, qreal start, const QRect &eventRect);
+ void updateLineAnnotation(QPainter &painter, const QTextBlock &block, qreal start, const QRect &eventRect);
void toggleBlockVisible(const QTextBlock &block);
QRect foldBox();
@@ -3866,9 +3866,11 @@ QRectF TextEditorWidgetPrivate::getLastLineLineRect(const QTextBlock &block)
return line.naturalTextRect().translated(contentOffset.x(), top).adjusted(0, 0, -1, -1);
}
-void TextEditorWidgetPrivate::drawLineAnnotation(
+void TextEditorWidgetPrivate::updateLineAnnotation(
QPainter &painter, const QTextBlock &block, qreal rightMargin, const QRect &eventRect)
{
+ m_annotationRects.remove(block.blockNumber());
+
if (!m_displaySettings.m_displayAnnotations)
return;
@@ -3912,16 +3914,17 @@ void TextEditorWidgetPrivate::drawLineAnnotation(
boundingRect = QRectF(x, lineRect.top(), q->viewport()->width() - x, lineRect.height());
if (boundingRect.isEmpty())
break;
+ if (eventRect.intersects(boundingRect.toRect()))
+ mark->paintAnnotation(painter, &boundingRect, offset, itemOffset / 2, q->contentOffset());
- // paint annotation
- mark->paintAnnotation(painter, &boundingRect, offset, itemOffset / 2, q->contentOffset());
x = boundingRect.right();
offset = itemOffset / 2;
m_annotationRects[block.blockNumber()].append({boundingRect, mark});
}
QRect updateRect(lineRect.toRect().topRight(), boundingRect.toRect().bottomRight());
- updateRect.setLeft(qMax(0, updateRect.left()));
+ updateRect.setLeft(qBound(0, updateRect.left(), q->viewport()->width() - 1));
+ updateRect.setRight(qBound(0, updateRect.right(), q->viewport()->width() - 1));
if (!updateRect.isEmpty() && !eventRect.contains(updateRect))
q->viewport()->update(updateRect);
}
@@ -4425,10 +4428,8 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|| d->m_blockSelection.positionColumn == d->m_blockSelection.anchorColumn)
&& blockSelectionCursorRect.isValid())
painter.fillRect(blockSelectionCursorRect, palette().text());
-
- d->m_annotationRects.remove(block.blockNumber());
- d->drawLineAnnotation(painter, block, lineX < viewportRect.width() ? lineX : 0, er);
}
+ d->updateLineAnnotation(painter, block, lineX < viewportRect.width() ? lineX : 0, er);
offset.ry() += r.height();