Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
6c56fcf5
Commit
6c56fcf5
authored
Aug 09, 2010
by
Roberto Raggi
Browse files
Nicer implementation of setExtraAdditionalFormats()
parent
6021a889
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/syntaxhighlighter.cpp
View file @
6c56fcf5
...
...
@@ -684,7 +684,12 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
if
(
block
.
layout
()
==
0
)
return
;
QList
<
QTextLayout
::
FormatRange
>
formats
=
fmts
;
QList
<
QTextLayout
::
FormatRange
>
formats
;
formats
.
reserve
(
fmts
.
size
());
foreach
(
QTextLayout
::
FormatRange
r
,
fmts
)
{
r
.
format
.
setProperty
(
QTextFormat
::
UserProperty
,
true
);
formats
.
append
(
r
);
}
qSort
(
formats
.
begin
(),
formats
.
end
(),
byStartOfRange
);
QList
<
QTextLayout
::
FormatRange
>
previousSemanticFormats
;
...
...
@@ -698,19 +703,12 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
formatsToApply
.
append
(
r
);
}
qSort
(
previousSemanticFormats
.
begin
(),
previousSemanticFormats
.
end
(),
byStartOfRange
);
foreach
(
QTextLayout
::
FormatRange
r
,
formats
)
{
r
.
format
.
setProperty
(
QTextFormat
::
UserProperty
,
true
);
formatsToApply
.
append
(
r
);
}
if
(
formats
.
size
()
==
previousSemanticFormats
.
size
())
{
qSort
(
previousSemanticFormats
.
begin
(),
previousSemanticFormats
.
end
(),
byStartOfRange
);
int
index
=
0
;
for
(;
index
!=
formats
.
size
();
++
index
)
{
QTextLayout
::
FormatRange
range
=
formats
.
at
(
index
);
range
.
format
.
setProperty
(
QTextFormat
::
UserProperty
,
true
);
const
QTextLayout
::
FormatRange
&
range
=
formats
.
at
(
index
);
const
QTextLayout
::
FormatRange
&
previousRange
=
previousSemanticFormats
.
at
(
index
);
if
(
range
.
start
!=
previousRange
.
start
||
...
...
@@ -723,6 +721,8 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
return
;
}
formatsToApply
+=
formats
;
bool
wasInReformatBlocks
=
d
->
inReformatBlocks
;
d
->
inReformatBlocks
=
true
;
block
.
layout
()
->
setAdditionalFormats
(
formatsToApply
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment