OSDN Git Service

Editors: Make block highlights go beyond the margin
authorLeandro Melo <leandro.melo@nokia.com>
Fri, 12 Nov 2010 10:31:12 +0000 (11:31 +0100)
committerLeandro Melo <leandro.melo@nokia.com>
Fri, 12 Nov 2010 13:06:45 +0000 (14:06 +0100)
Block highlights should still be visible even outside the margin (when
margins are displayed naturally), since it acts only as indicator of
the character limit.

Apparently this had already been noticed before and recently there was
a merge request (no. 204) with an attempt to fix it. However, the
implementation was not handling it in a nice form. This is a small
patch that solves the issue and keeps the editor beautiful. (Check
the merge request for more details.)

Reviewed-by: Thorbjorn Lindeijer
src/plugins/texteditor/basetexteditor.cpp

index a11f0bd..3d3ab57 100644 (file)
@@ -2866,13 +2866,22 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
 
             int count = d->m_highlightBlocksInfo.count();
             if (count) {
-                QRectF rr = r;
-                rr.setWidth(viewport()->width());
-                if (lineX > 0)
-                    rr.setRight(qMin(lineX, rr.right()));
                 for (int i = 0; i <= depth; ++i) {
+                    const QColor &blendedColor = calcBlendColor(baseColor, i, count);
                     int vi = i > 0 ? d->m_highlightBlocksInfo.visualIndent.at(i-1) : 0;
-                    painter.fillRect(rr.adjusted(vi, 0, -8*i, 0), calcBlendColor(baseColor, i, count));
+                    QRectF oneRect = r;
+                    oneRect.setWidth(viewport()->width());
+                    oneRect.adjust(vi, 0, -8*i, 0);
+                    if (oneRect.left() >= oneRect.right())
+                        continue;
+                    if (lineX > 0 && oneRect.left() < lineX && oneRect.right() > lineX) {
+                        QRectF otherRect = r;
+                        otherRect.setLeft(lineX + 1);
+                        otherRect.setRight(oneRect.right());
+                        oneRect.setRight(lineX - 1);
+                        painter.fillRect(otherRect, blendedColor);
+                    }
+                    painter.fillRect(oneRect, blendedColor);
                 }
             }
             offsetFP.ry() += r.height();