From 516ffeecded9ed20ef309143b5f15bcce4abbe60 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 25 Aug 2011 15:28:43 +0200 Subject: Doc: Added a note to Code Editor example docs Task-number: QTBUG-9004 Reviewed-by: David Boddie --- doc/src/examples/codeeditor.qdoc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/src/examples/codeeditor.qdoc b/doc/src/examples/codeeditor.qdoc index 435f650..1718d52 100644 --- a/doc/src/examples/codeeditor.qdoc +++ b/doc/src/examples/codeeditor.qdoc @@ -194,4 +194,30 @@ with QSyntaxHighlighter" article in Qt Quarterly 31 implements this. You find it here: \l{http://doc.qt.nokia.com/qq/}. + The line number area is now painted every time the cursor blinks + (because we connect \l{QPlainTextEdit::}{updateRequest()} to + \c updateLineNumberArea()). We can avoid this by introducing a new + member variable to CodeEditor that keeps track of when the update + request comes from a cursor blink (in which case we do not + repaint). The code below requires the \c m_countCache variable, + which is a QPair initialized with \c -1 for both + \l{QPair::}{first} and \l{QPair::}{second}. + + \code + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) { + lineNumberArea->scroll(0, dy); + } else if (m_countCache.first != blockCount() + || m_countCache.second != textCursor().block().lineCount()) { + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + m_countCache.first = blockCount(); + m_countCache.second = textCursor().block().lineCount(); + } + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + \endcode */ + -- cgit v0.12