summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2009-07-13 09:03:41 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-07-13 09:03:41 (GMT)
commite8e6e8c1722618a48cb4a2e46b24ecad4b056270 (patch)
tree5f16d826c98fc39289c99026b298d5d42f56c7b3 /src/gui/text
parentd705f5cd9d3bac765346af361038f2f9249183e7 (diff)
downloadQt-e8e6e8c1722618a48cb4a2e46b24ecad4b056270.zip
Qt-e8e6e8c1722618a48cb4a2e46b24ecad4b056270.tar.gz
Qt-e8e6e8c1722618a48cb4a2e46b24ecad4b056270.tar.bz2
Added QSyntaxHighlighter::rehighlightBlock(QTextBlock)
Merge-request: 379 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp27
-rw-r--r--src/gui/text/qsyntaxhighlighter.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index db1a38e..ccf229e 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -356,6 +356,8 @@ QTextDocument *QSyntaxHighlighter::document() const
\since 4.2
Redoes the highlighting of the whole document.
+
+ \sa rehighlightBlock()
*/
void QSyntaxHighlighter::rehighlight()
{
@@ -375,6 +377,31 @@ void QSyntaxHighlighter::rehighlight()
}
/*!
+ \since 4.6
+
+ Redoes the highlighting of the given QTextBlock \a block.
+
+ \sa rehighlight()
+*/
+void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
+{
+ Q_D(QSyntaxHighlighter);
+ if (!d->doc)
+ return;
+
+ disconnect(d->doc, SIGNAL(contentsChange(int,int,int)),
+ this, SLOT(_q_reformatBlocks(int,int,int)));
+ QTextCursor cursor(block);
+ cursor.beginEditBlock();
+ int from = cursor.position();
+ cursor.movePosition(QTextCursor::EndOfBlock);
+ d->_q_reformatBlocks(from, 0, cursor.position() - from);
+ cursor.endEditBlock();
+ connect(d->doc, SIGNAL(contentsChange(int,int,int)),
+ this, SLOT(_q_reformatBlocks(int,int,int)));
+}
+
+/*!
\fn void QSyntaxHighlighter::highlightBlock(const QString &text)
Highlights the given text block. This function is called when
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index 4e5271b..ee249b8 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -78,6 +78,7 @@ public:
public Q_SLOTS:
void rehighlight();
+ void rehighlightBlock(const QTextBlock &block);
protected:
virtual void highlightBlock(const QString &text) = 0;