summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2009-07-13 09:03:44 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-07-13 09:03:44 (GMT)
commitd5c71b7ede48fd832145cc3921da77b10772053c (patch)
treeb10e3781dba83e0b94a751a10facc1f0ce168d2e /src
parent9a46bc5f02866134fb66ff1a03863d09382f7d40 (diff)
downloadQt-d5c71b7ede48fd832145cc3921da77b10772053c.zip
Qt-d5c71b7ede48fd832145cc3921da77b10772053c.tar.gz
Qt-d5c71b7ede48fd832145cc3921da77b10772053c.tar.bz2
Unified common code in QSyntaxHighlighter::rehighlight() and QSyntaxHighlighter::rehighlightBlock()
Merge-request: 379 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index ccf229e..f69562d 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -65,6 +65,18 @@ public:
void _q_reformatBlocks(int from, int charsRemoved, int charsAdded);
void reformatBlock(QTextBlock block);
+
+ inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
+ QObject::disconnect(doc, SIGNAL(contentsChange(int,int,int)),
+ q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ cursor.beginEditBlock();
+ int from = cursor.position();
+ cursor.movePosition(operation);
+ _q_reformatBlocks(from, 0, cursor.position() - from);
+ cursor.endEditBlock();
+ QObject::connect(doc, SIGNAL(contentsChange(int,int,int)),
+ q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ }
inline void _q_delayedRehighlight() {
if (!rehighlightPending)
@@ -365,15 +377,8 @@ void QSyntaxHighlighter::rehighlight()
if (!d->doc)
return;
- disconnect(d->doc, SIGNAL(contentsChange(int,int,int)),
- this, SLOT(_q_reformatBlocks(int,int,int)));
QTextCursor cursor(d->doc);
- cursor.beginEditBlock();
- cursor.movePosition(QTextCursor::End);
- d->_q_reformatBlocks(0, 0, cursor.position());
- cursor.endEditBlock();
- connect(d->doc, SIGNAL(contentsChange(int,int,int)),
- this, SLOT(_q_reformatBlocks(int,int,int)));
+ d->rehighlight(cursor, QTextCursor::End);
}
/*!
@@ -389,16 +394,8 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
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)));
+ d->rehighlight(cursor, QTextCursor::EndOfBlock);
}
/*!