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
Utilities
Kate
Commits
910fb07c
Commit
910fb07c
authored
Jan 02, 2021
by
Waqar Ahmed
Browse files
Cache colors outside the loop
parent
2b97a197
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/search/plugin_search.cpp
View file @
910fb07c
...
...
@@ -962,10 +962,14 @@ void KatePluginSearchView::matchesFound(const QString &url, const QString &fName
return
;
}
const
QString
bgColor
=
m_searchBackgroundColor
.
color
().
name
();
const
QString
fgColor
=
m_foregroundColor
.
color
().
name
();
/**
* handle all received matches, add them as one operation to the widget afterwards
*/
QList
<
QTreeWidgetItem
*>
items
;
items
.
reserve
(
searchMatches
.
size
());
for
(
const
auto
&
searchMatch
:
searchMatches
)
{
int
preLen
=
contextLen
;
int
preStart
=
searchMatch
.
matchRange
.
start
().
column
()
-
preLen
;
...
...
@@ -988,7 +992,7 @@ void KatePluginSearchView::matchesFound(const QString &url, const QString &fName
// (line:col)[space][space] ...Line text pre [highlighted match] Line text post....
QString
displayText
=
QStringLiteral
(
"(<b>%1:%2</b>) "
).
arg
(
searchMatch
.
matchRange
.
start
().
line
()
+
1
).
arg
(
searchMatch
.
matchRange
.
start
().
column
()
+
1
);
QString
matchHighlighted
=
QStringLiteral
(
"<span style=
\"
background-color:%1; color:%2;
\"
>%3</span>"
).
arg
(
m_searchBackgroundColor
.
color
().
name
()).
arg
(
m_foregroundColor
.
color
().
name
()
).
arg
(
match
);
QString
matchHighlighted
=
QStringLiteral
(
"<span style=
\"
background-color:%1; color:%2;
\"
>%3</span>"
).
arg
(
bgColor
).
arg
(
fgColor
).
arg
(
match
);
displayText
=
displayText
+
pre
+
matchHighlighted
+
post
;
TreeWidgetItem
*
item
=
new
TreeWidgetItem
(
static_cast
<
TreeWidgetItem
*>
(
nullptr
),
QStringList
{
displayText
});
...
...
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