summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorGeir Vattekar <geir.vattekar@nokia.com>2011-08-25 13:28:43 (GMT)
committerGeir Vattekar <geir.vattekar@nokia.com>2011-08-25 13:28:43 (GMT)
commit516ffeecded9ed20ef309143b5f15bcce4abbe60 (patch)
tree175ee09c92df54a5ea11c2a8031a5589094a41b6 /doc/src
parent678a8a137b334e86a30ea3f8ed2334dbb4f92631 (diff)
downloadQt-516ffeecded9ed20ef309143b5f15bcce4abbe60.zip
Qt-516ffeecded9ed20ef309143b5f15bcce4abbe60.tar.gz
Qt-516ffeecded9ed20ef309143b5f15bcce4abbe60.tar.bz2
Doc: Added a note to Code Editor example docs
Task-number: QTBUG-9004 Reviewed-by: David Boddie
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/examples/codeeditor.qdoc26
1 files changed, 26 insertions, 0 deletions
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<int, int> 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
*/
+