summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qsyntaxhighlighter.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-03-01 13:43:30 (GMT)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-03-02 09:59:14 (GMT)
commit24c5bc6c0c5c23d808f055dabefd15a551cb0902 (patch)
tree5484a5870d152947ab3f66c241e0ae4a115d8570 /src/gui/text/qsyntaxhighlighter.cpp
parent667ef5950bc16ff8582ac32f5150fc9f45a09682 (diff)
downloadQt-24c5bc6c0c5c23d808f055dabefd15a551cb0902.zip
Qt-24c5bc6c0c5c23d808f055dabefd15a551cb0902.tar.gz
Qt-24c5bc6c0c5c23d808f055dabefd15a551cb0902.tar.bz2
minor clean-ups and styling fixes
Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Diffstat (limited to 'src/gui/text/qsyntaxhighlighter.cpp')
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index de16ca5..02dabbb 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -67,8 +67,8 @@ public:
void _q_reformatBlocks(int from, int charsRemoved, int charsAdded);
void reformatBlocks(int from, int charsRemoved, int charsAdded);
- void reformatBlock(QTextBlock block);
-
+ void reformatBlock(const QTextBlock &block);
+
inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
inReformatBlocks = true;
cursor.beginEditBlock();
@@ -84,7 +84,6 @@ public:
return;
rehighlightPending = false;
q_func()->rehighlight();
- return;
}
void applyFormatChanges();
@@ -106,10 +105,11 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
while (it != ranges.end()) {
if (it->start >= preeditAreaStart
- && it->start + it->length <= preeditAreaStart + preeditAreaLength)
+ && it->start + it->length <= preeditAreaStart + preeditAreaLength) {
++it;
- else
+ } else {
it = ranges.erase(it);
+ }
}
QTextCharFormat emptyFormat;
@@ -137,11 +137,10 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
r.length = i - r.start;
- if (r.start >= preeditAreaStart) {
+ if (r.start >= preeditAreaStart)
r.start += preeditAreaLength;
- } else if (r.start + r.length >= preeditAreaStart) {
+ else if (r.start + r.length >= preeditAreaStart)
r.length += preeditAreaLength;
- }
ranges << r;
r.start = r.length = -1;
@@ -150,11 +149,10 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
if (r.start != -1) {
r.length = formatChanges.count() - r.start;
- if (r.start >= preeditAreaStart) {
+ if (r.start >= preeditAreaStart)
r.start += preeditAreaLength;
- } else if (r.start + r.length >= preeditAreaStart) {
+ else if (r.start + r.length >= preeditAreaStart)
r.length += preeditAreaLength;
- }
ranges << r;
}
@@ -170,7 +168,6 @@ void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, in
void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded)
{
- Q_UNUSED(charsRemoved);
rehighlightPending = false;
QTextBlock block = doc->findBlock(from);
@@ -199,7 +196,7 @@ void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int c
formatChanges.clear();
}
-void QSyntaxHighlighterPrivate::reformatBlock(QTextBlock block)
+void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
{
Q_Q(QSyntaxHighlighter);
@@ -357,8 +354,8 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc)
if (d->doc) {
connect(d->doc, SIGNAL(contentsChange(int,int,int)),
this, SLOT(_q_reformatBlocks(int,int,int)));
- QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight()));
d->rehighlightPending = true;
+ QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight()));
}
}
@@ -473,7 +470,6 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
void QSyntaxHighlighter::setFormat(int start, int count, const QTextCharFormat &format)
{
Q_D(QSyntaxHighlighter);
-
if (start < 0 || start >= d->formatChanges.count())
return;
@@ -641,7 +637,7 @@ QTextBlockUserData *QSyntaxHighlighter::currentBlockUserData() const
\since 4.4
Returns the current text block.
- */
+*/
QTextBlock QSyntaxHighlighter::currentBlock() const
{
Q_D(const QSyntaxHighlighter);